feat: confirm close while edit work name
This commit is contained in:
parent
a460fb5c61
commit
e06abf1e77
5 changed files with 43 additions and 14 deletions
|
|
@ -139,7 +139,6 @@ const tabsList = defineModel<{ name: string; label: string }[]>('tabsList');
|
||||||
padding="xs"
|
padding="xs"
|
||||||
class="close-btn"
|
class="close-btn"
|
||||||
:class="{ dark: $q.dark.isActive }"
|
:class="{ dark: $q.dark.isActive }"
|
||||||
v-close-popup
|
|
||||||
@click="close"
|
@click="close"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
export default {
|
export default {
|
||||||
warning: 'Warning',
|
warning: 'Warning',
|
||||||
warningForgetInput: 'You have incomplete information.',
|
warningForgetInput: 'You have incomplete information.',
|
||||||
|
warningClose:
|
||||||
|
"You haven't saved your data. Do you want to close this window?",
|
||||||
|
|
||||||
errorOccurred: 'An error occurred.',
|
errorOccurred: 'An error occurred.',
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
export default {
|
export default {
|
||||||
warning: 'เตือน',
|
warning: 'เตือน',
|
||||||
warningForgetInput: 'คุณกรอกข้อมูลไม่ครบ',
|
warningForgetInput: 'คุณกรอกข้อมูลไม่ครบ',
|
||||||
|
warningClose: 'คุณยังไม่ได้บันทึกการแก้ไข ยืนยันที่จะปิดใช่หรือไม่',
|
||||||
|
|
||||||
errorOccurred: 'เกิดข้อผิดพลาด.',
|
errorOccurred: 'เกิดข้อผิดพลาด.',
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import useOptionStore from 'src/stores/options';
|
||||||
import { Status } from 'src/stores/types';
|
import { Status } from 'src/stores/types';
|
||||||
import NoData from 'components/NoData.vue';
|
import NoData from 'components/NoData.vue';
|
||||||
|
|
||||||
import { dialog } from 'src/stores/utils';
|
import { dialog, dialogWarningClose } from 'src/stores/utils';
|
||||||
|
|
||||||
import useProductServiceStore from 'src/stores/product-service';
|
import useProductServiceStore from 'src/stores/product-service';
|
||||||
import {
|
import {
|
||||||
|
|
@ -647,16 +647,20 @@ function confirmDeleteWork(id: string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmCloseWork() {
|
function triggerConfirmCloseWork() {
|
||||||
dialog({
|
const isWorkNameEdit =
|
||||||
color: 'negative',
|
workNameRef.value && workNameRef.value.isWorkNameEdit
|
||||||
icon: 'mdi-alert',
|
? workNameRef.value.isWorkNameEdit()
|
||||||
title: t('deleteConfirmTitle'),
|
: false;
|
||||||
actionText: t('delete'),
|
if (isWorkNameEdit) {
|
||||||
message: t('deleteConfirmMessage'),
|
dialogWarningClose(t, {
|
||||||
action: async () => {},
|
action: () => {
|
||||||
cancel: () => {},
|
manageWorkNameDialog.value = false;
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
manageWorkNameDialog.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const tempValueProperties = ref<Attributes>({
|
const tempValueProperties = ref<Attributes>({
|
||||||
|
|
@ -1785,8 +1789,9 @@ watch(currentStatus, async () => {
|
||||||
no-footer
|
no-footer
|
||||||
height="65vh"
|
height="65vh"
|
||||||
width="65%"
|
width="65%"
|
||||||
:title="$t('manage')"
|
|
||||||
v-model:modal="manageWorkNameDialog"
|
v-model:modal="manageWorkNameDialog"
|
||||||
|
:title="$t('manage')"
|
||||||
|
:close="triggerConfirmCloseWork"
|
||||||
>
|
>
|
||||||
<WorkNameManagement
|
<WorkNameManagement
|
||||||
ref="workNameRef"
|
ref="workNameRef"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Dialog } from 'quasar';
|
import { Dialog } from 'quasar';
|
||||||
import GlobalDialog from 'components/GlobalDialog.vue';
|
import GlobalDialog from 'components/GlobalDialog.vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { ComposerTranslation, useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
export function dialog(opts: {
|
export function dialog(opts: {
|
||||||
title: string;
|
title: string;
|
||||||
|
|
@ -20,6 +20,28 @@ export function dialog(opts: {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function dialogWarningClose(
|
||||||
|
t: ComposerTranslation,
|
||||||
|
opts: {
|
||||||
|
action?: (...args: unknown[]) => unknown;
|
||||||
|
cancel?: (...args: unknown[]) => unknown;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
dialog({
|
||||||
|
color: 'warning',
|
||||||
|
icon: 'mdi-alert',
|
||||||
|
title: t('warning'),
|
||||||
|
actionText: t('ok'),
|
||||||
|
message: t('warningClose'),
|
||||||
|
action: async () => {
|
||||||
|
if (opts.action) opts.action();
|
||||||
|
},
|
||||||
|
cancel: () => {
|
||||||
|
if (opts.cancel) opts.cancel();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function calculateAge(birthDate: Date | null | string) {
|
export function calculateAge(birthDate: Date | null | string) {
|
||||||
const { locale } = useI18n();
|
const { locale } = useI18n();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue