Skip to content

Commit

Permalink
Merge pull request #4684 from activepieces/fix/sort-pieces-by-origina…
Browse files Browse the repository at this point in the history
…l-order

fix: sort inputs by original order intended by the action/trigger creator
  • Loading branch information
abuaboud committed May 14, 2024
2 parents f77c4c8 + 1aa72b0 commit 79bf734
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
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

0 comments on commit 79bf734

Please sign in to comment.