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

Update 20-inject.html

Cleanup old payload, topic & type.
Move name and remove tip.
This commit is contained in:
Paul Wieland 2020-04-08 12:29:55 -04:00
parent 82490b0a58
commit 7c1853431a

View File

@ -15,6 +15,10 @@
-->
<script type="text/html" data-template-name="inject">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
</div>
<div class="form-row node-input-property-container-row">
<ol id="node-input-property-container"></ol>
@ -108,12 +112,7 @@
</div>
</div>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
</div>
<div class="form-tips" data-i18n="[html]inject.tip"></div>
</script>
<style>
.inject-time-row {
@ -278,6 +277,8 @@
$("#node-once").hide();
$("#node-input-once").prop('checked', false);
}
// Fire oneditresize?
});
$("#node-input-once").on("change", function() {
@ -466,9 +467,53 @@
var prop = this.props[i];
$("#node-input-property-container").editableList('addItem',prop);
}
/* Experimental paste object
* This allows you to copy an object to your clipboard from the debug and then paste it back into an inject node
*/
// $("#dialog-form").on('paste', function(e) {
// var pasteData = e.originalEvent.clipboardData.getData('text');
// try{
// var pasteObject = JSON.parse(pasteData);
// } catch(e){ }
//
// if(pasteObject){
// for(var p in pasteObject){
// if(p === '_msgid') continue;
// var v = pasteObject[p];
// var vt = 'json';
//
// // Remove existing property before adding to avoid duplicates
// $(`#node-input-property-container .node-input-prop-property-name[value=${p}]`).closest('.red-ui-editableList-item-content').parent().remove();
//
// if(typeof v === 'string'){
// vt = 'str';
// } else if (typeof v === "boolean") {
// vt = 'bool';
// } else if (!isNaN(v)) {
// vt = 'num';
// } else if(Array.isArray(v) && v.every(e => Number.isInteger(e) && e >= 0 && e <=255)) { // Fuzzy buffer detection
// vt = 'bin';
// v = JSON.stringify(pasteObject[p]);
// } else {
// vt = 'json';
// v = JSON.stringify(pasteObject[p]);
// }
//
// var prop = {p, v, vt};
// $("#node-input-property-container").editableList('addItem',prop);
// }
// }
// });
},
oneditsave: function() {
/* Cleanup Legacy */
delete this.payload;
delete this.payloadType
delete this.topic
/* */
var repeat = "";
var crontab = "";
var type = $("#inject-time-type-select").val();