Skip to content

Fix used in entities of the same type are displayed separately in delete warning #29490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ define([
*/
getRecordRelatedContentMessage: function (images) {
var usedInMessage = $t('The selected assets are used in the content of the following entities: '),
usedIn = [];
usedIn = {};

$.each(images, function (key, image) {
$.each(image.details, function (sectionIndex, section) {
if (section.title === 'Used In' && _.isObject(section) && !_.isEmpty(section.value)) {
$.each(section.value, function (entityTypeIndex, entityTypeData) {
usedIn.push(entityTypeData.name + '(' + entityTypeData.number + ')');
usedIn[entityTypeData.name] = entityTypeData.name in usedIn ?
usedIn[entityTypeData.name] + entityTypeData.number :
entityTypeData.number;
});
}
});
Expand All @@ -68,7 +70,23 @@ define([
return '';
}

return usedInMessage + usedIn.join(', ') + '.';
return usedInMessage + this.usedInObjectToString(usedIn);
},

/**
* Fromats usedIn object to string
*
* @param {Object} usedIn
* @return {String}
*/
usedInObjectToString: function (usedIn) {
var entities = [];

$.each(usedIn, function (entityName, number) {
entities.push(entityName + '(' + number + ')');
});

return entities.join(', ') + '.';
}
};
});