Edit panes should not need to create own tray content div

This commit is contained in:
Nick O'Leary 2021-09-02 21:44:06 +01:00
parent c3d0b1114f
commit 4e92492165
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
8 changed files with 27 additions and 31 deletions

View File

@ -26,7 +26,7 @@ RED.editor = (function() {
var customEditTypes = {}; var customEditTypes = {};
var editPanes = {}; var editPanes = {};
var filteredEditPanes = []; var filteredEditPanes = {};
var editTrayWidthCache = {}; var editTrayWidthCache = {};
@ -414,10 +414,10 @@ RED.editor = (function() {
element:editorTabEl, element:editorTabEl,
onchange:function(tab) { onchange:function(tab) {
editorContent.children().hide(); editorContent.children().hide();
tab.content.show();
if (tab.onchange) { if (tab.onchange) {
tab.onchange.call(tab); tab.onchange.call(tab);
} }
tab.content.show();
if (finishedBuilding) { if (finishedBuilding) {
RED.tray.resize(); RED.tray.resize();
} }
@ -427,6 +427,16 @@ RED.editor = (function() {
}); });
var activeEditPanes = []; var activeEditPanes = [];
nodeEditPanes = nodeEditPanes.slice();
for (var i in filteredEditPanes) {
if (filteredEditPanes.hasOwnProperty(i)) {
if (filteredEditPanes[i](node)) {
nodeEditPanes.push(i);
}
}
}
nodeEditPanes.forEach(function(id) { nodeEditPanes.forEach(function(id) {
try { try {
var editPaneDefinition = editPanes[id]; var editPaneDefinition = editPanes[id];
@ -434,15 +444,17 @@ RED.editor = (function() {
if (typeof editPaneDefinition === 'function') { if (typeof editPaneDefinition === 'function') {
editPaneDefinition = editPaneDefinition.call(editPaneDefinition); editPaneDefinition = editPaneDefinition.call(editPaneDefinition);
} }
var editPaneContent = $('<div>', {class:"red-ui-tray-content"}).appendTo(editorContent).hide();
editPaneDefinition.create.call(editPaneDefinition,editPaneContent,node);
var editTab = { var editTab = {
id: id, id: id,
label: editPaneDefinition.label, label: editPaneDefinition.label,
name: editPaneDefinition.name, name: editPaneDefinition.name,
iconClass: editPaneDefinition.iconClass, iconClass: editPaneDefinition.iconClass,
content: editPaneDefinition.create.call(editPaneDefinition,editorContent,node).hide(), content: editPaneContent,
onchange: function() { onchange: function() {
if (editPaneDefinition.onchange) { if (editPaneDefinition.show) {
editPaneDefinition.onchange.call(editPaneDefinition,node) editPaneDefinition.show.call(editPaneDefinition,node)
} }
} }
} }
@ -1901,10 +1913,9 @@ RED.editor = (function() {
registerEditorPane: function(type, definition, filter) { registerEditorPane: function(type, definition, filter) {
if (filter) { if (filter) {
filteredEditPanes.push({type, definition, filter}) filteredEditPanes[type] = filter
} else {
editPanes[type] = definition;
} }
editPanes[type] = definition;
} }
} }
})(); })();

View File

@ -6,7 +6,7 @@
name: RED._("editor-tab.appearance"), name: RED._("editor-tab.appearance"),
iconClass: "fa fa-object-group", iconClass: "fa fa-object-group",
create: function(container, node) { create: function(container, node) {
this.content = $('<div>', {class:"red-ui-tray-content"}).appendTo(container); this.content = container;
buildAppearanceForm(this.content,node); buildAppearanceForm(this.content,node);
if (node.type === 'subflow') { if (node.type === 'subflow') {
@ -20,7 +20,6 @@
this.isDefaultIcon = true; this.isDefaultIcon = true;
} }
} }
return this.content;
}, },
resize: function(node, size) { resize: function(node, size) {

View File

@ -7,9 +7,8 @@
iconClass: "fa fa-file-text-o", iconClass: "fa fa-file-text-o",
create: function(container, node) { create: function(container, node) {
var content = $('<div>', {class:"red-ui-tray-content"}).appendTo(container); this.editor = buildDescriptionForm(container,node);
this.editor = buildDescriptionForm(content,node); RED.e = this.editor;
return content;
}, },
resize: function(node, size) { resize: function(node, size) {
this.editor.resize(); this.editor.resize();

View File

@ -6,12 +6,10 @@
name: RED._("editor-tab.envProperties"), name: RED._("editor-tab.envProperties"),
iconClass: "fa fa-list", iconClass: "fa fa-list",
create: function(container, node) { create: function(container, node) {
var content = $('<div>', {class:"red-ui-tray-content"}).appendTo(container); var form = $('<form class="dialog-form form-horizontal"></form>').appendTo(container);
var form = $('<form class="dialog-form form-horizontal"></form>').appendTo(content);
var listContainer = $('<div class="form-row node-input-env-container-row"></div>').appendTo(form); var listContainer = $('<div class="form-row node-input-env-container-row"></div>').appendTo(form);
this.list = $('<ol></ol>').appendTo(listContainer); this.list = $('<ol></ol>').appendTo(listContainer);
RED.editor.envVarList.create(this.list, node); RED.editor.envVarList.create(this.list, node);
return content;
}, },
resize: function(node, size) { resize: function(node, size) {
this.list.editableList('height',size.height); this.list.editableList('height',size.height);

View File

@ -6,9 +6,7 @@
name: RED._("editor-tab.properties"), name: RED._("editor-tab.properties"),
iconClass: "fa fa-cog", iconClass: "fa fa-cog",
create: function(container, node) { create: function(container, node) {
var content = $('<div>', {class:"red-ui-tray-content"}).appendTo(container); var dialogForm = $('<form id="dialog-form" class="form-horizontal"></form>').appendTo(container);
var dialogForm = $('<form id="dialog-form" class="form-horizontal"></form>').appendTo(content);
$('<div class="form-row">'+ $('<div class="form-row">'+
'<label for="node-input-name" data-i18n="[append]editor:common.label.name"><i class="fa fa-tag"></i> </label>'+ '<label for="node-input-name" data-i18n="[append]editor:common.label.name"><i class="fa fa-tag"></i> </label>'+
'<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">'+ '<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">'+
@ -30,7 +28,6 @@
$("#node-input-name").val(node.label); $("#node-input-name").val(node.label);
RED.text.bidi.prepareInput($("#node-input-name")); RED.text.bidi.prepareInput($("#node-input-name"));
this.tabflowEditor.getSession().setValue(node.info || "", -1); this.tabflowEditor.getSession().setValue(node.info || "", -1);
return content;
}, },
resize: function(node, size) { resize: function(node, size) {
$("#node-input-info").css("height", (size.height-70)+"px"); $("#node-input-info").css("height", (size.height-70)+"px");

View File

@ -6,7 +6,6 @@
name: RED._("editor-tab.properties"), name: RED._("editor-tab.properties"),
iconClass: "fa fa-cog", iconClass: "fa fa-cog",
create: function(container, node) { create: function(container, node) {
var content = $('<div>', {class:"red-ui-tray-content"}).appendTo(container);
var nodeType = node.type; var nodeType = node.type;
if (node.type === "subflow") { if (node.type === "subflow") {
@ -28,9 +27,7 @@
this.inputClass = "node-config-input"; this.inputClass = "node-config-input";
formStyle = "node-config-dialog-edit-form"; formStyle = "node-config-dialog-edit-form";
} }
RED.editor.buildEditForm(content,formStyle,nodeType,i18nNamespace,node); RED.editor.buildEditForm(container,formStyle,nodeType,i18nNamespace,node);
return content;
}, },
resize: function(node, size) { resize: function(node, size) {
if (node && node._def.oneditresize) { if (node && node._def.oneditresize) {

View File

@ -36,9 +36,7 @@
name: RED._("editor-tab.module"), name: RED._("editor-tab.module"),
iconClass: "fa fa-cube", iconClass: "fa fa-cube",
create: function(container, node) { create: function(container, node) {
var content = $('<div>', {class:"red-ui-tray-content"}).appendTo(container); buildModuleForm(container, node);
buildModuleForm(content, node);
return content;
}, },
resize: function(node, size) { resize: function(node, size) {
}, },

View File

@ -6,9 +6,7 @@
name: RED._("editor-tab.properties"), name: RED._("editor-tab.properties"),
iconClass: "fa fa-cog", iconClass: "fa fa-cog",
create: function(container, node) { create: function(container, node) {
var content = $('<div>', {class:"red-ui-tray-content"}).appendTo(container); var dialogForm = $('<form id="dialog-form" class="form-horizontal"></form>').appendTo(container);
var dialogForm = $('<form id="dialog-form" class="form-horizontal"></form>').appendTo(content);
$('<div class="form-row">'+ $('<div class="form-row">'+
'<label for="node-input-name" data-i18n="[append]editor:common.label.name"><i class="fa fa-tag"></i> </label>'+ '<label for="node-input-name" data-i18n="[append]editor:common.label.name"><i class="fa fa-tag"></i> </label>'+
'<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">'+ '<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">'+
@ -30,7 +28,6 @@
$("#node-input-name").val(node.label); $("#node-input-name").val(node.label);
RED.text.bidi.prepareInput($("#node-input-name")); RED.text.bidi.prepareInput($("#node-input-name"));
this.tabflowEditor.getSession().setValue(node.info || "", -1); this.tabflowEditor.getSession().setValue(node.info || "", -1);
return content;
}, },
resize: function(node, size) { resize: function(node, size) {
$("#node-input-info").css("height", (size.height-70)+"px"); $("#node-input-info").css("height", (size.height-70)+"px");