Move palette editor to settings panel

This commit is contained in:
Nick O'Leary 2017-05-03 11:37:42 +01:00
parent ccfcbe8526
commit 93ef84f495
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
7 changed files with 58 additions and 66 deletions

View File

@ -296,8 +296,6 @@ RED.clipboard = (function() {
RED.events.on("search:close",function() { disabled = false; }); RED.events.on("search:close",function() { disabled = false; });
RED.events.on("type-search:open",function() { disabled = true; }); RED.events.on("type-search:open",function() { disabled = true; });
RED.events.on("type-search:close",function() { disabled = false; }); RED.events.on("type-search:close",function() { disabled = false; });
RED.events.on("palette-editor:open",function() { disabled = true; });
RED.events.on("palette-editor:close",function() { disabled = false; });
$('#chart').on("dragenter",function(event) { $('#chart').on("dragenter",function(event) {

View File

@ -91,6 +91,9 @@
} else { } else {
this.resultCount.text(val).show(); this.resultCount.text(val).show();
} }
},
change: function() {
this._trigger("change");
} }
}); });
})(jQuery); })(jQuery);

View File

@ -90,7 +90,12 @@ RED.keyboard = (function() {
RED.userSettings.add({ RED.userSettings.add({
id:'keyboard', id:'keyboard',
title: 'Keyboard', title: 'Keyboard',
get: getSettingsPane get: getSettingsPane,
focus: function() {
setTimeout(function() {
$("#user-settings-tab-keyboard-filter").focus();
},200);
}
}) })
} }
@ -463,7 +468,7 @@ RED.keyboard = (function() {
var pane = $('<div id="user-settings-tab-keyboard"></div>'); var pane = $('<div id="user-settings-tab-keyboard"></div>');
$('<div class="keyboard-shortcut-entry keyboard-shortcut-list-header">'+ $('<div class="keyboard-shortcut-entry keyboard-shortcut-list-header">'+
'<div class="keyboard-shortcut-entry-key keyboard-shortcut-entry-text"><input type="text" placeholder="filter actions"></div>'+ '<div class="keyboard-shortcut-entry-key keyboard-shortcut-entry-text"><input id="user-settings-tab-keyboard-filter" type="text" placeholder="filter actions"></div>'+
'<div class="keyboard-shortcut-entry-key">shortcut</div>'+ '<div class="keyboard-shortcut-entry-key">shortcut</div>'+
'<div class="keyboard-shortcut-entry-scope">scope</div>'+ '<div class="keyboard-shortcut-entry-scope">scope</div>'+
'</div>').appendTo(pane); '</div>').appendTo(pane);

View File

@ -207,10 +207,7 @@ RED.palette.editor = (function() {
} }
} }
nodeEntries[module].index = index.join(",").toLowerCase(); nodeEntries[module].index = index.join(",").toLowerCase();
nodeList.editableList('addItem', nodeEntries[module]); nodeList.editableList('addItem', nodeEntries[module]);
//console.log(nodeList.editableList('items'));
} else { } else {
var moduleInfo = nodeEntries[module].info; var moduleInfo = nodeEntries[module].info;
var nodeEntry = nodeEntries[module].elements; var nodeEntry = nodeEntries[module].elements;
@ -274,7 +271,7 @@ RED.palette.editor = (function() {
} else { } else {
nodeEntry.enableButton.removeClass('disabled'); nodeEntry.enableButton.removeClass('disabled');
if (moduleInfo.local) { if (moduleInfo.local) {
nodeEntry.removeButton.show(); nodeEntry.removeButton.css('display', 'inline-block');
} }
if (activeTypeCount === 0) { if (activeTypeCount === 0) {
nodeEntry.enableButton.html(RED._('palette.editor.enableall')); nodeEntry.enableButton.html(RED._('palette.editor.enableall'));
@ -299,49 +296,6 @@ RED.palette.editor = (function() {
} }
} }
}
function showPaletteEditor() {
if (RED.settings.theme('palette.editable') === false) {
return;
}
if (disabled) {
return;
}
initInstallTab();
// $("#header-shade").show();
// $("#editor-shade").show();
// $("#sidebar-shade").show();
// $("#sidebar-separator").hide();
editorTabs.activateTab('nodes');
// $("#main-container").addClass("palette-expanded");
setTimeout(function() {
editorTabs.resize();
filterInput.focus();
},250);
// RED.events.emit("palette-editor:open");
// RED.keyboard.add("*","escape",function(){hidePaletteEditor()});
RED.userSettings.show('palette');
}
function hidePaletteEditor() {
RED.keyboard.remove("escape");
$("#main-container").removeClass("palette-expanded");
$("#header-shade").hide();
$("#editor-shade").hide();
$("#sidebar-shade").hide();
$("#sidebar-separator").show();
$("#palette-editor").find('.expanded').each(function(i,el) {
$(el).find(".palette-module-content").slideUp();
$(el).removeClass('expanded');
});
filterInput.searchBox('value',"");
searchInput.searchBox('value',"");
RED.events.emit("palette-editor:close");
} }
function filterChange(val) { function filterChange(val) {
@ -406,6 +360,7 @@ RED.palette.editor = (function() {
loadedList = []; loadedList = [];
loadedIndex = {}; loadedIndex = {};
packageList.editableList('empty'); packageList.editableList('empty');
$(".palette-module-shade-status").html(RED._('palette.editor.loading')); $(".palette-module-shade-status").html(RED._('palette.editor.loading'));
var catalogues = RED.settings.theme('palette.catalogues')||['https://catalogue.nodered.org/catalogue.json']; var catalogues = RED.settings.theme('palette.catalogues')||['https://catalogue.nodered.org/catalogue.json'];
catalogueLoadStatus = []; catalogueLoadStatus = [];
@ -416,12 +371,18 @@ RED.palette.editor = (function() {
} }
$("#palette-module-install-shade").show(); $("#palette-module-install-shade").show();
catalogueLoadStart = Date.now(); catalogueLoadStart = Date.now();
var handled = 0;
catalogues.forEach(function(catalog,index) { catalogues.forEach(function(catalog,index) {
$.getJSON(catalog, {_: new Date().getTime()},function(v) { $.getJSON(catalog, {_: new Date().getTime()},function(v) {
handleCatalogResponse(null,catalog,index,v); handleCatalogResponse(null,catalog,index,v);
refreshNodeModuleList(); refreshNodeModuleList();
}).fail(function(jqxhr, textStatus, error) { }).fail(function(jqxhr, textStatus, error) {
handleCatalogResponse(jqxhr,catalog,index); handleCatalogResponse(jqxhr,catalog,index);
}).always(function() {
handled++;
if (handled === catalogueCount) {
searchInput.searchBox('change');
}
}) })
}); });
} }
@ -429,6 +390,11 @@ RED.palette.editor = (function() {
function refreshFilteredItems() { function refreshFilteredItems() {
packageList.editableList('empty'); packageList.editableList('empty');
var currentFilter = searchInput.searchBox('value').trim();
if (currentFilter === ""){
packageList.editableList('addItem',{count:loadedList.length})
return;
}
filteredList.sort(activeSort); filteredList.sort(activeSort);
for (var i=0;i<Math.min(10,filteredList.length);i++) { for (var i=0;i<Math.min(10,filteredList.length);i++) {
packageList.editableList('addItem',filteredList[i]); packageList.editableList('addItem',filteredList[i]);
@ -461,17 +427,18 @@ RED.palette.editor = (function() {
get: getSettingsPane, get: getSettingsPane,
close: function() { close: function() {
settingsPane.detach(); settingsPane.detach();
},
focus: function() {
editorTabs.resize();
setTimeout(function() {
filterInput.focus();
},200);
} }
}) })
// RED.events.on("editor:open",function() { disabled = true; }); RED.actions.add("core:manage-palette",function() {
// RED.events.on("editor:close",function() { disabled = false; }); RED.userSettings.show('palette');
// RED.events.on("search:open",function() { disabled = true; }); });
// RED.events.on("search:close",function() { disabled = false; });
// RED.events.on("type-search:open",function() { disabled = true; });
// RED.events.on("type-search:close",function() { disabled = false; });
RED.actions.add("core:manage-palette",RED.palette.editor.show);
RED.events.on('registry:module-updated', function(ns) { RED.events.on('registry:module-updated', function(ns) {
refreshNodeModule(ns.module); refreshNodeModule(ns.module);
@ -545,9 +512,15 @@ RED.palette.editor = (function() {
} }
var settingsPane; var settingsPane;
function getSettingsPane() { function getSettingsPane() {
initInstallTab();
editorTabs.activateTab('nodes');
return settingsPane; return settingsPane;
} }
function createSettingsPane() { function createSettingsPane() {
settingsPane = $('<div id="user-settings-tab-palette"></div>'); settingsPane = $('<div id="user-settings-tab-palette"></div>');
var content = $('<div id="palette-editor">'+ var content = $('<div id="palette-editor">'+
@ -625,6 +598,7 @@ RED.palette.editor = (function() {
var buttonGroup = $('<div>',{class:"palette-module-button-group"}).appendTo(buttonRow); var buttonGroup = $('<div>',{class:"palette-module-button-group"}).appendTo(buttonRow);
var updateButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.update')).appendTo(buttonGroup); var updateButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.update')).appendTo(buttonGroup);
updateButton.attr('id','up_'+Math.floor(Math.random()*1000000000));
updateButton.click(function(evt) { updateButton.click(function(evt) {
evt.preventDefault(); evt.preventDefault();
if ($(this).hasClass('disabled')) { if ($(this).hasClass('disabled')) {
@ -652,6 +626,7 @@ RED.palette.editor = (function() {
var removeButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.remove')).appendTo(buttonGroup); var removeButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.remove')).appendTo(buttonGroup);
removeButton.attr('id','up_'+Math.floor(Math.random()*1000000000));
removeButton.click(function(evt) { removeButton.click(function(evt) {
evt.preventDefault(); evt.preventDefault();
@ -760,7 +735,7 @@ RED.palette.editor = (function() {
.searchBox({ .searchBox({
delay: 300, delay: 300,
change: function() { change: function() {
var searchTerm = $(this).val().toLowerCase(); var searchTerm = $(this).val().trim().toLowerCase();
if (searchTerm.length > 0) { if (searchTerm.length > 0) {
filteredList = loadedList.filter(function(m) { filteredList = loadedList.filter(function(m) {
return (m.index.indexOf(searchTerm) > -1); return (m.index.indexOf(searchTerm) > -1);
@ -770,6 +745,8 @@ RED.palette.editor = (function() {
} else { } else {
searchInput.searchBox('count',loadedList.length); searchInput.searchBox('count',loadedList.length);
packageList.editableList('empty'); packageList.editableList('empty');
packageList.editableList('addItem',{count:loadedList.length});
} }
} }
}); });
@ -816,7 +793,10 @@ RED.palette.editor = (function() {
addButton: false, addButton: false,
scrollOnAdd: false, scrollOnAdd: false,
addItem: function(container,i,object) { addItem: function(container,i,object) {
if (object.count) {
$('<div>',{class:"red-ui-search-empty"}).html(RED._('palette.editor.moduleCount',{count:object.count})).appendTo(container);
return
}
if (object.more) { if (object.more) {
container.addClass('palette-module-more'); container.addClass('palette-module-more');
var moreRow = $('<div>',{class:"palette-module-header palette-module"}).appendTo(container); var moreRow = $('<div>',{class:"palette-module-header palette-module"}).appendTo(container);
@ -962,7 +942,6 @@ RED.palette.editor = (function() {
} }
return { return {
init: init, init: init
show: showPaletteEditor
} }
})(); })();

View File

@ -265,8 +265,6 @@ RED.search = (function() {
RED.events.on("editor:open",function() { disabled = true; }); RED.events.on("editor:open",function() { disabled = true; });
RED.events.on("editor:close",function() { disabled = false; }); RED.events.on("editor:close",function() { disabled = false; });
RED.events.on("palette-editor:open",function() { disabled = true; });
RED.events.on("palette-editor:close",function() { disabled = false; });
RED.events.on("type-search:open",function() { disabled = true; }); RED.events.on("type-search:open",function() { disabled = true; });
RED.events.on("type-search:close",function() { disabled = false; }); RED.events.on("type-search:close",function() { disabled = false; });

View File

@ -60,6 +60,9 @@ RED.userSettings = (function() {
setTimeout(function() { setTimeout(function() {
$("#user-settings-tabs-content").children().hide(); $("#user-settings-tabs-content").children().hide();
$("#" + tab.id).show(); $("#" + tab.id).show();
if (tab.pane.focus) {
tab.pane.focus();
}
},50); },50);
} }
}); });
@ -68,12 +71,14 @@ RED.userSettings = (function() {
panes.forEach(function(pane) { panes.forEach(function(pane) {
settingsTabs.addTab({ settingsTabs.addTab({
id: "user-settings-tab-"+pane.id, id: "user-settings-tab-"+pane.id,
label: pane.title label: pane.title,
pane: pane
}); });
pane.get().hide().appendTo(tabContents); pane.get().hide().appendTo(tabContents);
}); });
settingsContent.i18n(); settingsContent.i18n();
settingsTabs.activateTab("user-settings-tab-"+(initialTab||'view')) settingsTabs.activateTab("user-settings-tab-"+(initialTab||'view'))
$("#sidebar-shade").show();
}, },
close: function() { close: function() {
settingsVisible = false; settingsVisible = false;
@ -82,6 +87,8 @@ RED.userSettings = (function() {
pane.close(); pane.close();
} }
}); });
$("#sidebar-shade").hide();
}, },
show: function() {} show: function() {}
} }

View File

@ -293,6 +293,8 @@
}, },
"nodeCount": "__label__ node", "nodeCount": "__label__ node",
"nodeCount_plural": "__label__ nodes", "nodeCount_plural": "__label__ nodes",
"moduleCount": "__count__ module available",
"moduleCount_plural": "__count__ modules available",
"inuse": "in use", "inuse": "in use",
"enableall": "enable all", "enableall": "enable all",
"disableall": "disable all", "disableall": "disable all",