@iapps/ng-dhis2-ui 1.1.41 → 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.
@@ -3334,6 +3334,7 @@ class LineListTableComponent extends ReactWrapperModule {
3334
3334
  this.approvalSelected = new EventEmitter();
3335
3335
  this.isButtonLoading = false;
3336
3336
  this.buttonLabel = '';
3337
+ this.firstValue = new EventEmitter();
3337
3338
  this.setReactStateUpdaters = (updaters) => {
3338
3339
  this.reactStateUpdaters = updaters;
3339
3340
  };
@@ -3408,6 +3409,8 @@ class LineListTableComponent extends ReactWrapperModule {
3408
3409
  const { columns, data, filteredEntityColumns } = getTrackedEntityData(response, this.programId, pager, this.filters);
3409
3410
  entityColumns = columns;
3410
3411
  entityData = data;
3412
+ let firstTei = response.data.trackedEntityInstances[0].trackedEntityInstance;
3413
+ this.firstValue.emit(firstTei);
3411
3414
  // setFilteredColumns(filteredEntityColumns);
3412
3415
  // Ensure filter inputs do not disappear when no data is returned
3413
3416
  // If filteredEntityColumns is empty, keep the previous columns instead of clearing them
@@ -3478,15 +3481,6 @@ class LineListTableComponent extends ReactWrapperModule {
3478
3481
  }
3479
3482
  });
3480
3483
  };
3481
- // const handleInputChange = (key: string, value: string) => {
3482
- // setInputValues((prevValues) => ({
3483
- // ...prevValues,
3484
- // [key]: value ?? '', // Ensure no undefined values
3485
- // }));
3486
- // };
3487
- // if (!filteredColumns || filteredColumns.length === 0) {
3488
- // return <div>No fields available</div>;
3489
- // }
3490
3484
  const handleInputChange = (key, value) => {
3491
3485
  setInputValues((prevValues) => ({
3492
3486
  ...prevValues,
@@ -3502,29 +3496,7 @@ class LineListTableComponent extends ReactWrapperModule {
3502
3496
  // console.log(`Updated Filters:`, updatedFilters); // Debugging
3503
3497
  return updatedFilters;
3504
3498
  });
3505
- // setAttributeFiltersState((prevFilters = []) => {
3506
- // // Check if attribute already exists
3507
- // const existingFilterIndex = prevFilters.findIndex(
3508
- // (f) => f.attribute === key
3509
- // );
3510
- // // Create a new filter object
3511
- // const newFilter = { attribute: key, operator: 'like', value };
3512
- // if (existingFilterIndex !== -1) {
3513
- // // If attribute exists, update its value
3514
- // const updatedFilters = [...prevFilters];
3515
- // updatedFilters[existingFilterIndex] = newFilter;
3516
- // console.log(`Updated Filters:`, updatedFilters); // Log updated filter list
3517
- // return updatedFilters;
3518
- // } else {
3519
- // // If attribute doesn't exist, add a new object
3520
- // return [...prevFilters, newFilter];
3521
- // }
3522
- // });
3523
3499
  };
3524
- // console.log(
3525
- // 'these are the filtered columns which have the attributes neede',
3526
- // filteredColumns
3527
- // );
3528
3500
  return (React__default.createElement("div", null,
3529
3501
  React__default.createElement("div", { style: {
3530
3502
  width: '100%',
@@ -3554,7 +3526,7 @@ class LineListTableComponent extends ReactWrapperModule {
3554
3526
  gap: 8,
3555
3527
  }, onClick: () => {
3556
3528
  setFilters(!filters);
3557
- } },
3529
+ }, secondary: true },
3558
3530
  React__default.createElement(IconFilter16, null),
3559
3531
  filters ? 'Hide Filters' : 'Show Filters'))),
3560
3532
  filters && (React__default.createElement("div", { style: {
@@ -3640,7 +3612,7 @@ class LineListTableComponent extends ReactWrapperModule {
3640
3612
  this.render();
3641
3613
  }
3642
3614
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LineListTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
3643
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: LineListTableComponent, isStandalone: false, selector: "app-line-list", inputs: { programId: "programId", orgUnit: "orgUnit", programStageId: "programStageId", actionOptions: "actionOptions", attributeFilters: "attributeFilters", startDate: "startDate", endDate: "endDate", filters: "filters", ouMode: "ouMode", dispatchTeis: "dispatchTeis", showFilterButton: "showFilterButton", isButtonLoading: "isButtonLoading", buttonLabel: "buttonLabel" }, outputs: { actionSelected: "actionSelected", approvalSelected: "approvalSelected" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["[data-test=dhis2-uiwidgets-pagination]{display:flex!important;flex-direction:row!important;justify-content:space-between!important;align-items:center!important}\n"] }); }
3615
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: LineListTableComponent, isStandalone: false, selector: "app-line-list", inputs: { programId: "programId", orgUnit: "orgUnit", programStageId: "programStageId", actionOptions: "actionOptions", attributeFilters: "attributeFilters", startDate: "startDate", endDate: "endDate", filters: "filters", ouMode: "ouMode", dispatchTeis: "dispatchTeis", showFilterButton: "showFilterButton", isButtonLoading: "isButtonLoading", buttonLabel: "buttonLabel" }, outputs: { actionSelected: "actionSelected", approvalSelected: "approvalSelected", firstValue: "firstValue" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["[data-test=dhis2-uiwidgets-pagination]{display:flex!important;flex-direction:row!important;justify-content:space-between!important;align-items:center!important}\n"] }); }
3644
3616
  }
3645
3617
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LineListTableComponent, decorators: [{
3646
3618
  type: Component,
@@ -3675,6 +3647,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
3675
3647
  type: Input
3676
3648
  }], buttonLabel: [{
3677
3649
  type: Input
3650
+ }], firstValue: [{
3651
+ type: Output
3678
3652
  }] } });
3679
3653
 
3680
3654
  class LineListModule {
@@ -4546,6 +4520,9 @@ class FormMetaData {
4546
4520
  }
4547
4521
  #getSectionFromPrograms(programs) {
4548
4522
  const sections = flatten(programs.map((program) => {
4523
+ if (this.params.programStage) {
4524
+ return this.#getProgramStageSections(program, this.params.programStage);
4525
+ }
4549
4526
  return [
4550
4527
  ...(this.params.splitRegistrationSection
4551
4528
  ? [
@@ -4554,43 +4531,7 @@ class FormMetaData {
4554
4531
  this.#getRegistrationSection(program),
4555
4532
  ]
4556
4533
  : [this.#getMergedRegistrationSection(program)]),
4557
- ...(program.programStages || []).map((programStage) => {
4558
- return new FormMetadataSection({
4559
- section: {
4560
- id: programStage.id,
4561
- name: programStage.name,
4562
- fieldGroups: (programStage.programStageSections || []).length > 0
4563
- ? programStage.programStageSections.map((programStageSection) => {
4564
- return {
4565
- id: programStageSection.id,
4566
- name: programStageSection.name,
4567
- dataKey: camelCase(programStage.code),
4568
- repeatableStage: programStage.repeatable
4569
- ? programStage.id
4570
- : undefined,
4571
- sortOrder: programStageSection.sortOrder,
4572
- fields: programStageSection.dataElements,
4573
- };
4574
- })
4575
- : [
4576
- {
4577
- id: programStage.id,
4578
- dataKey: camelCase(programStage.code),
4579
- repeatableStage: programStage.repeatable
4580
- ? programStage.id
4581
- : undefined,
4582
- fields: (programStage.programStageDataElements || []).map((programStageDataElement) => {
4583
- return {
4584
- id: programStageDataElement.dataElement?.id,
4585
- };
4586
- }),
4587
- },
4588
- ],
4589
- },
4590
- program,
4591
- locale: this.params.locale,
4592
- }).toJson();
4593
- }),
4534
+ ...this.#getProgramStageSections(program),
4594
4535
  ];
4595
4536
  }));
4596
4537
  if (sections.length === 0) {
@@ -4598,6 +4539,52 @@ class FormMetaData {
4598
4539
  }
4599
4540
  return sections;
4600
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
+ }
4601
4588
  #getRegisteringUnitSection(program) {
4602
4589
  return new FormMetadataSection({
4603
4590
  section: {
@@ -4750,7 +4737,7 @@ class FormMetaData {
4750
4737
  : [
4751
4738
  {
4752
4739
  id: 'registration',
4753
- name: '',
4740
+ name: 'Registration',
4754
4741
  sortOrder: 1,
4755
4742
  fields: (program.programTrackedEntityAttributes || []).map((programTrackedEntityAttribute) => {
4756
4743
  return {
@@ -6013,6 +6000,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
6013
6000
  class TrackerFormComponent {
6014
6001
  constructor() {
6015
6002
  this.program = input.required();
6003
+ this.programStage = input();
6016
6004
  this.trackedEntity = input();
6017
6005
  this.d2 = window.d2Web;
6018
6006
  }
@@ -6027,6 +6015,7 @@ class TrackerFormComponent {
6027
6015
  if (program) {
6028
6016
  this.formMetaData = new FormMetaData({
6029
6017
  programs: [program],
6018
+ programStage: this.programStage(),
6030
6019
  }).toJson();
6031
6020
  console.log(this.formMetaData, this.instance.enrollmentDate);
6032
6021
  }
@@ -6034,7 +6023,7 @@ class TrackerFormComponent {
6034
6023
  onSave(event) { }
6035
6024
  onCancel() { }
6036
6025
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: TrackerFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
6037
- 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"] }] }); }
6038
6027
  }
6039
6028
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: TrackerFormComponent, decorators: [{
6040
6029
  type: Component,