mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Initial locking flows UX
This commit is contained in:
parent
a351cd9d9f
commit
3cb5259494
@ -63,6 +63,7 @@ RED.nodes = (function() {
|
|||||||
defaults: {
|
defaults: {
|
||||||
label: {value:""},
|
label: {value:""},
|
||||||
disabled: {value: false},
|
disabled: {value: false},
|
||||||
|
locked: {value: false},
|
||||||
info: {value: ""},
|
info: {value: ""},
|
||||||
env: {value: []}
|
env: {value: []}
|
||||||
}
|
}
|
||||||
@ -1052,6 +1053,9 @@ RED.nodes = (function() {
|
|||||||
node.type = n.type;
|
node.type = n.type;
|
||||||
for (var d in n._def.defaults) {
|
for (var d in n._def.defaults) {
|
||||||
if (n._def.defaults.hasOwnProperty(d)) {
|
if (n._def.defaults.hasOwnProperty(d)) {
|
||||||
|
if (d === 'locked' && !n.locked) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
node[d] = n[d];
|
node[d] = n[d];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1852,6 +1852,16 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var locked = $("#node-input-locked").prop("checked");
|
||||||
|
if (workspace.locked !== locked) {
|
||||||
|
editState.changes.locked = workspace.locked;
|
||||||
|
editState.changed = true;
|
||||||
|
workspace.locked = locked;
|
||||||
|
$("#red-ui-tab-"+(workspace.id.replace(".","-"))).toggleClass('red-ui-workspace-locked',!!workspace.locked);
|
||||||
|
// if (workspace.id === RED.workspaces.active()) {
|
||||||
|
// $("#red-ui-workspace").toggleClass("red-ui-workspace-locked",!!workspace.locked);
|
||||||
|
// }
|
||||||
|
}
|
||||||
if (editState.changed) {
|
if (editState.changed) {
|
||||||
var historyEvent = {
|
var historyEvent = {
|
||||||
t: "edit",
|
t: "edit",
|
||||||
@ -1892,6 +1902,7 @@ RED.editor = (function() {
|
|||||||
var trayBody = tray.find('.red-ui-tray-body');
|
var trayBody = tray.find('.red-ui-tray-body');
|
||||||
trayBody.parent().css('overflow','hidden');
|
trayBody.parent().css('overflow','hidden');
|
||||||
var trayFooterLeft = $('<div class="red-ui-tray-footer-left"></div>').appendTo(trayFooter)
|
var trayFooterLeft = $('<div class="red-ui-tray-footer-left"></div>').appendTo(trayFooter)
|
||||||
|
var trayFooterRight = $('<div class="red-ui-tray-footer-right"></div>').appendTo(trayFooter)
|
||||||
|
|
||||||
var nodeEditPanes = [
|
var nodeEditPanes = [
|
||||||
'editor-tab-flow-properties',
|
'editor-tab-flow-properties',
|
||||||
@ -1906,6 +1917,18 @@ RED.editor = (function() {
|
|||||||
disabledIcon: "fa-ban",
|
disabledIcon: "fa-ban",
|
||||||
invertState: true
|
invertState: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!workspace.hasOwnProperty("locked")) {
|
||||||
|
workspace.locked = false;
|
||||||
|
}
|
||||||
|
$('<input id="node-input-locked" type="checkbox">').prop("checked",workspace.locked).appendTo(trayFooterRight).toggleButton({
|
||||||
|
enabledLabel: 'Unlocked',
|
||||||
|
enabledIcon: "fa-unlock-alt",
|
||||||
|
disabledLabel: 'Locked',
|
||||||
|
disabledIcon: "fa-lock",
|
||||||
|
invertState: true
|
||||||
|
})
|
||||||
|
|
||||||
prepareEditDialog(trayBody, nodeEditPanes, workspace, {}, "node-input", defaultTab, function(_activeEditPanes) {
|
prepareEditDialog(trayBody, nodeEditPanes, workspace, {}, "node-input", defaultTab, function(_activeEditPanes) {
|
||||||
activeEditPanes = _activeEditPanes;
|
activeEditPanes = _activeEditPanes;
|
||||||
trayBody.i18n();
|
trayBody.i18n();
|
||||||
|
@ -221,6 +221,22 @@ RED.sidebar.info.outliner = (function() {
|
|||||||
} else {
|
} else {
|
||||||
$('<div class="red-ui-info-outline-item-control-spacer">').appendTo(controls)
|
$('<div class="red-ui-info-outline-item-control-spacer">').appendTo(controls)
|
||||||
}
|
}
|
||||||
|
if (n.type === 'tab') {
|
||||||
|
var lockToggleButton = $('<button type="button" class="red-ui-info-outline-item-control-lock red-ui-button red-ui-button-small"><i class="fa fa-unlock-alt"></i><i class="fa fa-lock"></i></button>').appendTo(controls).on("click",function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
evt.stopPropagation();
|
||||||
|
if (n.locked) {
|
||||||
|
RED.workspaces.unlock(n.id)
|
||||||
|
} else {
|
||||||
|
RED.workspaces.lock(n.id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
RED.popover.tooltip(lockToggleButton,function() {
|
||||||
|
return RED._("common.label."+(n.locked?"unlock":"lock"));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('<div class="red-ui-info-outline-item-control-spacer">').appendTo(controls)
|
||||||
|
}
|
||||||
controls.find("button").on("dblclick", function(evt) {
|
controls.find("button").on("dblclick", function(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
@ -364,6 +380,8 @@ RED.sidebar.info.outliner = (function() {
|
|||||||
flowList.treeList.addChild(objects[ws.id])
|
flowList.treeList.addChild(objects[ws.id])
|
||||||
objects[ws.id].element.toggleClass("red-ui-info-outline-item-disabled", !!ws.disabled)
|
objects[ws.id].element.toggleClass("red-ui-info-outline-item-disabled", !!ws.disabled)
|
||||||
objects[ws.id].treeList.container.toggleClass("red-ui-info-outline-item-disabled", !!ws.disabled)
|
objects[ws.id].treeList.container.toggleClass("red-ui-info-outline-item-disabled", !!ws.disabled)
|
||||||
|
objects[ws.id].element.toggleClass("red-ui-info-outline-item-locked", !!ws.locked)
|
||||||
|
// objects[ws.id].treeList.container.toggleClass("red-ui-info-outline-item-disabled", !!ws.disabled)
|
||||||
updateSearch();
|
updateSearch();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -378,6 +396,7 @@ RED.sidebar.info.outliner = (function() {
|
|||||||
existingObject.element.find(".red-ui-info-outline-item-label").text(label);
|
existingObject.element.find(".red-ui-info-outline-item-label").text(label);
|
||||||
existingObject.element.toggleClass("red-ui-info-outline-item-disabled", !!n.disabled)
|
existingObject.element.toggleClass("red-ui-info-outline-item-disabled", !!n.disabled)
|
||||||
existingObject.treeList.container.toggleClass("red-ui-info-outline-item-disabled", !!n.disabled)
|
existingObject.treeList.container.toggleClass("red-ui-info-outline-item-disabled", !!n.disabled)
|
||||||
|
existingObject.element.toggleClass("red-ui-info-outline-item-locked", !!n.locked)
|
||||||
updateSearch();
|
updateSearch();
|
||||||
}
|
}
|
||||||
function onFlowsReorder(order) {
|
function onFlowsReorder(order) {
|
||||||
|
@ -58,6 +58,9 @@ RED.workspaces = (function() {
|
|||||||
if (!ws.closeable) {
|
if (!ws.closeable) {
|
||||||
ws.hideable = true;
|
ws.hideable = true;
|
||||||
}
|
}
|
||||||
|
if (!ws.hasOwnProperty('locked')) {
|
||||||
|
ws.locked = false
|
||||||
|
}
|
||||||
workspace_tabs.addTab(ws,targetIndex);
|
workspace_tabs.addTab(ws,targetIndex);
|
||||||
|
|
||||||
var hiddenTabs = JSON.parse(RED.settings.getLocal("hiddenTabs")||"{}");
|
var hiddenTabs = JSON.parse(RED.settings.getLocal("hiddenTabs")||"{}");
|
||||||
@ -75,6 +78,7 @@ RED.workspaces = (function() {
|
|||||||
type: "tab",
|
type: "tab",
|
||||||
id: tabId,
|
id: tabId,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
locked: false,
|
||||||
info: "",
|
info: "",
|
||||||
label: RED._('workspace.defaultName',{number:workspaceIndex}),
|
label: RED._('workspace.defaultName',{number:workspaceIndex}),
|
||||||
env: [],
|
env: [],
|
||||||
@ -329,6 +333,12 @@ RED.workspaces = (function() {
|
|||||||
if (tab.disabled) {
|
if (tab.disabled) {
|
||||||
$("#red-ui-tab-"+(tab.id.replace(".","-"))).addClass('red-ui-workspace-disabled');
|
$("#red-ui-tab-"+(tab.id.replace(".","-"))).addClass('red-ui-workspace-disabled');
|
||||||
}
|
}
|
||||||
|
$('<span class="red-ui-workspace-locked-icon"><i class="fa fa-lock"></i> </span>').prependTo("#red-ui-tab-"+(tab.id.replace(".","-"))+" .red-ui-tab-label");
|
||||||
|
if (tab.locked) {
|
||||||
|
$("#red-ui-tab-"+(tab.id.replace(".","-"))).addClass('red-ui-workspace-locked');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RED.menu.setDisabled("menu-item-workspace-delete",activeWorkspace === 0 || workspaceTabCount <= 1);
|
RED.menu.setDisabled("menu-item-workspace-delete",activeWorkspace === 0 || workspaceTabCount <= 1);
|
||||||
if (workspaceTabCount === 1) {
|
if (workspaceTabCount === 1) {
|
||||||
showWorkspace();
|
showWorkspace();
|
||||||
@ -465,6 +475,8 @@ RED.workspaces = (function() {
|
|||||||
RED.actions.add("core:remove-flow",removeWorkspace);
|
RED.actions.add("core:remove-flow",removeWorkspace);
|
||||||
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:lock-flow",lockWorkspace);
|
||||||
|
RED.actions.add("core:unlock-flow",unlockWorkspace);
|
||||||
RED.actions.add("core:move-flow-to-start", function(id) { moveWorkspace(id, 'start') });
|
RED.actions.add("core:move-flow-to-start", function(id) { moveWorkspace(id, 'start') });
|
||||||
RED.actions.add("core:move-flow-to-end", function(id) { moveWorkspace(id, 'end') });
|
RED.actions.add("core:move-flow-to-end", function(id) { moveWorkspace(id, 'end') });
|
||||||
|
|
||||||
@ -638,6 +650,49 @@ RED.workspaces = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function lockWorkspace(id) {
|
||||||
|
setWorkspaceLockState(id,true);
|
||||||
|
}
|
||||||
|
function unlockWorkspace(id) {
|
||||||
|
setWorkspaceLockState(id,false);
|
||||||
|
}
|
||||||
|
function setWorkspaceLockState(id,locked) {
|
||||||
|
var workspace = RED.nodes.workspace(id||activeWorkspace);
|
||||||
|
if (!workspace) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (workspace.locked !== locked) {
|
||||||
|
var changes = { locked: workspace.locked };
|
||||||
|
workspace.locked = locked;
|
||||||
|
$("#red-ui-tab-"+(workspace.id.replace(".","-"))).toggleClass('red-ui-workspace-locked',!!workspace.locked);
|
||||||
|
if (!id || (id === activeWorkspace)) {
|
||||||
|
$("#red-ui-workspace").toggleClass("red-ui-workspace-locked",!!workspace.locked);
|
||||||
|
}
|
||||||
|
var historyEvent = {
|
||||||
|
t: "edit",
|
||||||
|
changes:changes,
|
||||||
|
node: workspace,
|
||||||
|
dirty: RED.nodes.dirty()
|
||||||
|
}
|
||||||
|
workspace.changed = true;
|
||||||
|
RED.history.push(historyEvent);
|
||||||
|
RED.events.emit("flows:change",workspace);
|
||||||
|
RED.nodes.dirty(true);
|
||||||
|
// RED.sidebar.config.refresh();
|
||||||
|
// var selection = RED.view.selection();
|
||||||
|
// if (!selection.nodes && !selection.links && workspace.id === activeWorkspace) {
|
||||||
|
// RED.sidebar.info.refresh(workspace);
|
||||||
|
// }
|
||||||
|
// if (changes.hasOwnProperty('disabled')) {
|
||||||
|
// RED.nodes.eachNode(function(n) {
|
||||||
|
// if (n.z === workspace.id) {
|
||||||
|
// n.dirty = true;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// RED.view.redraw();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function removeWorkspace(ws) {
|
function removeWorkspace(ws) {
|
||||||
if (!ws) {
|
if (!ws) {
|
||||||
@ -793,6 +848,8 @@ RED.workspaces = (function() {
|
|||||||
workspace_tabs.resize();
|
workspace_tabs.resize();
|
||||||
},
|
},
|
||||||
enable: enableWorkspace,
|
enable: enableWorkspace,
|
||||||
disable: disableWorkspace
|
disable: disableWorkspace,
|
||||||
|
lock: lockWorkspace,
|
||||||
|
unlock: unlockWorkspace
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -467,6 +467,9 @@ div.red-ui-info-table {
|
|||||||
.fa-eye {
|
.fa-eye {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
.fa-unlock-alt {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.red-ui-info-outline-item-control-reveal,
|
.red-ui-info-outline-item-control-reveal,
|
||||||
.red-ui-info-outline-item-control-action {
|
.red-ui-info-outline-item-control-action {
|
||||||
@ -500,6 +503,17 @@ div.red-ui-info-table {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.fa-lock {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.red-ui-info-outline-item.red-ui-info-outline-item-locked & {
|
||||||
|
.fa-lock {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.fa-unlock-alt {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
button {
|
button {
|
||||||
margin-right: 3px
|
margin-right: 3px
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,28 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.red-ui-workspace-locked-icon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.red-ui-workspace-locked {
|
||||||
|
&.red-ui-tab {
|
||||||
|
// border-top-style: dashed;
|
||||||
|
// border-left-style: dashed;
|
||||||
|
// border-right-style: dashed;
|
||||||
|
|
||||||
|
// a {
|
||||||
|
// font-style: italic;
|
||||||
|
// color: var(--red-ui-tab-text-color-disabled-inactive) !important;
|
||||||
|
// }
|
||||||
|
// &.active a {
|
||||||
|
// font-weight: normal;
|
||||||
|
// color: var(--red-ui-tab-text-color-disabled-active) !important;
|
||||||
|
// }
|
||||||
|
.red-ui-workspace-locked-icon {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#red-ui-navigator-canvas {
|
#red-ui-navigator-canvas {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
Loading…
Reference in New Issue
Block a user