@@ -52,13 +52,15 @@ define([
52
52
*/
53
53
getRecordRelatedContentMessage : function ( images ) {
54
54
var usedInMessage = $t ( 'The selected assets are used in the content of the following entities: ' ) ,
55
- usedIn = [ ] ;
55
+ usedIn = { } ;
56
56
57
57
$ . each ( images , function ( key , image ) {
58
58
$ . each ( image . details , function ( sectionIndex , section ) {
59
59
if ( section . title === 'Used In' && _ . isObject ( section ) && ! _ . isEmpty ( section . value ) ) {
60
60
$ . 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 ;
62
64
} ) ;
63
65
}
64
66
} ) ;
@@ -68,7 +70,23 @@ define([
68
70
return '' ;
69
71
}
70
72
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 entities = [ ] ;
84
+
85
+ $ . each ( usedIn , function ( entityName , number ) {
86
+ entities . push ( entityName + '(' + number + ')' ) ;
87
+ } ) ;
88
+
89
+ return entities . join ( ', ' ) + '.' ;
72
90
}
73
91
} ;
74
92
} ) ;
0 commit comments