@iapps/ng-dhis2-ui 1.1.42 → 1.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4520,6 +4520,9 @@ class FormMetaData {
4520
4520
  }
4521
4521
  #getSectionFromPrograms(programs) {
4522
4522
  const sections = flatten(programs.map((program) => {
4523
+ if (this.params.programStage) {
4524
+ return this.#getProgramStageSections(program, this.params.programStage);
4525
+ }
4523
4526
  return [
4524
4527
  ...(this.params.splitRegistrationSection
4525
4528
  ? [
@@ -4528,43 +4531,7 @@ class FormMetaData {
4528
4531
  this.#getRegistrationSection(program),
4529
4532
  ]
4530
4533
  : [this.#getMergedRegistrationSection(program)]),
4531
- ...(program.programStages || []).map((programStage) => {
4532
- return new FormMetadataSection({
4533
- section: {
4534
- id: programStage.id,
4535
- name: programStage.name,
4536
- fieldGroups: (programStage.programStageSections || []).length > 0
4537
- ? programStage.programStageSections.map((programStageSection) => {
4538
- return {
4539
- id: programStageSection.id,
4540
- name: programStageSection.name,
4541
- dataKey: camelCase(programStage.code),
4542
- repeatableStage: programStage.repeatable
4543
- ? programStage.id
4544
- : undefined,
4545
- sortOrder: programStageSection.sortOrder,
4546
- fields: programStageSection.dataElements,
4547
- };
4548
- })
4549
- : [
4550
- {
4551
- id: programStage.id,
4552
- dataKey: camelCase(programStage.code),
4553
- repeatableStage: programStage.repeatable
4554
- ? programStage.id
4555
- : undefined,
4556
- fields: (programStage.programStageDataElements || []).map((programStageDataElement) => {
4557
- return {
4558
- id: programStageDataElement.dataElement?.id,
4559
- };
4560
- }),
4561
- },
4562
- ],
4563
- },
4564
- program,
4565
- locale: this.params.locale,
4566
- }).toJson();
4567
- }),
4534
+ ...this.#getProgramStageSections(program),
4568
4535
  ];
4569
4536
  }));
4570
4537
  if (sections.length === 0) {
@@ -4572,6 +4539,52 @@ class FormMetaData {
4572
4539
  }
4573
4540
  return sections;
4574
4541
  }
4542
+ #getProgramStageSections(program, programStageId) {
4543
+ const programStages = programStageId
4544
+ ? (program.programStages || []).filter((programStage) => programStage.id === programStageId)
4545
+ : this.params.includeAllProgramStages
4546
+ ? program.programStages
4547
+ : program.useFirstStageDuringRegistration
4548
+ ? [(program.programStages || [])[0]]
4549
+ : [];
4550
+ return (programStages || []).map((programStage) => {
4551
+ return new FormMetadataSection({
4552
+ section: {
4553
+ id: programStage.id,
4554
+ name: programStage.name,
4555
+ fieldGroups: (programStage.programStageSections || []).length > 0
4556
+ ? programStage.programStageSections.map((programStageSection) => {
4557
+ return {
4558
+ id: programStageSection.id,
4559
+ name: programStageSection.name,
4560
+ dataKey: camelCase(programStage.code),
4561
+ repeatableStage: programStage.repeatable
4562
+ ? programStage.id
4563
+ : undefined,
4564
+ sortOrder: programStageSection.sortOrder,
4565
+ fields: programStageSection.dataElements,
4566
+ };
4567
+ })
4568
+ : [
4569
+ {
4570
+ id: programStage.id,
4571
+ dataKey: camelCase(programStage.code),
4572
+ repeatableStage: programStage.repeatable
4573
+ ? programStage.id
4574
+ : undefined,
4575
+ fields: (programStage.programStageDataElements || []).map((programStageDataElement) => {
4576
+ return {
4577
+ id: programStageDataElement.dataElement?.id,
4578
+ };
4579
+ }),
4580
+ },
4581
+ ],
4582
+ },
4583
+ program,
4584
+ locale: this.params.locale,
4585
+ }).toJson();
4586
+ });
4587
+ }
4575
4588
  #getRegisteringUnitSection(program) {
4576
4589
  return new FormMetadataSection({
4577
4590
  section: {
@@ -4724,7 +4737,7 @@ class FormMetaData {
4724
4737
  : [
4725
4738
  {
4726
4739
  id: 'registration',
4727
- name: '',
4740
+ name: 'Registration',
4728
4741
  sortOrder: 1,
4729
4742
  fields: (program.programTrackedEntityAttributes || []).map((programTrackedEntityAttribute) => {
4730
4743
  return {
@@ -5987,6 +6000,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
5987
6000
  class TrackerFormComponent {
5988
6001
  constructor() {
5989
6002
  this.program = input.required();
6003
+ this.programStage = input();
5990
6004
  this.trackedEntity = input();
5991
6005
  this.d2 = window.d2Web;
5992
6006
  }
@@ -6001,6 +6015,7 @@ class TrackerFormComponent {
6001
6015
  if (program) {
6002
6016
  this.formMetaData = new FormMetaData({
6003
6017
  programs: [program],
6018
+ programStage: this.programStage(),
6004
6019
  }).toJson();
6005
6020
  console.log(this.formMetaData, this.instance.enrollmentDate);
6006
6021
  }
@@ -6008,7 +6023,7 @@ class TrackerFormComponent {
6008
6023
  onSave(event) { }
6009
6024
  onCancel() { }
6010
6025
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: TrackerFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
6011
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.8", type: TrackerFormComponent, isStandalone: false, selector: "ng-dhis2-ui-tracker-form", inputs: { program: { classPropertyName: "program", publicName: "program", isSignal: true, isRequired: true, transformFunction: null }, trackedEntity: { classPropertyName: "trackedEntity", publicName: "trackedEntity", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if(formMetaData) {\n<ng-dhis2-ui-section-form\n [formMetaData]=\"formMetaData\"\n [dataValueEntities]=\"instance\"\n (save)=\"onSave($event)\"\n (cancel)=\"onCancel()\"\n/>\n}\n", dependencies: [{ kind: "component", type: SectionFormComponent, selector: "ng-dhis2-ui-section-form", inputs: ["loading", "formMetaData", "dataValueEntities"], outputs: ["save", "formUpdate", "cancel"] }] }); }
6026
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.8", type: TrackerFormComponent, isStandalone: false, selector: "ng-dhis2-ui-tracker-form", inputs: { program: { classPropertyName: "program", publicName: "program", isSignal: true, isRequired: true, transformFunction: null }, programStage: { classPropertyName: "programStage", publicName: "programStage", isSignal: true, isRequired: false, transformFunction: null }, trackedEntity: { classPropertyName: "trackedEntity", publicName: "trackedEntity", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if(formMetaData) {\n<ng-dhis2-ui-section-form\n [formMetaData]=\"formMetaData\"\n [dataValueEntities]=\"instance\"\n (save)=\"onSave($event)\"\n (cancel)=\"onCancel()\"\n/>\n}\n", dependencies: [{ kind: "component", type: SectionFormComponent, selector: "ng-dhis2-ui-section-form", inputs: ["loading", "formMetaData", "dataValueEntities"], outputs: ["save", "formUpdate", "cancel"] }] }); }
6012
6027
  }
6013
6028
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: TrackerFormComponent, decorators: [{
6014
6029
  type: Component,