| 1 | <template> |
| 2 | <div> |
| 3 | <n-button size="small" type="primary" @click="showForm = true"> |
| 4 | <template #icon> |
| 5 | <Icon :name="NewNewExclusionRuleIcon" :size="16" /> |
| 6 | </template> |
| 7 | {{ hideButtonExtendedLabel ? "Create" : " Create Exclusion Rule" }} |
| 8 | </n-button> |
| 9 | |
| 10 | <n-modal |
| 11 | v-model:show="showForm" |
| 12 | display-directive="show" |
| 13 | preset="card" |
| 14 | :style="{ maxWidth: 'min(600px, 90vw)', minHeight: 'min(200px, 90vh)', overflow: 'hidden' }" |
| 15 | title="Create Exclusion Rule" |
| 16 | :bordered="false" |
| 17 | content-class="flex flex-col" |
| 18 | segmented |
| 19 | > |
| 20 | <ExclusionRuleForm reset-on-submit @submitted="submitted()" @mounted="formCTX = $event" /> |
| 21 | </n-modal> |
| 22 | </div> |
| 23 | </template> |
| 24 | |
| 25 | <script setup lang="ts"> |
| 26 | import { NButton, NModal } from "naive-ui" |
| 27 | import { ref, toRefs, watch } from "vue" |
| 28 | import Icon from "@/components/common/Icon.vue" |
| 29 | import ExclusionRuleForm from "./ExclusionRuleForm.vue" |
| 30 | |
| 31 | const props = defineProps<{ hideButtonExtendedLabel?: boolean }>() |
| 32 | |
| 33 | const emit = defineEmits<{ |
| 34 | (e: "success"): void |
| 35 | }>() |
| 36 | |
| 37 | const { hideButtonExtendedLabel } = toRefs(props) |
| 38 | |
| 39 | const NewNewExclusionRuleIcon = "ic:outline-do-not-disturb-on" |
| 40 | const showForm = ref(false) |
| 41 | const formCTX = ref<{ reset: () => void } | null>(null) |
| 42 | |
| 43 | function submitted() { |
| 44 | emit("success") |
| 45 | showForm.value = false |
| 46 | } |
| 47 | |
| 48 | watch(showForm, val => { |
| 49 | if (val) { |
| 50 | formCTX.value?.reset() |
| 51 | } |
| 52 | }) |
| 53 | </script> |