Closed mythsman closed 4 weeks ago
Hello @mythsman,
I'm not sure if I understand correctly. The getToolboxGroups
method returns groups and steps in alphabetical order. For that, the localeCompare
method is used.
public getToolboxGroups(): ToolboxGroup[] {
const stepModels = Object.values(this.definitionModel.steps);
...
categories.forEach((category: string | undefined) => {
...
groupSteps.sort((a, b) => a.name.localeCompare(b.name));
groups.push({
name,
steps: groupSteps
});
});
groups.sort((a, b) => a.name.localeCompare(b.name));
return groups;
}
Do you want to keep the order from the model builder?
@b4rtaz Oh, you know exactly what I want. I have confused 'the order from the model builder' with 'alphabetical order using localCompare' .
There's an issue when using localCompare
because the displayed order may differ on machines with different language settings, which made me think it was due to unstable sorting.
So, I think maintaining the order as provided by the model builder might be a better choice.
And , i am currently facing a scenario related to node definition upgrade. I have designed a node that works perfectly fine. However, as the business grows, the definition of this node needs to be changed. Directly modifying the node definition is not an option since the old workflow definition wouldn't render correctly in the new workflow.
My current solution is to define a new node based on the original one and hide the old one in the getToolboxGroups. This would allow the new workflows to only use the new node while the old workflows can still read from the old node as usual.
Therefore, I believe adding a hidden property or similar in the Step or DefinitionModel, and then filtering it in the getToolboxGroups could be a better choice.
Of course, a custom getToolboxGroups could resolve all these issues as well.
@mythsman please check the 0.14.3 version. I added both features. If you want to keep the default order from the builder, you should use a sorter that does nothing (an empty function).
Thanks for your great work!
Oh ,you forgot to export it in index.d.ts 😅
Although the sorting of
EditorProvider#getToolboxGroups
itself is stable, when adding steps usingDefinitionModelBuilder#steps
, the originally ordered steps get regrouped based onmodel.type
. After that, usingObject.values(this.definitionModel.steps)
does not guarantee the order.