@@ -48,7 +48,7 @@ RED.editor = (function() {
4848 isValid = validateNode ( subflow ) ;
4949 hasChanged = subflow . changed ;
5050 }
51- node . valid = isValid ;
51+ node . valid = isValid && validateNodeProperties ( node , node . _def . defaults , node ) ;
5252 node . changed = node . changed || hasChanged ;
5353 } else if ( node . _def ) {
5454 node . valid = validateNodeProperties ( node , node . _def . defaults , node ) ;
@@ -170,6 +170,10 @@ RED.editor = (function() {
170170 }
171171 }
172172 }
173+ validateIcon ( node ) ;
174+ }
175+
176+ function validateIcon ( node ) {
173177 if ( node . _def . hasOwnProperty ( "defaults" ) && ! node . _def . defaults . hasOwnProperty ( "icon" ) && node . icon ) {
174178 var iconPath = RED . utils . separateIconPath ( node . icon ) ;
175179 var iconSets = RED . nodes . getIconSets ( ) ;
@@ -188,6 +192,7 @@ RED.editor = (function() {
188192 }
189193 }
190194 }
195+
191196 function validateNodeEditorProperty ( node , defaults , property , prefix ) {
192197 var input = $ ( "#" + prefix + "-" + property ) ;
193198 if ( input . length > 0 ) {
@@ -742,7 +747,7 @@ RED.editor = (function() {
742747 buildLabelRow ( ) . appendTo ( outputsDiv ) ;
743748 }
744749
745- if ( ( ! node . _def . defaults || ! node . _def . defaults . hasOwnProperty ( "icon" ) ) && node . type !== "subflow" ) {
750+ if ( ( ! node . _def . defaults || ! node . _def . defaults . hasOwnProperty ( "icon" ) ) ) {
746751 $ ( '<div class="form-row"><div id="node-settings-icon"></div></div>' ) . appendTo ( dialogForm ) ;
747752 var iconDiv = $ ( "#node-settings-icon" ) ;
748753 $ ( '<label data-i18n="editor.settingIcon">' ) . appendTo ( iconDiv ) ;
@@ -816,6 +821,7 @@ RED.editor = (function() {
816821 } ) ;
817822 }
818823 selectIconFile . prop ( "disabled" , ! iconFileList ) ;
824+ selectIconFile . removeClass ( "input-error" ) ;
819825 selectIconModule . removeClass ( "input-error" ) ;
820826 }
821827
@@ -1686,10 +1692,22 @@ RED.editor = (function() {
16861692 if ( updateLabels ( editing_node , changes , null ) ) {
16871693 changed = true ;
16881694 }
1695+ var iconModule = $ ( "#node-settings-icon-module-hidden" ) . val ( ) ;
1696+ var iconFile = $ ( "#node-settings-icon-file-hidden" ) . val ( ) ;
1697+ var icon = ( iconModule && iconFile ) ? iconModule + "/" + iconFile : "" ;
1698+ if ( ( editing_node . icon === undefined && icon !== "node-red/subflow.png" ) ||
1699+ ( editing_node . icon !== undefined && editing_node . icon !== icon ) ) {
1700+ changes . icon = editing_node . icon ;
1701+ editing_node . icon = icon ;
1702+ changed = true ;
1703+ }
16891704
16901705 RED . palette . refresh ( ) ;
16911706
16921707 if ( changed ) {
1708+ var wasChanged = editing_node . changed ;
1709+ editing_node . changed = true ;
1710+ validateNode ( editing_node ) ;
16931711 var subflowInstances = [ ] ;
16941712 RED . nodes . eachNode ( function ( n ) {
16951713 if ( n . type == "subflow:" + editing_node . id ) {
@@ -1700,10 +1718,9 @@ RED.editor = (function() {
17001718 n . changed = true ;
17011719 n . dirty = true ;
17021720 updateNodeProperties ( n ) ;
1721+ validateNode ( n ) ;
17031722 }
17041723 } ) ;
1705- var wasChanged = editing_node . changed ;
1706- editing_node . changed = true ;
17071724 RED . nodes . dirty ( true ) ;
17081725 var historyEvent = {
17091726 t :'edit' ,
@@ -1782,6 +1799,7 @@ RED.editor = (function() {
17821799 $ ( "#subflow-dialog-user-count" ) . html ( RED . _ ( "subflow.subflowInstances" , { count :userCount } ) ) . show ( ) ;
17831800
17841801 buildLabelForm ( portLabels . content , subflow ) ;
1802+ validateIcon ( subflow ) ;
17851803 trayBody . i18n ( ) ;
17861804 } ,
17871805 close : function ( ) {
0 commit comments