| 1 | <template> |
| 2 | <div> |
| 3 | <CardEntity :embedded clickable hoverable @click.stop="openForm()"> |
| 4 | <template #headerMain>shuffle_workflow_id</template> |
| 5 | <template #headerExtra> |
| 6 | <div class="flex items-center gap-2"> |
| 7 | <span :class="{ 'text-default': incidentNotification.enabled }"> |
| 8 | {{ incidentNotification.enabled ? "Enabled" : "Disabled" }} |
| 9 | </span> |
| 10 | <Icon v-if="incidentNotification.enabled" :name="EnabledIcon" :size="14" class="text-success" /> |
| 11 | <Icon v-else :name="DisabledIcon" :size="14" class="text-secondary" /> |
| 12 | </div> |
| 13 | </template> |
| 14 | <template #default> |
| 15 | {{ incidentNotification.shuffle_workflow_id }} |
| 16 | </template> |
| 17 | </CardEntity> |
| 18 | |
| 19 | <n-modal |
| 20 | v-model:show="showForm" |
| 21 | preset="card" |
| 22 | :style="{ maxWidth: 'min(800px, 90vw)', minHeight: 'min(300px, 90vh)', overflow: 'hidden' }" |
| 23 | title="Notification" |
| 24 | :bordered="false" |
| 25 | display-directive="show" |
| 26 | segmented |
| 27 | > |
| 28 | <CustomerNotificationsWorkflowsForm |
| 29 | :incident-notification |
| 30 | :customer-code="incidentNotification.customer_code" |
| 31 | @mounted="formCTX = $event" |
| 32 | @submitted="emitUpdate" |
| 33 | /> |
| 34 | </n-modal> |
| 35 | </div> |
| 36 | </template> |
| 37 | |
| 38 | <script setup lang="ts"> |
| 39 | import type { IncidentNotification } from "@/types/incidentManagement/notifications.d" |
| 40 | import { NModal } from "naive-ui" |
| 41 | import { defineAsyncComponent, ref, toRefs, watch } from "vue" |
| 42 | import CardEntity from "@/components/common/cards/CardEntity.vue" |
| 43 | import Icon from "@/components/common/Icon.vue" |
| 44 | |
| 45 | const props = defineProps<{ |
| 46 | incidentNotification: IncidentNotification |
| 47 | embedded?: boolean |
| 48 | }>() |
| 49 | |
| 50 | const emit = defineEmits<{ |
| 51 | (e: "updated", value: IncidentNotification): void |
| 52 | }>() |
| 53 | |
| 54 | const CustomerNotificationsWorkflowsForm = defineAsyncComponent( |
| 55 | () => import("./CustomerNotificationsWorkflowsForm.vue") |
| 56 | ) |
| 57 | |
| 58 | const { incidentNotification, embedded } = toRefs(props) |
| 59 | |
| 60 | const EnabledIcon = "carbon:circle-solid" |
| 61 | const DisabledIcon = "carbon:subtract-alt" |
| 62 | |
| 63 | const formCTX = ref<{ reset: (incidentNotification?: IncidentNotification) => void } | null>(null) |
| 64 | const showForm = ref(false) |
| 65 | |
| 66 | watch(showForm, val => { |
| 67 | if (val) { |
| 68 | formCTX.value?.reset(incidentNotification.value) |
| 69 | } |
| 70 | }) |
| 71 | |
| 72 | function openForm() { |
| 73 | showForm.value = true |
| 74 | } |
| 75 | |
| 76 | function emitUpdate(incidentNotification: IncidentNotification) { |
| 77 | emit("updated", incidentNotification) |
| 78 | } |
| 79 | </script> |