From ee456c4eb3bf9d6920f7ce6cd5d776a46c591129 Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Mon, 4 Jan 2021 11:08:21 -0400 Subject: [PATCH] PMCORE-2628 Message of Delete attribute does not display correctly --- .../translations/english/processmaker.en.po | 6 ++ workflow/engine/data/mysql/insert.sql | 1 + .../methods/userExtendedAttributes/index.php | 20 ++++++ .../src/components/userExtendedAttributes.vue | 71 ++++++++++++------- 4 files changed, 72 insertions(+), 26 deletions(-) diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po index 84141438a..948d5f504 100755 --- a/workflow/engine/content/translations/english/processmaker.en.po +++ b/workflow/engine/content/translations/english/processmaker.en.po @@ -25907,6 +25907,12 @@ msgstr "There was a problem sending the email to" msgid "Error: The application {0} is not canceled." msgstr "Error: The application {0} is not canceled." +# TRANSLATION +# LABEL/ID_THE_ATTRIBUTE_HAS_ALREADY_INFORMATION_STORED_FOR_USERS_PLEASE_CONFIRM_THE_DELETE +#: LABEL/ID_THE_ATTRIBUTE_HAS_ALREADY_INFORMATION_STORED_FOR_USERS_PLEASE_CONFIRM_THE_DELETE +msgid "The attribute {0} has already information stored for users, if you proceed to delete this attribute all information for users stored in the attribute will be deleted, please confirm." +msgstr "The attribute {0} has already information stored for users, if you proceed to delete this attribute all information for users stored in the attribute will be deleted, please confirm." + # TRANSLATION # LABEL/ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM #: LABEL/ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql index 90c798bdc..bcb55472b 100755 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -61274,6 +61274,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_THERE_MUST__LEAST_HOLIDAY','en','There must be at least a holiday','2014-01-15') , ( 'LABEL','ID_THERE_PROBLEM_SENDING_EMAIL','en','There was a problem sending the email to','2016-04-08') , ( 'LABEL','ID_THE_APPLICATION_IS_NOT_CANCELED','en','Error: The application {0} is not canceled.','2016-06-15') , +( 'LABEL','ID_THE_ATTRIBUTE_HAS_ALREADY_INFORMATION_STORED_FOR_USERS_PLEASE_CONFIRM_THE_DELETE','en','The attribute {0} has already information stored for users, if you proceed to delete this attribute all information for users stored in the attribute will be deleted, please confirm.','2020-12-15') , ( 'LABEL','ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM','en','The attribute {0} will be deleted, please confirm.','2020-12-15') , ( 'LABEL','ID_THE_DEFAULT_CONFIGURATION','en','The default configuration was not defined','2016-11-16') , ( 'LABEL','ID_THE_FILE_COULDNT_BE_UPLOADED','en','The file couldn’t be uploaded please review the allowed files or contact your System Administrator.','2020-06-12') , diff --git a/workflow/engine/methods/userExtendedAttributes/index.php b/workflow/engine/methods/userExtendedAttributes/index.php index 7b7af2c97..467878446 100644 --- a/workflow/engine/methods/userExtendedAttributes/index.php +++ b/workflow/engine/methods/userExtendedAttributes/index.php @@ -2,6 +2,7 @@ use Illuminate\Support\Facades\DB; use ProcessMaker\BusinessModel\Role; +use ProcessMaker\Model\User; use ProcessMaker\Model\UserExtendedAttributes; global $G_PUBLISH; @@ -215,6 +216,25 @@ try { ]; echo G::json_encode($result); break; + case "verifyAttributeUse": + $name = empty($_REQUEST["name"]) ? "" : $_REQUEST["name"]; + $attributeId = empty($_REQUEST["attributeId"]) ? "" : $_REQUEST["attributeId"]; + $user = User::query() + ->where("USR_EXTENDED_ATTRIBUTES_DATA", "LIKE", "%\"{$attributeId}\"%") + ->get() + ->first(); + $isUsed = false; + $message = ""; + if (!empty($user)) { + $isUsed = true; + $message = G::loadTranslation("ID_THE_ATTRIBUTE_HAS_ALREADY_INFORMATION_STORED_FOR_USERS_PLEASE_CONFIRM_THE_DELETE", [$name]); + } + $result = [ + "isUsed" => $isUsed, + "message" => $message + ]; + echo G::json_encode($result); + break; default: $conf = new Configurations(); $pageSize = $conf->getEnvSetting('casesListRowNumber'); diff --git a/workflow/engine/methods/userExtendedAttributes/src/components/userExtendedAttributes.vue b/workflow/engine/methods/userExtendedAttributes/src/components/userExtendedAttributes.vue index ae5bcc8df..ad79bcf37 100644 --- a/workflow/engine/methods/userExtendedAttributes/src/components/userExtendedAttributes.vue +++ b/workflow/engine/methods/userExtendedAttributes/src/components/userExtendedAttributes.vue @@ -137,33 +137,52 @@ this.$emit("editAttribute", row); }, deleteAttribute(row) { - this.$bvModal.msgBoxConfirm(this.$root.translation('ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM', [row.name]), { - title: " ", //is important because title disappear - hideHeaderClose: false, - okTitle: this.$root.translation('ID_CONFIRM'), - okVariant: "success", - cancelTitle: this.$root.translation('ID_CANCEL'), - cancelVariant: "danger" - }).then(value => { - if (value === false) { - return; - } - let formData = new FormData(); - formData.append("option", "delete"); - formData.append("id", row.id); - axios.post(this.$root.baseUrl() + "userExtendedAttributes/index", formData) - .then(response => { - response; - this.refresh(); - }) - .catch(error => { - error; - }) - .finally(() => { + let formData = new FormData(); + formData.append("option", "verifyAttributeUse"); + formData.append("name", row.name); + formData.append("attributeId", row.attributeId); + axios.post(this.$root.baseUrl() + "userExtendedAttributes/index", formData) + .then(response => { + response; + let message = this.$root.translation('ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM', [row.name]); + if ("isUsed" in response.data && "message" in response.data) { + if (response.data.isUsed === true) { + message = response.data.message; + } + } + this.$bvModal.msgBoxConfirm(message, { + title: " ", //is important because title disappear + hideHeaderClose: false, + okTitle: this.$root.translation('ID_CONFIRM'), + okVariant: "success", + cancelTitle: this.$root.translation('ID_CANCEL'), + cancelVariant: "danger" + }).then(value => { + if (value === false) { + return; + } + let formData = new FormData(); + formData.append("option", "delete"); + formData.append("id", row.id); + axios.post(this.$root.baseUrl() + "userExtendedAttributes/index", formData) + .then(response => { + response; + this.refresh(); + }) + .catch(error => { + error; + }) + .finally(() => { + }); + }).catch(err => { + err; }); - }).catch(err => { - err; - }); + }) + .catch(error => { + error; + }) + .finally(() => { + }); }, refresh() { this.$refs.vServerTable1.refresh();