Better handling of empty projects and lifecycle

This commit is contained in:
Nick O'Leary
2018-01-09 15:06:05 +00:00
parent 8a6488b067
commit 13356047dc
9 changed files with 96 additions and 40 deletions

View File

@@ -118,6 +118,7 @@
text: "Setup project files",
click: function() {
persistentNotifications[notificationId].close();
delete persistentNotifications[notificationId];
RED.projects.showFilesPrompt();
}
}
@@ -128,11 +129,13 @@
text: "No thanks",
click: function() {
persistentNotifications[notificationId].close();
delete persistentNotifications[notificationId];
}
}, {
text: "Create default project files",
click: function() {
persistentNotifications[notificationId].close();
delete persistentNotifications[notificationId];
RED.projects.createDefaultFileSet();
}
}
@@ -142,7 +145,7 @@
if (!persistentNotifications.hasOwnProperty(notificationId)) {
persistentNotifications[notificationId] = RED.notify(text,options);
} else {
persistentNotifications[notificationId].update(text,msg.timeout);
persistentNotifications[notificationId].update(text,options);
}
} else if (persistentNotifications.hasOwnProperty(notificationId)) {
persistentNotifications[notificationId].close();

View File

@@ -85,18 +85,34 @@ RED.notify = (function() {
n.update = (function() {
var nn = n;
return function(msg,timeout) {
return function(msg,options) {
if (typeof msg === "string") {
nn.innerHTML = msg;
} else {
$(nn).empty().append(msg);
}
var timeout;
if (typeof options === 'number') {
timeout = options;
} else if (options !== undefined) {
timeout = options.timeout;
if (options.buttons) {
var buttonSet = $('<div style="margin-top: 20px;" class="ui-dialog-buttonset"></div>').appendTo(nn)
options.buttons.forEach(function(buttonDef) {
var b = $('<button>').html(buttonDef.text).click(buttonDef.click).appendTo(buttonSet);
if (buttonDef.class) {
b.addClass(buttonDef.class);
}
})
}
}
if (timeout !== undefined && timeout > 0) {
window.clearTimeout(nn.timeoutid);
nn.timeoutid = window.setTimeout(nn.close,timeout);
} else {
window.clearTimeout(nn.timeoutid);
}
}
})();

View File

@@ -1067,7 +1067,7 @@ RED.projects = (function() {
'open': (function() {
var selectedProject;
return {
title: "Open a project", // TODO: NLS
title: "Select a project to open", // TODO: NLS
content: function() {
return createProjectList({
canSelectActive: false,
@@ -1111,6 +1111,7 @@ RED.projects = (function() {
'delete': (function() {
var selectedProject;
return {
title: "Select a project to delete", // TODO: NLS
content: function() {
return createProjectList({
canSelectActive: false,

View File

@@ -55,7 +55,7 @@ RED.sidebar.info = (function() {
});
nodeSection.expand();
infoSection = sections.add({
title: RED._("sidebar.info.help"),
title: RED._("sidebar.info.nodeHelp"),
collapsible: true
});
infoSection.expand();