PMCORE-2628 Message of Delete attribute does not display correctly

This commit is contained in:
Roly Rudy Gutierrez Pinto
2021-01-04 11:08:21 -04:00
parent 8e080147b7
commit ee456c4eb3
4 changed files with 72 additions and 26 deletions

View File

@@ -25907,6 +25907,12 @@ msgstr "There was a problem sending the email to"
msgid "Error: The application {0} is not canceled." msgid "Error: The application {0} is not canceled."
msgstr "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 # TRANSLATION
# LABEL/ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM # LABEL/ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM
#: LABEL/ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM #: LABEL/ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM

View File

@@ -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_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_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_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_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_DEFAULT_CONFIGURATION','en','The default configuration was not defined','2016-11-16') ,
( 'LABEL','ID_THE_FILE_COULDNT_BE_UPLOADED','en','The file couldnt be uploaded please review the allowed files or contact your System Administrator.','2020-06-12') , ( 'LABEL','ID_THE_FILE_COULDNT_BE_UPLOADED','en','The file couldnt be uploaded please review the allowed files or contact your System Administrator.','2020-06-12') ,

View File

@@ -2,6 +2,7 @@
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Role; use ProcessMaker\BusinessModel\Role;
use ProcessMaker\Model\User;
use ProcessMaker\Model\UserExtendedAttributes; use ProcessMaker\Model\UserExtendedAttributes;
global $G_PUBLISH; global $G_PUBLISH;
@@ -215,6 +216,25 @@ try {
]; ];
echo G::json_encode($result); echo G::json_encode($result);
break; 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: default:
$conf = new Configurations(); $conf = new Configurations();
$pageSize = $conf->getEnvSetting('casesListRowNumber'); $pageSize = $conf->getEnvSetting('casesListRowNumber');

View File

@@ -137,33 +137,52 @@
this.$emit("editAttribute", row); this.$emit("editAttribute", row);
}, },
deleteAttribute(row) { deleteAttribute(row) {
this.$bvModal.msgBoxConfirm(this.$root.translation('ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM', [row.name]), { let formData = new FormData();
title: " ", //is important because title disappear formData.append("option", "verifyAttributeUse");
hideHeaderClose: false, formData.append("name", row.name);
okTitle: this.$root.translation('ID_CONFIRM'), formData.append("attributeId", row.attributeId);
okVariant: "success", axios.post(this.$root.baseUrl() + "userExtendedAttributes/index", formData)
cancelTitle: this.$root.translation('ID_CANCEL'), .then(response => {
cancelVariant: "danger" response;
}).then(value => { let message = this.$root.translation('ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM', [row.name]);
if (value === false) { if ("isUsed" in response.data && "message" in response.data) {
return; if (response.data.isUsed === true) {
} message = response.data.message;
let formData = new FormData(); }
formData.append("option", "delete"); }
formData.append("id", row.id); this.$bvModal.msgBoxConfirm(message, {
axios.post(this.$root.baseUrl() + "userExtendedAttributes/index", formData) title: " ", //is important because title disappear
.then(response => { hideHeaderClose: false,
response; okTitle: this.$root.translation('ID_CONFIRM'),
this.refresh(); okVariant: "success",
}) cancelTitle: this.$root.translation('ID_CANCEL'),
.catch(error => { cancelVariant: "danger"
error; }).then(value => {
}) if (value === false) {
.finally(() => { 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() { refresh() {
this.$refs.vServerTable1.refresh(); this.$refs.vServerTable1.refresh();