mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
handle other fields in library - by only changing prefix
(rather than whole property - so ...-name is still the name required)
This commit is contained in:
parent
5e87828b29
commit
5fbd5bf9e2
@ -16,7 +16,7 @@
|
|||||||
RED.library = (function() {
|
RED.library = (function() {
|
||||||
|
|
||||||
var exportToLibraryDialog;
|
var exportToLibraryDialog;
|
||||||
var element = "node-input-name";
|
var elementPrefix = "node-input-";
|
||||||
|
|
||||||
function loadFlowLibrary() {
|
function loadFlowLibrary() {
|
||||||
$.getJSON("library/flows",function(data) {
|
$.getJSON("library/flows",function(data) {
|
||||||
@ -86,7 +86,7 @@ RED.library = (function() {
|
|||||||
var libraryData = {};
|
var libraryData = {};
|
||||||
var selectedLibraryItem = null;
|
var selectedLibraryItem = null;
|
||||||
var libraryEditor = null;
|
var libraryEditor = null;
|
||||||
element = options.element || "node-input-name";
|
elementPrefix = options.elementPrefix || "node-input-";
|
||||||
|
|
||||||
// Orion editor has set/getText
|
// Orion editor has set/getText
|
||||||
// ACE editor has set/getValue
|
// ACE editor has set/getValue
|
||||||
@ -158,7 +158,7 @@ RED.library = (function() {
|
|||||||
return ul;
|
return ul;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#'+element).css("width","calc(100% - 52px)").after(
|
$('#'+elementPrefix+"name").css("width","calc(100% - 52px)").after(
|
||||||
'<div class="btn-group" style="margin-left:5px;">'+
|
'<div class="btn-group" style="margin-left:5px;">'+
|
||||||
'<a id="node-input-'+options.type+'-lookup" class="editor-button" data-toggle="dropdown"><i class="fa fa-book"></i> <i class="fa fa-caret-down"></i></a>'+
|
'<a id="node-input-'+options.type+'-lookup" class="editor-button" data-toggle="dropdown"><i class="fa fa-book"></i> <i class="fa fa-caret-down"></i></a>'+
|
||||||
'<ul class="dropdown-menu pull-right" role="menu">'+
|
'<ul class="dropdown-menu pull-right" role="menu">'+
|
||||||
@ -188,7 +188,7 @@ RED.library = (function() {
|
|||||||
|
|
||||||
$('#node-input-'+options.type+'-menu-save-library').click(function(e) {
|
$('#node-input-'+options.type+'-menu-save-library').click(function(e) {
|
||||||
//var found = false;
|
//var found = false;
|
||||||
var name = $("#"+element).val().replace(/(^\s*)|(\s*$)/g,"");
|
var name = $("#"+elementPrefix+"name").val().replace(/(^\s*)|(\s*$)/g,"");
|
||||||
|
|
||||||
//var buildPathList = function(data,root) {
|
//var buildPathList = function(data,root) {
|
||||||
// var paths = [];
|
// var paths = [];
|
||||||
@ -265,7 +265,7 @@ RED.library = (function() {
|
|||||||
if (selectedLibraryItem) {
|
if (selectedLibraryItem) {
|
||||||
for (var i=0; i<options.fields.length; i++) {
|
for (var i=0; i<options.fields.length; i++) {
|
||||||
var field = options.fields[i];
|
var field = options.fields[i];
|
||||||
$("#node-input-"+field).val(selectedLibraryItem[field]);
|
$("#"+elementPrefix+field).val(selectedLibraryItem[field]);
|
||||||
}
|
}
|
||||||
options.editor.setValue(libraryEditor.getValue(),-1);
|
options.editor.setValue(libraryEditor.getValue(),-1);
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ RED.library = (function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function saveToLibrary(overwrite) {
|
function saveToLibrary(overwrite) {
|
||||||
var name = $("#"+element).val().replace(/(^\s*)|(\s*$)/g,"");
|
var name = $("#"+elementPrefix+"name").val().replace(/(^\s*)|(\s*$)/g,"");
|
||||||
if (name === "") {
|
if (name === "") {
|
||||||
name = RED._("library.unnamedType",{type:options.type});
|
name = RED._("library.unnamedType",{type:options.type});
|
||||||
}
|
}
|
||||||
@ -331,7 +331,7 @@ RED.library = (function() {
|
|||||||
if (field == "name") {
|
if (field == "name") {
|
||||||
data.name = name;
|
data.name = name;
|
||||||
} else {
|
} else {
|
||||||
data[field] = $("#node-input-"+field).val();
|
data[field] = $("#"+elementPrefix+field).val();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user