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:
parent
2de9a804a0
commit
cc0933eee4
@ -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/library.js",
|
||||||
"packages/node_modules/@node-red/editor-client/src/js/ui/notifications.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/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/typeSearch.js",
|
||||||
"packages/node_modules/@node-red/editor-client/src/js/ui/subflow.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",
|
"packages/node_modules/@node-red/editor-client/src/js/ui/userSettings.js",
|
||||||
|
@ -351,7 +351,8 @@
|
|||||||
"pasteNode": "Paste nodes",
|
"pasteNode": "Paste nodes",
|
||||||
"undoChange": "Undo the last change performed",
|
"undoChange": "Undo the last change performed",
|
||||||
"searchBox": "Open search box",
|
"searchBox": "Open search box",
|
||||||
"managePalette": "Manage palette"
|
"managePalette": "Manage palette",
|
||||||
|
"actionList":"Action list"
|
||||||
},
|
},
|
||||||
"library": {
|
"library": {
|
||||||
"library": "Library",
|
"library": "Library",
|
||||||
@ -710,8 +711,7 @@
|
|||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"empty": "No matches found",
|
"empty": "No matches found",
|
||||||
"addNode": "add a node...",
|
"addNode": "add a node..."
|
||||||
"actions": "search available actions"
|
|
||||||
},
|
},
|
||||||
"expressionEditor": {
|
"expressionEditor": {
|
||||||
"functions": "Functions",
|
"functions": "Functions",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"*": {
|
"*": {
|
||||||
"ctrl-shift-p":"core:manage-palette",
|
"alt-shift-p":"core:manage-palette",
|
||||||
"ctrl-f": "core:search",
|
"ctrl-f": "core:search",
|
||||||
"ctrl-shift-f": "core:list-flows",
|
"ctrl-shift-f": "core:list-flows",
|
||||||
"ctrl-=": "core:zoom-in",
|
"ctrl-=": "core:zoom-in",
|
||||||
@ -23,7 +23,7 @@
|
|||||||
"ctrl-alt-o": "core:open-project",
|
"ctrl-alt-o": "core:open-project",
|
||||||
"ctrl-g v": "core:show-version-control-tab",
|
"ctrl-g v": "core:show-version-control-tab",
|
||||||
"ctrl-shift-l": "core:show-event-log",
|
"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": {
|
"red-ui-sidebar-node-config": {
|
||||||
"backspace": "core:delete-config-selection",
|
"backspace": "core:delete-config-selection",
|
||||||
|
@ -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-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-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-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
|
null
|
||||||
]});
|
]});
|
||||||
menuOptions.push(null);
|
menuOptions.push(null);
|
||||||
@ -521,7 +522,7 @@ var RED = (function() {
|
|||||||
RED.subflow.init();
|
RED.subflow.init();
|
||||||
RED.clipboard.init();
|
RED.clipboard.init();
|
||||||
RED.search.init();
|
RED.search.init();
|
||||||
RED.commandPrompt.init();
|
RED.actionList.init();
|
||||||
RED.editor.init();
|
RED.editor.init();
|
||||||
RED.diff.init();
|
RED.diff.init();
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
RED.commandPrompt = (function() {
|
RED.actionList = (function() {
|
||||||
|
|
||||||
var disabled = false;
|
var disabled = false;
|
||||||
var dialog = null;
|
var dialog = null;
|
||||||
@ -22,34 +22,7 @@ RED.commandPrompt = (function() {
|
|||||||
var selected = -1;
|
var selected = -1;
|
||||||
var visible = false;
|
var visible = false;
|
||||||
|
|
||||||
var results = [];
|
var filterTerm = "";
|
||||||
|
|
||||||
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)
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function ensureSelectedIsVisible() {
|
function ensureSelectedIsVisible() {
|
||||||
var selectedEntry = searchResults.find("li.selected");
|
var selectedEntry = searchResults.find("li.selected");
|
||||||
@ -68,48 +41,50 @@ RED.commandPrompt = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createDialog() {
|
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);
|
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
|
||||||
searchInput = $('<input type="text" data-i18n="[placeholder]search.actions">').appendTo(searchDiv).searchBox({
|
searchInput = $('<input type="text" data-i18n="[placeholder]keyboard.filterActions">').appendTo(searchDiv).searchBox({
|
||||||
delay: 200,
|
|
||||||
change: function() {
|
change: function() {
|
||||||
search($(this).val());
|
filterTerm = $(this).val();
|
||||||
|
searchResults.editableList('filter');
|
||||||
|
searchResults.find("li.selected").removeClass("selected");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
searchInput.on('keydown',function(evt) {
|
searchInput.on('keydown',function(evt) {
|
||||||
var children;
|
var selectedChild;
|
||||||
if (results.length > 0) {
|
if (evt.keyCode === 40) {
|
||||||
if (evt.keyCode === 40) {
|
// Down
|
||||||
// Down
|
selectedChild = searchResults.find("li.selected");
|
||||||
children = searchResults.children();
|
if (!selectedChild.length) {
|
||||||
if (selected < children.length-1) {
|
var children = searchResults.children(":visible");
|
||||||
if (selected > -1) {
|
if (children.length) {
|
||||||
$(children[selected]).removeClass('selected');
|
$(children[0]).addClass('selected');
|
||||||
}
|
RED.a = children[0];
|
||||||
selected++;
|
|
||||||
}
|
}
|
||||||
$(children[selected]).addClass('selected');
|
} else {
|
||||||
ensureSelectedIsVisible();
|
var nextChild = selectedChild.nextAll(":visible").first();
|
||||||
evt.preventDefault();
|
if (nextChild.length) {
|
||||||
} else if (evt.keyCode === 38) {
|
selectedChild.removeClass('selected');
|
||||||
// Up
|
nextChild.addClass('selected');
|
||||||
children = searchResults.children();
|
|
||||||
if (selected > 0) {
|
|
||||||
if (selected < children.length) {
|
|
||||||
$(children[selected]).removeClass('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)]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ensureSelectedIsVisible();
|
||||||
|
evt.preventDefault();
|
||||||
|
} else if (evt.keyCode === 38) {
|
||||||
|
// Up
|
||||||
|
selectedChild = searchResults.find("li.selected");
|
||||||
|
var nextChild = selectedChild.prevAll(":visible").first();
|
||||||
|
if (nextChild.length) {
|
||||||
|
selectedChild.removeClass('selected');
|
||||||
|
nextChild.addClass('selected');
|
||||||
|
}
|
||||||
|
ensureSelectedIsVisible();
|
||||||
|
evt.preventDefault();
|
||||||
|
} else if (evt.keyCode === 13) {
|
||||||
|
// Enter
|
||||||
|
selectedChild = searchResults.find("li.selected");
|
||||||
|
selectCommand(searchResults.editableList('getItem',selectedChild));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
searchInput.i18n();
|
searchInput.i18n();
|
||||||
@ -137,14 +112,22 @@ 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) {
|
function selectCommand(command) {
|
||||||
hide();
|
hide();
|
||||||
RED.actions.invoke(command.id);
|
if (command) {
|
||||||
|
RED.actions.invoke(command.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(v) {
|
function show(v) {
|
||||||
@ -163,8 +146,17 @@ RED.commandPrompt = (function() {
|
|||||||
}
|
}
|
||||||
dialog.slideDown(300);
|
dialog.slideDown(300);
|
||||||
searchInput.searchBox('value',v)
|
searchInput.searchBox('value',v)
|
||||||
search(v);
|
searchResults.editableList('empty');
|
||||||
RED.events.emit("commandPrompt:open");
|
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;
|
visible = true;
|
||||||
}
|
}
|
||||||
searchInput.trigger("focus");
|
searchInput.trigger("focus");
|
||||||
@ -184,12 +176,12 @@ RED.commandPrompt = (function() {
|
|||||||
searchInput.searchBox('value','');
|
searchInput.searchBox('value','');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.events.emit("commandPrompt:close");
|
RED.events.emit("actionList:close");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
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:open",function() { disabled = true; });
|
||||||
RED.events.on("editor:close",function() { disabled = false; });
|
RED.events.on("editor:close",function() { disabled = false; });
|
@ -742,8 +742,8 @@ RED.clipboard = (function() {
|
|||||||
RED.events.on("editor:close",function() { disabled = false; });
|
RED.events.on("editor:close",function() { disabled = false; });
|
||||||
RED.events.on("search:open",function() { disabled = true; });
|
RED.events.on("search:open",function() { disabled = true; });
|
||||||
RED.events.on("search:close",function() { disabled = false; });
|
RED.events.on("search:close",function() { disabled = false; });
|
||||||
RED.events.on("commandPrompt:open",function() { disabled = true; });
|
RED.events.on("actionList:open",function() { disabled = true; });
|
||||||
RED.events.on("commandPrompt:close",function() { disabled = false; });
|
RED.events.on("actionList: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; });
|
||||||
|
|
||||||
|
@ -323,6 +323,7 @@
|
|||||||
},
|
},
|
||||||
empty: function() {
|
empty: function() {
|
||||||
this.element.empty();
|
this.element.empty();
|
||||||
|
this.uiContainer.scrollTop(0);
|
||||||
},
|
},
|
||||||
filter: function(filter) {
|
filter: function(filter) {
|
||||||
if (filter !== undefined) {
|
if (filter !== undefined) {
|
||||||
@ -346,6 +347,14 @@
|
|||||||
if (items.length > 0) {
|
if (items.length > 0) {
|
||||||
this.uiContainer.scrollTop(this.uiContainer.scrollTop()+items.position().top)
|
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);
|
})(jQuery);
|
||||||
|
@ -296,8 +296,8 @@ RED.search = (function() {
|
|||||||
RED.events.on("editor:close",function() { disabled = false; });
|
RED.events.on("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; });
|
||||||
RED.events.on("commandPrompt:open",function() { disabled = true; });
|
RED.events.on("actionList:open",function() { disabled = true; });
|
||||||
RED.events.on("commandPrompt:close",function() { disabled = false; });
|
RED.events.on("actionList:close",function() { disabled = false; });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,7 +198,9 @@
|
|||||||
color: $primary-text-color;
|
color: $primary-text-color;
|
||||||
}
|
}
|
||||||
.red-ui-search-result-action-key {
|
.red-ui-search-result-action-key {
|
||||||
float:right;
|
position: absolute;
|
||||||
|
top: 9px;
|
||||||
|
right: 0;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
color: $tertiary-text-color;
|
color: $tertiary-text-color;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user