mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add 'juntion' to quick-add type search
This commit is contained in:
parent
db1ad0df63
commit
2396e28479
@ -171,17 +171,21 @@ RED.typeSearch = (function() {
|
|||||||
var div = $('<div>',{class:"red-ui-search-result"}).appendTo(container);
|
var div = $('<div>',{class:"red-ui-search-result"}).appendTo(container);
|
||||||
|
|
||||||
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).appendTo(div);
|
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).appendTo(div);
|
||||||
var colour = RED.utils.getNodeColor(object.type,def);
|
if (object.type === "junction") {
|
||||||
|
nodeDiv.addClass("red-ui-palette-icon-junction");
|
||||||
|
} else {
|
||||||
|
var colour = RED.utils.getNodeColor(object.type,def);
|
||||||
|
nodeDiv.css('backgroundColor',colour);
|
||||||
|
}
|
||||||
var icon_url = RED.utils.getNodeIcon(def);
|
var icon_url = RED.utils.getNodeIcon(def);
|
||||||
nodeDiv.css('backgroundColor',colour);
|
|
||||||
|
|
||||||
var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container"}).appendTo(nodeDiv);
|
var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container"}).appendTo(nodeDiv);
|
||||||
RED.utils.createIconElement(icon_url, iconContainer, false);
|
RED.utils.createIconElement(icon_url, iconContainer, false);
|
||||||
|
|
||||||
if (def.inputs > 0) {
|
if (object.type !== "junction" && def.inputs > 0) {
|
||||||
$('<div/>',{class:"red-ui-search-result-node-port"}).appendTo(nodeDiv);
|
$('<div/>',{class:"red-ui-search-result-node-port"}).appendTo(nodeDiv);
|
||||||
}
|
}
|
||||||
if (def.outputs > 0) {
|
if (object.type !== "junction" && def.outputs > 0) {
|
||||||
$('<div/>',{class:"red-ui-search-result-node-port red-ui-search-result-node-output"}).appendTo(nodeDiv);
|
$('<div/>',{class:"red-ui-search-result-node-port red-ui-search-result-node-output"}).appendTo(nodeDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,8 +317,8 @@ RED.typeSearch = (function() {
|
|||||||
return !filter ||
|
return !filter ||
|
||||||
(
|
(
|
||||||
(!filter.type || type === filter.type) &&
|
(!filter.type || type === filter.type) &&
|
||||||
(!filter.input || def.inputs > 0) &&
|
(!filter.input || type === 'junction' || def.inputs > 0) &&
|
||||||
(!filter.output || def.outputs > 0)
|
(!filter.output || type === 'junction' || def.outputs > 0)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
function refreshTypeList(opts) {
|
function refreshTypeList(opts) {
|
||||||
@ -323,7 +327,7 @@ RED.typeSearch = (function() {
|
|||||||
searchInput.searchBox('value','').focus();
|
searchInput.searchBox('value','').focus();
|
||||||
selected = -1;
|
selected = -1;
|
||||||
var common = [
|
var common = [
|
||||||
'inject','debug','function','change','switch'
|
'inject','debug','function','change','switch','junction'
|
||||||
].filter(function(t) { return applyFilter(opts.filter,t,RED.nodes.getType(t)); });
|
].filter(function(t) { return applyFilter(opts.filter,t,RED.nodes.getType(t)); });
|
||||||
|
|
||||||
var recentlyUsed = Object.keys(typesUsed);
|
var recentlyUsed = Object.keys(typesUsed);
|
||||||
@ -348,6 +352,9 @@ RED.typeSearch = (function() {
|
|||||||
var index = 0;
|
var index = 0;
|
||||||
for(i=0;i<common.length;i++) {
|
for(i=0;i<common.length;i++) {
|
||||||
var itemDef = RED.nodes.getType(common[i]);
|
var itemDef = RED.nodes.getType(common[i]);
|
||||||
|
if (common[i] === 'junction') {
|
||||||
|
itemDef = { inputs:1, outputs: 1, label: 'junction', type: 'junction'}
|
||||||
|
}
|
||||||
if (itemDef) {
|
if (itemDef) {
|
||||||
item = {
|
item = {
|
||||||
type: common[i],
|
type: common[i],
|
||||||
|
@ -1028,7 +1028,7 @@ RED.utils = (function() {
|
|||||||
return "font-awesome/fa-object-ungroup";
|
return "font-awesome/fa-object-ungroup";
|
||||||
} else if (node && node.type === 'group') {
|
} else if (node && node.type === 'group') {
|
||||||
return "font-awesome/fa-object-group"
|
return "font-awesome/fa-object-group"
|
||||||
} else if (node && node.type === 'junction') {
|
} else if ((node && node.type === 'junction') || (def.type === "junction") ) {
|
||||||
return "font-awesome/fa-circle-o"
|
return "font-awesome/fa-circle-o"
|
||||||
} else if (def.category === 'config') {
|
} else if (def.category === 'config') {
|
||||||
return RED.settings.apiRootUrl+"icons/node-red/cog.svg"
|
return RED.settings.apiRootUrl+"icons/node-red/cog.svg"
|
||||||
|
@ -1117,16 +1117,38 @@ RED.view = (function() {
|
|||||||
keepAdding = false;
|
keepAdding = false;
|
||||||
resetMouseVars();
|
resetMouseVars();
|
||||||
}
|
}
|
||||||
var result = createNode(type);
|
|
||||||
if (!result) {
|
var nn;
|
||||||
return;
|
var historyEvent;
|
||||||
|
if (type === 'junction') {
|
||||||
|
nn = {
|
||||||
|
_def: {defaults:{}},
|
||||||
|
type: 'junction',
|
||||||
|
z: RED.workspaces.active(),
|
||||||
|
id: RED.nodes.id(),
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
w: 0, h: 0,
|
||||||
|
outputs: 1,
|
||||||
|
inputs: 1,
|
||||||
|
dirty: true
|
||||||
|
}
|
||||||
|
historyEvent = {
|
||||||
|
t:'add',
|
||||||
|
junctions:[nn]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var result = createNode(type);
|
||||||
|
if (!result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nn = result.node;
|
||||||
|
historyEvent = result.historyEvent;
|
||||||
}
|
}
|
||||||
if (keepAdding) {
|
if (keepAdding) {
|
||||||
mouse_mode = RED.state.QUICK_JOINING;
|
mouse_mode = RED.state.QUICK_JOINING;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nn = result.node;
|
|
||||||
var historyEvent = result.historyEvent;
|
|
||||||
nn.x = point[0];
|
nn.x = point[0];
|
||||||
nn.y = point[1];
|
nn.y = point[1];
|
||||||
var showLabel = RED.utils.getMessageProperty(RED.settings.get('editor'),"view.view-node-show-label");
|
var showLabel = RED.utils.getMessageProperty(RED.settings.get('editor'),"view.view-node-show-label");
|
||||||
@ -1235,8 +1257,11 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (nn.type === 'junction') {
|
||||||
RED.nodes.add(nn);
|
RED.nodes.addJunction(nn);
|
||||||
|
} else {
|
||||||
|
RED.nodes.add(nn);
|
||||||
|
}
|
||||||
RED.editor.validateNode(nn);
|
RED.editor.validateNode(nn);
|
||||||
|
|
||||||
if (targetGroup) {
|
if (targetGroup) {
|
||||||
|
@ -66,8 +66,9 @@
|
|||||||
border-left-width: 3px;
|
border-left-width: 3px;
|
||||||
border-right-width: 3px;
|
border-right-width: 3px;
|
||||||
.red-ui-palette-icon-fa {
|
.red-ui-palette-icon-fa {
|
||||||
|
font-size: 11px;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: -2.5px;
|
top: -3px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user