antares/src/renderer/components/ModalDiscardChanges.vue

54 lines
1.2 KiB
Vue
Raw Normal View History

2020-12-04 11:19:16 +01:00
<template>
<ConfirmModal
:confirm-text="t('general.discard')"
:cancel-text="t('general.stay')"
@confirm="emit('confirm')"
@hide="emit('close')"
2020-12-04 11:19:16 +01:00
>
2021-12-10 17:34:44 +01:00
<template #header>
2020-12-04 11:19:16 +01:00
<div class="d-flex">
<BaseIcon
icon-name="mdiContentSaveAlert"
class="mr-1"
:size="24"
/> {{ t('application.unsavedChanges') }}
2020-12-04 11:19:16 +01:00
</div>
</template>
2021-12-10 17:34:44 +01:00
<template #body>
2020-12-04 11:19:16 +01:00
<div>
{{ t('application.discardUnsavedChanges') }}
2020-12-04 11:19:16 +01:00
</div>
2021-12-10 17:34:44 +01:00
</template>
2020-12-04 11:19:16 +01:00
</ConfirmModal>
</template>
<script setup lang="ts">
import { onBeforeUnmount } from 'vue';
import { useI18n } from 'vue-i18n';
import ConfirmModal from '@/components/BaseConfirmModal.vue';
import BaseIcon from '@/components/BaseIcon.vue';
const { t } = useI18n();
2020-12-04 11:19:16 +01:00
const emit = defineEmits(['confirm', 'close']);
const onKey = (e: KeyboardEvent) => {
e.stopPropagation();
if (e.key === 'Escape')
emit('close');
2020-12-04 11:19:16 +01:00
};
window.addEventListener('keydown', onKey);
onBeforeUnmount(() => {
window.removeEventListener('keydown', onKey);
});
2020-12-04 11:19:16 +01:00
</script>
<style scoped>
.modal-container {
max-width: 360px;
}
</style>