@@ -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,26 @@ 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 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 ;
72
93
}
73
94
} ;
74
95
} ) ;
0 commit comments