Skip to content

Commit

Permalink
Merge pull request #38 from EyeSeeTea/feat/sort-form-options
Browse files Browse the repository at this point in the history
Sort form options
  • Loading branch information
MiquelAdell authored May 8, 2024
2 parents 562a264 + c283836 commit 1f1ffdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/data/entities/D2Program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface Option {
name: string;
code: string;
optionSet: { id: string };
sortOrder: number;
}

export interface TrackedEntityAttibute {
Expand Down
6 changes: 5 additions & 1 deletion src/data/repositories/SurveyFormD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export class SurveyD2Repository implements SurveyRepository {
.value()
: resp.trackedEntityAttributes;

const sortedOptions = _(resp.options)
.sortBy(option => option.sortOrder)
.value();

//If event specified,populate the form
if (eventId) {
if (isTrackerProgram(programId)) {
Expand All @@ -86,7 +90,7 @@ export class SurveyD2Repository implements SurveyRepository {
trackedEntity,
programDataElements,
resp.dataElements,
resp.options,
sortedOptions,
resp.programStages,
resp.programStageSections,
sortedTrackedentityAttr,
Expand Down

0 comments on commit 1f1ffdb

Please sign in to comment.