mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Sort nodes in expression editor relative to current node position
This commit is contained in:
parent
3e92fae954
commit
11336fdbae
|
@ -114,7 +114,7 @@ export default mixins(
|
||||||
const newOptions = this.removeEmptyEntries(inputData.options);
|
const newOptions = this.removeEmptyEntries(inputData.options);
|
||||||
if (Array.isArray(newOptions) && newOptions.length) {
|
if (Array.isArray(newOptions) && newOptions.length) {
|
||||||
// Has still options left so return
|
// Has still options left so return
|
||||||
inputData.options = this.sortOptions(newOptions);
|
inputData.options = newOptions;
|
||||||
return inputData;
|
return inputData;
|
||||||
} else if (Array.isArray(newOptions) && newOptions.length === 0) {
|
} else if (Array.isArray(newOptions) && newOptions.length === 0) {
|
||||||
delete inputData.options;
|
delete inputData.options;
|
||||||
|
@ -546,7 +546,14 @@ export default mixins(
|
||||||
let nodeOptions: IVariableSelectorOption[];
|
let nodeOptions: IVariableSelectorOption[];
|
||||||
const upstreamNodes = this.workflow.getParentNodes(activeNode.name, inputName);
|
const upstreamNodes = this.workflow.getParentNodes(activeNode.name, inputName);
|
||||||
|
|
||||||
for (const [nodeName, node] of Object.entries(this.workflow.nodes)) {
|
const workflowNodes = Object.entries(this.workflow.nodes);
|
||||||
|
|
||||||
|
// Sort the nodes according to their position relative to the current node
|
||||||
|
workflowNodes.sort((a, b) => {
|
||||||
|
return upstreamNodes.indexOf(b[0]) - upstreamNodes.indexOf(a[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const [nodeName, node] of workflowNodes) {
|
||||||
// Add the parameters of all nodes
|
// Add the parameters of all nodes
|
||||||
// TODO: Later have to make sure that no parameters can be referenced which have expression which use input-data (for nodes which are not parent nodes)
|
// TODO: Later have to make sure that no parameters can be referenced which have expression which use input-data (for nodes which are not parent nodes)
|
||||||
|
|
||||||
|
@ -606,7 +613,7 @@ export default mixins(
|
||||||
returnData.push(
|
returnData.push(
|
||||||
{
|
{
|
||||||
name: this.$locale.baseText('variableSelector.nodes'),
|
name: this.$locale.baseText('variableSelector.nodes'),
|
||||||
options: this.sortOptions(allNodesData),
|
options: allNodesData,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue