| 1 | <template> |
| 2 | <n-button :size :type :secondary :loading @click="openModal"> |
| 3 | <template #icon> |
| 4 | <Icon :name="InvokeIcon" /> |
| 5 | </template> |
| 6 | Active Response |
| 7 | </n-button> |
| 8 | |
| 9 | <n-modal |
| 10 | v-model:show="showInvokeWizard" |
| 11 | display-directive="show" |
| 12 | preset="card" |
| 13 | :style="{ maxWidth: 'min(600px, 90vw)', minHeight: 'min(300px, 90vh)', overflow: 'hidden' }" |
| 14 | title="Active Response Wizard" |
| 15 | :bordered="false" |
| 16 | content-class="flex flex-col p-0!" |
| 17 | segmented |
| 18 | > |
| 19 | <ActiveResponseWizard v-model:loading="loading" @mounted="activeResponseWizardCTX = $event" /> |
| 20 | </n-modal> |
| 21 | </template> |
| 22 | |
| 23 | <script setup lang="ts"> |
| 24 | import type { ButtonSize, ButtonType } from "naive-ui" |
| 25 | import { NButton, NModal } from "naive-ui" |
| 26 | import { ref, watch } from "vue" |
| 27 | import Icon from "@/components/common/Icon.vue" |
| 28 | import ActiveResponseWizard from "./ActiveResponseWizard.vue" |
| 29 | |
| 30 | defineProps<{ |
| 31 | size?: ButtonSize |
| 32 | type?: ButtonType |
| 33 | secondary?: boolean |
| 34 | }>() |
| 35 | |
| 36 | const InvokeIcon = "solar:playback-speed-outline" |
| 37 | const showInvokeWizard = ref(false) |
| 38 | const activeResponseWizardCTX = ref<{ reset: () => void } | null>(null) |
| 39 | const loading = ref(false) |
| 40 | |
| 41 | function openModal() { |
| 42 | showInvokeWizard.value = true |
| 43 | } |
| 44 | |
| 45 | function closeModal() { |
| 46 | showInvokeWizard.value = false |
| 47 | } |
| 48 | |
| 49 | watch(showInvokeWizard, () => { |
| 50 | activeResponseWizardCTX.value?.reset() |
| 51 | }) |
| 52 | |
| 53 | defineExpose({ |
| 54 | openModal, |
| 55 | closeModal |
| 56 | }) |
| 57 | </script> |