mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-01-11 14:52:55 +01:00
chore(runtime): Clean up "Push Component To Stack" (#30)
This commit is contained in:
committed by
Richard Osborne
parent
af81e1304e
commit
e21926d0df
@@ -72,8 +72,10 @@ const Navigate = {
|
|||||||
backCallback: (action, results) => {
|
backCallback: (action, results) => {
|
||||||
this._internal.backResults = results;
|
this._internal.backResults = results;
|
||||||
|
|
||||||
for (var key in results) {
|
for (const key in results) {
|
||||||
if (this.hasOutput('backResult-' + key)) this.flagOutputDirty('backResult-' + key);
|
if (this.hasOutput('backResult-' + key)) {
|
||||||
|
this.flagOutputDirty('backResult-' + key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action !== undefined) this.sendSignalOnOutput(action);
|
if (action !== undefined) this.sendSignalOnOutput(action);
|
||||||
@@ -114,22 +116,23 @@ const Navigate = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name === 'target')
|
if (name === 'target') {
|
||||||
return this.registerInput(name, {
|
return this.registerInput(name, {
|
||||||
set: this.setTargetPageId.bind(this)
|
set: this.setTargetPageId.bind(this)
|
||||||
});
|
});
|
||||||
else if (name === 'transition')
|
} else if (name === 'transition') {
|
||||||
return this.registerInput(name, {
|
return this.registerInput(name, {
|
||||||
set: this.setTransition.bind(this)
|
set: this.setTransition.bind(this)
|
||||||
});
|
});
|
||||||
else if (name.startsWith('tr-'))
|
} else if (name.startsWith('tr-')) {
|
||||||
return this.registerInput(name, {
|
return this.registerInput(name, {
|
||||||
set: this.setTransitionParam.bind(this, name.substring('tr-'.length))
|
set: this.setTransitionParam.bind(this, name.substring('tr-'.length))
|
||||||
});
|
});
|
||||||
else if (name.startsWith('pm-'))
|
} else if (name.startsWith('pm-')) {
|
||||||
return this.registerInput(name, {
|
return this.registerInput(name, {
|
||||||
set: this.setPageParam.bind(this, name.substring('pm-'.length))
|
set: this.setPageParam.bind(this, name.substring('pm-'.length))
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
registerOutputIfNeeded: function (name) {
|
registerOutputIfNeeded: function (name) {
|
||||||
if (this.hasOutput(name)) {
|
if (this.hasOutput(name)) {
|
||||||
@@ -174,18 +177,24 @@ function setup(context, graphModel) {
|
|||||||
if (Transitions[transition]) ports = ports.concat(Transitions[transition].ports(node.parameters));
|
if (Transitions[transition]) ports = ports.concat(Transitions[transition].ports(node.parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(node.parameters['stack'] !== undefined) {
|
const pageStacks = graphModel.getNodesWithType('Page Stack');
|
||||||
var pageStacks = graphModel.getNodesWithType('Page Stack');
|
const pageStack = pageStacks.find(
|
||||||
var pageStack = pageStacks.find(
|
|
||||||
(ps) => (ps.parameters['name'] || 'Main') === (node.parameters['stack'] || 'Main')
|
(ps) => (ps.parameters['name'] || 'Main') === (node.parameters['stack'] || 'Main')
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pageStack !== undefined) {
|
if (pageStack !== undefined) {
|
||||||
var pages = pageStack.parameters['pages'];
|
const pages = pageStack.parameters['pages'];
|
||||||
if (pages !== undefined && pages.length > 0) {
|
if (pages !== undefined && pages.length > 0) {
|
||||||
ports.push({
|
ports.push({
|
||||||
plug: 'input',
|
plug: 'input',
|
||||||
type: { name: 'enum', enums: pages.map((p) => ({ label: p.label, value: p.id })), allowEditOnly: true },
|
type: {
|
||||||
|
name: 'enum',
|
||||||
|
enums: pages.map((p) => ({
|
||||||
|
label: p.label,
|
||||||
|
value: p.id
|
||||||
|
})),
|
||||||
|
allowEditOnly: true
|
||||||
|
},
|
||||||
group: 'General',
|
group: 'General',
|
||||||
displayName: 'Target Page',
|
displayName: 'Target Page',
|
||||||
name: 'target',
|
name: 'target',
|
||||||
@@ -193,14 +202,14 @@ function setup(context, graphModel) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// See if there is a target page with component
|
// See if there is a target page with component
|
||||||
var targetPageId = node.parameters['target'] || pages[0].id;
|
const targetPageId = node.parameters['target'] || pages[0].id;
|
||||||
var targetComponentName = pageStack.parameters['pageComp-' + targetPageId];
|
const targetComponentName = pageStack.parameters['pageComp-' + targetPageId];
|
||||||
if (targetComponentName !== undefined) {
|
if (targetComponentName !== undefined) {
|
||||||
const component = graphModel.components[targetComponentName];
|
const component = graphModel.components[targetComponentName];
|
||||||
|
|
||||||
if (component !== undefined) {
|
if (component !== undefined) {
|
||||||
// Make all inputs of the component to inputs of this navigation node
|
// Make all inputs of the component to inputs of this navigation node
|
||||||
for (var inputName in component.inputPorts) {
|
for (const inputName in component.inputPorts) {
|
||||||
ports.push({
|
ports.push({
|
||||||
name: 'pm-' + inputName,
|
name: 'pm-' + inputName,
|
||||||
displayName: inputName,
|
displayName: inputName,
|
||||||
@@ -245,7 +254,6 @@ function setup(context, graphModel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
context.editorConnection.sendDynamicPorts(node.id, ports);
|
context.editorConnection.sendDynamicPorts(node.id, ports);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user