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

Ensure existing grid settings are migrated to new keys

This commit is contained in:
Nick O'Leary 2017-06-28 22:15:30 +01:00
parent dded98e30c
commit 74ea85d19c
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -102,21 +102,21 @@ RED.userSettings = (function() {
{ {
title: "Grid", title: "Grid",
options: [ options: [
{setting:"view-show-grid",label:"menu.label.view.showGrid",toggle:true,onchange:"core:toggle-show-grid"}, {setting:"view-show-grid",oldSetting:"menu-menu-item-view-show-grid",label:"menu.label.view.showGrid",toggle:true,onchange:"core:toggle-show-grid"},
{setting:"view-snap-grid",label:"menu.label.view.snapGrid",toggle:true,onchange:"core:toggle-snap-grid"}, {setting:"view-snap-grid",oldSetting:"menu-menu-item-view-snap-grid",label:"menu.label.view.snapGrid",toggle:true,onchange:"core:toggle-snap-grid"},
{setting:"view-grid-size",label:"menu.label.view.gridSize",type:"number",default: 20, onchange:RED.view.gridSize} {setting:"view-grid-size",label:"menu.label.view.gridSize",type:"number",default: 20, onchange:RED.view.gridSize}
] ]
}, },
{ {
title: "Nodes", title: "Nodes",
options: [ options: [
{setting:"view-node-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"}
] ]
}, },
{ {
title: "Other", title: "Other",
options: [ options: [
{setting:"view-show-tips",label:"menu.label.showTips",toggle:true,default:true,onchange:"core:toggle-show-tips"} {setting:"view-show-tips",oldSettings:"menu-menu-item-show-tips",label:"menu.label.showTips",toggle:true,default:true,onchange:"core:toggle-show-tips"}
] ]
} }
]; ];
@ -187,6 +187,13 @@ RED.userSettings = (function() {
viewSettings.forEach(function(section) { viewSettings.forEach(function(section) {
section.options.forEach(function(opt) { section.options.forEach(function(opt) {
if (opt.oldSetting) {
var oldValue = RED.settings.get(opt.oldSetting);
if (oldValue !== undefined && oldValue !== null) {
RED.settings.set(opt.setting,oldValue);
RED.settings.remove(opt.oldSetting);
}
}
allSettings[opt.setting] = opt; allSettings[opt.setting] = opt;
if (opt.onchange) { if (opt.onchange) {
var value = RED.settings.get(opt.setting); var value = RED.settings.get(opt.setting);