main
vue 50 lines 1.27 KB
Raw
1 <template>
2 <n-button :size type="primary" :loading @click="showForm = true">
3 <template v-if="showIcon" #icon>
4 <Icon :name="NewCaseIcon" :size="14" />
5 </template>
6 <span>Create Case</span>
7 </n-button>
8
9 <n-modal
10 v-model:show="showForm"
11 display-directive="show"
12 preset="card"
13 :style="{ maxWidth: 'min(600px, 90vw)', minHeight: 'min(300px, 90vh)', overflow: 'hidden' }"
14 title="Create a new Case"
15 :bordered="false"
16 segmented
17 >
18 <CaseCreationForm
19 v-model:loading="loading"
20 @mounted="formCTX = $event"
21 @submitted="emit('submitted', $event)"
22 />
23 </n-modal>
24 </template>
25
26 <script setup lang="ts">
27 import type { ButtonSize } from "naive-ui"
28 import type { Case } from "@/types/incidentManagement/cases"
29 import { NButton, NModal } from "naive-ui"
30 import { ref, watch } from "vue"
31 import Icon from "@/components/common/Icon.vue"
32 import CaseCreationForm from "./CaseCreationForm.vue"
33
34 const { showIcon, size } = defineProps<{ showIcon?: boolean; size?: ButtonSize }>()
35
36 const emit = defineEmits<{
37 (e: "submitted", value: Case): void
38 }>()
39
40 const NewCaseIcon = "carbon:fetch-upload-cloud"
41 const formCTX = ref<{ load: () => void } | null>(null)
42 const showForm = ref(false)
43 const loading = ref(false)
44
45 watch(showForm, val => {
46 if (val) {
47 formCTX.value?.load()
48 }
49 })
50 </script>