2023-03-17 15:13:37 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { computed } from 'vue';
|
|
|
|
import { mdiClose } from '@mdi/js';
|
|
|
|
import BaseButton from '@/Components/BaseButton.vue';
|
|
|
|
import BaseButtons from '@/Components/BaseButtons.vue';
|
|
|
|
import CardBox from '@/Components/CardBox.vue';
|
|
|
|
import OverlayLayer from '@/Components/OverlayLayer.vue';
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
title: {
|
|
|
|
type: String,
|
2023-03-17 15:13:37 +00:00
|
|
|
default: null,
|
2023-03-03 15:54:28 +00:00
|
|
|
},
|
|
|
|
largeTitle: {
|
|
|
|
type: String,
|
2023-03-17 15:13:37 +00:00
|
|
|
default: null,
|
2023-03-03 15:54:28 +00:00
|
|
|
},
|
|
|
|
button: {
|
|
|
|
type: String,
|
2023-03-17 15:13:37 +00:00
|
|
|
default: 'info',
|
2023-03-03 15:54:28 +00:00
|
|
|
},
|
|
|
|
buttonLabel: {
|
|
|
|
type: String,
|
2023-03-17 15:13:37 +00:00
|
|
|
default: 'Done',
|
2023-03-03 15:54:28 +00:00
|
|
|
},
|
|
|
|
hasCancel: Boolean,
|
|
|
|
modelValue: {
|
|
|
|
type: [String, Number, Boolean],
|
2023-03-17 15:13:37 +00:00
|
|
|
default: null,
|
|
|
|
},
|
2023-03-31 12:54:15 +00:00
|
|
|
deleteId: {
|
|
|
|
type: Number,
|
2023-10-31 14:38:43 +00:00
|
|
|
default: null,
|
|
|
|
},
|
2023-03-17 15:13:37 +00:00
|
|
|
});
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-03-17 15:13:37 +00:00
|
|
|
const emit = defineEmits(['update:modelValue', 'cancel', 'confirm']);
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
const value = computed({
|
|
|
|
get: () => props.modelValue,
|
2023-03-17 15:13:37 +00:00
|
|
|
set: (value) => emit('update:modelValue', value),
|
|
|
|
});
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-03-31 12:54:15 +00:00
|
|
|
// mode = cancel or confirm
|
2023-03-03 15:54:28 +00:00
|
|
|
const confirmCancel = (mode) => {
|
2023-10-31 14:38:43 +00:00
|
|
|
value.value = false; //close
|
|
|
|
if (props.deleteId) {
|
2023-03-31 12:54:15 +00:00
|
|
|
emit(mode, props.deleteId);
|
|
|
|
} else {
|
|
|
|
emit(mode);
|
|
|
|
}
|
2023-03-17 15:13:37 +00:00
|
|
|
};
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-03-17 15:13:37 +00:00
|
|
|
const confirm = () => confirmCancel('confirm');
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-03-17 15:13:37 +00:00
|
|
|
const cancel = () => confirmCancel('cancel');
|
2023-03-03 15:54:28 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<OverlayLayer v-show="value" @overlay-click="cancel">
|
2023-03-17 15:13:37 +00:00
|
|
|
<CardBox
|
|
|
|
v-show="value"
|
|
|
|
:title="title"
|
|
|
|
class="shadow-lg max-h-modal w-11/12 md:w-3/5 lg:w-2/5 xl:w-4/12 z-50"
|
|
|
|
:header-icon="mdiClose"
|
|
|
|
modal
|
|
|
|
@header-icon-click="cancel"
|
|
|
|
>
|
2023-03-03 15:54:28 +00:00
|
|
|
<div class="space-y-3">
|
|
|
|
<h1 v-if="largeTitle" class="text-2xl">
|
|
|
|
{{ largeTitle }}
|
|
|
|
</h1>
|
|
|
|
<slot />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
<BaseButtons>
|
|
|
|
<BaseButton :label="buttonLabel" :color="button" @click="confirm" />
|
|
|
|
<BaseButton v-if="hasCancel" label="Cancel" :color="button" outline @click="cancel" />
|
|
|
|
</BaseButtons>
|
|
|
|
</template>
|
|
|
|
</CardBox>
|
|
|
|
</OverlayLayer>
|
|
|
|
</template>
|