1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add configurable option for showing node label

This commit is contained in:
Nick O'Leary 2018-10-22 15:38:43 +01:00
parent 0a98ba6985
commit c66c5ea53c
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 22 additions and 9 deletions

View File

@ -75,7 +75,8 @@
"projects": "Projects",
"projects-new": "New",
"projects-open": "Open",
"projects-settings": "Project Settings"
"projects-settings": "Project Settings",
"showNodeLabelDefault": "Show label of newly added nodes"
}
},
"actions": {

View File

@ -114,7 +114,8 @@ RED.userSettings = (function() {
{
title: "menu.label.nodes",
options: [
{setting:"view-node-status",oldSetting:"menu-menu-item-status",label:"menu.label.displayStatus",default: true, toggle:true,onchange:"core:toggle-status"}
{setting:"view-node-status",oldSetting:"menu-menu-item-status",label:"menu.label.displayStatus",default: true, toggle:true,onchange:"core:toggle-status"},
{setting:"view-node-show-label",label:"menu.label.showNodeLabelDefault",default: true, toggle:true}
]
},
{
@ -210,7 +211,6 @@ RED.userSettings = (function() {
}
}
allSettings[opt.setting] = opt;
if (opt.onchange) {
var value = currentEditorSettings.view[opt.setting];
if ((value === null || value === undefined) && opt.hasOwnProperty('default')) {
value = opt.default;
@ -218,6 +218,7 @@ RED.userSettings = (function() {
editorSettingsChanged = true;
}
if (opt.onchange) {
var callback = opt.onchange;
if (typeof callback === 'string') {
callback = RED.actions.get(callback);

View File

@ -365,6 +365,11 @@ RED.view = (function() {
var historyEvent = result.historyEvent;
var nn = result.node;
var showLabel = RED.utils.getMessageProperty(RED.settings.get('editor'),"view.view-node-show-label");
if (showLabel !== undefined && !/^link (in|out)$/.test(nn._def.type) && !nn._def.defaults.hasOwnProperty("l")) {
nn.l = showLabel;
}
var helperOffset = d3.touches(ui.helper.get(0))[0]||d3.mouse(ui.helper.get(0));
var mousePos = d3.touches(this)[0]||d3.mouse(this);
@ -668,6 +673,12 @@ RED.view = (function() {
var historyEvent = result.historyEvent;
nn.x = point[0];
nn.y = point[1];
var showLabel = RED.utils.getMessageProperty(RED.settings.get('editor'),"view.view-node-show-label");
if (showLabel !== undefined && !/^link (in|out)$/.test(nn._def.type) && !nn._def.defaults.hasOwnProperty("l")) {
nn.l = showLabel;
}
if (mouse_mode === RED.state.QUICK_JOINING || quickAddLink) {
if (quickAddLink || drag_lines.length > 0) {
var drag_line = quickAddLink||drag_lines[0];