Skip to content

EspoCRM – Open Source CRM Application

client record actions duplicate prevention

Yurii0368d0569c85
diff --git a/client/src/helpers/action-item-setup.js b/client/src/helpers/action-item-setup.js
index 18f1aa3851..abc8fe2010 100644
--- a/client/src/helpers/action-item-setup.js
+++ b/client/src/helpers/action-item-setup.js
@@ -84,18 +84,30 @@ class ActionItemSetupHelper {
throw new Error();
}
- const actionDefsList = [
+ /** @type {({name?: string} & Record | string)[]} */
+ const actionDefsListOriginal = [
...this.metadata.get(['clientDefs', 'Global', type + 'ActionList']) || [],
...this.metadata.get(['clientDefs', scope, type + 'ActionList']) || [],
];
- actionDefsList.forEach(item => {
+ /** @type {({name?: string} & Object.<string, *>)[]} */
+ let actionDefsList = actionDefsListOriginal.map(item => {
if (typeof item === 'string') {
- item = {name: item};
+ return {name: item};
}
- item = Espo.Utils.cloneDeep(item);
+ return Espo.Utils.cloneDeep(item);
+ })
+
+ actionDefsList.reverse();
+
+ actionDefsList = actionDefsList.filter((it, i, self) => {
+ return self.findIndex(sIt => sIt.name === it.name) === i;
+ });
+
+ actionDefsList.reverse();
+ actionDefsList.forEach(item => {
const name = item.name;
if (!item.label) {
diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js
index eef2f504e3..f538030512 100644
--- a/client/src/views/record/list.js
+++ b/client/src/views/record/list.js
@@ -2378,12 +2378,12 @@ class ListRecordView extends View {
const metadataMassActionList = [
...this.getMetadata().get(['clientDefs', 'Global', 'massActionList']) || [],
...this.getMetadata().get(['clientDefs', this.scope, 'massActionList']) || [],
- ];
+ ].filter((it, i, self) => self.indexOf(it) === i);
const metadataCheckAllMassActionList = [
...this.getMetadata().get(['clientDefs', 'Global', 'checkAllResultMassActionList']) || [],
...this.getMetadata().get(['clientDefs', this.scope, 'checkAllResultMassActionList']) || [],
- ];
+ ].filter((it, i, self) => self.indexOf(it) === i);
metadataMassActionList.forEach(item => {
const defs = /** @type {Espo.Utils~ActionAccessDefs & Espo.Utils~ActionAvailabilityDefs} */