@iapps/ng-dhis2-ui 1.2.119 → 1.2.122

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.
@@ -28,7 +28,7 @@ import { isObject, isString, debounce, sortBy, isArray, find, camelCase, flatten
28
28
  import cx from 'classnames';
29
29
  import { getNowInCalendar, generateFixedPeriods } from '@dhis2/multi-calendar-dates';
30
30
  import { Pager, DataOrderCriteria, DataQueryFilter, DataFilterCondition, ProgramRuleEngine } from '@iapps/d2-web-sdk';
31
- import { parseISO, isValid, format, parse as parse$1, addDays } from 'date-fns';
31
+ import { parseISO, isValid, format, addDays } from 'date-fns';
32
32
  import { map as map$1 } from 'rxjs/operators';
33
33
  import * as XLSX from 'xlsx';
34
34
  import * as i2 from '@angular/forms';
@@ -4104,6 +4104,7 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
4104
4104
  id: element.id,
4105
4105
  options: element.optionSet?.options.map((opt) => ({
4106
4106
  name: opt.name,
4107
+ code: opt.code,
4107
4108
  color: opt.style?.color,
4108
4109
  })),
4109
4110
  }));
@@ -4125,13 +4126,19 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
4125
4126
  type: 'attribute',
4126
4127
  }));
4127
4128
  const getOptionColor = (option) => option?.color || option?.style?.color;
4129
+ // const formatDate = (value: string): string => {
4130
+ // try {
4131
+ // return format(parse(value, 'yyyy-MM-dd', new Date()), 'dd/MM/yyyy');
4132
+ // } catch {
4133
+ // return value;
4134
+ // }
4135
+ // };
4128
4136
  const formatDate = (value) => {
4129
- try {
4130
- return format(parse$1(value, 'yyyy-MM-dd', new Date()), 'dd/MM/yyyy');
4131
- }
4132
- catch {
4133
- return value;
4137
+ const date = new Date(value);
4138
+ if (isValid(date)) {
4139
+ return format(date, 'dd/MM/yyyy');
4134
4140
  }
4141
+ return value;
4135
4142
  };
4136
4143
  const trackedEntityAttributeMap = new Map();
4137
4144
  (metaData.programTrackedEntityAttributes || []).forEach(({ trackedEntityAttribute }) => {
@@ -4192,9 +4199,9 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
4192
4199
  if (!dataElementId || value == null)
4193
4200
  return;
4194
4201
  const dataElementOption = dataElementOptionMap.get(dataElementId);
4195
- const matchedOption = dataElementOption?.options?.find((opt) => opt.name === value);
4202
+ const matchedOption = dataElementOption?.options?.find((opt) => opt.code === value);
4196
4203
  row[dataElementId] = {
4197
- value,
4204
+ value: matchedOption?.name || value,
4198
4205
  ...(getOptionColor(matchedOption) && {
4199
4206
  style: getOptionColor(matchedOption),
4200
4207
  }),
@@ -8630,6 +8637,7 @@ class ProgramEntryFormModule {
8630
8637
  this.isFormValid = signal(true, ...(ngDevMode ? [{ debugName: "isFormValid" }] : []));
8631
8638
  this.isFormValid$ = toObservable(this.isFormValid);
8632
8639
  this.instance = signal(null, ...(ngDevMode ? [{ debugName: "instance" }] : []));
8640
+ this.preprocess = input(...(ngDevMode ? [undefined, { debugName: "preprocess" }] : []));
8633
8641
  this.instanceSave = new EventEmitter();
8634
8642
  this.instanceSaveCompleted = new EventEmitter();
8635
8643
  this.instanceUpdate = new EventEmitter();
@@ -8729,6 +8737,11 @@ class ProgramEntryFormModule {
8729
8737
  });
8730
8738
  }
8731
8739
  async #saveInstance() {
8740
+ if (this.preprocess() && this.instance()) {
8741
+ this.preprocess()({
8742
+ instance: this.instance(),
8743
+ });
8744
+ }
8732
8745
  switch (this.config().formType) {
8733
8746
  case 'TRACKER': {
8734
8747
  if (this.config().autoComplete) {
@@ -8801,7 +8814,7 @@ class ProgramEntryFormModule {
8801
8814
  }
8802
8815
  }
8803
8816
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: ProgramEntryFormModule, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
8804
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: ProgramEntryFormModule, isStandalone: true, selector: "ng-dhis2-ui-program-entry-form", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null }, trackedEntity: { classPropertyName: "trackedEntity", publicName: "trackedEntity", isSignal: true, isRequired: false, transformFunction: null }, event: { classPropertyName: "event", publicName: "event", isSignal: true, isRequired: false, transformFunction: null }, enrollment: { classPropertyName: "enrollment", publicName: "enrollment", isSignal: true, isRequired: false, transformFunction: null }, orgUnit: { classPropertyName: "orgUnit", publicName: "orgUnit", isSignal: true, isRequired: false, transformFunction: null }, customOrgUnitRoots: { classPropertyName: "customOrgUnitRoots", publicName: "customOrgUnitRoots", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { instanceSave: "instanceSave", instanceSaveCompleted: "instanceSaveCompleted", instanceUpdate: "instanceUpdate", formValidityUpdate: "formValidityUpdate", formCancel: "formCancel" }, ngImport: i0, template: "@if (loading()) {\n<div className=\"program-entry__form-loader\">\n <ng-dhis2-ui-wrapper [component]=\"FormLoader\" />\n</div>\n} @else if(metaData()) {\n\n<div>\n <!-- Form content -->\n @switch (config().displayType) {\n\n <!-- Flat display -->\n @case ('FLAT') {\n\n <ng-dhis2-ui-flat-form\n [name]=\"metaData()!.name\"\n [dataValues]=\"instance() || {}\"\n [dataId]=\"dataId()\"\n [rules]=\"metaData()!.rules\"\n [fields]=\"metaData()!.formFields\"\n [customOrgUnitRoots]=\"customOrgUnitRoots()\"\n [program]=\"config().program\"\n (formUpdate)=\"onFormUpdate($event)\"\n (formValidityUpdate)=\"onValidityUpdate($event)\"\n />\n }\n\n <!-- SECTION display -->\n @case ('SECTION') { Section form }\n\n <!-- CUSTOM FORM -->\n @case ('CUSTOM') { } }\n\n <!-- Action buttons -->\n\n @if(!config().hideActionButtons) {\n <ng-dhis2-ui-wrapper [component]=\"FormActionButtons()\" />\n }\n</div>\n}\n", styles: ["::ng-deep .program-entry__form-loader{padding:8px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: D2FormModule }, { kind: "component", type: FlatFormComponent, selector: "ng-dhis2-ui-flat-form" }, { kind: "directive", type: ReactWrapperModule, selector: "ng-dhis2-ui-wrapper", inputs: ["props", "component"] }] }); }
8817
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: ProgramEntryFormModule, isStandalone: true, selector: "ng-dhis2-ui-program-entry-form", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null }, trackedEntity: { classPropertyName: "trackedEntity", publicName: "trackedEntity", isSignal: true, isRequired: false, transformFunction: null }, event: { classPropertyName: "event", publicName: "event", isSignal: true, isRequired: false, transformFunction: null }, enrollment: { classPropertyName: "enrollment", publicName: "enrollment", isSignal: true, isRequired: false, transformFunction: null }, orgUnit: { classPropertyName: "orgUnit", publicName: "orgUnit", isSignal: true, isRequired: false, transformFunction: null }, customOrgUnitRoots: { classPropertyName: "customOrgUnitRoots", publicName: "customOrgUnitRoots", isSignal: true, isRequired: false, transformFunction: null }, preprocess: { classPropertyName: "preprocess", publicName: "preprocess", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { instanceSave: "instanceSave", instanceSaveCompleted: "instanceSaveCompleted", instanceUpdate: "instanceUpdate", formValidityUpdate: "formValidityUpdate", formCancel: "formCancel" }, ngImport: i0, template: "@if (loading()) {\n<div className=\"program-entry__form-loader\">\n <ng-dhis2-ui-wrapper [component]=\"FormLoader\" />\n</div>\n} @else if(metaData()) {\n\n<div>\n <!-- Form content -->\n @switch (config().displayType) {\n\n <!-- Flat display -->\n @case ('FLAT') {\n\n <ng-dhis2-ui-flat-form\n [name]=\"metaData()!.name\"\n [dataValues]=\"instance() || {}\"\n [dataId]=\"dataId()\"\n [rules]=\"metaData()!.rules\"\n [fields]=\"metaData()!.formFields\"\n [customOrgUnitRoots]=\"customOrgUnitRoots()\"\n [program]=\"config().program\"\n (formUpdate)=\"onFormUpdate($event)\"\n (formValidityUpdate)=\"onValidityUpdate($event)\"\n />\n }\n\n <!-- SECTION display -->\n @case ('SECTION') { Section form }\n\n <!-- CUSTOM FORM -->\n @case ('CUSTOM') { } }\n\n <!-- Action buttons -->\n\n @if(!config().hideActionButtons) {\n <ng-dhis2-ui-wrapper [component]=\"FormActionButtons()\" />\n }\n</div>\n}\n", styles: ["::ng-deep .program-entry__form-loader{padding:8px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: D2FormModule }, { kind: "component", type: FlatFormComponent, selector: "ng-dhis2-ui-flat-form" }, { kind: "directive", type: ReactWrapperModule, selector: "ng-dhis2-ui-wrapper", inputs: ["props", "component"] }] }); }
8805
8818
  }
8806
8819
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: ProgramEntryFormModule, decorators: [{
8807
8820
  type: Component,