Skip to content

Commit c410eae

Browse files
committed
1 parent 6d15bb1 commit c410eae

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/action/deleteImageWithDetailConfirmation.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ define([
5252
*/
5353
getRecordRelatedContentMessage: function (images) {
5454
var usedInMessage = $t('The selected assets are used in the content of the following entities: '),
55-
usedIn = [];
55+
usedIn = {};
5656

5757
$.each(images, function (key, image) {
5858
$.each(image.details, function (sectionIndex, section) {
5959
if (section.title === 'Used In' && _.isObject(section) && !_.isEmpty(section.value)) {
6060
$.each(section.value, function (entityTypeIndex, entityTypeData) {
61-
usedIn.push(entityTypeData.name + '(' + entityTypeData.number + ')');
61+
usedIn[entityTypeData.name] = entityTypeData.name in usedIn ?
62+
usedIn[entityTypeData.name] + entityTypeData.number :
63+
entityTypeData.number;
6264
});
6365
}
6466
});
@@ -68,7 +70,26 @@ define([
6870
return '';
6971
}
7072

71-
return usedInMessage + usedIn.join(', ') + '.';
73+
return usedInMessage + this.usedInObjectToString(usedIn);
74+
},
75+
76+
/**
77+
* Fromats usedIn object to string
78+
*
79+
* @param {Object} usedIn
80+
* @return {String}
81+
*/
82+
usedInObjectToString: function (usedIn) {
83+
var message = '',
84+
count = 0;
85+
86+
$.each(usedIn, function (entityName, number) {
87+
count++;
88+
message += entityName + '(' + number + ')';
89+
message += count != Object.keys(usedIn).length ? ', ' : '.';
90+
});
91+
92+
return message;
7293
}
7394
};
7495
});

0 commit comments

Comments
 (0)