@@ -144,42 +144,43 @@ function newThingUI (context, thePanes) {
144144 )
145145 } // makeNewAppInstance
146146
147- var iconArray = [ ]
148- for ( var pn in thePanes ) {
149- var pane = thePanes [ pn ]
150- if ( pane . mintNew ) {
151- var icon = context . div . appendChild ( dom . createElement ( 'img' ) )
152- icon . setAttribute ( 'src' , pane . icon )
153- var noun = pane . mintClass ? UI . utils . label ( pane . mintClass ) : ( pane . name + ' @@' )
154- icon . setAttribute ( 'title' , 'Make new ' + noun )
155- icon . setAttribute ( 'style' , iconStyle + 'display: none;' )
156- iconArray . push ( icon )
157- var foo = function ( pane , icon , noun ) {
158- var iconEle = icon
159- var thisPane = pane
160- var thisNoun = noun
161- if ( ! icon . disabled ) {
162- icon . addEventListener ( 'click' , function ( e ) {
163- selectTool ( iconEle )
164- var options = {
165- event : e ,
166- folder : context . folder ,
167- iconEle : iconEle ,
168- pane : thisPane ,
169- noun : thisNoun ,
170- noIndexHTML : true , // do NOT @@ for now write a HTML file
171- div : context . div ,
172- me : context . me ,
173- dom : context . dom ,
174- refreshTarget : context . refreshTarget
175- }
176- makeNewAppInstance ( options )
177- } )
178- }
179- } // foo
180- foo ( pane , icon , noun )
147+ const iconArray = [ ]
148+ const mintingPanes = Object . values ( thePanes ) . filter ( pane => pane . mintNew )
149+ const mintingClassMap = mintingPanes . reduce ( ( classMap , pane ) => {
150+ if ( pane . mintClass ) {
151+ classMap [ pane . mintClass ] = ( classMap [ pane . mintClass ] || 0 ) + 1
181152 }
182- }
153+ return classMap
154+ } , { } )
155+ mintingPanes . forEach ( pane => {
156+ const icon = context . div . appendChild ( dom . createElement ( 'img' ) )
157+ icon . setAttribute ( 'src' , pane . icon )
158+ const noun = pane . mintClass
159+ ? ( mintingClassMap [ pane . mintClass ] > 1
160+ ? `${ UI . utils . label ( pane . mintClass ) } (using ${ pane . name } pane)`
161+ : UI . utils . label ( pane . mintClass ) )
162+ : ( pane . name + ' @@' )
163+ icon . setAttribute ( 'title' , 'Make new ' + noun )
164+ icon . setAttribute ( 'style' , iconStyle + 'display: none;' )
165+ iconArray . push ( icon )
166+ if ( ! icon . disabled ) {
167+ icon . addEventListener ( 'click' , function ( e ) {
168+ selectTool ( icon )
169+ makeNewAppInstance ( {
170+ event : e ,
171+ folder : context . folder ,
172+ iconEle : icon ,
173+ pane,
174+ noun,
175+ noIndexHTML : true , // do NOT @@ for now write a HTML file
176+ div : context . div ,
177+ me : context . me ,
178+ dom : context . dom ,
179+ refreshTarget : context . refreshTarget
180+ } )
181+ } )
182+ }
183+ } )
183184
184185 var styleTheIcons = function ( style ) {
185186 for ( var i = 0 ; i < iconArray . length ; i ++ ) {
0 commit comments