From 18c4e023b088b41de71019707830eeb3653dc83e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Schauer-K=C3=B6ckeis?= Date: Mon, 16 Sep 2024 12:25:41 +0200 Subject: [PATCH 1/4] New notification Dialog, that is used for deletion confirmation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Schauer-Köckeis --- src/i18n/locales/en.json | 2 + src/views/components/NotificationDialog.vue | 41 +++++++++++++++++++ .../projects/ProjectDetailsModal.vue | 37 ++++++++++++++++- 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/views/components/NotificationDialog.vue diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 04ea8105f..11f1f851c 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -702,6 +702,8 @@ "profile_updated": "Profile updated", "project_cloning_in_progress": "The project is being created with the cloning options specified", "project_created": "Project created", + "project_delete_message": "Deleting this project will also permanently delete all associated child projects. This action cannot be undone. Are you sure you want to proceed?", + "project_delete_title": "Confirm Project Deletion", "project_deleted": "Project deleted", "project_details": "Project Details", "project_metadata_supplier_name_desc": "The organization that supplied the BOM", diff --git a/src/views/components/NotificationDialog.vue b/src/views/components/NotificationDialog.vue new file mode 100644 index 000000000..fe506419b --- /dev/null +++ b/src/views/components/NotificationDialog.vue @@ -0,0 +1,41 @@ + + + diff --git a/src/views/portfolio/projects/ProjectDetailsModal.vue b/src/views/portfolio/projects/ProjectDetailsModal.vue index 967c7d8c1..ba5f8f7b8 100644 --- a/src/views/portfolio/projects/ProjectDetailsModal.vue +++ b/src/views/portfolio/projects/ProjectDetailsModal.vue @@ -452,6 +452,8 @@ import permissionsMixin from '../../../mixins/permissionsMixin'; import common from '../../../shared/common'; import Multiselect from 'vue-multiselect'; import xssFilters from 'xss-filters'; +import NotificationDialog from '../../components/NotificationDialog'; +import Vue from 'vue'; export default { name: 'ProjectDetailsModal', @@ -708,8 +710,16 @@ export default { this.$root.$emit('bv::hide::modal', 'projectDetailsModal'); }); }, - deleteProject: function () { + deleteProject: async function () { this.$root.$emit('bv::hide::modal', 'projectDetailsModal'); + try { + await this.showWarning( + this.$t('message.project_delete_message'), + this.$t('message.project_delete_title'), + ); + } catch { + return; + } let url = `${this.$api.BASE_URL}/${this.$api.URL_PROJECT}/` + this.project.uuid; this.axios @@ -722,6 +732,31 @@ export default { this.$toastr.w(this.$t('condition.unsuccessful_action')); }); }, + async showWarning(message, title) { + return new Promise((resolve, reject) => { + const WarningConstructor = Vue.extend(NotificationDialog); + const instance = new WarningConstructor({ + propsData: { message, title }, + }); + instance.$mount(); + document.body.appendChild(instance.$el); + + instance.$bvModal.show('notification-dialog'); + instance.$on('confirm', () => { + resolve(); + this.cleanupInstance(instance); + }); + + instance.$on('cancel', () => { + reject(); + this.cleanupInstance(instance); + }); + }); + }, + cleanupInstance(instance) { + document.body.removeChild(instance.$el); + instance.$destroy(); + }, hasActiveChild: function (project) { return ( project.children && From 573ece3890e35fbca5b4b29aff1440fdb3e633ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Schauer-K=C3=B6ckeis?= Date: Mon, 16 Sep 2024 12:33:36 +0200 Subject: [PATCH 2/4] Added translations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Schauer-Köckeis --- src/i18n/locales/de.json | 2 ++ src/i18n/locales/es.json | 2 ++ src/i18n/locales/fr.json | 2 ++ src/i18n/locales/hi.json | 2 ++ src/i18n/locales/it.json | 2 ++ src/i18n/locales/ja.json | 2 ++ src/i18n/locales/pl.json | 2 ++ src/i18n/locales/pt-BR.json | 2 ++ src/i18n/locales/pt.json | 2 ++ src/i18n/locales/ru.json | 2 ++ src/i18n/locales/uk-UA.json | 2 ++ src/i18n/locales/zh.json | 2 ++ 12 files changed, 24 insertions(+) diff --git a/src/i18n/locales/de.json b/src/i18n/locales/de.json index 979d5e06d..d94d30fef 100644 --- a/src/i18n/locales/de.json +++ b/src/i18n/locales/de.json @@ -702,6 +702,8 @@ "profile_updated": "Profil aktualisiert", "project_cloning_in_progress": "Das Projekt wird mit den angegebenen Klonoptionen erstellt", "project_created": "Projekt erstellt", + "project_delete_message": "Durch das Löschen dieses Projekts werden auch alle zugehörigen untergeordneten Projekte dauerhaft gelöscht. \nDiese Aktion kann nicht rückgängig gemacht werden. \nSind Sie sicher, dass Sie fortfahren möchten?", + "project_delete_title": "Bestätigen Sie die Projektlöschung", "project_deleted": "Projekt gelöscht", "project_details": "Projekt Details", "project_metadata_supplier_name_desc": "Die Organisation, die die BOM bereitgestellt hat", diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index 7297b7afa..90a68898d 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -702,6 +702,8 @@ "profile_updated": "Perfil actualizado", "project_cloning_in_progress": "El proyecto se está creando con las opciones de clonación especificadas.", "project_created": "Proyecto creado", + "project_delete_message": "Al eliminar este proyecto, también se eliminarán permanentemente todos los proyectos secundarios asociados. \nEsta acción no se puede deshacer. \n¿Estás seguro de que quieres continuar?", + "project_delete_title": "Confirmar la eliminación del proyecto", "project_deleted": "Proyecto eliminado", "project_details": "detalles del proyecto", "project_metadata_supplier_name_desc": "La organización que suministró el BOM.", diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json index 14bba4b07..087c2868c 100644 --- a/src/i18n/locales/fr.json +++ b/src/i18n/locales/fr.json @@ -702,6 +702,8 @@ "profile_updated": "Profil mis à jour", "project_cloning_in_progress": "Le projet est en cours de création avec les options de clonage spécifiées", "project_created": "Projet créé", + "project_delete_message": "La suppression de ce projet supprimera également définitivement tous les projets enfants associés. \nCette action ne peut pas être annulée. \nÊtes-vous sûr de vouloir continuer ?", + "project_delete_title": "Confirmer la suppression du projet", "project_deleted": "Projet supprimé", "project_details": "Détails du projet", "project_metadata_supplier_name_desc": "L'organisation qui a fourni la nomenclature", diff --git a/src/i18n/locales/hi.json b/src/i18n/locales/hi.json index 47dbed1fe..bd12b973e 100644 --- a/src/i18n/locales/hi.json +++ b/src/i18n/locales/hi.json @@ -702,6 +702,8 @@ "profile_updated": "प्रोफाइल अद्यतन किया गया", "project_cloning_in_progress": "परियोजना को निर्दिष्ट क्लोनिंग विकल्पों के साथ बनाया जा रहा है", "project_created": "प्रोजेक्ट बनाया गया", + "project_delete_message": "इस प्रोजेक्ट को हटाने से सभी संबद्ध चाइल्ड प्रोजेक्ट भी स्थायी रूप से हटा दिए जाएंगे। \nइस एक्शन को वापस नहीं किया जा सकता। \nक्या आप सुनिश्चित रूप से आगे बढ़ना चाहते हैं?", + "project_delete_title": "प्रोजेक्ट विलोपन की पुष्टि करें", "project_deleted": "परियोजना हटा दी गई", "project_details": "परियोजना विवरण", "project_metadata_supplier_name_desc": "वह संगठन जिसने BOM की आपूर्ति की", diff --git a/src/i18n/locales/it.json b/src/i18n/locales/it.json index c58b0c783..39d9ff999 100644 --- a/src/i18n/locales/it.json +++ b/src/i18n/locales/it.json @@ -702,6 +702,8 @@ "profile_updated": "profilo aggiornato", "project_cloning_in_progress": "Il progetto viene creato con le opzioni di clonazione specificate", "project_created": "Progetto creato", + "project_delete_message": "L'eliminazione di questo progetto eliminerà definitivamente anche tutti i progetti secondari associati. \nQuesta azione non può essere annullata. \nSei sicuro di voler procedere?", + "project_delete_title": "Conferma l'eliminazione del progetto", "project_deleted": "Progetto eliminato", "project_details": "Dettagli del progetto", "project_metadata_supplier_name_desc": "L'organizzazione che ha fornito la distinta base", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index b054b3749..7b6a5afcd 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -702,6 +702,8 @@ "profile_updated": "プロフィール更新", "project_cloning_in_progress": "プロジェクトは指定されたクローンオプションで作成されています", "project_created": "プロジェクトが作成されました", + "project_delete_message": "このプロジェクトを削除すると、関連するすべての子プロジェクトも完全に削除されます。\nこの操作は元に戻すことができません。\n続行してもよろしいですか?", + "project_delete_title": "プロジェクトの削除の確認", "project_deleted": "プロジェクトが削除されました", "project_details": "プロジェクトの詳細", "project_metadata_supplier_name_desc": "BOMを提供した組織", diff --git a/src/i18n/locales/pl.json b/src/i18n/locales/pl.json index 83cebffef..2e2898776 100644 --- a/src/i18n/locales/pl.json +++ b/src/i18n/locales/pl.json @@ -702,6 +702,8 @@ "profile_updated": "Profil zaktualizowany", "project_cloning_in_progress": "Projekt jest tworzony z określonymi opcjami klonowania", "project_created": "Projekt stworzony", + "project_delete_message": "Usunięcie tego projektu spowoduje również trwałe usunięcie wszystkich powiązanych projektów podrzędnych. \nTej akcji nie można cofnąć. \nCzy na pewno chcesz kontynuować?", + "project_delete_title": "Potwierdź usunięcie projektu", "project_deleted": "Projekt usunięty", "project_details": "Szczegóły Projektu", "project_metadata_supplier_name_desc": "Organizacja, która dostarczyła BOM", diff --git a/src/i18n/locales/pt-BR.json b/src/i18n/locales/pt-BR.json index 0b7bc9225..b500b6dc2 100644 --- a/src/i18n/locales/pt-BR.json +++ b/src/i18n/locales/pt-BR.json @@ -702,6 +702,8 @@ "profile_updated": "perfil atualizado", "project_cloning_in_progress": "O projeto está sendo criado com as opções de clonagem especificadas", "project_created": "Projeto criado", + "project_delete_message": "A exclusão deste projeto também excluirá permanentemente todos os projetos secundários associados. \nEsta ação não pode ser desfeita. \nTem certeza de que deseja prosseguir?", + "project_delete_title": "Confirmar exclusão do projeto", "project_deleted": "Projeto excluído", "project_details": "Detalhes do Projeto", "project_metadata_supplier_name_desc": "A organização que forneceu a lista técnica", diff --git a/src/i18n/locales/pt.json b/src/i18n/locales/pt.json index 9b9ea0e53..0ceb2256d 100644 --- a/src/i18n/locales/pt.json +++ b/src/i18n/locales/pt.json @@ -702,6 +702,8 @@ "profile_updated": "perfil atualizado", "project_cloning_in_progress": "O projeto está sendo criado com as opções de clonagem especificadas", "project_created": "Projeto criado", + "project_delete_message": "A exclusão deste projeto também excluirá permanentemente todos os projetos secundários associados. \nEsta ação não pode ser desfeita. \nTem certeza de que deseja prosseguir?", + "project_delete_title": "Confirmar exclusão do projeto", "project_deleted": "Projeto excluído", "project_details": "Detalhes do Projeto", "project_metadata_supplier_name_desc": "A organização que forneceu a lista técnica", diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json index 149ccc33d..8de82e115 100644 --- a/src/i18n/locales/ru.json +++ b/src/i18n/locales/ru.json @@ -702,6 +702,8 @@ "profile_updated": "Профиль обновлен", "project_cloning_in_progress": "Проект создается с указанными параметрами клонирования.", "project_created": "Проект создан", + "project_delete_message": "Удаление этого проекта также приведет к безвозвратному удалению всех связанных с ним дочерних проектов. \nЭто действие невозможно отменить. \nВы уверены, что хотите продолжить?", + "project_delete_title": "Подтвердить удаление проекта", "project_deleted": "Проект удален", "project_details": "Детали проекта", "project_metadata_supplier_name_desc": "Организация, предоставившая спецификацию", diff --git a/src/i18n/locales/uk-UA.json b/src/i18n/locales/uk-UA.json index afa35d362..c85bca1e7 100644 --- a/src/i18n/locales/uk-UA.json +++ b/src/i18n/locales/uk-UA.json @@ -702,6 +702,8 @@ "profile_updated": "Профіль оновлено", "project_cloning_in_progress": "Проект створюється із зазначеними параметрами клонування", "project_created": "Проект створено", + "project_delete_message": "Видалення цього проекту призведе до остаточного видалення всіх пов’язаних дочірніх проектів. \nЦю дію не можна скасувати. \nВи впевнені, що бажаєте продовжити?", + "project_delete_title": "Підтвердити видалення проекту", "project_deleted": "Проект видалено", "project_details": "Деталі проекту", "project_metadata_supplier_name_desc": "Організація, яка надала специфікацію", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index bcfa26d72..1bdd1c3b3 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -702,6 +702,8 @@ "profile_updated": "个人资料已更新", "project_cloning_in_progress": "正在使用指定的克隆选项创建项目", "project_created": "项目已创建", + "project_delete_message": "删除此项目还将永久删除所有关联的子项目。\n此操作无法撤消。\n您确定要继续吗?", + "project_delete_title": "确认项目删除", "project_deleted": "项目已删除", "project_details": "项目细节", "project_metadata_supplier_name_desc": "提供 BOM 的组织", From 7054907cd3d004a9252139e088ece655cae60491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Schauer-K=C3=B6ckeis?= Date: Tue, 17 Sep 2024 13:49:06 +0200 Subject: [PATCH 3/4] Switched to msgBoxConfirm instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Schauer-Köckeis --- src/views/components/NotificationDialog.vue | 41 ------------- .../projects/ProjectDetailsModal.vue | 61 +++++-------------- 2 files changed, 16 insertions(+), 86 deletions(-) delete mode 100644 src/views/components/NotificationDialog.vue diff --git a/src/views/components/NotificationDialog.vue b/src/views/components/NotificationDialog.vue deleted file mode 100644 index fe506419b..000000000 --- a/src/views/components/NotificationDialog.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - diff --git a/src/views/portfolio/projects/ProjectDetailsModal.vue b/src/views/portfolio/projects/ProjectDetailsModal.vue index ba5f8f7b8..c7b028389 100644 --- a/src/views/portfolio/projects/ProjectDetailsModal.vue +++ b/src/views/portfolio/projects/ProjectDetailsModal.vue @@ -452,8 +452,6 @@ import permissionsMixin from '../../../mixins/permissionsMixin'; import common from '../../../shared/common'; import Multiselect from 'vue-multiselect'; import xssFilters from 'xss-filters'; -import NotificationDialog from '../../components/NotificationDialog'; -import Vue from 'vue'; export default { name: 'ProjectDetailsModal', @@ -712,50 +710,23 @@ export default { }, deleteProject: async function () { this.$root.$emit('bv::hide::modal', 'projectDetailsModal'); - try { - await this.showWarning( - this.$t('message.project_delete_message'), - this.$t('message.project_delete_title'), - ); - } catch { - return; - } - let url = - `${this.$api.BASE_URL}/${this.$api.URL_PROJECT}/` + this.project.uuid; - this.axios - .delete(url) - .then((response) => { - this.$toastr.s(this.$t('message.project_deleted')); - this.$router.replace({ name: 'Projects' }); - }) - .catch((error) => { - this.$toastr.w(this.$t('condition.unsuccessful_action')); - }); - }, - async showWarning(message, title) { - return new Promise((resolve, reject) => { - const WarningConstructor = Vue.extend(NotificationDialog); - const instance = new WarningConstructor({ - propsData: { message, title }, - }); - instance.$mount(); - document.body.appendChild(instance.$el); - - instance.$bvModal.show('notification-dialog'); - instance.$on('confirm', () => { - resolve(); - this.cleanupInstance(instance); - }); - - instance.$on('cancel', () => { - reject(); - this.cleanupInstance(instance); + let confirmed = await this.$bvModal + .msgBoxConfirm(this.$t('message.project_delete_message'), { + title: this.$t('message.project_delete_title'), }); - }); - }, - cleanupInstance(instance) { - document.body.removeChild(instance.$el); - instance.$destroy(); + if (confirmed) { + let url = + `${this.$api.BASE_URL}/${this.$api.URL_PROJECT}/` + this.project.uuid; + this.axios + .delete(url) + .then((response) => { + this.$toastr.s(this.$t('message.project_deleted')); + this.$router.replace({ name: 'Projects' }); + }) + .catch((error) => { + this.$toastr.w(this.$t('condition.unsuccessful_action')); + }); + } }, hasActiveChild: function (project) { return ( From 1ad17b4c352f3e3b521f037b883184682f1ad06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Schauer-K=C3=B6ckeis?= Date: Tue, 17 Sep 2024 13:54:44 +0200 Subject: [PATCH 4/4] Fixed linter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Schauer-Köckeis --- src/views/portfolio/projects/ProjectDetailsModal.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/views/portfolio/projects/ProjectDetailsModal.vue b/src/views/portfolio/projects/ProjectDetailsModal.vue index c7b028389..200e80c26 100644 --- a/src/views/portfolio/projects/ProjectDetailsModal.vue +++ b/src/views/portfolio/projects/ProjectDetailsModal.vue @@ -710,10 +710,12 @@ export default { }, deleteProject: async function () { this.$root.$emit('bv::hide::modal', 'projectDetailsModal'); - let confirmed = await this.$bvModal - .msgBoxConfirm(this.$t('message.project_delete_message'), { + let confirmed = await this.$bvModal.msgBoxConfirm( + this.$t('message.project_delete_message'), + { title: this.$t('message.project_delete_title'), - }); + }, + ); if (confirmed) { let url = `${this.$api.BASE_URL}/${this.$api.URL_PROJECT}/` + this.project.uuid;