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

Rename commandPrompt to actionList

This commit is contained in:
Nick O'Leary 2019-06-11 22:43:01 +01:00
parent 2de9a804a0
commit cc0933eee4
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
9 changed files with 84 additions and 80 deletions

View File

@ -169,7 +169,7 @@ module.exports = function(grunt) {
"packages/node_modules/@node-red/editor-client/src/js/ui/library.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/notifications.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/search.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/commandPrompt.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/actionList.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/userSettings.js",

View File

@ -351,7 +351,8 @@
"pasteNode": "Paste nodes",
"undoChange": "Undo the last change performed",
"searchBox": "Open search box",
"managePalette": "Manage palette"
"managePalette": "Manage palette",
"actionList":"Action list"
},
"library": {
"library": "Library",
@ -710,8 +711,7 @@
},
"search": {
"empty": "No matches found",
"addNode": "add a node...",
"actions": "search available actions"
"addNode": "add a node..."
},
"expressionEditor": {
"functions": "Functions",

View File

@ -1,6 +1,6 @@
{
"*": {
"ctrl-shift-p":"core:manage-palette",
"alt-shift-p":"core:manage-palette",
"ctrl-f": "core:search",
"ctrl-shift-f": "core:list-flows",
"ctrl-=": "core:zoom-in",
@ -23,7 +23,7 @@
"ctrl-alt-o": "core:open-project",
"ctrl-g v": "core:show-version-control-tab",
"ctrl-shift-l": "core:show-event-log",
"alt-shift-p":"core:show-command-prompt"
"ctrl-shift-p":"core:show-action-list"
},
"red-ui-sidebar-node-config": {
"backspace": "core:delete-config-selection",

View File

@ -451,6 +451,7 @@ var RED = (function() {
{id:"menu-item-palette",label:RED._("menu.label.palette.show"),toggle:true,onselect:"core:toggle-palette", selected: true},
{id:"menu-item-sidebar",label:RED._("menu.label.sidebar.show"),toggle:true,onselect:"core:toggle-sidebar", selected: true},
{id:"menu-item-event-log",label:RED._("eventLog.title"),onselect:"core:show-event-log"},
{id:"menu-item-action-list",label:RED._("keyboard.actionList"),onselect:"core:show-action-list"},
null
]});
menuOptions.push(null);
@ -521,7 +522,7 @@ var RED = (function() {
RED.subflow.init();
RED.clipboard.init();
RED.search.init();
RED.commandPrompt.init();
RED.actionList.init();
RED.editor.init();
RED.diff.init();

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
RED.commandPrompt = (function() {
RED.actionList = (function() {
var disabled = false;
var dialog = null;
@ -22,34 +22,7 @@ RED.commandPrompt = (function() {
var selected = -1;
var visible = false;
var results = [];
var scopes = {};
function search(val) {
scopes = {};
results = [];
selected = -1;
val = val ||"";
searchResults.editableList('empty');
var actions = RED.actions.list();
actions.sort(function(A,B) {
return A.id.localeCompare(B.id);
});
val = val.trim().toLowerCase();
actions.forEach(function(action) {
action.label = action.id.replace(/:/,": ").replace(/-/g," ").replace(/(^| )./g,function() { return arguments[0].toUpperCase()});
if (val !== "" && action.label.toLowerCase().indexOf(val) === -1) {
return;
}
results.push(action);
searchResults.editableList('addItem',action)
})
}
var filterTerm = "";
function ensureSelectedIsVisible() {
var selectedEntry = searchResults.find("li.selected");
@ -68,48 +41,50 @@ RED.commandPrompt = (function() {
}
function createDialog() {
dialog = $("<div>",{id:"red-ui-commandPrompt",class:"red-ui-search"}).appendTo("#red-ui-main-container");
dialog = $("<div>",{id:"red-ui-actionList",class:"red-ui-search"}).appendTo("#red-ui-main-container");
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
searchInput = $('<input type="text" data-i18n="[placeholder]search.actions">').appendTo(searchDiv).searchBox({
delay: 200,
searchInput = $('<input type="text" data-i18n="[placeholder]keyboard.filterActions">').appendTo(searchDiv).searchBox({
change: function() {
search($(this).val());
filterTerm = $(this).val();
searchResults.editableList('filter');
searchResults.find("li.selected").removeClass("selected");
}
});
searchInput.on('keydown',function(evt) {
var children;
if (results.length > 0) {
var selectedChild;
if (evt.keyCode === 40) {
// Down
children = searchResults.children();
if (selected < children.length-1) {
if (selected > -1) {
$(children[selected]).removeClass('selected');
selectedChild = searchResults.find("li.selected");
if (!selectedChild.length) {
var children = searchResults.children(":visible");
if (children.length) {
$(children[0]).addClass('selected');
RED.a = children[0];
}
} else {
var nextChild = selectedChild.nextAll(":visible").first();
if (nextChild.length) {
selectedChild.removeClass('selected');
nextChild.addClass('selected');
}
selected++;
}
$(children[selected]).addClass('selected');
ensureSelectedIsVisible();
evt.preventDefault();
} else if (evt.keyCode === 38) {
// Up
children = searchResults.children();
if (selected > 0) {
if (selected < children.length) {
$(children[selected]).removeClass('selected');
selectedChild = searchResults.find("li.selected");
var nextChild = selectedChild.prevAll(":visible").first();
if (nextChild.length) {
selectedChild.removeClass('selected');
nextChild.addClass('selected');
}
selected--;
}
$(children[selected]).addClass('selected');
ensureSelectedIsVisible();
evt.preventDefault();
} else if (evt.keyCode === 13) {
// Enter
if (results.length > 0) {
selectCommand(results[Math.max(0,selected)]);
}
}
selectedChild = searchResults.find("li.selected");
selectCommand(searchResults.editableList('getItem',selectedChild));
}
});
searchInput.i18n();
@ -137,15 +112,23 @@ RED.commandPrompt = (function() {
});
}
},
scrollOnAdd: false
scrollOnAdd: false,
filter: function(item) {
if (filterTerm !== "" && item.label.toLowerCase().indexOf(filterTerm) === -1) {
return false;
}
return true;
}
});
}
function selectCommand(command) {
hide();
if (command) {
RED.actions.invoke(command.id);
}
}
function show(v) {
if (disabled) {
@ -163,8 +146,17 @@ RED.commandPrompt = (function() {
}
dialog.slideDown(300);
searchInput.searchBox('value',v)
search(v);
RED.events.emit("commandPrompt:open");
searchResults.editableList('empty');
results = [];
var actions = RED.actions.list();
actions.sort(function(A,B) {
return A.id.localeCompare(B.id);
});
actions.forEach(function(action) {
action.label = action.id.replace(/:/,": ").replace(/-/g," ").replace(/(^| )./g,function() { return arguments[0].toUpperCase()});
searchResults.editableList('addItem',action)
})
RED.events.emit("actionList:open");
visible = true;
}
searchInput.trigger("focus");
@ -184,12 +176,12 @@ RED.commandPrompt = (function() {
searchInput.searchBox('value','');
});
}
RED.events.emit("commandPrompt:close");
RED.events.emit("actionList:close");
}
}
function init() {
RED.actions.add("core:show-command-prompt",show);
RED.actions.add("core:show-action-list",show);
RED.events.on("editor:open",function() { disabled = true; });
RED.events.on("editor:close",function() { disabled = false; });

View File

@ -742,8 +742,8 @@ RED.clipboard = (function() {
RED.events.on("editor:close",function() { disabled = false; });
RED.events.on("search:open",function() { disabled = true; });
RED.events.on("search:close",function() { disabled = false; });
RED.events.on("commandPrompt:open",function() { disabled = true; });
RED.events.on("commandPrompt:close",function() { disabled = false; });
RED.events.on("actionList:open",function() { disabled = true; });
RED.events.on("actionList:close",function() { disabled = false; });
RED.events.on("type-search:open",function() { disabled = true; });
RED.events.on("type-search:close",function() { disabled = false; });

View File

@ -323,6 +323,7 @@
},
empty: function() {
this.element.empty();
this.uiContainer.scrollTop(0);
},
filter: function(filter) {
if (filter !== undefined) {
@ -346,6 +347,14 @@
if (items.length > 0) {
this.uiContainer.scrollTop(this.uiContainer.scrollTop()+items.position().top)
}
},
getItem: function(li) {
var el = li.find(".red-ui-editableList-item-content");
if (el.length) {
return el.data('data');
} else {
return null;
}
}
});
})(jQuery);

View File

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

View File

@ -198,7 +198,9 @@
color: $primary-text-color;
}
.red-ui-search-result-action-key {
float:right;
position: absolute;
top: 9px;
right: 0;
margin-right: 10px;
color: $tertiary-text-color;
}