@iapps/ng-dhis2-ui 1.3.4 → 1.3.6

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.
@@ -9139,7 +9139,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
9139
9139
  case 'transfer':
9140
9140
  return (React__default.createElement(Transfer, { filterable: true, filterPlaceholder: "Search", selected: selected, leftHeader: React__default.createElement("div", { style: { fontSize: 14, padding: '8px 4px' } }, f.availableOptionsLabel), rightHeader: React__default.createElement("div", { style: { fontSize: 14, padding: '8px 4px' } }, f.selectedOptionsLabel), options: f.options, onChange: (event) => onValueChange(event.selected) }));
9141
9141
  case 'checkbox':
9142
- return (React__default.createElement(Checkbox, { checked: Boolean(value), error: hasError, label: this.label(), name: f.id, disabled: disabled, onChange: (event) => onValueChange(event.checked), onBlur: () => checkValueUniqueness() }));
9142
+ return (React__default.createElement(Checkbox, { checked: Boolean(value), error: hasError, label: this.label(), name: f.id, disabled: disabled, onChange: (event) => onValueChange(event.checked ? true : null), onBlur: () => checkValueUniqueness() }));
9143
9143
  case 'dropdown':
9144
9144
  return (React__default.createElement(FieldSet, null,
9145
9145
  React__default.createElement(FormFieldLabel, { field: this.field(), fieldConfig: this.fieldConfig() }),
@@ -11895,6 +11895,7 @@ class ProgramEntryFormConfig {
11895
11895
  this.cancelButtonLabel = 'Cancel';
11896
11896
  this.fieldDescriptionLabel = 'Description';
11897
11897
  this.updateTeiOrgUnit = false;
11898
+ this.enableCustomFieldConfigurations = false;
11898
11899
  Object.assign(this, config);
11899
11900
  }
11900
11901
  }
@@ -11939,6 +11940,9 @@ class ProgramEntryFormFieldUtil {
11939
11940
  });
11940
11941
  }
11941
11942
  get dataElements() {
11943
+ if (this.config.excludeProgramStages) {
11944
+ return [];
11945
+ }
11942
11946
  const programStages = this.config.programStage
11943
11947
  ? this.program.programStages?.filter((programStage) => programStage.id === this.config.programStage)
11944
11948
  : this.program.programStages;
@@ -12920,7 +12924,7 @@ class ProgramEntryFormMetaData {
12920
12924
  });
12921
12925
  }
12922
12926
  get programStageSections() {
12923
- if (!this.program) {
12927
+ if (!this.program || this.config.excludeProgramStages) {
12924
12928
  return [];
12925
12929
  }
12926
12930
  const { displayType, formType } = this.config;
@@ -12978,8 +12982,10 @@ class ProgramEntryFormMetaData {
12978
12982
  };
12979
12983
  }
12980
12984
  async #getCustomFieldConfigurations() {
12985
+ console.log('Fetching custom field configurations...');
12981
12986
  try {
12982
12987
  const response = await this.d2.httpInstance.get('dataStore/field-extensions?fields=id,fieldOptionsDependsOn,optionSet&paging=false', { useIndexDb: true });
12988
+ console.log('Fetching custom field configurations...', response?.data);
12983
12989
  const responseData = response?.data;
12984
12990
  const entries = Array.isArray(responseData)
12985
12991
  ? responseData
@@ -13009,8 +13015,9 @@ class ProgramEntryFormMetaData {
13009
13015
  if (program) {
13010
13016
  this.program = program;
13011
13017
  // TODO FIND ANOTHER WAY TO PASS IN CUSTOM FIELD CONFIGURATIONS, AVOID TIGHT COUPLING HERE
13012
- // this.customFieldConfigurations =
13013
- // await this.#getCustomFieldConfigurations();
13018
+ this.customFieldConfigurations = this.config.enableCustomFieldConfigurations === true
13019
+ ? await this.#getCustomFieldConfigurations()
13020
+ : {};
13014
13021
  if (this.config?.formFieldExtensions &&
13015
13022
  this.config.formFieldExtensions.length > 0 &&
13016
13023
  this.config.formFieldExtensions[0]?.optionsSourceCode) {
@@ -13094,15 +13101,16 @@ class ProgramEntryFormModule {
13094
13101
  if (!this.instance()) {
13095
13102
  return {};
13096
13103
  }
13097
- const trackedEntity = this.trackedEntityInstance();
13098
- const attributeValues = Object.keys(trackedEntity?.attributeEntities ?? {}).reduce((acc, key) => {
13099
- acc[key] = trackedEntity?.attributeEntities?.[key]?.value;
13100
- return acc;
13101
- }, {});
13104
+ const attributeDataValues = this.trackedEntityInstance()
13105
+ ? this.#getTrackedEntityDataValues(this.trackedEntityInstance())
13106
+ : {};
13107
+ // TODO: Consider refactoring this logic to avoid potential issues with nested data values. The current implementation may not handle deeply nested structures correctly, which could lead to unexpected behavior when updating the instance with new data values.
13108
+ const currentInstanceDataValues = this.config().formType === 'TRACKER'
13109
+ ? this.#getTrackedEntityDataValues(this.instance())
13110
+ : this.instance();
13102
13111
  return {
13103
- ...attributeValues,
13104
- ...(trackedEntity?.reportEntities ?? {}),
13105
- ...(this.instance() || {}),
13112
+ ...attributeDataValues,
13113
+ ...(currentInstanceDataValues || {}),
13106
13114
  };
13107
13115
  }, /* @ts-ignore */
13108
13116
  ...(ngDevMode ? [{ debugName: "dataEntities" }] : /* istanbul ignore next */ []));
@@ -13140,6 +13148,16 @@ class ProgramEntryFormModule {
13140
13148
  }, /* @ts-ignore */
13141
13149
  ...(ngDevMode ? [{ debugName: "FormActionButtons" }] : /* istanbul ignore next */ []));
13142
13150
  }
13151
+ #getTrackedEntityDataValues(trackedEntity) {
13152
+ const attributeDataValues = Object.keys(trackedEntity?.attributeEntities ?? {}).reduce((acc, key) => {
13153
+ acc[key] = trackedEntity?.attributeEntities?.[key]?.value;
13154
+ return acc;
13155
+ }, {});
13156
+ return {
13157
+ ...attributeDataValues,
13158
+ ...(trackedEntity?.reportEntities ?? {}),
13159
+ };
13160
+ }
13143
13161
  async ngOnInit() {
13144
13162
  this.loading.set(true);
13145
13163
  try {