mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Allow tabs to be enabled/disabled in the editor
This commit is contained in:
parent
2db65b9d1f
commit
17e092afb3
@ -276,7 +276,8 @@ RED.nodes = (function() {
|
|||||||
workspaces[ws.id] = ws;
|
workspaces[ws.id] = ws;
|
||||||
ws._def = {
|
ws._def = {
|
||||||
defaults: {
|
defaults: {
|
||||||
label: {value:""}
|
label: {value:""},
|
||||||
|
disabled: {value: false}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -215,6 +215,7 @@ RED.tabs = (function() {
|
|||||||
addTab: function(tab) {
|
addTab: function(tab) {
|
||||||
tabs[tab.id] = tab;
|
tabs[tab.id] = tab;
|
||||||
var li = $("<li/>",{class:"red-ui-tab"}).appendTo(ul);
|
var li = $("<li/>",{class:"red-ui-tab"}).appendTo(ul);
|
||||||
|
li.attr('id',"red-ui-tab-"+(tab.id.replace(".","-")));
|
||||||
li.data("tabId",tab.id);
|
li.data("tabId",tab.id);
|
||||||
var link = $("<a/>",{href:"#"+tab.id, class:"red-ui-tab-label"}).appendTo(li);
|
var link = $("<a/>",{href:"#"+tab.id, class:"red-ui-tab-label"}).appendTo(li);
|
||||||
if (tab.icon) {
|
if (tab.icon) {
|
||||||
@ -334,7 +335,7 @@ RED.tabs = (function() {
|
|||||||
tabs[id].label = label;
|
tabs[id].label = label;
|
||||||
var tab = ul.find("a[href='#"+id+"']");
|
var tab = ul.find("a[href='#"+id+"']");
|
||||||
tab.attr("title",label);
|
tab.attr("title",label);
|
||||||
tab.find("span").text(label).attr('dir', RED.text.bidi.resolveBaseTextDir(label));
|
tab.find("span.bidiAware").text(label).attr('dir', RED.text.bidi.resolveBaseTextDir(label));
|
||||||
updateTabWidths();
|
updateTabWidths();
|
||||||
},
|
},
|
||||||
order: function(order) {
|
order: function(order) {
|
||||||
|
@ -84,10 +84,24 @@ RED.workspaces = (function() {
|
|||||||
text: RED._("common.label.done"),
|
text: RED._("common.label.done"),
|
||||||
click: function() {
|
click: function() {
|
||||||
var label = $( "#node-input-name" ).val();
|
var label = $( "#node-input-name" ).val();
|
||||||
|
var changed = false;
|
||||||
|
var changes = {};
|
||||||
if (workspace.label != label) {
|
if (workspace.label != label) {
|
||||||
var changes = {
|
changes.label = workspace.label;
|
||||||
label:workspace.label
|
changed = true;
|
||||||
|
workspace.label = label;
|
||||||
|
workspace_tabs.renameTab(workspace.id,label);
|
||||||
}
|
}
|
||||||
|
var disabled = $("#node-input-disabled").prop("checked");
|
||||||
|
if (workspace.disabled !== disabled) {
|
||||||
|
changes.disabled = workspace.disabled;
|
||||||
|
changed = true;
|
||||||
|
workspace.disabled = disabled;
|
||||||
|
}
|
||||||
|
$("#red-ui-tab-"+(workspace.id.replace(".","-"))).toggleClass('workspace-disabled',workspace.disabled);
|
||||||
|
// $("#workspace").toggleClass("workspace-disabled",workspace.disabled);
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
var historyEvent = {
|
var historyEvent = {
|
||||||
t: "edit",
|
t: "edit",
|
||||||
changes:changes,
|
changes:changes,
|
||||||
@ -96,7 +110,6 @@ RED.workspaces = (function() {
|
|||||||
}
|
}
|
||||||
workspace.changed = true;
|
workspace.changed = true;
|
||||||
RED.history.push(historyEvent);
|
RED.history.push(historyEvent);
|
||||||
workspace_tabs.renameTab(workspace.id,label);
|
|
||||||
RED.nodes.dirty(true);
|
RED.nodes.dirty(true);
|
||||||
RED.sidebar.config.refresh();
|
RED.sidebar.config.refresh();
|
||||||
}
|
}
|
||||||
@ -111,6 +124,38 @@ RED.workspaces = (function() {
|
|||||||
'<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">'+
|
'<input type="text" id="node-input-name">'+
|
||||||
'</div>').appendTo(dialogForm);
|
'</div>').appendTo(dialogForm);
|
||||||
|
|
||||||
|
$('<div class="form-row">'+
|
||||||
|
'<label for="node-input-disabled-btn">Status</label>'+
|
||||||
|
'<button id="node-input-disabled-btn" class="editor-button"><i class="fa fa-toggle-on"></i> <span id="node-input-disabled-label">Enabled</span></button> '+
|
||||||
|
'<input type="checkbox" id="node-input-disabled" style="display: none;"/>'+
|
||||||
|
'</div>').appendTo(dialogForm);
|
||||||
|
|
||||||
|
dialogForm.find('#node-input-disabled-btn').on("click",function(e) {
|
||||||
|
var i = $(this).find("i");
|
||||||
|
if (i.hasClass('fa-toggle-off')) {
|
||||||
|
i.addClass('fa-toggle-on');
|
||||||
|
i.removeClass('fa-toggle-off');
|
||||||
|
$("#node-input-disabled").prop("checked",false);
|
||||||
|
$("#node-input-disabled-label").html("Enabled");
|
||||||
|
} else {
|
||||||
|
i.addClass('fa-toggle-off');
|
||||||
|
i.removeClass('fa-toggle-on');
|
||||||
|
$("#node-input-disabled").prop("checked",true);
|
||||||
|
$("#node-input-disabled-label").html("Disabled");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (workspace.hasOwnProperty("disabled")) {
|
||||||
|
$("#node-input-disabled").prop("checked",workspace.disabled);
|
||||||
|
if (workspace.disabled) {
|
||||||
|
dialogForm.find("#node-input-disabled-btn i").removeClass('fa-toggle-on').addClass('fa-toggle-off');
|
||||||
|
$("#node-input-disabled-label").html("Disabled");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
workspace.disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
$('<input type="text" style="display: none;" />').prependTo(dialogForm);
|
$('<input type="text" style="display: none;" />').prependTo(dialogForm);
|
||||||
dialogForm.submit(function(e) { e.preventDefault();});
|
dialogForm.submit(function(e) { e.preventDefault();});
|
||||||
$("#node-input-name").val(workspace.label);
|
$("#node-input-name").val(workspace.label);
|
||||||
@ -137,6 +182,7 @@ RED.workspaces = (function() {
|
|||||||
}
|
}
|
||||||
activeWorkspace = tab.id;
|
activeWorkspace = tab.id;
|
||||||
event.workspace = activeWorkspace;
|
event.workspace = activeWorkspace;
|
||||||
|
// $("#workspace").toggleClass("workspace-disabled",tab.disabled);
|
||||||
RED.events.emit("workspace:change",event);
|
RED.events.emit("workspace:change",event);
|
||||||
window.location.hash = 'flow/'+tab.id;
|
window.location.hash = 'flow/'+tab.id;
|
||||||
RED.sidebar.config.refresh();
|
RED.sidebar.config.refresh();
|
||||||
@ -153,6 +199,10 @@ RED.workspaces = (function() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onadd: function(tab) {
|
onadd: function(tab) {
|
||||||
|
$('<span class="workspace-disabled-icon"><i class="fa fa-ban"></i> </span>').prependTo("#red-ui-tab-"+(tab.id.replace(".","-"))+" .red-ui-tab-label");
|
||||||
|
if (tab.disabled) {
|
||||||
|
$("#red-ui-tab-"+(tab.id.replace(".","-"))).addClass('workspace-disabled');
|
||||||
|
}
|
||||||
RED.menu.setDisabled("menu-item-workspace-delete",workspace_tabs.count() == 1);
|
RED.menu.setDisabled("menu-item-workspace-delete",workspace_tabs.count() == 1);
|
||||||
},
|
},
|
||||||
onremove: function(tab) {
|
onremove: function(tab) {
|
||||||
|
@ -58,3 +58,25 @@
|
|||||||
color:#666;
|
color:#666;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.workspace-disabled-icon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.workspace-disabled {
|
||||||
|
&.red-ui-tab {
|
||||||
|
border-top-style: dashed;
|
||||||
|
border-left-style: dashed;
|
||||||
|
border-right-style: dashed;
|
||||||
|
|
||||||
|
a {
|
||||||
|
font-style: italic;
|
||||||
|
color: #aaa !important;
|
||||||
|
}
|
||||||
|
&.active a {
|
||||||
|
font-weight: normal;
|
||||||
|
color: #999 !important;
|
||||||
|
}
|
||||||
|
.workspace-disabled-icon {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user