chore(runtime): Clean up "Push Component To Stack" (#30)

This commit is contained in:
Eric Tuvesson
2024-06-13 22:25:16 +02:00
committed by Richard Osborne
parent af81e1304e
commit e21926d0df

View File

@@ -72,8 +72,10 @@ const Navigate = {
backCallback: (action, results) => {
this._internal.backResults = results;
for (var key in results) {
if (this.hasOutput('backResult-' + key)) this.flagOutputDirty('backResult-' + key);
for (const key in results) {
if (this.hasOutput('backResult-' + key)) {
this.flagOutputDirty('backResult-' + key);
}
}
if (action !== undefined) this.sendSignalOnOutput(action);
@@ -114,22 +116,23 @@ const Navigate = {
return;
}
if (name === 'target')
if (name === 'target') {
return this.registerInput(name, {
set: this.setTargetPageId.bind(this)
});
else if (name === 'transition')
} else if (name === 'transition') {
return this.registerInput(name, {
set: this.setTransition.bind(this)
});
else if (name.startsWith('tr-'))
} else if (name.startsWith('tr-')) {
return this.registerInput(name, {
set: this.setTransitionParam.bind(this, name.substring('tr-'.length))
});
else if (name.startsWith('pm-'))
} else if (name.startsWith('pm-')) {
return this.registerInput(name, {
set: this.setPageParam.bind(this, name.substring('pm-'.length))
});
}
},
registerOutputIfNeeded: function (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(node.parameters['stack'] !== undefined) {
var pageStacks = graphModel.getNodesWithType('Page Stack');
var pageStack = pageStacks.find(
const pageStacks = graphModel.getNodesWithType('Page Stack');
const pageStack = pageStacks.find(
(ps) => (ps.parameters['name'] || 'Main') === (node.parameters['stack'] || 'Main')
);
if (pageStack !== undefined) {
var pages = pageStack.parameters['pages'];
const pages = pageStack.parameters['pages'];
if (pages !== undefined && pages.length > 0) {
ports.push({
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',
displayName: 'Target Page',
name: 'target',
@@ -193,14 +202,14 @@ function setup(context, graphModel) {
});
// See if there is a target page with component
var targetPageId = node.parameters['target'] || pages[0].id;
var targetComponentName = pageStack.parameters['pageComp-' + targetPageId];
const targetPageId = node.parameters['target'] || pages[0].id;
const targetComponentName = pageStack.parameters['pageComp-' + targetPageId];
if (targetComponentName !== undefined) {
const component = graphModel.components[targetComponentName];
if (component !== undefined) {
// 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({
name: 'pm-' + inputName,
displayName: inputName,
@@ -245,7 +254,6 @@ function setup(context, graphModel) {
}
}
}
// }
context.editorConnection.sendDynamicPorts(node.id, ports);
}