mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add core:hide-other-tabs and handle multiple tab selection
This commit is contained in:
parent
0874ba7a03
commit
c880cc0987
@ -896,6 +896,17 @@ RED.tabs = (function() {
|
|||||||
return $.makeArray(ul.children().map(function() { return $(this).data('tabId');}));
|
return $.makeArray(ul.children().map(function() { return $(this).data('tabId');}));
|
||||||
},
|
},
|
||||||
selection: getSelection,
|
selection: getSelection,
|
||||||
|
clearSelection: function() {
|
||||||
|
if (options.onselect) {
|
||||||
|
var selection = ul.find("li.red-ui-tab.selected");
|
||||||
|
console.log(selection.length)
|
||||||
|
if (selection.length > 0) {
|
||||||
|
selection.removeClass("selected");
|
||||||
|
selectionChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
order: function(order) {
|
order: function(order) {
|
||||||
preferredOrder = order;
|
preferredOrder = order;
|
||||||
var existingTabOrder = $.makeArray(ul.children().map(function() { return $(this).data('tabId');}));
|
var existingTabOrder = $.makeArray(ul.children().map(function() { return $(this).data('tabId');}));
|
||||||
|
@ -33,6 +33,24 @@ RED.workspaces = (function() {
|
|||||||
viewStackPos = viewStack.length;
|
viewStackPos = viewStack.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeFromHideStack(id) {
|
||||||
|
hideStack = hideStack.filter(function(v) {
|
||||||
|
if (v === id) {
|
||||||
|
return false;
|
||||||
|
} else if (Array.isArray(v)) {
|
||||||
|
var i = v.indexOf(id);
|
||||||
|
if (i > -1) {
|
||||||
|
v.splice(i,1);
|
||||||
|
}
|
||||||
|
if (v.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function addWorkspace(ws,skipHistoryEntry,targetIndex) {
|
function addWorkspace(ws,skipHistoryEntry,targetIndex) {
|
||||||
if (ws) {
|
if (ws) {
|
||||||
if (!ws.closeable) {
|
if (!ws.closeable) {
|
||||||
@ -329,10 +347,7 @@ RED.workspaces = (function() {
|
|||||||
RED.events.emit("workspace:hide",{workspace: tab.id})
|
RED.events.emit("workspace:hide",{workspace: tab.id})
|
||||||
},
|
},
|
||||||
onshow: function(tab) {
|
onshow: function(tab) {
|
||||||
var i = hideStack.indexOf(tab.id);
|
removeFromHideStack(tab.id);
|
||||||
if (i > -1) {
|
|
||||||
hideStack.splice(i,1);
|
|
||||||
}
|
|
||||||
RED.events.emit("workspace:show",{workspace: tab.id})
|
RED.events.emit("workspace:show",{workspace: tab.id})
|
||||||
},
|
},
|
||||||
minimumActiveTabWidth: 150,
|
minimumActiveTabWidth: 150,
|
||||||
@ -396,12 +411,54 @@ RED.workspaces = (function() {
|
|||||||
RED.actions.add("core:enable-flow",enableWorkspace);
|
RED.actions.add("core:enable-flow",enableWorkspace);
|
||||||
RED.actions.add("core:disable-flow",disableWorkspace);
|
RED.actions.add("core:disable-flow",disableWorkspace);
|
||||||
|
|
||||||
RED.actions.add("core:hide-tab", function() { RED.workspaces.hide(); })
|
RED.actions.add("core:hide-tab", function() {
|
||||||
|
var selection = workspace_tabs.selection();
|
||||||
|
if (selection.length === 0) {
|
||||||
|
selection = [{id:activeWorkspace}]
|
||||||
|
}
|
||||||
|
var hiddenTabs = [];
|
||||||
|
selection.forEach(function(ws) {
|
||||||
|
RED.workspaces.hide(ws.id);
|
||||||
|
hideStack.pop();
|
||||||
|
hiddenTabs.push(ws.id);
|
||||||
|
})
|
||||||
|
if (hiddenTabs.length > 0) {
|
||||||
|
hideStack.push(hiddenTabs);
|
||||||
|
}
|
||||||
|
workspace_tabs.clearSelection();
|
||||||
|
})
|
||||||
|
|
||||||
|
RED.actions.add("core:hide-other-tabs", function() {
|
||||||
|
var selection = workspace_tabs.selection();
|
||||||
|
if (selection.length === 0) {
|
||||||
|
selection = [{id:activeWorkspace}]
|
||||||
|
}
|
||||||
|
var selected = new Set(selection.map(function(ws) { return ws.id }))
|
||||||
|
|
||||||
|
var currentTabs = workspace_tabs.listTabs();
|
||||||
|
var hiddenTabs = [];
|
||||||
|
currentTabs.forEach(function(id) {
|
||||||
|
if (!selected.has(id)) {
|
||||||
|
RED.workspaces.hide(id);
|
||||||
|
hideStack.pop();
|
||||||
|
hiddenTabs.push(id);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (hiddenTabs.length > 0) {
|
||||||
|
hideStack.push(hiddenTabs);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
RED.actions.add("core:hide-all-tabs", function() {
|
RED.actions.add("core:hide-all-tabs", function() {
|
||||||
var currentTabs = workspace_tabs.listTabs();
|
var currentTabs = workspace_tabs.listTabs();
|
||||||
currentTabs.forEach(function(id) {
|
currentTabs.forEach(function(id) {
|
||||||
RED.workspaces.hide(id)
|
RED.workspaces.hide(id);
|
||||||
|
hideStack.pop();
|
||||||
})
|
})
|
||||||
|
if (currentTabs.length > 0) {
|
||||||
|
hideStack.push(currentTabs);
|
||||||
|
}
|
||||||
|
workspace_tabs.clearSelection();
|
||||||
})
|
})
|
||||||
RED.actions.add("core:show-all-tabs", function() {
|
RED.actions.add("core:show-all-tabs", function() {
|
||||||
var currentTabs = workspace_tabs.listTabs();
|
var currentTabs = workspace_tabs.listTabs();
|
||||||
@ -422,7 +479,15 @@ RED.workspaces = (function() {
|
|||||||
})
|
})
|
||||||
RED.actions.add("core:show-last-hidden-tab", function() {
|
RED.actions.add("core:show-last-hidden-tab", function() {
|
||||||
var id = hideStack.pop();
|
var id = hideStack.pop();
|
||||||
RED.workspaces.show(id);
|
if (id) {
|
||||||
|
if (typeof id === 'string') {
|
||||||
|
RED.workspaces.show(id);
|
||||||
|
} else {
|
||||||
|
id.forEach(function(i) {
|
||||||
|
RED.workspaces.show(i);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
RED.actions.add("core:list-flows",function() {
|
RED.actions.add("core:list-flows",function() {
|
||||||
@ -555,11 +620,7 @@ RED.workspaces = (function() {
|
|||||||
null,
|
null,
|
||||||
workspace_tabs.activeIndex()+1
|
workspace_tabs.activeIndex()+1
|
||||||
);
|
);
|
||||||
var i = hideStack.indexOf(id);
|
removeFromHideStack(id);
|
||||||
if (i > -1) {
|
|
||||||
hideStack.splice(i,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user