Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sort inputs by original order intended by the action/trigger creator #4684

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<form [formGroup]="form" class="ap-flex ap-flex-col">
@for (
property of sortedPropertiesByRequired | objectToArray;
property of propertiesMap | objectToArray;
track property.key
) {
@if (
Expand Down Expand Up @@ -179,6 +179,7 @@
@case (PropertyType.MARKDOWN) {
@if (property.value.description) {
<ap-markdown
[fullWidth]="true"
[data]="
property.value.description
| replaceMarkdownConsts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class PiecePropertiesFormComponent
valid: boolean;
}>();
readonly PropertyType = PropertyType;
sortedPropertiesByRequired: PiecePropertyMap;
emitNewChanges$?: Observable<unknown>;
stepChanged$ = new BehaviorSubject('');
constructor(private fb: UntypedFormBuilder) {
Expand All @@ -85,26 +84,9 @@ export class PiecePropertiesFormComponent
}

private initializeForm() {
this.sortPropertiesByRequired();
this.buildForm();
}

private sortPropertiesByRequired() {
const requiredProperties: PiecePropertyMap = {};
const optionalProperties: PiecePropertyMap = {};
Object.entries(this.propertiesMap).forEach(([key, value]) => {
if (value.required || value.type === PropertyType.MARKDOWN) {
requiredProperties[key] = value;
} else {
optionalProperties[key] = value;
}
});
this.sortedPropertiesByRequired = {
...requiredProperties,
...optionalProperties,
};
}

private buildForm() {
createFormControlsWithTheirValidators(
this.fb,
Expand Down
Loading