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

@@ -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');

View File

@@ -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();