mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Allow a node to decide for itself if its button should be enabled or not
This means: 1. an Inject node that has only been moved can still inject 2. the Debug node is now marked as changed when its button is clicked which, without this fix, then prevented the button from being clicked to toggle its state again
This commit is contained in:
@@ -510,8 +510,19 @@ If you want every 20 minutes from now - use the "interval" option.</p>
|
||||
$("#node-input-crontab").val(crontab);
|
||||
},
|
||||
button: {
|
||||
enabled: function() {
|
||||
return !this.changed
|
||||
},
|
||||
onclick: function() {
|
||||
var label = (this.name||this.payload).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
|
||||
if (this.changed) {
|
||||
return RED.notify(RED._("notification.warning", {message:RED._("notification.warnings.undeployedChanges")}),"warning");
|
||||
}
|
||||
var label = (this.name||this.payload);
|
||||
if (label.length > 30) {
|
||||
label = label.substring(0,50)+"...";
|
||||
}
|
||||
label = label.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
|
||||
|
||||
if (this.payloadType === "date") { label = this._("inject.timestamp"); }
|
||||
if (this.payloadType === "none") { label = this._("inject.blank"); }
|
||||
var node = this;
|
||||
|
Reference in New Issue
Block a user