mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
1280e5bc8b
commit
04cd19349d
@ -35,9 +35,7 @@ RED.clipboard = (function() {
|
|||||||
id: "clipboard-dialog-ok",
|
id: "clipboard-dialog-ok",
|
||||||
text: RED._("common.label.ok"),
|
text: RED._("common.label.ok"),
|
||||||
click: function() {
|
click: function() {
|
||||||
if (/Import/.test(dialog.dialog("option","title"))) {
|
|
||||||
RED.view.importNodes($("#clipboard-import").val());
|
RED.view.importNodes($("#clipboard-import").val());
|
||||||
}
|
|
||||||
$( this ).dialog( "close" );
|
$( this ).dialog( "close" );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -306,22 +306,6 @@ RED.editor = (function() {
|
|||||||
editing_node.dirty = true;
|
editing_node.dirty = true;
|
||||||
validateNode(editing_node);
|
validateNode(editing_node);
|
||||||
RED.view.redraw();
|
RED.view.redraw();
|
||||||
} else if (/Export nodes to library/.test($( "#dialog" ).dialog("option","title"))) {
|
|
||||||
//TODO: move this to RED.library
|
|
||||||
var flowName = $("#node-input-filename").val();
|
|
||||||
if (!/^\s*$/.test(flowName)) {
|
|
||||||
$.ajax({
|
|
||||||
url:'library/flows/'+flowName,
|
|
||||||
type: "POST",
|
|
||||||
data: $("#node-input-filename").attr('nodes'),
|
|
||||||
contentType: "application/json; charset=utf-8"
|
|
||||||
}).done(function() {
|
|
||||||
RED.library.loadFlowLibrary();
|
|
||||||
RED.notify(RED._("library.savedNodes"),"success");
|
|
||||||
}).fail(function(xhr,textStatus,err) {
|
|
||||||
RED.notify(RED._("library.saveFailed",{message:xhr.responseText}),"error");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$( this ).dialog( "close" );
|
$( this ).dialog( "close" );
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
RED.library = (function() {
|
RED.library = (function() {
|
||||||
|
|
||||||
|
|
||||||
|
var exportToLibraryDialog;
|
||||||
|
|
||||||
function loadFlowLibrary() {
|
function loadFlowLibrary() {
|
||||||
$.getJSON("library/flows",function(data) {
|
$.getJSON("library/flows",function(data) {
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
@ -382,10 +384,8 @@ RED.library = (function() {
|
|||||||
function exportFlow() {
|
function exportFlow() {
|
||||||
//TODO: don't rely on the main dialog
|
//TODO: don't rely on the main dialog
|
||||||
var nns = RED.nodes.createExportableNodeSet(RED.view.selection().nodes);
|
var nns = RED.nodes.createExportableNodeSet(RED.view.selection().nodes);
|
||||||
$("#dialog-form").html($("script[data-template-name='export-library-dialog']").html());
|
|
||||||
$("#node-input-filename").attr('nodes',JSON.stringify(nns));
|
$("#node-input-filename").attr('nodes',JSON.stringify(nns));
|
||||||
$("#dialog").i18n();
|
exportToLibraryDialog.dialog( "open" );
|
||||||
$("#dialog").dialog("option","title",RED._("library.exportToLibrary")).dialog( "open" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -405,6 +405,61 @@ RED.library = (function() {
|
|||||||
if (RED.settings.theme("menu.menu-item-import-library") !== false) {
|
if (RED.settings.theme("menu.menu-item-import-library") !== false) {
|
||||||
loadFlowLibrary();
|
loadFlowLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exportToLibraryDialog = $('<div id="library-dialog" class="hide"><form class="dialog-form form-horizontal"></form></div>')
|
||||||
|
.appendTo("body")
|
||||||
|
.dialog({
|
||||||
|
modal: true,
|
||||||
|
autoOpen: false,
|
||||||
|
width: 500,
|
||||||
|
resizable: false,
|
||||||
|
title: RED._("library.exportToLibrary"),
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
id: "library-dialog-ok",
|
||||||
|
text: RED._("common.label.ok"),
|
||||||
|
click: function() {
|
||||||
|
//TODO: move this to RED.library
|
||||||
|
var flowName = $("#node-input-filename").val();
|
||||||
|
if (!/^\s*$/.test(flowName)) {
|
||||||
|
$.ajax({
|
||||||
|
url:'library/flows/'+flowName,
|
||||||
|
type: "POST",
|
||||||
|
data: $("#node-input-filename").attr('nodes'),
|
||||||
|
contentType: "application/json; charset=utf-8"
|
||||||
|
}).done(function() {
|
||||||
|
RED.library.loadFlowLibrary();
|
||||||
|
RED.notify(RED._("library.savedNodes"),"success");
|
||||||
|
}).fail(function(xhr,textStatus,err) {
|
||||||
|
RED.notify(RED._("library.saveFailed",{message:xhr.responseText}),"error");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "library-dialog-cancel",
|
||||||
|
text: RED._("common.label.cancel"),
|
||||||
|
click: function() {
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
open: function(e) {
|
||||||
|
$(this).parent().find(".ui-dialog-titlebar-close").hide();
|
||||||
|
RED.keyboard.disable();
|
||||||
|
},
|
||||||
|
close: function(e) {
|
||||||
|
RED.keyboard.enable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
exportToLibraryDialog.children(".dialog-form").append($(
|
||||||
|
'<div class="form-row">'+
|
||||||
|
'<label for="node-input-filename" data-i18n="[append]editor:library.filename"><i class="fa fa-file"></i> </label>'+
|
||||||
|
'<input type="text" id="node-input-filename" data-i18n="[placeholder]editor:library.fullFilenamePlaceholder">'+
|
||||||
|
'<input type="text" style="display: none;" />'+ // Second hidden input to prevent submit on Enter
|
||||||
|
'</div>'
|
||||||
|
));
|
||||||
},
|
},
|
||||||
create: createUI,
|
create: createUI,
|
||||||
loadFlowLibrary: loadFlowLibrary,
|
loadFlowLibrary: loadFlowLibrary,
|
||||||
|
@ -162,13 +162,6 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/x-red" data-template-name="export-library-dialog">
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-filename" data-i18n="[append]editor:library.filename"><i class="fa fa-file"></i> </label>
|
|
||||||
<input type="text" id="node-input-filename" data-i18n="[placeholder]editor:library.fullFilenamePlaceholder">
|
|
||||||
</div>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/x-red" data-template-name="subflow">
|
<script type="text/x-red" data-template-name="subflow">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name" data-i18n="[append]editor:common.label.name"><i class="fa fa-tag"></i> </label>
|
<label for="node-input-name" data-i18n="[append]editor:common.label.name"><i class="fa fa-tag"></i> </label>
|
||||||
|
Loading…
Reference in New Issue
Block a user