mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fixed name conflict of icon property for dashboard node (#1524)
This commit is contained in:
parent
d7c8adfd82
commit
7697c46652
@ -492,7 +492,7 @@ RED.nodes = (function() {
|
|||||||
if (n.outputs > 0 && n.outputLabels && !/^\s*$/.test(n.outputLabels.join(""))) {
|
if (n.outputs > 0 && n.outputLabels && !/^\s*$/.test(n.outputLabels.join(""))) {
|
||||||
node.outputLabels = n.outputLabels.slice();
|
node.outputLabels = n.outputLabels.slice();
|
||||||
}
|
}
|
||||||
if (n.icon) {
|
if (!n._def.defaults.hasOwnProperty("icon") && n.icon) {
|
||||||
var defIcon = RED.utils.getDefaultNodeIcon(n._def, n);
|
var defIcon = RED.utils.getDefaultNodeIcon(n._def, n);
|
||||||
if (n.icon !== defIcon.module+"/"+defIcon.file) {
|
if (n.icon !== defIcon.module+"/"+defIcon.file) {
|
||||||
node.icon = n.icon;
|
node.icon = n.icon;
|
||||||
|
@ -110,6 +110,9 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
if (node.icon) {
|
if (node.icon) {
|
||||||
var iconPath = RED.utils.separateIconPath(node.icon);
|
var iconPath = RED.utils.separateIconPath(node.icon);
|
||||||
|
if (!iconPath.module) {
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
var iconSets = RED.nodes.getIconSets();
|
var iconSets = RED.nodes.getIconSets();
|
||||||
var iconFileList = iconSets[iconPath.module];
|
var iconFileList = iconSets[iconPath.module];
|
||||||
if (!iconFileList || iconFileList.indexOf(iconPath.file) === -1) {
|
if (!iconFileList || iconFileList.indexOf(iconPath.file) === -1) {
|
||||||
@ -167,7 +170,7 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node.icon) {
|
if (!node._def.defaults.hasOwnProperty("icon") && node.icon) {
|
||||||
var iconPath = RED.utils.separateIconPath(node.icon);
|
var iconPath = RED.utils.separateIconPath(node.icon);
|
||||||
var iconSets = RED.nodes.getIconSets();
|
var iconSets = RED.nodes.getIconSets();
|
||||||
var iconFileList = iconSets[iconPath.module];
|
var iconFileList = iconSets[iconPath.module];
|
||||||
@ -736,49 +739,51 @@ RED.editor = (function() {
|
|||||||
buildLabelRow().appendTo(outputsDiv);
|
buildLabelRow().appendTo(outputsDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('<div class="form-row"><div id="node-settings-icon"></div></div>').appendTo(dialogForm);
|
if (!node._def.defaults.hasOwnProperty("icon")) {
|
||||||
var iconDiv = $("#node-settings-icon");
|
$('<div class="form-row"><div id="node-settings-icon"></div></div>').appendTo(dialogForm);
|
||||||
$('<label data-i18n="editor.settingIcon">').appendTo(iconDiv);
|
var iconDiv = $("#node-settings-icon");
|
||||||
var iconForm = $('<div>',{class:"node-label-form-row"});
|
$('<label data-i18n="editor.settingIcon">').appendTo(iconDiv);
|
||||||
iconForm.appendTo(iconDiv);
|
var iconForm = $('<div>',{class:"node-label-form-row"});
|
||||||
$('<label>').appendTo(iconForm);
|
iconForm.appendTo(iconDiv);
|
||||||
|
$('<label>').appendTo(iconForm);
|
||||||
|
|
||||||
var selectIconModule = $('<select id="node-settings-icon-module"><option value=""></option></select>').appendTo(iconForm);
|
var selectIconModule = $('<select id="node-settings-icon-module"><option value=""></option></select>').appendTo(iconForm);
|
||||||
var iconPath;
|
var iconPath;
|
||||||
if (node.icon) {
|
if (node.icon) {
|
||||||
iconPath = RED.utils.separateIconPath(node.icon);
|
iconPath = RED.utils.separateIconPath(node.icon);
|
||||||
} else {
|
} else {
|
||||||
iconPath = RED.utils.getDefaultNodeIcon(node._def, node);
|
iconPath = RED.utils.getDefaultNodeIcon(node._def, node);
|
||||||
}
|
}
|
||||||
var iconSets = RED.nodes.getIconSets();
|
var iconSets = RED.nodes.getIconSets();
|
||||||
Object.keys(iconSets).forEach(function(moduleName) {
|
Object.keys(iconSets).forEach(function(moduleName) {
|
||||||
selectIconModule.append($("<option></option>").val(moduleName).text(moduleName));
|
selectIconModule.append($("<option></option>").val(moduleName).text(moduleName));
|
||||||
});
|
});
|
||||||
if (iconPath.module && !iconSets[iconPath.module]) {
|
if (iconPath.module && !iconSets[iconPath.module]) {
|
||||||
selectIconModule.append($("<option disabled></option>").val(iconPath.module).text(iconPath.module));
|
selectIconModule.append($("<option disabled></option>").val(iconPath.module).text(iconPath.module));
|
||||||
}
|
}
|
||||||
selectIconModule.val(iconPath.module);
|
selectIconModule.val(iconPath.module);
|
||||||
var iconModuleHidden = $('<input type="hidden" id="node-settings-icon-module-hidden"></input>').appendTo(iconForm);
|
var iconModuleHidden = $('<input type="hidden" id="node-settings-icon-module-hidden"></input>').appendTo(iconForm);
|
||||||
iconModuleHidden.val(iconPath.module);
|
iconModuleHidden.val(iconPath.module);
|
||||||
|
|
||||||
var selectIconFile = $('<select id="node-settings-icon-file"><option value=""></option></select>').appendTo(iconForm);
|
var selectIconFile = $('<select id="node-settings-icon-file"><option value=""></option></select>').appendTo(iconForm);
|
||||||
selectIconModule.change(function() {
|
selectIconModule.change(function() {
|
||||||
moduleChange(selectIconModule, selectIconFile, iconModuleHidden, iconFileHidden, iconSets, true);
|
moduleChange(selectIconModule, selectIconFile, iconModuleHidden, iconFileHidden, iconSets, true);
|
||||||
});
|
});
|
||||||
var iconFileHidden = $('<input type="hidden" id="node-settings-icon-file-hidden"></input>').appendTo(iconForm);
|
var iconFileHidden = $('<input type="hidden" id="node-settings-icon-file-hidden"></input>').appendTo(iconForm);
|
||||||
iconFileHidden.val(iconPath.file);
|
iconFileHidden.val(iconPath.file);
|
||||||
selectIconFile.change(function() {
|
selectIconFile.change(function() {
|
||||||
selectIconFile.removeClass("input-error");
|
selectIconFile.removeClass("input-error");
|
||||||
var fileName = selectIconFile.val();
|
var fileName = selectIconFile.val();
|
||||||
iconFileHidden.val(fileName);
|
iconFileHidden.val(fileName);
|
||||||
});
|
});
|
||||||
|
|
||||||
moduleChange(selectIconModule, selectIconFile, iconModuleHidden, iconFileHidden, iconSets, false);
|
moduleChange(selectIconModule, selectIconFile, iconModuleHidden, iconFileHidden, iconSets, false);
|
||||||
var iconFileList = iconSets[selectIconModule.val()];
|
var iconFileList = iconSets[selectIconModule.val()];
|
||||||
if (!iconFileList || iconFileList.indexOf(iconPath.file) === -1) {
|
if (!iconFileList || iconFileList.indexOf(iconPath.file) === -1) {
|
||||||
selectIconFile.append($("<option disabled></option>").val(iconPath.file).text(iconPath.file));
|
selectIconFile.append($("<option disabled></option>").val(iconPath.file).text(iconPath.file));
|
||||||
|
}
|
||||||
|
selectIconFile.val(iconPath.file);
|
||||||
}
|
}
|
||||||
selectIconFile.val(iconPath.file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function moduleChange(selectIconModule, selectIconFile, iconModuleHidden, iconFileHidden, iconSets, updateIconFile) {
|
function moduleChange(selectIconModule, selectIconFile, iconModuleHidden, iconFileHidden, iconSets, updateIconFile) {
|
||||||
@ -1051,28 +1056,30 @@ RED.editor = (function() {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var iconModule = $("#node-settings-icon-module-hidden").val();
|
if (!editing_node._def.defaults.hasOwnProperty("icon")) {
|
||||||
var iconFile = $("#node-settings-icon-file-hidden").val();
|
var iconModule = $("#node-settings-icon-module-hidden").val();
|
||||||
var icon = (iconModule && iconFile) ? iconModule+"/"+iconFile : "";
|
var iconFile = $("#node-settings-icon-file-hidden").val();
|
||||||
if (!isDefaultIcon) {
|
var icon = (iconModule && iconFile) ? iconModule+"/"+iconFile : "";
|
||||||
if (icon !== editing_node.icon) {
|
if (!isDefaultIcon) {
|
||||||
changes.icon = editing_node.icon;
|
if (icon !== editing_node.icon) {
|
||||||
editing_node.icon = icon;
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (icon !== defaultIcon) {
|
|
||||||
changes.icon = editing_node.icon;
|
|
||||||
editing_node.icon = icon;
|
|
||||||
changed = true;
|
|
||||||
} else {
|
|
||||||
var iconPath = RED.utils.getDefaultNodeIcon(editing_node._def, editing_node);
|
|
||||||
var currentDefaultIcon = iconPath.module+"/"+iconPath.file;
|
|
||||||
if (defaultIcon !== currentDefaultIcon) {
|
|
||||||
changes.icon = editing_node.icon;
|
changes.icon = editing_node.icon;
|
||||||
editing_node.icon = currentDefaultIcon;
|
editing_node.icon = icon;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (icon !== defaultIcon) {
|
||||||
|
changes.icon = editing_node.icon;
|
||||||
|
editing_node.icon = icon;
|
||||||
|
changed = true;
|
||||||
|
} else {
|
||||||
|
var iconPath = RED.utils.getDefaultNodeIcon(editing_node._def, editing_node);
|
||||||
|
var currentDefaultIcon = iconPath.module+"/"+iconPath.file;
|
||||||
|
if (defaultIcon !== currentDefaultIcon) {
|
||||||
|
changes.icon = editing_node.icon;
|
||||||
|
editing_node.icon = currentDefaultIcon;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user