Skip to content

Commit 8af50a5

Browse files
dceejayknolleary
authored andcommitted
add validation triangle to ace function editor on errors
1 parent ddf31e8 commit 8af50a5

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

nodes/core/core/80-function.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
<input type="text" id="node-input-name" placeholder="Name">
2121
</div>
2222
<div class="form-row" style="margin-bottom: 0px;">
23-
<label for="node-input-func"><i class="fa fa-wrench"></i> Function</label>
24-
<input type="hidden" id="node-input-func" autofocus="autofocus">
23+
<label for="node-input-func"><i class="fa fa-wrench"></i> Function</label>
24+
<input type="hidden" id="node-input-func" autofocus="autofocus">
25+
<input type="hidden" id="node-input-valid">
2526
</div>
2627
<div class="form-row node-text-editor-row">
2728
<div style="height: 250px;" class="node-text-editor" id="node-input-func-editor" ></div>
@@ -59,7 +60,8 @@
5960
defaults: {
6061
name: {value:""},
6162
func: {value:"\nreturn msg;"},
62-
outputs: {value:1}
63+
outputs: {value:1},
64+
valid: {value:true,required:true}
6365
},
6466
inputs:1,
6567
outputs:1,
@@ -122,6 +124,16 @@
122124
$("#node-input-name").focus();
123125
},
124126
oneditsave: function() {
127+
var annot = this.editor.getSession().getAnnotations();
128+
console.log(this);
129+
this.valid = true;
130+
for (var k=0; k < annot.length; k++) {
131+
//console.log(annot[k].type,":",annot[k].text, "on line", annot[k].row);
132+
if (annot[k].type === "error") {
133+
$("#node-input-valid").val(null);
134+
delete this.valid;
135+
}
136+
}
125137
$("#node-input-func").val(this.editor.getValue());
126138
delete this.editor;
127139
}

0 commit comments

Comments
 (0)