@webitel/ui-sdk 3.1.4 → 3.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -293,5 +293,11 @@ export default {
293
293
  score: 'Score',
294
294
  },
295
295
  },
296
+ deleteConfirmationPopup: {
297
+ title: 'Confirm deletion',
298
+ askingAlert: 'Are you sure you want to delete {count} item? | Are you sure you want to delete {count} items?',
299
+ undoneActionAlert: 'This action cannot be undone.',
300
+ deleteAll: 'ALL',
301
+ },
296
302
  },
297
303
  };
@@ -290,5 +290,11 @@ export default {
290
290
  score: 'Бал',
291
291
  },
292
292
  },
293
+ deleteConfirmationPopup: {
294
+ title: 'Подтвердите удаление',
295
+ askingAlert: 'Вы уверенны, что хотите удалить {count} запись? | Вы уверенны, что хотите удалить {count} записей?',
296
+ undoneActionAlert: 'Это действие не может быть отменено.',
297
+ deleteAll: 'ВСЕ',
298
+ },
293
299
  },
294
300
  };
@@ -290,5 +290,11 @@ export default {
290
290
  score: 'Бал',
291
291
  },
292
292
  },
293
+ deleteConfirmationPopup: {
294
+ title: 'Підтвердіть видалення',
295
+ askingAlert: 'Ви впевнені, що хочете видалити {count} запис? | Ви впевнені, що хочете видалити {count} записів?',
296
+ undoneActionAlert: 'Дана дія не може бути скасована.',
297
+ deleteAll: 'ВСІ',
298
+ },
293
299
  },
294
300
  };
@@ -0,0 +1,96 @@
1
+ <template>
2
+ <wt-popup
3
+ class="delete-confirmation-popup"
4
+ min-width="480"
5
+ @close="close"
6
+ >
7
+ <template v-slot:title>{{ $t('webitelUI.deleteConfirmationPopup.title') }}</template>
8
+ <template v-slot:main>
9
+ <p>
10
+ {{ deleteMessage }}
11
+ {{ $t('webitelUI.deleteConfirmationPopup.undoneActionAlert') }}
12
+ </p>
13
+ </template>
14
+ <template v-slot:actions>
15
+ <wt-button
16
+ color="secondary"
17
+ :disabled="isDeleting"
18
+ @click="cancel"
19
+ >{{ $t('reusable.cancel') }}
20
+ </wt-button>
21
+ <wt-button
22
+ color="danger"
23
+ :loading="isDeleting"
24
+ @click="confirm"
25
+ >{{ $t('reusable.delete') }}
26
+ </wt-button>
27
+ </template>
28
+ </wt-popup>
29
+ </template>
30
+
31
+ <script setup>
32
+ import { computed, ref } from 'vue';
33
+ import { useI18n } from 'vue-i18n';
34
+
35
+ const props = defineProps({
36
+ deleteCount: {
37
+ type: Number,
38
+ required: true,
39
+ },
40
+ callback: {
41
+ type: Function,
42
+ required: true,
43
+ },
44
+ });
45
+
46
+ const emit = defineEmits([
47
+ 'confirm',
48
+ 'cancel',
49
+ 'close',
50
+ ]);
51
+
52
+ const { t } = useI18n();
53
+
54
+ const isDeleting = ref(false);
55
+
56
+ const deleteMessage = computed(() => {
57
+ if (props.deleteCount === 0) {
58
+ return t(
59
+ 'webitelUI.deleteConfirmationPopup.askingAlert',
60
+ 2,
61
+ null,
62
+ { count: t('webitelUI.deleteConfirmationPopup.deleteAll') },
63
+ );
64
+ }
65
+ return t(
66
+ 'webitelUI.deleteConfirmationPopup.askingAlert',
67
+ props.deleteCount === 1 ? 1 : 2,
68
+ null,
69
+ { count: props.deleteCount },
70
+ );
71
+ });
72
+
73
+ function close() {
74
+ emit('close');
75
+ }
76
+
77
+ async function confirm() {
78
+ try {
79
+ isDeleting.value = true;
80
+ emit('confirm');
81
+ await props.callback();
82
+ } finally {
83
+ isDeleting.value = false;
84
+ close();
85
+ }
86
+ }
87
+
88
+ function cancel() {
89
+ emit('cancel');
90
+ close();
91
+ }
92
+ </script>
93
+
94
+ <style scoped>
95
+
96
+ </style>
@@ -0,0 +1,33 @@
1
+ import { ref } from 'vue';
2
+
3
+ // eslint-disable-next-line import/prefer-default-export
4
+ export const useDeleteConfirmationPopup = () => {
5
+ const isVisible = ref(false);
6
+ const deleteCount = ref(null);
7
+ const deleteCallback = ref(null);
8
+
9
+ function askDeleteConfirmation({ deleted, callback }) {
10
+ if (Array.isArray(deleted)) deleteCount.value = deleted.length;
11
+ else deleteCount.value = 1;
12
+ isVisible.value = true;
13
+ deleteCallback.value = callback;
14
+ }
15
+
16
+ function confirmDelete() {
17
+ return deleteCallback.value();
18
+ }
19
+
20
+ function closeDelete() {
21
+ isVisible.value = false;
22
+ }
23
+
24
+ return {
25
+ isVisible,
26
+ deleteCount,
27
+ deleteCallback,
28
+
29
+ askDeleteConfirmation,
30
+ confirmDelete,
31
+ closeDelete,
32
+ };
33
+ };