@iapps/ng-dhis2-ui 1.1.54 → 1.1.56

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.
Files changed (38) hide show
  1. package/fesm2022/iapps-ng-dhis2-ui.mjs +874 -263
  2. package/fesm2022/iapps-ng-dhis2-ui.mjs.map +1 -1
  3. package/index.d.ts +2 -0
  4. package/lib/modules/event-form/event-form.component.d.ts +21 -0
  5. package/lib/modules/event-form/event-form.module.d.ts +9 -0
  6. package/lib/modules/event-form/index.d.ts +2 -0
  7. package/lib/modules/form/components/base-form-field.component.d.ts +8 -23
  8. package/lib/modules/form/containers/flat-form/flat-form.component.d.ts +11 -0
  9. package/lib/modules/form/containers/form/form.component.d.ts +14 -10
  10. package/lib/modules/form/containers/form-field/form-field.component.d.ts +10 -5
  11. package/lib/modules/form/containers/section-form/section-form.component.d.ts +1 -1
  12. package/lib/modules/form/form.module.d.ts +7 -6
  13. package/lib/modules/form/hooks/field-validation.hook.d.ts +2 -2
  14. package/lib/modules/form/index.d.ts +1 -0
  15. package/lib/modules/form/interfaces/form-field.interface.d.ts +4 -0
  16. package/lib/modules/form/models/form-field.model.d.ts +7 -1
  17. package/lib/modules/form/models/form-metadata-rule.model.d.ts +9 -2
  18. package/lib/modules/form/models/form-metadata-section.model.d.ts +2 -0
  19. package/lib/modules/form/models/form-metadata.model.d.ts +3 -3
  20. package/lib/modules/form/models/form-value.model.d.ts +4 -4
  21. package/lib/modules/form/shared/components/base-form-wrapper.component.d.ts +26 -0
  22. package/lib/modules/form/shared/components/index.d.ts +1 -0
  23. package/lib/modules/form/shared/index.d.ts +1 -0
  24. package/lib/modules/form/utils/field-type.util.d.ts +1 -1
  25. package/lib/modules/form/utils/field.util.d.ts +1 -1
  26. package/lib/modules/form/utils/form.util.d.ts +3 -2
  27. package/lib/modules/program-entry-form/index.d.ts +2 -0
  28. package/lib/modules/program-entry-form/models/index.d.ts +3 -0
  29. package/lib/modules/program-entry-form/models/program-entry-form-metadata.d.ts +28 -0
  30. package/lib/modules/program-entry-form/models/program-entry-form-section.model.d.ts +16 -0
  31. package/lib/modules/program-entry-form/models/program-entry-form.config.d.ts +47 -0
  32. package/lib/modules/program-entry-form/program-entry-form.component.d.ts +35 -0
  33. package/lib/modules/program-entry-form/utils/index.d.ts +2 -0
  34. package/lib/modules/program-entry-form/utils/program-entry-form-field.util.d.ts +62 -0
  35. package/lib/modules/program-entry-form/utils/program-entry-form-section.util.d.ts +8 -0
  36. package/lib/modules/tracker-form/tracker-form.component.d.ts +1 -0
  37. package/lib/shared/utils/predefinedDimensions.d.ts +6 -6
  38. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import * as i1$1 from '@angular/common';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
- import { NgModule, Directive, Input, ContentChild, Component, EventEmitter, Output, inject, NgZone, input, ChangeDetectionStrategy, Injectable, model, signal, computed, ViewChildren } from '@angular/core';
4
+ import { NgModule, Directive, Input, ContentChild, Component, EventEmitter, Output, inject, NgZone, input, ChangeDetectionStrategy, Injectable, model, computed, signal, effect, ViewChildren } from '@angular/core';
5
5
  import { useDataQuery, useConfig, useAlert, clearSensitiveCaches, DataProvider, useDataEngine, Provider } from '@dhis2/app-runtime';
6
6
  import * as i1 from '@iapps/ngx-dhis2-http-client';
7
7
  import { NgxDhis2HttpClientService } from '@iapps/ngx-dhis2-http-client';
@@ -25,8 +25,8 @@ import { Layer } from '@dhis2-ui/layer';
25
25
  import { CircularLoader } from '@dhis2-ui/loader';
26
26
  import { MenuItem, MenuDivider } from '@dhis2-ui/menu';
27
27
  import parse from 'html-react-parser';
28
- import { Button as Button$1, IconDimensionData16, IconClock16, IconDimensionOrgUnit16, spacers as spacers$1, colors as colors$1, IconEdit16, theme as theme$1, Tooltip, IconChevronRight16, SingleSelectField, SingleSelectOption, InputField as InputField$1, TabBar, Tab, Transfer, Modal as Modal$1, ModalTitle as ModalTitle$1, ModalContent as ModalContent$1, ModalActions as ModalActions$1, ButtonStrip as ButtonStrip$1, Checkbox, OrganisationUnitTree, MultiSelect, MultiSelectOption, IconWarningFilled16, Layer as Layer$1, Popper, FlyoutMenu, MenuItem as MenuItem$1, IconMore24, CircularLoader as CircularLoader$1, IconFilter16, DataTable, TableHead, DataTableRow, DataTableColumnHeader, TableBody, DataTableCell, TableFoot, Pagination, Chip, FileInputField, FileListItem, MultiSelectField, TextAreaField } from '@dhis2/ui';
29
- import { isObject, isString, sortBy, isArray, find, camelCase, flatten, debounce, isUndefined, head, isEmpty } from 'lodash';
28
+ import { Button as Button$1, IconDimensionData16, IconClock16, IconDimensionOrgUnit16, spacers as spacers$1, colors as colors$1, IconEdit16, theme as theme$1, Tooltip, IconChevronRight16, SingleSelectField, SingleSelectOption, InputField as InputField$1, TabBar, Tab, Transfer, Modal as Modal$1, ModalTitle as ModalTitle$1, ModalContent as ModalContent$1, ModalActions as ModalActions$1, ButtonStrip as ButtonStrip$1, Checkbox, OrganisationUnitTree, MultiSelect, MultiSelectOption, IconWarningFilled16, Layer as Layer$1, Popper, FlyoutMenu, MenuItem as MenuItem$1, IconMore24, CircularLoader as CircularLoader$1, IconFilter16, DataTable, TableHead, DataTableRow, DataTableColumnHeader, TableBody, DataTableCell, TableFoot, Pagination, FileInputField, FileListItem, Chip, MultiSelectField, TextAreaField } from '@dhis2/ui';
29
+ import { isObject, isString, sortBy, isArray, find, camelCase, flatten, isUndefined, debounce, head, isEmpty } from 'lodash';
30
30
  import cx from 'classnames';
31
31
  import { getNowInCalendar, generateFixedPeriods } from '@dhis2/multi-calendar-dates';
32
32
  import { map as map$1, switchMap } from 'rxjs/operators';
@@ -4061,6 +4061,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
4061
4061
  }]
4062
4062
  }] });
4063
4063
 
4064
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
4065
+ // Use of this source code is governed by a BSD-style
4066
+ // license that can be found in the LICENSE file.
4067
+ const useFieldValidation = (props) => {
4068
+ const { form, touched, field, value } = props;
4069
+ const hasError = useMemo(() => {
4070
+ return touched && (form.get(field.id) || form.get(field.key))?.invalid;
4071
+ }, [value, touched]);
4072
+ const validationError = useMemo(() => {
4073
+ if (!touched) {
4074
+ return undefined;
4075
+ }
4076
+ const error = (form.get(field.id) || form.get(field.key))?.errors;
4077
+ if (!error) {
4078
+ return undefined;
4079
+ }
4080
+ if (error['min']) {
4081
+ return `${field.label || 'Value'} should not be less than ${error['min'].min}!`;
4082
+ }
4083
+ else if (error['max']) {
4084
+ return `${field.label || 'Value'} should not be greater than ${error['max'].max}!`;
4085
+ }
4086
+ else if (error['pattern']) {
4087
+ if (field.type === 'email') {
4088
+ return `The email address provided is not valid`;
4089
+ }
4090
+ else if (field.type === 'tel') {
4091
+ return 'Phone number provided is not valid';
4092
+ }
4093
+ else {
4094
+ return `${field.label || 'Value'} should have appropriate format`;
4095
+ }
4096
+ }
4097
+ return error['required']
4098
+ ? `${field.label || 'Value'} is required`
4099
+ : undefined;
4100
+ }, [hasError]);
4101
+ return { hasError, validationError };
4102
+ };
4103
+
4104
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
4105
+ // Use of this source code is governed by a BSD-style
4106
+ // license that can be found in the LICENSE file.
4107
+
4064
4108
  class FormField {
4065
4109
  constructor(options = {}) {
4066
4110
  this.value = options.value || '';
@@ -4074,11 +4118,10 @@ class FormField {
4074
4118
  this.controlType = options.controlType;
4075
4119
  this.type = options.type || '';
4076
4120
  this.options = options.options || [];
4077
- this.disabled = options.disabled || false;
4121
+ this.disabled = options.disabled ?? false;
4078
4122
  this.placeholder = options.placeholder || '';
4079
4123
  this.min = options.min;
4080
- this.max =
4081
- options.max || (this.controlType === 'date' ? new Date() : undefined);
4124
+ this.max = this.setMax(options);
4082
4125
  this.maxLength = options.maxLength;
4083
4126
  this.hidden = options.hidden || false;
4084
4127
  this.unique = options.unique || false;
@@ -4103,6 +4146,16 @@ class FormField {
4103
4146
  options.availableOptionsLabel ?? 'Available options';
4104
4147
  this.selectedOptionsLabel =
4105
4148
  options.availableOptionsLabel ?? 'Selected options';
4149
+ this.allowFutureDate = options.allowFutureDate;
4150
+ }
4151
+ setMax(field) {
4152
+ if (field.controlType !== 'date') {
4153
+ return field.max;
4154
+ }
4155
+ if (field.allowFutureDate) {
4156
+ return undefined;
4157
+ }
4158
+ return format(new Date(), 'yyyy-MM-dd');
4106
4159
  }
4107
4160
  }
4108
4161
 
@@ -4583,8 +4636,9 @@ class FormFieldGroup {
4583
4636
  }
4584
4637
 
4585
4638
  class MetadataRuleAction {
4586
- constructor(ruleAction) {
4639
+ constructor(ruleAction, ruleVariables) {
4587
4640
  this.ruleAction = ruleAction;
4641
+ this.ruleVariables = ruleVariables;
4588
4642
  }
4589
4643
  get field() {
4590
4644
  return (this.ruleAction.dataElement?.id ||
@@ -4593,10 +4647,36 @@ class MetadataRuleAction {
4593
4647
  get actionType() {
4594
4648
  return this.ruleAction.programRuleActionType;
4595
4649
  }
4650
+ get assignedData() {
4651
+ const regex = /(A|#|V)\{([^}]+)\}/g;
4652
+ return this.ruleAction?.data?.replace(regex, (match, _, dataVariable) => {
4653
+ const ruleVariableObject = this.ruleVariables?.find((variable) => variable.name === dataVariable);
4654
+ if (!ruleVariableObject) {
4655
+ return `{${dataVariable}}`;
4656
+ }
4657
+ const code = camelCase(ruleVariableObject?.dataElement?.code) ||
4658
+ ruleVariableObject?.dataElement?.id ||
4659
+ camelCase(ruleVariableObject?.trackedEntityAttribute?.code) ||
4660
+ ruleVariableObject?.trackedEntityAttribute?.id;
4661
+ return `{${code}}`;
4662
+ });
4663
+ }
4664
+ get displayedContent() {
4665
+ return this.ruleAction.displayContent;
4666
+ }
4667
+ get options() {
4668
+ if (this.ruleAction.option) {
4669
+ return [this.ruleAction.option];
4670
+ }
4671
+ return this.ruleAction.optionGroup?.options || [];
4672
+ }
4596
4673
  toJson() {
4597
4674
  return {
4598
4675
  field: this.field,
4599
4676
  actionType: this.actionType,
4677
+ assignedData: this.assignedData,
4678
+ displayedContent: this.ruleAction.displayContent,
4679
+ options: this.options,
4600
4680
  };
4601
4681
  }
4602
4682
  }
@@ -4606,10 +4686,10 @@ class MetadataRule {
4606
4686
  this.ruleVariables = ruleVariables;
4607
4687
  }
4608
4688
  get actions() {
4609
- return (this.rule?.programRuleActions || []).map((action) => new MetadataRuleAction(action));
4689
+ return (this.rule?.programRuleActions || []).map((action) => new MetadataRuleAction(action, this.ruleVariables));
4610
4690
  }
4611
4691
  get condition() {
4612
- const regex = /(A|#)\{([^}]+)\}/g;
4692
+ const regex = /(A|#|V)\{([^}]+)\}/g;
4613
4693
  return this.rule?.condition?.replace(regex, (match, _, ruleVariable) => {
4614
4694
  const ruleVariableObject = this.ruleVariables?.find((variable) => variable.name === ruleVariable);
4615
4695
  const code = camelCase(ruleVariableObject?.dataElement?.code) ||
@@ -4638,6 +4718,7 @@ class FormMetadataSection {
4638
4718
  formName: (programTrackedEntityAttribute['trackedEntityAttribute'] || {})['name'],
4639
4719
  sortOrder: programTrackedEntityAttribute['sortOrder'],
4640
4720
  mandatory: programTrackedEntityAttribute['mandatory'],
4721
+ allowFutureDate: programTrackedEntityAttribute['allowFutureDate'],
4641
4722
  metaType: 'ATTRIBUTE',
4642
4723
  };
4643
4724
  });
@@ -4650,6 +4731,7 @@ class FormMetadataSection {
4650
4731
  ...(stageDataElement['dataElement'] ||
4651
4732
  {}),
4652
4733
  mandatory: stageDataElement['compulsory'],
4734
+ allowFutureDate: stageDataElement['allowFutureDate'],
4653
4735
  stepId: programStage['id'],
4654
4736
  metaType: 'DATA_ELEMENT',
4655
4737
  };
@@ -4824,6 +4906,7 @@ class FormMetaData {
4824
4906
  code: 'enrollmentDate',
4825
4907
  key: 'enrollmentDate',
4826
4908
  required: true,
4909
+ disabled: this.params.disableEnrollmentDate,
4827
4910
  }),
4828
4911
  program.displayIncidentDate
4829
4912
  ? new DateField({
@@ -4908,6 +4991,7 @@ class FormMetaData {
4908
4991
  code: 'enrollmentDate',
4909
4992
  key: 'enrollmentDate',
4910
4993
  required: true,
4994
+ disabled: this.params.disableEnrollmentDate,
4911
4995
  }),
4912
4996
  program.displayIncidentDate
4913
4997
  ? new DateField({
@@ -4997,47 +5081,62 @@ class FormValue {
4997
5081
  // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
4998
5082
  // Use of this source code is governed by a BSD-style
4999
5083
  // license that can be found in the LICENSE file.
5000
- const useFieldValidation = (props) => {
5001
- const { form, touched, field, value } = props;
5002
- const hasError = useMemo(() => {
5003
- return touched && (form.get(field.id) || form.get(field.key))?.invalid;
5004
- }, [value, touched]);
5005
- const validationError = useMemo(() => {
5006
- if (!touched) {
5007
- return undefined;
5008
- }
5009
- const error = (form.get(field.id) || form.get(field.key))?.errors;
5010
- if (!error) {
5084
+ const FileUploadField = (props) => {
5085
+ const { label, id, uploadUrl, performUpload, validationText, required, hasError, onChange, onUploadSuccess, } = props;
5086
+ const d2 = window?.d2Web;
5087
+ const [file, setFile] = useState(null);
5088
+ const [uploading, setUploading] = useState();
5089
+ const valid = useMemo(() => {
5090
+ if (isUndefined(hasError)) {
5011
5091
  return undefined;
5012
5092
  }
5013
- if (error['min']) {
5014
- return `${field.label || 'Value'} should not be less than ${error['min'].min}!`;
5015
- }
5016
- else if (error['max']) {
5017
- return `${field.label || 'Value'} should not be greater than ${error['max'].max}!`;
5018
- }
5019
- else if (error['pattern']) {
5020
- if (field.type === 'email') {
5021
- return `The email address provided is not valid`;
5093
+ return !hasError;
5094
+ }, [hasError]);
5095
+ const uploadFile = async (fileItem) => {
5096
+ if (fileItem) {
5097
+ setUploading(true);
5098
+ const formData = new FormData();
5099
+ formData.append('file', fileItem);
5100
+ try {
5101
+ const fileUploadResponse = await d2.httpInstance.post(uploadUrl, formData);
5102
+ setUploading(false);
5103
+ const fileId = fileUploadResponse?.data?.response?.fileResource
5104
+ ?.id;
5105
+ if (fileId) {
5106
+ onUploadSuccess(fileId);
5107
+ }
5022
5108
  }
5023
- else if (field.type === 'tel') {
5024
- return 'Phone number provided is not valid';
5109
+ catch (error) {
5110
+ setUploading(false);
5111
+ }
5112
+ }
5113
+ };
5114
+ return (React__default.createElement(FileInputField, { accept: "*", buttonLabel: "Upload a file", label: label, name: id, required: required, validationText: validationText, onChange: (event) => {
5115
+ const fileItem = (event?.files || [])[0];
5116
+ setFile(fileItem);
5117
+ if (performUpload) {
5118
+ uploadFile(fileItem);
5025
5119
  }
5026
5120
  else {
5027
- return `${field.label || 'Value'} should have appropriate format`;
5121
+ onChange(file);
5028
5122
  }
5029
- }
5030
- return error['required']
5031
- ? `${field.label || 'Value'} is required`
5032
- : undefined;
5033
- }, [hasError]);
5034
- return { hasError, validationError };
5123
+ // this.ngZone.run(() => {
5124
+ // this.form().get(this.field().id) ||
5125
+ // this.form()
5126
+ // .get(this.field().key)
5127
+ // ?.setValue((event?.files || [])[0]);
5128
+ // this.update.emit({
5129
+ // form: this.form(),
5130
+ // value: (event?.files || [])[0],
5131
+ // });
5132
+ // });
5133
+ // setValue((event?.files || [])[0]);
5134
+ // setTouched(true);
5135
+ } }, file && (React__default.createElement(FileListItem, { cancelText: "Cancel", label: file.name, loading: uploading, onRemove: () => {
5136
+ setFile(null);
5137
+ }, removeText: "Remove" }))));
5035
5138
  };
5036
5139
 
5037
- // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
5038
- // Use of this source code is governed by a BSD-style
5039
- // license that can be found in the LICENSE file.
5040
-
5041
5140
  // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
5042
5141
  // Use of this source code is governed by a BSD-style
5043
5142
  // license that can be found in the LICENSE file.
@@ -5222,65 +5321,6 @@ const OrgUnitFormField = (props) => {
5222
5321
  React__default.createElement(CircularLoader$1, { small: true }))) : (React__default.createElement("div", { className: classes.orgUnitTreeContainer, style: { maxHeight: '200px', overflowY: 'auto' } }, renderOrgUnitTree()))))))));
5223
5322
  };
5224
5323
 
5225
- // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
5226
- // Use of this source code is governed by a BSD-style
5227
- // license that can be found in the LICENSE file.
5228
- const FileUploadField = (props) => {
5229
- const { label, id, uploadUrl, performUpload, validationText, required, hasError, onChange, onUploadSuccess, } = props;
5230
- const d2 = window?.d2Web;
5231
- const [file, setFile] = useState(null);
5232
- const [uploading, setUploading] = useState();
5233
- const valid = useMemo(() => {
5234
- if (isUndefined(hasError)) {
5235
- return undefined;
5236
- }
5237
- return !hasError;
5238
- }, [hasError]);
5239
- const uploadFile = async (fileItem) => {
5240
- if (fileItem) {
5241
- setUploading(true);
5242
- const formData = new FormData();
5243
- formData.append('file', fileItem);
5244
- try {
5245
- const fileUploadResponse = await d2.httpInstance.post(uploadUrl, formData);
5246
- setUploading(false);
5247
- const fileId = fileUploadResponse?.data?.response?.fileResource
5248
- ?.id;
5249
- if (fileId) {
5250
- onUploadSuccess(fileId);
5251
- }
5252
- }
5253
- catch (error) {
5254
- setUploading(false);
5255
- }
5256
- }
5257
- };
5258
- return (React__default.createElement(FileInputField, { accept: "*", buttonLabel: "Upload a file", label: label, name: id, required: required, validationText: validationText, onChange: (event) => {
5259
- const fileItem = (event?.files || [])[0];
5260
- setFile(fileItem);
5261
- if (performUpload) {
5262
- uploadFile(fileItem);
5263
- }
5264
- else {
5265
- onChange(file);
5266
- }
5267
- // this.ngZone.run(() => {
5268
- // this.form().get(this.field().id) ||
5269
- // this.form()
5270
- // .get(this.field().key)
5271
- // ?.setValue((event?.files || [])[0]);
5272
- // this.update.emit({
5273
- // form: this.form(),
5274
- // value: (event?.files || [])[0],
5275
- // });
5276
- // });
5277
- // setValue((event?.files || [])[0]);
5278
- // setTouched(true);
5279
- } }, file && (React__default.createElement(FileListItem, { cancelText: "Cancel", label: file.name, loading: uploading, onRemove: () => {
5280
- setFile(null);
5281
- }, removeText: "Remove" }))));
5282
- };
5283
-
5284
5324
  // Copyright 2024 UDSM DHIS2 Lab. All rights reserved.
5285
5325
  // Use of this source code is governed by a BSD-style
5286
5326
  // license that can be found in the LICENSE file.
@@ -5294,43 +5334,10 @@ class BaseFormFieldComponent extends ReactWrapperModule {
5294
5334
  this.fieldConfig = input(new FieldConfig());
5295
5335
  this.form = model.required();
5296
5336
  this.isValid = input();
5297
- this.uploadedFiles = [];
5337
+ this.isValueAssigned = input();
5298
5338
  this.value = model();
5299
5339
  this.value$ = toObservable(this.value);
5300
- this.FieldOrgUnitSelector = (props) => {
5301
- const { onSelectOrgUnit, selectedOrgUnits } = props;
5302
- const [selected, setSelected] = useState(selectedOrgUnits);
5303
- const [rootOrgUnits, setRootOrgUnits] = useState();
5304
- const [config, setConfig] = useState();
5305
- useEffect(() => {
5306
- zip(this.getAppConfig(), this.getRootOrgUnits()).subscribe({
5307
- next: ([appConfig, rootOrgUnits]) => {
5308
- setConfig(appConfig);
5309
- setRootOrgUnits(rootOrgUnits);
5310
- },
5311
- error: (error) => console.error(error),
5312
- });
5313
- }, []);
5314
- return config ? (React__default.createElement(Provider, { config: config, plugin: false, parentAlertsAdd: undefined, showAlertsInPlugin: false }, React__default.createElement(Modal$1, { position: "middle", large: true },
5315
- React__default.createElement(ModalTitle$1, null,
5316
- "Select ",
5317
- this.field().label),
5318
- React__default.createElement(ModalContent$1, null,
5319
- React__default.createElement(OrgUnitDimension, { selected: selected, allowSingleSelection: true, hideGroupSelect: this.orgUnitSelectionConfig.hideGroupSelect, hideLevelSelect: this.orgUnitSelectionConfig.hideLevelSelect, hideUserOrgUnits: this.orgUnitSelectionConfig.hideUserOrgUnits, onSelect: (selectionEvent) => {
5320
- setSelected(selectionEvent.items);
5321
- onSelectOrgUnit(selectionEvent.items);
5322
- }, orgUnitGroupPromise: this.getOrgUnitGroups(), orgUnitLevelPromise: this.getOrgUnitLevels(), roots: rootOrgUnits }))))) : (React__default.createElement(CircularLoader$1, { small: true }));
5323
- };
5324
- this.showOrgUnitTree = signal(false);
5325
- this.orgUnitSelectionConfig = {
5326
- hideGroupSelect: true,
5327
- hideLevelSelect: true,
5328
- hideUserOrgUnits: true,
5329
- allowSingleSelection: true,
5330
- usageType: 'DATA_ENTRY',
5331
- };
5332
- this.selectedOrgUnit = signal(null);
5333
- this.selectedOrgUnit$ = toObservable(this.selectedOrgUnit);
5340
+ this.isValueAssigned$ = toObservable(this.isValueAssigned);
5334
5341
  this.label = computed(() => {
5335
5342
  return !this.fieldConfig()?.hideLabel ? this.field().label : undefined;
5336
5343
  });
@@ -5359,10 +5366,16 @@ class BaseFormFieldComponent extends ReactWrapperModule {
5359
5366
  return () => {
5360
5367
  const [value, setValue] = useState(this.form().get(this.field().id)?.value ||
5361
5368
  this.form().get(this.field().key)?.value);
5362
- const [displayValue, setDisplayValue] = useState(null);
5363
5369
  const [selected, setSelected] = useState();
5364
5370
  const [touched, setTouched] = useState(false);
5365
- const [showOrgUnit, setShowOrgUnit] = useState(false);
5371
+ const [disabled, setDisabled] = useState(this.field()?.disabled ?? this.field()?.generated ?? false);
5372
+ useEffect(() => {
5373
+ if (this.isValueAssigned()) {
5374
+ setDisabled(true);
5375
+ setValue(this.form().get(this.field().id)?.value ||
5376
+ this.form().get(this.field().key)?.value);
5377
+ }
5378
+ }, [this.isValueAssigned()]);
5366
5379
  const onChange = (payload) => setSelected(payload.selected);
5367
5380
  const arrayValue = useMemo(() => {
5368
5381
  if (value && value.length > 0) {
@@ -5425,10 +5438,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
5425
5438
  this.update.emit({ form: this.form(), value });
5426
5439
  } }));
5427
5440
  case 'checkbox':
5428
- return (React__default.createElement(Checkbox, { checked: Boolean(value), error: hasError, label: this.label(), name: this.field().id, disabled: this.field()?.disabled ||
5429
- this.field()?.generated ||
5430
- this.field()?.unique ||
5431
- false, onChange: (event) => {
5441
+ return (React__default.createElement(Checkbox, { checked: Boolean(value), error: hasError, label: this.label(), name: this.field().id, disabled: disabled, onChange: (event) => {
5432
5442
  this.ngZone.run(() => {
5433
5443
  (this.form().get(this.field().id) ||
5434
5444
  this.form().get(this.field().key))?.setValue(event.checked);
@@ -5441,10 +5451,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
5441
5451
  });
5442
5452
  } }));
5443
5453
  case 'dropdown':
5444
- return (React__default.createElement(SingleSelectField, { filterable: (this.field().options || []).length > 5, clearable: true, error: hasError, validationText: validationError, inputWidth: this.fieldConfig()?.inputWidth, disabled: this.field()?.disabled ||
5445
- this.field()?.generated ||
5446
- this.field()?.unique ||
5447
- false, required: this.field().required, className: "select", label: this.label(), selected: value, onChange: (event) => {
5454
+ return (React__default.createElement(SingleSelectField, { filterable: (this.field().options || []).length > 5, clearable: true, error: hasError, validationText: validationError, inputWidth: this.fieldConfig()?.inputWidth, disabled: disabled, required: this.field().required, className: "select", label: this.label(), selected: value, onChange: (event) => {
5448
5455
  this.ngZone.run(() => {
5449
5456
  (this.form().get(this.field().id) ||
5450
5457
  this.form().get(this.field().key))?.setValue(event.selected);
@@ -5457,10 +5464,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
5457
5464
  setTouched(true);
5458
5465
  } }, (this.field().options || []).map((option) => (React__default.createElement(SingleSelectOption, { key: crypto.randomUUID() || option.key, label: option.label, value: option.value })))));
5459
5466
  case 'multi-dropdown':
5460
- return (React__default.createElement(MultiSelectField, { clearText: "Clear", clearable: true, empty: "No data found", filterable: (this.field().options || []).length > 5, filterPlaceholder: "Type to filter options", error: hasError, validationText: validationError, inputWidth: this.fieldConfig()?.inputWidth, disabled: this.field()?.disabled ||
5461
- this.field()?.generated ||
5462
- this.field()?.unique ||
5463
- false, label: this.label(), required: this.field().required, loadingText: "Loading options", noMatchText: "No options found", onChange: (event) => {
5467
+ return (React__default.createElement(MultiSelectField, { clearText: "Clear", clearable: true, empty: "No data found", filterable: (this.field().options || []).length > 5, filterPlaceholder: "Type to filter options", error: hasError, validationText: validationError, inputWidth: this.fieldConfig()?.inputWidth, disabled: disabled, label: this.label(), required: this.field().required, loadingText: "Loading options", noMatchText: "No options found", onChange: (event) => {
5464
5468
  const selectedValue = (event.selected || []).join(',');
5465
5469
  this.ngZone.run(() => {
5466
5470
  (this.form().get(this.field().id) ||
@@ -5488,13 +5492,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
5488
5492
  setTouched(true);
5489
5493
  } })));
5490
5494
  default:
5491
- return (React__default.createElement(InputField$1, { error: hasError, validationText: validationError, type: this.field().type, inputWidth: this.fieldConfig()?.inputWidth, required: this.field().required, name: this.field().id, label: this.label(), min: this.field().min?.toString(), max: this.field().max?.toString(), placeholder: this.placeholder(), value: value, disabled: this.field()?.disabled ||
5492
- this.field()?.generated ||
5493
- this.field()?.unique ||
5494
- false, readOnly: this.field()?.disabled ||
5495
- this.field()?.generated ||
5496
- this.field()?.unique ||
5497
- false, onChange: (event) => {
5495
+ return (React__default.createElement(InputField$1, { error: hasError, validationText: validationError, type: this.field().type, inputWidth: this.fieldConfig()?.inputWidth, required: this.field().required, name: this.field().id, label: this.label(), min: this.field().min?.toString(), max: this.field().max?.toString(), placeholder: this.placeholder(), value: value, readOnly: disabled, onChange: (event) => {
5498
5496
  this.ngZone.run(() => {
5499
5497
  (this.form().get(this.field().id) ||
5500
5498
  this.form().get(this.field().key))?.setValue(event.value);
@@ -5516,54 +5514,8 @@ class BaseFormFieldComponent extends ReactWrapperModule {
5516
5514
  onChange(event) {
5517
5515
  this.value.set(event);
5518
5516
  }
5519
- onSelectOrgUnit(selectedOrgUnits) {
5520
- this.showOrgUnitTree.set(false);
5521
- if ((selectedOrgUnits || [])[0]) {
5522
- this.selectedOrgUnit.set(selectedOrgUnits[0]);
5523
- }
5524
- }
5525
- onCancelOrgUnit() {
5526
- this.showOrgUnitTree.set(false);
5527
- }
5528
- getAppConfig() {
5529
- return this.httpClient.systemInfo().pipe(map((response) => {
5530
- const systemInfo = response;
5531
- return {
5532
- baseUrl: (document?.location?.host?.includes('localhost')
5533
- ? `${document.location.protocol}//${document.location.host}`
5534
- : systemInfo['contextPath']),
5535
- apiVersion: Number(((systemInfo['version'] || '')?.split('.') || [])[1]),
5536
- };
5537
- }));
5538
- }
5539
- getOrgUnitAttributeByUsage(usageType) {
5540
- switch (usageType) {
5541
- case 'DATA_ENTRY':
5542
- return 'organisationUnits';
5543
- case 'DATA_VIEW':
5544
- return 'dataViewOrganisationUnits';
5545
- default:
5546
- return 'organisationUnits';
5547
- }
5548
- }
5549
- getRootOrgUnits() {
5550
- const orgUnitAttribute = this.getOrgUnitAttributeByUsage(this.orgUnitSelectionConfig.usageType);
5551
- return this.httpClient
5552
- .me()
5553
- .pipe(map((user) => (user ? user[orgUnitAttribute] : []).map((orgUnit) => orgUnit.id)));
5554
- }
5555
- getOrgUnitGroups() {
5556
- return firstValueFrom(this.httpClient
5557
- .get('organisationUnitGroups.json?fields=id,displayName,name&paging=false')
5558
- .pipe(map((res) => res?.['organisationUnitGroups'])));
5559
- }
5560
- getOrgUnitLevels() {
5561
- return firstValueFrom(this.httpClient
5562
- .get('organisationUnitLevels.json?fields=id,level,displayName,name&paging=false')
5563
- .pipe(map((res) => res?.['organisationUnitLevels'])));
5564
- }
5565
5517
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: BaseFormFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
5566
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.8", type: BaseFormFieldComponent, isStandalone: true, inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, fieldConfig: { classPropertyName: "fieldConfig", publicName: "fieldConfig", isSignal: true, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: true, transformFunction: null }, isValid: { classPropertyName: "isValid", publicName: "isValid", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { form: "formChange", value: "valueChange", update: "update", immediateUpdate: "immediateUpdate" }, usesInheritance: true, usesOnChanges: true, ngImport: i0 }); }
5518
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.8", type: BaseFormFieldComponent, isStandalone: true, inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, fieldConfig: { classPropertyName: "fieldConfig", publicName: "fieldConfig", isSignal: true, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: true, transformFunction: null }, isValid: { classPropertyName: "isValid", publicName: "isValid", isSignal: true, isRequired: false, transformFunction: null }, isValueAssigned: { classPropertyName: "isValueAssigned", publicName: "isValueAssigned", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { form: "formChange", value: "valueChange", update: "update", immediateUpdate: "immediateUpdate" }, usesInheritance: true, usesOnChanges: true, ngImport: i0 }); }
5567
5519
  }
5568
5520
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: BaseFormFieldComponent, decorators: [{
5569
5521
  type: Directive
@@ -5589,6 +5541,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
5589
5541
  class FormFieldComponent {
5590
5542
  constructor() {
5591
5543
  this.field = input.required();
5544
+ this.programRuleActions = input([]);
5592
5545
  this.maxDate = new Date();
5593
5546
  this.color = 'primary';
5594
5547
  this.fieldUpdate = new EventEmitter();
@@ -5599,6 +5552,10 @@ class FormFieldComponent {
5599
5552
  this.runtimeOptions = [];
5600
5553
  this.fieldFilterControl = new FormControl();
5601
5554
  this._onDestroy = new Subject();
5555
+ this.isValueAssigned = signal(false);
5556
+ this.ruleProcessor = effect(() => {
5557
+ this.#processRules(this.programRuleActions());
5558
+ });
5602
5559
  }
5603
5560
  ngOnChanges(changes) {
5604
5561
  if (changes && changes['dataEntities'] && this.field()?.dependentField) {
@@ -5623,9 +5580,33 @@ class FormFieldComponent {
5623
5580
  this.optionSearchTerm = this.fieldFilterControl.value;
5624
5581
  });
5625
5582
  }
5583
+ #processRules(ruleActions) {
5584
+ ruleActions
5585
+ .filter((ruleAction) => ruleAction.field === this.field().id)
5586
+ .forEach((ruleAction) => {
5587
+ switch (ruleAction.actionType) {
5588
+ case 'ASSIGN': {
5589
+ if (ruleAction.assignedData) {
5590
+ const currentValue = this.form?.get(this.field().key)?.value;
5591
+ if (currentValue != ruleAction.assignedData) {
5592
+ this.form
5593
+ ?.get(this.field().key)
5594
+ ?.setValue(ruleAction.assignedData);
5595
+ this.isValueAssigned.set(true);
5596
+ this.onValueChange();
5597
+ }
5598
+ }
5599
+ break;
5600
+ }
5601
+ default:
5602
+ break;
5603
+ }
5604
+ });
5605
+ }
5626
5606
  ngOnDestroy() {
5627
5607
  this._onDestroy.next();
5628
5608
  this._onDestroy.complete();
5609
+ this.ruleProcessor.destroy();
5629
5610
  }
5630
5611
  get isValid() {
5631
5612
  return this.form?.controls[this.field().id]?.valid;
@@ -5728,12 +5709,12 @@ class FormFieldComponent {
5728
5709
  this._runtimeOptions = [...options];
5729
5710
  }
5730
5711
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: FormFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
5731
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.8", type: FormFieldComponent, isStandalone: false, selector: "ng-dhis2-ui-form-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, fieldConfig: { classPropertyName: "fieldConfig", publicName: "fieldConfig", isSignal: false, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: false, isRequired: false, transformFunction: null }, isCheckBoxButton: { classPropertyName: "isCheckBoxButton", publicName: "isCheckBoxButton", isSignal: false, isRequired: false, transformFunction: null }, fieldClass: { classPropertyName: "fieldClass", publicName: "fieldClass", isSignal: false, isRequired: false, transformFunction: null }, programRuleActions: { classPropertyName: "programRuleActions", publicName: "programRuleActions", isSignal: false, isRequired: false, transformFunction: null }, dataEntities: { classPropertyName: "dataEntities", publicName: "dataEntities", isSignal: false, isRequired: false, transformFunction: null }, minDate: { classPropertyName: "minDate", publicName: "minDate", isSignal: false, isRequired: false, transformFunction: null }, maxDate: { classPropertyName: "maxDate", publicName: "maxDate", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { fieldUpdate: "fieldUpdate", immediateFieldUpdate: "immediateFieldUpdate", runtimeOptionChange: "runtimeOptionChange" }, usesOnChanges: true, ngImport: i0, template: "<div *ngIf=\"field()\" class=\"form-field-item\">\n <ng-dhis2-ui-form-field-item\n [field]=\"field()\"\n [fieldConfig]=\"fieldConfig\"\n [(form)]=\"form\"\n [value]=\"value()\"\n (update)=\"onValueChange()\"\n (immediateUpdate)=\"onImmediateChange($event)\"\n />\n</div>\n", styles: [".form-field-item{margin-bottom:16px}\n"], dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FormFieldItemComponent, selector: "ng-dhis2-ui-form-field-item" }] }); }
5712
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.8", type: FormFieldComponent, isStandalone: false, selector: "ng-dhis2-ui-form-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, fieldConfig: { classPropertyName: "fieldConfig", publicName: "fieldConfig", isSignal: false, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: false, isRequired: false, transformFunction: null }, isCheckBoxButton: { classPropertyName: "isCheckBoxButton", publicName: "isCheckBoxButton", isSignal: false, isRequired: false, transformFunction: null }, fieldClass: { classPropertyName: "fieldClass", publicName: "fieldClass", isSignal: false, isRequired: false, transformFunction: null }, programRuleActions: { classPropertyName: "programRuleActions", publicName: "programRuleActions", isSignal: true, isRequired: false, transformFunction: null }, dataEntities: { classPropertyName: "dataEntities", publicName: "dataEntities", isSignal: false, isRequired: false, transformFunction: null }, minDate: { classPropertyName: "minDate", publicName: "minDate", isSignal: false, isRequired: false, transformFunction: null }, maxDate: { classPropertyName: "maxDate", publicName: "maxDate", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { fieldUpdate: "fieldUpdate", immediateFieldUpdate: "immediateFieldUpdate", runtimeOptionChange: "runtimeOptionChange" }, usesOnChanges: true, ngImport: i0, template: "<div *ngIf=\"field()\" class=\"form-field-item\">\n <ng-dhis2-ui-form-field-item\n [field]=\"field()\"\n [isValueAssigned]=\"isValueAssigned()\"\n [fieldConfig]=\"fieldConfig\"\n [(form)]=\"form\"\n [value]=\"value()\"\n (update)=\"onValueChange()\"\n (immediateUpdate)=\"onImmediateChange($event)\"\n />\n</div>\n", styles: [".form-field-item{margin-bottom:16px}\n"], dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FormFieldItemComponent, selector: "ng-dhis2-ui-form-field-item" }] }); }
5732
5713
  }
5733
5714
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: FormFieldComponent, decorators: [{
5734
5715
  type: Component,
5735
- args: [{ selector: 'ng-dhis2-ui-form-field', standalone: false, template: "<div *ngIf=\"field()\" class=\"form-field-item\">\n <ng-dhis2-ui-form-field-item\n [field]=\"field()\"\n [fieldConfig]=\"fieldConfig\"\n [(form)]=\"form\"\n [value]=\"value()\"\n (update)=\"onValueChange()\"\n (immediateUpdate)=\"onImmediateChange($event)\"\n />\n</div>\n", styles: [".form-field-item{margin-bottom:16px}\n"] }]
5736
- }], propDecorators: { fieldConfig: [{
5716
+ args: [{ selector: 'ng-dhis2-ui-form-field', standalone: false, template: "<div *ngIf=\"field()\" class=\"form-field-item\">\n <ng-dhis2-ui-form-field-item\n [field]=\"field()\"\n [isValueAssigned]=\"isValueAssigned()\"\n [fieldConfig]=\"fieldConfig\"\n [(form)]=\"form\"\n [value]=\"value()\"\n (update)=\"onValueChange()\"\n (immediateUpdate)=\"onImmediateChange($event)\"\n />\n</div>\n", styles: [".form-field-item{margin-bottom:16px}\n"] }]
5717
+ }], ctorParameters: () => [], propDecorators: { fieldConfig: [{
5737
5718
  type: Input
5738
5719
  }], form: [{
5739
5720
  type: Input
@@ -5741,8 +5722,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
5741
5722
  type: Input
5742
5723
  }], fieldClass: [{
5743
5724
  type: Input
5744
- }], programRuleActions: [{
5745
- type: Input
5746
5725
  }], dataEntities: [{
5747
5726
  type: Input
5748
5727
  }], minDate: [{
@@ -5758,18 +5737,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
5758
5737
  }] } });
5759
5738
 
5760
5739
  class FormComponent {
5761
- constructor() {
5762
- this.formConfig = input();
5763
- this.configuration = computed(() => {
5764
- if (!this.formConfig()) {
5765
- return new FormConfig({
5766
- direction: this.isFormHorizontal ? 'horizontal' : 'vertical',
5767
- });
5768
- }
5769
- return this.formConfig();
5770
- });
5771
- this.formUpdate = new EventEmitter();
5772
- }
5773
5740
  get sanitizedFields() {
5774
5741
  return (this.fields || []).filter((field) => {
5775
5742
  if (field.hidden) {
@@ -5782,17 +5749,14 @@ class FormComponent {
5782
5749
  if (!elementItem) {
5783
5750
  return true;
5784
5751
  }
5785
- const availableRule = head((this.programRuleActions || []).filter((ruleAction) => {
5786
- const fieldId = ruleAction.field || ruleAction[type]?.id;
5787
- return (fieldId === elementItem.id &&
5788
- (ruleAction.programRuleActionType === 'HIDEFIELD' ||
5789
- ruleAction.actionType === 'HIDEFIELD'));
5752
+ const availableRule = head((this.programRuleActions() || []).filter((ruleAction) => {
5753
+ return (ruleAction.field === elementItem.id &&
5754
+ ruleAction.actionType === 'HIDEFIELD');
5790
5755
  }));
5791
5756
  if (!availableRule) {
5792
5757
  return true;
5793
5758
  }
5794
- const actionType = availableRule?.programRuleActionType || availableRule?.actionType;
5795
- return actionType !== 'HIDEFIELD';
5759
+ return availableRule.actionType !== 'HIDEFIELD';
5796
5760
  });
5797
5761
  }
5798
5762
  get layoutCssClass() {
@@ -5808,29 +5772,44 @@ class FormComponent {
5808
5772
  }
5809
5773
  return 'col-sm-4';
5810
5774
  }
5811
- onUpdateFields(programRuleActions) {
5812
- this.fields = (this.fields || []).filter((field) => {
5813
- const type = field.isDataElement
5814
- ? 'dataElement'
5815
- : 'trackedEntityAttribute';
5816
- const elementItem = field[type] || field;
5817
- if (!elementItem) {
5818
- return true;
5819
- }
5820
- const availableRule = head((programRuleActions || []).filter((rule) => {
5821
- return (rule[type] &&
5822
- rule[type].id === elementItem.id &&
5823
- rule.programRuleActionType === 'HIDEFIELD');
5824
- }));
5825
- if (!availableRule) {
5826
- return true;
5775
+ constructor() {
5776
+ this.formConfig = input();
5777
+ this.programRuleActions = input([]);
5778
+ this.configuration = computed(() => {
5779
+ if (!this.formConfig()) {
5780
+ return new FormConfig({
5781
+ direction: this.isFormHorizontal ? 'horizontal' : 'vertical',
5782
+ });
5827
5783
  }
5828
- return (availableRule && availableRule.programRuleActionType !== 'HIDEFIELD');
5784
+ return this.formConfig();
5785
+ });
5786
+ this.formUpdate = new EventEmitter();
5787
+ this.ruleProcessor = effect(() => {
5788
+ this.#processRules(this.programRuleActions());
5829
5789
  });
5830
5790
  }
5831
- ngOnChanges() {
5791
+ ngOnChanges(changes) {
5832
5792
  this.values = this.form.getRawValue();
5833
5793
  }
5794
+ #processRules(ruleActions) {
5795
+ ruleActions.forEach((ruleAction) => {
5796
+ switch (ruleAction.actionType) {
5797
+ case 'HIDEFIELD': {
5798
+ const fieldToRemove = this.fields.find((field) => field.id === ruleAction.field);
5799
+ if (fieldToRemove) {
5800
+ const currentValue = this.form.get(fieldToRemove.key)?.value;
5801
+ if (currentValue != null) {
5802
+ this.form.get(fieldToRemove.key)?.setValue(null);
5803
+ this.onFieldUpdate(this.form, fieldToRemove);
5804
+ }
5805
+ }
5806
+ break;
5807
+ }
5808
+ default:
5809
+ break;
5810
+ }
5811
+ });
5812
+ }
5834
5813
  onSubmit() {
5835
5814
  this.formUpdate.emit(this.form.getRawValue());
5836
5815
  }
@@ -5853,13 +5832,16 @@ class FormComponent {
5853
5832
  fieldToUpdate?.onUpdateRuntimeOptions(parentOption?.options || []);
5854
5833
  }
5855
5834
  }
5835
+ ngOnDestroy() {
5836
+ this.ruleProcessor.destroy();
5837
+ }
5856
5838
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: FormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
5857
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.8", type: FormComponent, isStandalone: false, selector: "ng-dhis2-ui-form", inputs: { formConfig: { classPropertyName: "formConfig", publicName: "formConfig", isSignal: true, isRequired: false, transformFunction: null }, fields: { classPropertyName: "fields", publicName: "fields", isSignal: false, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: false, isRequired: false, transformFunction: null }, isFormHorizontal: { classPropertyName: "isFormHorizontal", publicName: "isFormHorizontal", isSignal: false, isRequired: false, transformFunction: null }, showSaveButton: { classPropertyName: "showSaveButton", publicName: "showSaveButton", isSignal: false, isRequired: false, transformFunction: null }, fieldsData: { classPropertyName: "fieldsData", publicName: "fieldsData", isSignal: false, isRequired: false, transformFunction: null }, fieldClass: { classPropertyName: "fieldClass", publicName: "fieldClass", isSignal: false, isRequired: false, transformFunction: null }, shouldRenderAsCheckBoxesButton: { classPropertyName: "shouldRenderAsCheckBoxesButton", publicName: "shouldRenderAsCheckBoxesButton", isSignal: false, isRequired: false, transformFunction: null }, programRuleActions: { classPropertyName: "programRuleActions", publicName: "programRuleActions", isSignal: false, isRequired: false, transformFunction: null }, dataEntities: { classPropertyName: "dataEntities", publicName: "dataEntities", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { formUpdate: "formUpdate" }, viewQueries: [{ propertyName: "fieldComponents", predicate: FormFieldComponent, descendants: true }], usesOnChanges: true, ngImport: i0, template: "<form [formGroup]=\"form\" class=\"{{ configuration().directionClassName }}\">\n <!-- form name -->\n <div class=\"form-name\">\n <h2>{{ configuration().formName }}</h2>\n </div>\n <div\n *ngFor=\"let field of sanitizedFields\"\n class=\"form-field-{{ configuration().direction }}\"\n >\n <ng-dhis2-ui-form-field\n [field]=\"field\"\n [fieldConfig]=\"configuration().fieldConfig\"\n [form]=\"form\"\n [fieldClass]=\"fieldClass\"\n [dataEntities]=\"dataEntities\"\n [programRuleActions]=\"programRuleActions\"\n [isCheckBoxButton]=\"shouldRenderAsCheckBoxesButton\"\n (fieldUpdate)=\"onFieldUpdate($event, field)\"\n (runtimeOptionChange)=\"onRunTimeOptionUpdate($event)\"\n />\n </div>\n</form>\n", styles: [".form-horizontal{display:flex;flex-wrap:wrap;gap:16px;width:100%}.hidden-field{display:none}.units-and-ranges span{margin-left:1%;font-weight:600}.for-warning{margin-left:8px}.form-field-vertical{margin-bottom:8px}.form-field-horizontal{flex:1;margin-bottom:8px;width:100%}\n"], dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: FormFieldComponent, selector: "ng-dhis2-ui-form-field", inputs: ["field", "fieldConfig", "form", "isCheckBoxButton", "fieldClass", "programRuleActions", "dataEntities", "minDate", "maxDate"], outputs: ["fieldUpdate", "immediateFieldUpdate", "runtimeOptionChange"] }] }); }
5839
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.8", type: FormComponent, isStandalone: false, selector: "ng-dhis2-ui-form", inputs: { formConfig: { classPropertyName: "formConfig", publicName: "formConfig", isSignal: true, isRequired: false, transformFunction: null }, fields: { classPropertyName: "fields", publicName: "fields", isSignal: false, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: false, isRequired: false, transformFunction: null }, isFormHorizontal: { classPropertyName: "isFormHorizontal", publicName: "isFormHorizontal", isSignal: false, isRequired: false, transformFunction: null }, showSaveButton: { classPropertyName: "showSaveButton", publicName: "showSaveButton", isSignal: false, isRequired: false, transformFunction: null }, fieldsData: { classPropertyName: "fieldsData", publicName: "fieldsData", isSignal: false, isRequired: false, transformFunction: null }, fieldClass: { classPropertyName: "fieldClass", publicName: "fieldClass", isSignal: false, isRequired: false, transformFunction: null }, shouldRenderAsCheckBoxesButton: { classPropertyName: "shouldRenderAsCheckBoxesButton", publicName: "shouldRenderAsCheckBoxesButton", isSignal: false, isRequired: false, transformFunction: null }, programRuleActions: { classPropertyName: "programRuleActions", publicName: "programRuleActions", isSignal: true, isRequired: false, transformFunction: null }, dataEntities: { classPropertyName: "dataEntities", publicName: "dataEntities", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { formUpdate: "formUpdate" }, viewQueries: [{ propertyName: "fieldComponents", predicate: FormFieldComponent, descendants: true }], usesOnChanges: true, ngImport: i0, template: "<form [formGroup]=\"form\" class=\"{{ configuration().directionClassName }}\">\n <!-- form name -->\n <div class=\"form-name\">\n <h2>{{ configuration().formName }}</h2>\n </div>\n <div\n *ngFor=\"let field of sanitizedFields\"\n class=\"form-field-{{ configuration().direction }}\"\n >\n <ng-dhis2-ui-form-field\n [field]=\"field\"\n [fieldConfig]=\"configuration().fieldConfig\"\n [form]=\"form\"\n [fieldClass]=\"fieldClass\"\n [dataEntities]=\"dataEntities\"\n [programRuleActions]=\"programRuleActions()\"\n [isCheckBoxButton]=\"shouldRenderAsCheckBoxesButton\"\n (fieldUpdate)=\"onFieldUpdate($event, field)\"\n (runtimeOptionChange)=\"onRunTimeOptionUpdate($event)\"\n />\n </div>\n</form>\n", styles: [".form-horizontal{display:flex;flex-wrap:wrap;gap:16px;width:100%}.hidden-field{display:none}.units-and-ranges span{margin-left:1%;font-weight:600}.for-warning{margin-left:8px}.form-field-vertical{margin-bottom:8px}.form-field-horizontal{flex:1;margin-bottom:8px;width:100%}\n"], dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: FormFieldComponent, selector: "ng-dhis2-ui-form-field", inputs: ["field", "fieldConfig", "form", "isCheckBoxButton", "fieldClass", "programRuleActions", "dataEntities", "minDate", "maxDate"], outputs: ["fieldUpdate", "immediateFieldUpdate", "runtimeOptionChange"] }] }); }
5858
5840
  }
5859
5841
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: FormComponent, decorators: [{
5860
5842
  type: Component,
5861
- args: [{ selector: 'ng-dhis2-ui-form', standalone: false, template: "<form [formGroup]=\"form\" class=\"{{ configuration().directionClassName }}\">\n <!-- form name -->\n <div class=\"form-name\">\n <h2>{{ configuration().formName }}</h2>\n </div>\n <div\n *ngFor=\"let field of sanitizedFields\"\n class=\"form-field-{{ configuration().direction }}\"\n >\n <ng-dhis2-ui-form-field\n [field]=\"field\"\n [fieldConfig]=\"configuration().fieldConfig\"\n [form]=\"form\"\n [fieldClass]=\"fieldClass\"\n [dataEntities]=\"dataEntities\"\n [programRuleActions]=\"programRuleActions\"\n [isCheckBoxButton]=\"shouldRenderAsCheckBoxesButton\"\n (fieldUpdate)=\"onFieldUpdate($event, field)\"\n (runtimeOptionChange)=\"onRunTimeOptionUpdate($event)\"\n />\n </div>\n</form>\n", styles: [".form-horizontal{display:flex;flex-wrap:wrap;gap:16px;width:100%}.hidden-field{display:none}.units-and-ranges span{margin-left:1%;font-weight:600}.for-warning{margin-left:8px}.form-field-vertical{margin-bottom:8px}.form-field-horizontal{flex:1;margin-bottom:8px;width:100%}\n"] }]
5862
- }], propDecorators: { fields: [{
5843
+ args: [{ selector: 'ng-dhis2-ui-form', standalone: false, template: "<form [formGroup]=\"form\" class=\"{{ configuration().directionClassName }}\">\n <!-- form name -->\n <div class=\"form-name\">\n <h2>{{ configuration().formName }}</h2>\n </div>\n <div\n *ngFor=\"let field of sanitizedFields\"\n class=\"form-field-{{ configuration().direction }}\"\n >\n <ng-dhis2-ui-form-field\n [field]=\"field\"\n [fieldConfig]=\"configuration().fieldConfig\"\n [form]=\"form\"\n [fieldClass]=\"fieldClass\"\n [dataEntities]=\"dataEntities\"\n [programRuleActions]=\"programRuleActions()\"\n [isCheckBoxButton]=\"shouldRenderAsCheckBoxesButton\"\n (fieldUpdate)=\"onFieldUpdate($event, field)\"\n (runtimeOptionChange)=\"onRunTimeOptionUpdate($event)\"\n />\n </div>\n</form>\n", styles: [".form-horizontal{display:flex;flex-wrap:wrap;gap:16px;width:100%}.hidden-field{display:none}.units-and-ranges span{margin-left:1%;font-weight:600}.for-warning{margin-left:8px}.form-field-vertical{margin-bottom:8px}.form-field-horizontal{flex:1;margin-bottom:8px;width:100%}\n"] }]
5844
+ }], ctorParameters: () => [], propDecorators: { fields: [{
5863
5845
  type: Input
5864
5846
  }], form: [{
5865
5847
  type: Input
@@ -5873,8 +5855,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
5873
5855
  type: Input
5874
5856
  }], shouldRenderAsCheckBoxesButton: [{
5875
5857
  type: Input
5876
- }], programRuleActions: [{
5877
- type: Input
5878
5858
  }], dataEntities: [{
5879
5859
  type: Input
5880
5860
  }], formUpdate: [{
@@ -5968,7 +5948,7 @@ class SectionFormComponent {
5968
5948
  this.formGroups = {};
5969
5949
  this.formValueEntity = {};
5970
5950
  this.repeatableFormValueEntity = {};
5971
- this.ruleActions = [];
5951
+ this.ruleActions = signal([]);
5972
5952
  this.save = new EventEmitter();
5973
5953
  this.formUpdate = new EventEmitter();
5974
5954
  this.cancel = new EventEmitter();
@@ -5993,10 +5973,10 @@ class SectionFormComponent {
5993
5973
  });
5994
5974
  });
5995
5975
  this.inValid.set(this.checkIfInValid());
5996
- this.ruleActions = new ProgramRuleEngine()
5976
+ this.ruleActions.set(new ProgramRuleEngine()
5997
5977
  .setRules(this.formMetaData().rules)
5998
5978
  .setDataValues(this.#getDataValue())
5999
- .execute();
5979
+ .execute());
6000
5980
  }
6001
5981
  }
6002
5982
  onUpdateRepeatableStage(repeatableData, fieldGroup) {
@@ -6012,10 +5992,10 @@ class SectionFormComponent {
6012
5992
  this.formValueEntity[fieldGroupId] = formValue;
6013
5993
  this.inValid.set(this.checkIfInValid());
6014
5994
  const dataValues = this.#getDataValue();
6015
- this.ruleActions = new ProgramRuleEngine()
5995
+ this.ruleActions.set(new ProgramRuleEngine()
6016
5996
  .setRules(this.formMetaData().rules)
6017
5997
  .setDataValues(dataValues)
6018
- .execute();
5998
+ .execute());
6019
5999
  this.formUpdate.emit(dataValues);
6020
6000
  }
6021
6001
  onSubmit() {
@@ -6058,11 +6038,11 @@ class SectionFormComponent {
6058
6038
  return valueValidity || repeatableDataValidity;
6059
6039
  }
6060
6040
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: SectionFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
6061
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.8", type: SectionFormComponent, isStandalone: false, selector: "ng-dhis2-ui-section-form", inputs: { loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, formMetaData: { classPropertyName: "formMetaData", publicName: "formMetaData", isSignal: true, isRequired: true, transformFunction: null }, dataValueEntities: { classPropertyName: "dataValueEntities", publicName: "dataValueEntities", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { save: "save", formUpdate: "formUpdate", cancel: "cancel" }, ngImport: i0, template: "<ng-container *ngIf=\"formMetaData()\">\n <ng-container *ngFor=\"let formSection of formMetaData().sections\">\n @if(formSection?.name; as sectionName) {\n <div class=\"form__section-name\">\n {{ sectionName }}\n </div>\n }\n <div class=\"form__section-content\">\n <ng-container *ngIf=\"formSection\">\n <div *ngFor=\"let fieldGroup of formSection?.fieldGroups\">\n <ng-container *ngIf=\"formGroups[fieldGroup.id] as formGroup\">\n <div\n *ngIf=\"fieldGroup.name && !fieldGroup.repeatableStage\"\n class=\"form__field-group-name\"\n >\n {{ fieldGroup?.name }}\n </div>\n <div *ngIf=\"fieldGroup.fields\">\n <!-- Single stage form section -->\n <ng-container *ngIf=\"!fieldGroup.repeatableStage\">\n <ng-dhis2-ui-form\n *ngIf=\"fieldGroup.fields.length > 0\"\n [fields]=\"fieldGroup.fields\"\n [form]=\"formGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [programRuleActions]=\"ruleActions\"\n [isFormHorizontal]=\"fieldGroup.isFormHorizontal || false\"\n (formUpdate)=\"onFormUpdate($event, fieldGroup.id)\"\n ></ng-dhis2-ui-form>\n </ng-container>\n\n <!-- Repeatable stage form section -->\n <ng-container *ngIf=\"fieldGroup.repeatableStage\">\n @if(fieldGroup.repeatDependentField) {\n\n <ng-container *ngIf=\"fieldGroup.repeatDependentField\">\n <ng-container\n *ngIf=\"{\n numberOfRows:\n dataValueEntities()[fieldGroup.repeatDependentField]\n } as dataParams\"\n >\n <ng-dhis2-ui-repeatable-form\n *ngIf=\"\n dataParams.numberOfRows &&\n dataParams.numberOfRows !== '0'\n \"\n [fieldGroup]=\"fieldGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [form]=\"formGroup\"\n [program]=\"formSection.program || ''\"\n [programStage]=\"fieldGroup.repeatableStage\"\n [programRuleActions]=\"ruleActions\"\n [numberOfRows]=\"+dataParams.numberOfRows\"\n [repeatDependentField]=\"\n fieldGroup.repeatDependentField || ''\n \"\n [events]=\"dataValueEntities()[fieldGroup.dataKey!]\"\n (repeatableStageUpdate)=\"\n onUpdateRepeatableStage($event, fieldGroup)\n \"\n ></ng-dhis2-ui-repeatable-form\n ></ng-container>\n </ng-container>\n } @else {\n <ng-dhis2-ui-repeatable-form\n [fieldGroup]=\"fieldGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [form]=\"formGroup\"\n [program]=\"formSection.program || ''\"\n [programStage]=\"fieldGroup.repeatableStage\"\n [programRuleActions]=\"ruleActions\"\n [numberOfRows]=\"1\"\n [repeatDependentField]=\"fieldGroup.repeatDependentField || ''\"\n [events]=\"dataValueEntities()[fieldGroup.dataKey!]\"\n (repeatableStageUpdate)=\"\n onUpdateRepeatableStage($event, fieldGroup)\n \"\n ></ng-dhis2-ui-repeatable-form>\n }\n </ng-container>\n </div>\n </ng-container>\n </div>\n </ng-container>\n </div>\n </ng-container>\n</ng-container>\n", styles: [".form__section-name{font-size:16px;font-weight:600;margin-bottom:16px}.form__section-content{margin-bottom:24px}.form__field-group-name{font-size:14px;font-weight:500;padding-bottom:8px;border-bottom:solid 1px rgb(232,237,242);margin-bottom:16px}\n"], dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FormComponent, selector: "ng-dhis2-ui-form", inputs: ["formConfig", "fields", "form", "isFormHorizontal", "showSaveButton", "fieldsData", "fieldClass", "shouldRenderAsCheckBoxesButton", "programRuleActions", "dataEntities"], outputs: ["formUpdate"] }, { kind: "component", type: RepeatableFormComponent, selector: "ng-dhis2-ui-repeatable-form", inputs: ["formObject", "formData", "fieldGroup", "form", "numberOfRows", "programRuleActions", "events", "program", "programStage", "repeatDependentField", "dataEntities"], outputs: ["eventsChange", "repeatableStageUpdate"] }] }); }
6041
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.8", type: SectionFormComponent, isStandalone: false, selector: "ng-dhis2-ui-section-form", inputs: { loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, formMetaData: { classPropertyName: "formMetaData", publicName: "formMetaData", isSignal: true, isRequired: true, transformFunction: null }, dataValueEntities: { classPropertyName: "dataValueEntities", publicName: "dataValueEntities", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { save: "save", formUpdate: "formUpdate", cancel: "cancel" }, ngImport: i0, template: "<ng-container *ngIf=\"formMetaData()\">\n <ng-container *ngFor=\"let formSection of formMetaData().sections\">\n @if(formSection?.name; as sectionName) {\n <div class=\"form__section-name\">\n {{ sectionName }}\n </div>\n }\n <div class=\"form__section-content\">\n <ng-container *ngIf=\"formSection\">\n <div *ngFor=\"let fieldGroup of formSection?.fieldGroups\">\n <ng-container *ngIf=\"formGroups[fieldGroup.id] as formGroup\">\n <div\n *ngIf=\"fieldGroup.name && !fieldGroup.repeatableStage\"\n class=\"form__field-group-name\"\n >\n {{ fieldGroup?.name }}\n </div>\n <div *ngIf=\"fieldGroup.fields\">\n <!-- Single stage form section -->\n <ng-container *ngIf=\"!fieldGroup.repeatableStage\">\n <ng-dhis2-ui-form\n *ngIf=\"fieldGroup.fields.length > 0\"\n [fields]=\"fieldGroup.fields\"\n [form]=\"formGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [programRuleActions]=\"ruleActions()\"\n [isFormHorizontal]=\"fieldGroup.isFormHorizontal || false\"\n (formUpdate)=\"onFormUpdate($event, fieldGroup.id)\"\n ></ng-dhis2-ui-form>\n </ng-container>\n\n <!-- Repeatable stage form section -->\n <ng-container *ngIf=\"fieldGroup.repeatableStage\">\n @if(fieldGroup.repeatDependentField) {\n\n <ng-container *ngIf=\"fieldGroup.repeatDependentField\">\n <ng-container\n *ngIf=\"{\n numberOfRows:\n dataValueEntities()[fieldGroup.repeatDependentField]\n } as dataParams\"\n >\n <ng-dhis2-ui-repeatable-form\n *ngIf=\"\n dataParams.numberOfRows &&\n dataParams.numberOfRows !== '0'\n \"\n [fieldGroup]=\"fieldGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [form]=\"formGroup\"\n [program]=\"formSection.program || ''\"\n [programStage]=\"fieldGroup.repeatableStage\"\n [programRuleActions]=\"ruleActions()\"\n [numberOfRows]=\"+dataParams.numberOfRows\"\n [repeatDependentField]=\"\n fieldGroup.repeatDependentField || ''\n \"\n [events]=\"dataValueEntities()[fieldGroup.dataKey!]\"\n (repeatableStageUpdate)=\"\n onUpdateRepeatableStage($event, fieldGroup)\n \"\n ></ng-dhis2-ui-repeatable-form\n ></ng-container>\n </ng-container>\n } @else {\n <ng-dhis2-ui-repeatable-form\n [fieldGroup]=\"fieldGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [form]=\"formGroup\"\n [program]=\"formSection.program || ''\"\n [programStage]=\"fieldGroup.repeatableStage\"\n [programRuleActions]=\"ruleActions()\"\n [numberOfRows]=\"1\"\n [repeatDependentField]=\"fieldGroup.repeatDependentField || ''\"\n [events]=\"dataValueEntities()[fieldGroup.dataKey!]\"\n (repeatableStageUpdate)=\"\n onUpdateRepeatableStage($event, fieldGroup)\n \"\n ></ng-dhis2-ui-repeatable-form>\n }\n </ng-container>\n </div>\n </ng-container>\n </div>\n </ng-container>\n </div>\n </ng-container>\n</ng-container>\n", styles: [".form__section-name{font-size:16px;font-weight:600;margin-bottom:16px}.form__section-content{margin-bottom:24px}.form__field-group-name{font-size:14px;font-weight:500;padding-bottom:8px;border-bottom:solid 1px rgb(232,237,242);margin-bottom:16px}\n"], dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FormComponent, selector: "ng-dhis2-ui-form", inputs: ["formConfig", "fields", "form", "isFormHorizontal", "showSaveButton", "fieldsData", "fieldClass", "shouldRenderAsCheckBoxesButton", "programRuleActions", "dataEntities"], outputs: ["formUpdate"] }, { kind: "component", type: RepeatableFormComponent, selector: "ng-dhis2-ui-repeatable-form", inputs: ["formObject", "formData", "fieldGroup", "form", "numberOfRows", "programRuleActions", "events", "program", "programStage", "repeatDependentField", "dataEntities"], outputs: ["eventsChange", "repeatableStageUpdate"] }] }); }
6062
6042
  }
6063
6043
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: SectionFormComponent, decorators: [{
6064
6044
  type: Component,
6065
- args: [{ selector: 'ng-dhis2-ui-section-form', standalone: false, template: "<ng-container *ngIf=\"formMetaData()\">\n <ng-container *ngFor=\"let formSection of formMetaData().sections\">\n @if(formSection?.name; as sectionName) {\n <div class=\"form__section-name\">\n {{ sectionName }}\n </div>\n }\n <div class=\"form__section-content\">\n <ng-container *ngIf=\"formSection\">\n <div *ngFor=\"let fieldGroup of formSection?.fieldGroups\">\n <ng-container *ngIf=\"formGroups[fieldGroup.id] as formGroup\">\n <div\n *ngIf=\"fieldGroup.name && !fieldGroup.repeatableStage\"\n class=\"form__field-group-name\"\n >\n {{ fieldGroup?.name }}\n </div>\n <div *ngIf=\"fieldGroup.fields\">\n <!-- Single stage form section -->\n <ng-container *ngIf=\"!fieldGroup.repeatableStage\">\n <ng-dhis2-ui-form\n *ngIf=\"fieldGroup.fields.length > 0\"\n [fields]=\"fieldGroup.fields\"\n [form]=\"formGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [programRuleActions]=\"ruleActions\"\n [isFormHorizontal]=\"fieldGroup.isFormHorizontal || false\"\n (formUpdate)=\"onFormUpdate($event, fieldGroup.id)\"\n ></ng-dhis2-ui-form>\n </ng-container>\n\n <!-- Repeatable stage form section -->\n <ng-container *ngIf=\"fieldGroup.repeatableStage\">\n @if(fieldGroup.repeatDependentField) {\n\n <ng-container *ngIf=\"fieldGroup.repeatDependentField\">\n <ng-container\n *ngIf=\"{\n numberOfRows:\n dataValueEntities()[fieldGroup.repeatDependentField]\n } as dataParams\"\n >\n <ng-dhis2-ui-repeatable-form\n *ngIf=\"\n dataParams.numberOfRows &&\n dataParams.numberOfRows !== '0'\n \"\n [fieldGroup]=\"fieldGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [form]=\"formGroup\"\n [program]=\"formSection.program || ''\"\n [programStage]=\"fieldGroup.repeatableStage\"\n [programRuleActions]=\"ruleActions\"\n [numberOfRows]=\"+dataParams.numberOfRows\"\n [repeatDependentField]=\"\n fieldGroup.repeatDependentField || ''\n \"\n [events]=\"dataValueEntities()[fieldGroup.dataKey!]\"\n (repeatableStageUpdate)=\"\n onUpdateRepeatableStage($event, fieldGroup)\n \"\n ></ng-dhis2-ui-repeatable-form\n ></ng-container>\n </ng-container>\n } @else {\n <ng-dhis2-ui-repeatable-form\n [fieldGroup]=\"fieldGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [form]=\"formGroup\"\n [program]=\"formSection.program || ''\"\n [programStage]=\"fieldGroup.repeatableStage\"\n [programRuleActions]=\"ruleActions\"\n [numberOfRows]=\"1\"\n [repeatDependentField]=\"fieldGroup.repeatDependentField || ''\"\n [events]=\"dataValueEntities()[fieldGroup.dataKey!]\"\n (repeatableStageUpdate)=\"\n onUpdateRepeatableStage($event, fieldGroup)\n \"\n ></ng-dhis2-ui-repeatable-form>\n }\n </ng-container>\n </div>\n </ng-container>\n </div>\n </ng-container>\n </div>\n </ng-container>\n</ng-container>\n", styles: [".form__section-name{font-size:16px;font-weight:600;margin-bottom:16px}.form__section-content{margin-bottom:24px}.form__field-group-name{font-size:14px;font-weight:500;padding-bottom:8px;border-bottom:solid 1px rgb(232,237,242);margin-bottom:16px}\n"] }]
6045
+ args: [{ selector: 'ng-dhis2-ui-section-form', standalone: false, template: "<ng-container *ngIf=\"formMetaData()\">\n <ng-container *ngFor=\"let formSection of formMetaData().sections\">\n @if(formSection?.name; as sectionName) {\n <div class=\"form__section-name\">\n {{ sectionName }}\n </div>\n }\n <div class=\"form__section-content\">\n <ng-container *ngIf=\"formSection\">\n <div *ngFor=\"let fieldGroup of formSection?.fieldGroups\">\n <ng-container *ngIf=\"formGroups[fieldGroup.id] as formGroup\">\n <div\n *ngIf=\"fieldGroup.name && !fieldGroup.repeatableStage\"\n class=\"form__field-group-name\"\n >\n {{ fieldGroup?.name }}\n </div>\n <div *ngIf=\"fieldGroup.fields\">\n <!-- Single stage form section -->\n <ng-container *ngIf=\"!fieldGroup.repeatableStage\">\n <ng-dhis2-ui-form\n *ngIf=\"fieldGroup.fields.length > 0\"\n [fields]=\"fieldGroup.fields\"\n [form]=\"formGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [programRuleActions]=\"ruleActions()\"\n [isFormHorizontal]=\"fieldGroup.isFormHorizontal || false\"\n (formUpdate)=\"onFormUpdate($event, fieldGroup.id)\"\n ></ng-dhis2-ui-form>\n </ng-container>\n\n <!-- Repeatable stage form section -->\n <ng-container *ngIf=\"fieldGroup.repeatableStage\">\n @if(fieldGroup.repeatDependentField) {\n\n <ng-container *ngIf=\"fieldGroup.repeatDependentField\">\n <ng-container\n *ngIf=\"{\n numberOfRows:\n dataValueEntities()[fieldGroup.repeatDependentField]\n } as dataParams\"\n >\n <ng-dhis2-ui-repeatable-form\n *ngIf=\"\n dataParams.numberOfRows &&\n dataParams.numberOfRows !== '0'\n \"\n [fieldGroup]=\"fieldGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [form]=\"formGroup\"\n [program]=\"formSection.program || ''\"\n [programStage]=\"fieldGroup.repeatableStage\"\n [programRuleActions]=\"ruleActions()\"\n [numberOfRows]=\"+dataParams.numberOfRows\"\n [repeatDependentField]=\"\n fieldGroup.repeatDependentField || ''\n \"\n [events]=\"dataValueEntities()[fieldGroup.dataKey!]\"\n (repeatableStageUpdate)=\"\n onUpdateRepeatableStage($event, fieldGroup)\n \"\n ></ng-dhis2-ui-repeatable-form\n ></ng-container>\n </ng-container>\n } @else {\n <ng-dhis2-ui-repeatable-form\n [fieldGroup]=\"fieldGroup\"\n [dataEntities]=\"dataValueEntities()\"\n [form]=\"formGroup\"\n [program]=\"formSection.program || ''\"\n [programStage]=\"fieldGroup.repeatableStage\"\n [programRuleActions]=\"ruleActions()\"\n [numberOfRows]=\"1\"\n [repeatDependentField]=\"fieldGroup.repeatDependentField || ''\"\n [events]=\"dataValueEntities()[fieldGroup.dataKey!]\"\n (repeatableStageUpdate)=\"\n onUpdateRepeatableStage($event, fieldGroup)\n \"\n ></ng-dhis2-ui-repeatable-form>\n }\n </ng-container>\n </div>\n </ng-container>\n </div>\n </ng-container>\n </div>\n </ng-container>\n</ng-container>\n", styles: [".form__section-name{font-size:16px;font-weight:600;margin-bottom:16px}.form__section-content{margin-bottom:24px}.form__field-group-name{font-size:14px;font-weight:500;padding-bottom:8px;border-bottom:solid 1px rgb(232,237,242);margin-bottom:16px}\n"] }]
6066
6046
  }], ctorParameters: () => [], propDecorators: { save: [{
6067
6047
  type: Output
6068
6048
  }], formUpdate: [{
@@ -6071,19 +6051,101 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
6071
6051
  type: Output
6072
6052
  }] } });
6073
6053
 
6054
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
6055
+ // Use of this source code is governed by a BSD-style
6056
+ // license that can be found in the LICENSE file.
6057
+ class BaseFormWrapperComponent {
6058
+ #updatedDataValues;
6059
+ constructor() {
6060
+ this.ngZone = inject(NgZone);
6061
+ this.name = input();
6062
+ this.fields = input.required();
6063
+ this.rules = input([]);
6064
+ this.dataValues = input({});
6065
+ this.ruleActions = signal([]);
6066
+ this.isFormValid = signal(true);
6067
+ this.#updatedDataValues = signal({});
6068
+ this.formSave = new EventEmitter();
6069
+ this.formUpdate = new EventEmitter();
6070
+ this.formCancel = new EventEmitter();
6071
+ this.formValidityUpdate = new EventEmitter();
6072
+ this.ruleProcessor = effect(() => {
6073
+ if (this.#updatedDataValues()) {
6074
+ this.executeRules();
6075
+ }
6076
+ });
6077
+ }
6078
+ updateDataValues(dataValues) {
6079
+ this.#updatedDataValues.set(dataValues);
6080
+ this.formUpdate.emit(this.#updatedDataValues());
6081
+ }
6082
+ updateFormValidity(isFormValid) {
6083
+ this.isFormValid.set(isFormValid);
6084
+ this.formValidityUpdate.emit(isFormValid);
6085
+ }
6086
+ executeRules() {
6087
+ this.ruleActions.set(new ProgramRuleEngine()
6088
+ .setRules(this.rules())
6089
+ .setDataValues(this.#updatedDataValues())
6090
+ .execute());
6091
+ }
6092
+ ngOnDestroy() {
6093
+ this.ruleProcessor.destroy();
6094
+ }
6095
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: BaseFormWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
6096
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.8", type: BaseFormWrapperComponent, isStandalone: true, inputs: { name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: true, transformFunction: null }, rules: { classPropertyName: "rules", publicName: "rules", isSignal: true, isRequired: false, transformFunction: null }, dataValues: { classPropertyName: "dataValues", publicName: "dataValues", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { formSave: "formSave", formUpdate: "formUpdate", formCancel: "formCancel", formValidityUpdate: "formValidityUpdate" }, ngImport: i0 }); }
6097
+ }
6098
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: BaseFormWrapperComponent, decorators: [{
6099
+ type: Directive
6100
+ }], ctorParameters: () => [], propDecorators: { formSave: [{
6101
+ type: Output
6102
+ }], formUpdate: [{
6103
+ type: Output
6104
+ }], formCancel: [{
6105
+ type: Output
6106
+ }], formValidityUpdate: [{
6107
+ type: Output
6108
+ }] } });
6109
+
6110
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
6111
+ // Use of this source code is governed by a BSD-style
6112
+ // license that can be found in the LICENSE file.
6113
+
6114
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
6115
+ // Use of this source code is governed by a BSD-style
6116
+ // license that can be found in the LICENSE file.
6117
+
6118
+ class FlatFormComponent extends BaseFormWrapperComponent {
6119
+ ngOnInit() {
6120
+ this.formGroup = FormUtil.getFormGroup(this.fields(), this.dataValues());
6121
+ }
6122
+ onFormUpdate() {
6123
+ this.updateDataValues(this.formGroup.getRawValue());
6124
+ this.updateFormValidity(this.formGroup.valid);
6125
+ }
6126
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: FlatFormComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
6127
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: FlatFormComponent, isStandalone: false, selector: "ng-dhis2-ui-flat-form", usesInheritance: true, ngImport: i0, template: "<!-- <ng-dhis2-ui-form\n*ngIf=\"fieldGroup.fields.length > 0\"\n[fields]=\"fieldGroup.fields\"\n[form]=\"formGroup\"\n[dataEntities]=\"dataValueEntities()\"\n[programRuleActions]=\"ruleActions()\"\n[isFormHorizontal]=\"fieldGroup.isFormHorizontal || false\"\n(formUpdate)=\"onFormUpdate($event, fieldGroup.id)\"\n></ng-dhis2-ui-form> -->\n\n<ng-dhis2-ui-form\n [fields]=\"fields()\"\n [form]=\"formGroup\"\n [dataEntities]=\"dataValues()\"\n [programRuleActions]=\"ruleActions()\"\n (formUpdate)=\"onFormUpdate()\"\n/>\n", dependencies: [{ kind: "component", type: FormComponent, selector: "ng-dhis2-ui-form", inputs: ["formConfig", "fields", "form", "isFormHorizontal", "showSaveButton", "fieldsData", "fieldClass", "shouldRenderAsCheckBoxesButton", "programRuleActions", "dataEntities"], outputs: ["formUpdate"] }] }); }
6128
+ }
6129
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: FlatFormComponent, decorators: [{
6130
+ type: Component,
6131
+ args: [{ selector: 'ng-dhis2-ui-flat-form', standalone: false, template: "<!-- <ng-dhis2-ui-form\n*ngIf=\"fieldGroup.fields.length > 0\"\n[fields]=\"fieldGroup.fields\"\n[form]=\"formGroup\"\n[dataEntities]=\"dataValueEntities()\"\n[programRuleActions]=\"ruleActions()\"\n[isFormHorizontal]=\"fieldGroup.isFormHorizontal || false\"\n(formUpdate)=\"onFormUpdate($event, fieldGroup.id)\"\n></ng-dhis2-ui-form> -->\n\n<ng-dhis2-ui-form\n [fields]=\"fields()\"\n [form]=\"formGroup\"\n [dataEntities]=\"dataValues()\"\n [programRuleActions]=\"ruleActions()\"\n (formUpdate)=\"onFormUpdate()\"\n/>\n" }]
6132
+ }] });
6133
+
6074
6134
  class D2FormModule {
6075
6135
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: D2FormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
6076
6136
  static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.8", ngImport: i0, type: D2FormModule, declarations: [FormFieldComponent,
6077
6137
  FormComponent,
6078
6138
  RepeatableFormComponent,
6079
6139
  SectionFormComponent,
6140
+ FlatFormComponent,
6080
6141
  FormFieldItemComponent], imports: [CommonModule,
6081
6142
  ReactiveFormsModule,
6082
6143
  ReactWrapperModule,
6083
6144
  OrganisationUnitSelectorModule], exports: [FormFieldComponent,
6084
6145
  FormComponent,
6085
6146
  RepeatableFormComponent,
6086
- SectionFormComponent] }); }
6147
+ SectionFormComponent,
6148
+ FlatFormComponent] }); }
6087
6149
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: D2FormModule, imports: [CommonModule,
6088
6150
  ReactiveFormsModule,
6089
6151
  OrganisationUnitSelectorModule] }); }
@@ -6096,6 +6158,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
6096
6158
  FormComponent,
6097
6159
  RepeatableFormComponent,
6098
6160
  SectionFormComponent,
6161
+ FlatFormComponent,
6099
6162
  FormFieldItemComponent,
6100
6163
  ],
6101
6164
  imports: [
@@ -6109,6 +6172,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
6109
6172
  FormComponent,
6110
6173
  RepeatableFormComponent,
6111
6174
  SectionFormComponent,
6175
+ FlatFormComponent,
6112
6176
  ],
6113
6177
  }]
6114
6178
  }] });
@@ -6461,18 +6525,22 @@ class TrackerFormComponent {
6461
6525
  this.formMetaData = new FormMetaData({
6462
6526
  programs: [program],
6463
6527
  programStage: this.programStage(),
6528
+ disableEnrollmentDate: true,
6464
6529
  }).toJson();
6465
- console.log(this.formMetaData, this.instance.enrollmentDate);
6466
6530
  }
6467
6531
  }
6532
+ onFormUpdate(values) {
6533
+ const instance = this.instance;
6534
+ instance?.updateDataValues(values);
6535
+ }
6468
6536
  onSave(event) { }
6469
6537
  onCancel() { }
6470
6538
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: TrackerFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
6471
- 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"] }] }); }
6539
+ 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 (formUpdate)=\"onFormUpdate($event)\"\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"] }] }); }
6472
6540
  }
6473
6541
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: TrackerFormComponent, decorators: [{
6474
6542
  type: Component,
6475
- args: [{ selector: 'ng-dhis2-ui-tracker-form', standalone: false, 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" }]
6543
+ args: [{ selector: 'ng-dhis2-ui-tracker-form', standalone: false, template: "@if(formMetaData) {\n<ng-dhis2-ui-section-form\n [formMetaData]=\"formMetaData\"\n [dataValueEntities]=\"instance\"\n (formUpdate)=\"onFormUpdate($event)\"\n (save)=\"onSave($event)\"\n (cancel)=\"onCancel()\"\n/>\n}\n" }]
6476
6544
  }] });
6477
6545
 
6478
6546
  class TrackerFormModule {
@@ -6493,9 +6561,552 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
6493
6561
  // Use of this source code is governed by a BSD-style
6494
6562
  // license that can be found in the LICENSE file.
6495
6563
 
6564
+ class EventFormComponent {
6565
+ constructor() {
6566
+ this.program = input.required();
6567
+ this.programStage = input.required();
6568
+ this.eventId = input();
6569
+ this.enrollment = input();
6570
+ this.trackedEntity = input();
6571
+ this.d2 = window.d2Web;
6572
+ }
6573
+ async ngOnInit() {
6574
+ this.eventQuery = this.d2.eventModule.event
6575
+ .setProgram(this.program())
6576
+ .setProgramStage(this.programStage())
6577
+ .setEnrollment(this.enrollment())
6578
+ .setTrackedEntity(this.trackedEntity());
6579
+ const program = await this.eventQuery.getMetaData();
6580
+ this.instance = this.eventId()
6581
+ ? (await this.eventQuery.setEvent(this.eventId()).get())
6582
+ .data || (await this.eventQuery.create())
6583
+ : await this.eventQuery.create();
6584
+ if (program) {
6585
+ this.formMetaData = new FormMetaData({
6586
+ programs: [program],
6587
+ programStage: this.programStage(),
6588
+ }).toJson();
6589
+ }
6590
+ }
6591
+ onFormUpdate(values) {
6592
+ const instance = this.instance;
6593
+ instance?.updateDataValues(values);
6594
+ }
6595
+ onSave(event) { }
6596
+ onCancel() { }
6597
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: EventFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
6598
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.8", type: EventFormComponent, isStandalone: false, selector: "ng-dhis2-ui-event-form", inputs: { program: { classPropertyName: "program", publicName: "program", isSignal: true, isRequired: true, transformFunction: null }, programStage: { classPropertyName: "programStage", publicName: "programStage", isSignal: true, isRequired: true, transformFunction: null }, eventId: { classPropertyName: "eventId", publicName: "eventId", isSignal: true, isRequired: false, transformFunction: null }, enrollment: { classPropertyName: "enrollment", publicName: "enrollment", 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 (formUpdate)=\"onFormUpdate($event)\"\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"] }] }); }
6599
+ }
6600
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: EventFormComponent, decorators: [{
6601
+ type: Component,
6602
+ args: [{ selector: 'ng-dhis2-ui-event-form', standalone: false, template: "@if(formMetaData) {\n<ng-dhis2-ui-section-form\n [formMetaData]=\"formMetaData\"\n [dataValueEntities]=\"instance\"\n (formUpdate)=\"onFormUpdate($event)\"\n (save)=\"onSave($event)\"\n (cancel)=\"onCancel()\"\n/>\n}\n" }]
6603
+ }] });
6604
+
6605
+ class EventFormModule {
6606
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: EventFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
6607
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.8", ngImport: i0, type: EventFormModule, declarations: [EventFormComponent], imports: [CommonModule, D2FormModule], exports: [EventFormComponent] }); }
6608
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: EventFormModule, imports: [CommonModule, D2FormModule] }); }
6609
+ }
6610
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: EventFormModule, decorators: [{
6611
+ type: NgModule,
6612
+ args: [{
6613
+ imports: [CommonModule, D2FormModule],
6614
+ declarations: [EventFormComponent],
6615
+ exports: [EventFormComponent],
6616
+ }]
6617
+ }] });
6618
+
6619
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
6620
+ // Use of this source code is governed by a BSD-style
6621
+ // license that can be found in the LICENSE file.
6622
+
6623
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
6624
+ // Use of this source code is governed by a BSD-style
6625
+ // license that can be found in the LICENSE file.
6626
+ class ProgramEntryFormConfig {
6627
+ constructor(config) {
6628
+ this.displayType = 'FLAT';
6629
+ this.submitButtonLabel = 'Submit';
6630
+ this.cancelButtonLabel = 'Cancel';
6631
+ Object.assign(this, config);
6632
+ }
6633
+ }
6634
+
6635
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
6636
+ // Use of this source code is governed by a BSD-style
6637
+ // license that can be found in the LICENSE file.
6638
+ class ProgramEntryFormFieldUtil {
6639
+ constructor(program, config) {
6640
+ this.program = program;
6641
+ this.config = config;
6642
+ }
6643
+ get attributes() {
6644
+ return (this.program.programTrackedEntityAttributes || []).map((programTrackedEntityAttribute) => {
6645
+ return {
6646
+ ...programTrackedEntityAttribute.trackedEntityAttribute,
6647
+ sortOrder: programTrackedEntityAttribute.sortOrder,
6648
+ mandatory: programTrackedEntityAttribute.mandatory,
6649
+ allowFutureDate: programTrackedEntityAttribute.allowFutureDate,
6650
+ metaType: 'ATTRIBUTE',
6651
+ stepId: null,
6652
+ };
6653
+ });
6654
+ }
6655
+ get dataElements() {
6656
+ return flatten((this.program.programStages || []).map((programStage) => {
6657
+ return (programStage.programStageDataElements || []).map((stageDataElement) => {
6658
+ return {
6659
+ ...stageDataElement.dataElement,
6660
+ sortOrder: stageDataElement.sortOrder,
6661
+ mandatory: stageDataElement.compulsory,
6662
+ allowFutureDate: stageDataElement.allowFutureDate,
6663
+ stepId: programStage.id,
6664
+ metaType: 'DATA_ELEMENT',
6665
+ };
6666
+ });
6667
+ }));
6668
+ }
6669
+ #getOrgUniField() {
6670
+ if (this.config.hideRegistrationUnit) {
6671
+ return null;
6672
+ }
6673
+ return new FormField({
6674
+ id: 'orgUnit',
6675
+ key: 'orgUnit',
6676
+ label: this.program.orgUnitLabel || 'Registering unit',
6677
+ code: 'orgUnit',
6678
+ required: true,
6679
+ controlType: 'org-unit',
6680
+ disabled: this.config.disableRegistrationUnit,
6681
+ });
6682
+ }
6683
+ #getEnrollmentDateField() {
6684
+ if (this.config.hideEnrollmentDate) {
6685
+ return null;
6686
+ }
6687
+ return new FormField({
6688
+ id: 'enrollmentDate',
6689
+ label: this.program.enrollmentDateLabel || 'Enrollment date',
6690
+ code: 'enrollmentDate',
6691
+ key: 'enrollmentDate',
6692
+ required: true,
6693
+ type: 'date',
6694
+ controlType: 'date',
6695
+ disabled: this.config.disableEnrollmentDate,
6696
+ });
6697
+ }
6698
+ #getIncidentDateField() {
6699
+ if (!this.program.displayIncidentDate) {
6700
+ return null;
6701
+ }
6702
+ return new DateField({
6703
+ id: 'incidentDate',
6704
+ label: this.program.incidentDateLabel || 'Incident date',
6705
+ code: 'incidentDate',
6706
+ key: 'incidentDate',
6707
+ required: true,
6708
+ type: 'date',
6709
+ controlType: 'date',
6710
+ disabled: this.config.disabledIncidentDate,
6711
+ });
6712
+ }
6713
+ get reportFields() {
6714
+ return [
6715
+ this.#getOrgUniField(),
6716
+ this.#getEnrollmentDateField(),
6717
+ this.#getIncidentDateField(),
6718
+ ].filter((field) => field != null);
6719
+ }
6720
+ get fields() {
6721
+ const fields = [...this.attributes, ...this.dataElements]
6722
+ .map((field) => {
6723
+ const options = FieldDropdown.getDropdownOptions(field);
6724
+ const hasOptions = options?.length > 0;
6725
+ return new FormField({
6726
+ ...field,
6727
+ id: field.id,
6728
+ code: field.code,
6729
+ label: field.formName || field.name,
6730
+ key: field.code ? camelCase(field.code) : field.id,
6731
+ required: field.mandatory,
6732
+ type: field.valueType,
6733
+ options,
6734
+ disabled: this.#getDisabledStatus(field),
6735
+ order: field.sortOrder,
6736
+ hasOptions,
6737
+ controlType: FieldUtil.getFieldControlType(field.valueType, hasOptions),
6738
+ metaType: field.metaType,
6739
+ stepId: field.stepId,
6740
+ });
6741
+ })
6742
+ .sort((a, b) => a.order ?? 0 - (b.order ?? 0));
6743
+ return [...this.reportFields, ...fields];
6744
+ }
6745
+ #getDisabledStatus(field) {
6746
+ if (field?.generated) {
6747
+ return true;
6748
+ }
6749
+ if (this.config.autoAssignedValues &&
6750
+ this.config.autoAssignedValues.length > 0) {
6751
+ const key = field.code ? camelCase(field.code) : field.id;
6752
+ const assignedValue = (this.config.autoAssignedValues || []).find((assignedValue) => assignedValue.field === key)?.value;
6753
+ return !isUndefined(assignedValue);
6754
+ }
6755
+ return false;
6756
+ }
6757
+ }
6758
+
6759
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
6760
+ // Use of this source code is governed by a BSD-style
6761
+ // license that can be found in the LICENSE file.
6762
+ class ProgramEntryFormSectionUtil {
6763
+ constructor(program, config) {
6764
+ this.program = program;
6765
+ this.config = config;
6766
+ }
6767
+ get sections() {
6768
+ return [];
6769
+ }
6770
+ }
6771
+
6772
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
6773
+ // Use of this source code is governed by a BSD-style
6774
+ // license that can be found in the LICENSE file.
6775
+
6776
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
6777
+ // Use of this source code is governed by a BSD-style
6778
+ // license that can be found in the LICENSE file.
6779
+ class ProgramEntryFormMetaData {
6780
+ constructor() {
6781
+ this.d2 = window?.d2Web;
6782
+ }
6783
+ setConfig(config) {
6784
+ this.config = config;
6785
+ return this;
6786
+ }
6787
+ getProgramPromise() {
6788
+ const program = this.config.program;
6789
+ const programQuery = this.d2.programModule.program
6790
+ .select([
6791
+ 'id',
6792
+ 'code',
6793
+ 'name',
6794
+ 'captureCoordinates',
6795
+ 'featureType',
6796
+ 'enrollmentDateLabel',
6797
+ 'incidentDateLabel',
6798
+ 'displayIncidentDate',
6799
+ 'onlyEnrollOnce',
6800
+ 'orgUnitLabel',
6801
+ 'programType',
6802
+ 'useFirstStageDuringRegistration',
6803
+ 'trackedEntityType',
6804
+ ])
6805
+ .with(this.d2.programModule.programTrackedEntityAttribute.with(this.d2.programModule.trackedEntityAttribute.with(this.d2.optionSetModule.optionSet.with(this.d2.optionSetModule.option), 'ToOne'), 'ToOne'))
6806
+ .with(this.d2.programModule.programRuleVariable
6807
+ .with(this.d2.dataElementModule.dataElement.select([
6808
+ 'id',
6809
+ 'code',
6810
+ 'name',
6811
+ ]), 'ToOne')
6812
+ .with(this.d2.programModule.trackedEntityAttribute.select([
6813
+ 'id',
6814
+ 'code',
6815
+ 'name',
6816
+ ]), 'ToOne'))
6817
+ .byId(program);
6818
+ if (this.config.displayType === 'FLAT') {
6819
+ programQuery.with(this.d2.programModule.programSection.with(this.d2.programModule.trackedEntityAttribute.select(['id'])));
6820
+ }
6821
+ if (!this.config.excludeProgramStages) {
6822
+ programQuery.with(this.d2.programModule.programStage
6823
+ .with(this.d2.programModule.programStageSection)
6824
+ .with(this.d2.programModule.programStageDataElement.with(this.d2.dataElementModule.dataElement.with(this.d2.optionSetModule.optionSet.with(this.d2.optionSetModule.option), 'ToOne'), 'ToOne')));
6825
+ }
6826
+ return programQuery.get();
6827
+ }
6828
+ async #getProgramMetaData() {
6829
+ const program = this.config.program;
6830
+ if (!this.d2) {
6831
+ return null;
6832
+ }
6833
+ const metaDataResponse = await Promise.all([
6834
+ this.getProgramPromise(),
6835
+ this.d2.programModule.programRule
6836
+ .where({
6837
+ attribute: 'program.id',
6838
+ value: program,
6839
+ })
6840
+ .with(this.d2.programModule.programRuleAction
6841
+ .select([
6842
+ 'id',
6843
+ 'programRuleActionType',
6844
+ 'data',
6845
+ 'displayContent',
6846
+ 'content',
6847
+ ])
6848
+ .with(this.d2.dataElementModule.dataElement.select([
6849
+ 'id',
6850
+ 'code',
6851
+ 'name',
6852
+ ]), 'ToOne')
6853
+ .with(this.d2.programModule.trackedEntityAttribute.select([
6854
+ 'id',
6855
+ 'code',
6856
+ 'name',
6857
+ ]), 'ToOne')
6858
+ .with(this.d2.optionSetModule.optionGroup
6859
+ .select(['id'])
6860
+ .with(this.d2.optionSetModule.option.select([
6861
+ 'id',
6862
+ 'code',
6863
+ 'displayName',
6864
+ ]), 'ToMany'), 'ToOne')
6865
+ .with(this.d2.optionSetModule.option.select([
6866
+ 'id',
6867
+ 'code',
6868
+ 'displayName',
6869
+ ]), 'ToOne'))
6870
+ .get(),
6871
+ ]);
6872
+ const [programResponse, programRuleResponse] = metaDataResponse;
6873
+ const metaData = programResponse.data;
6874
+ metaData.programRules = programRuleResponse.data;
6875
+ return metaData;
6876
+ }
6877
+ get formFields() {
6878
+ if (!this.metaData) {
6879
+ return [];
6880
+ }
6881
+ return new ProgramEntryFormFieldUtil(this.metaData, this.config).fields;
6882
+ }
6883
+ get sections() {
6884
+ if (!this.metaData || this.config.displayType !== 'SECTION') {
6885
+ return [];
6886
+ }
6887
+ return new ProgramEntryFormSectionUtil(this.metaData, this.config).sections;
6888
+ }
6889
+ get rules() {
6890
+ if (!this.metaData || !this.metaData.programRules) {
6891
+ return [];
6892
+ }
6893
+ return this.metaData.programRules.map((programRule) => new MetadataRule(programRule, this.metaData.programRuleVariables || []).toJson());
6894
+ }
6895
+ toJson() {
6896
+ return {
6897
+ id: this.metaData?.id,
6898
+ name: this.metaData?.name,
6899
+ description: this.metaData?.description,
6900
+ formFields: this.formFields,
6901
+ sections: this.sections,
6902
+ rules: this.rules,
6903
+ };
6904
+ }
6905
+ async get() {
6906
+ try {
6907
+ const metaData = await this.#getProgramMetaData();
6908
+ if (metaData) {
6909
+ this.metaData = metaData;
6910
+ return this.toJson();
6911
+ }
6912
+ return null;
6913
+ }
6914
+ catch (err) {
6915
+ return null;
6916
+ }
6917
+ }
6918
+ }
6919
+
6920
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
6921
+ // Use of this source code is governed by a BSD-style
6922
+ // license that can be found in the LICENSE file.
6923
+ class ProgramEntryFormSection {
6924
+ constructor(props) {
6925
+ this.formFields = [];
6926
+ this.orientation = 'HORIZONTAL';
6927
+ Object.assign(this, props);
6928
+ }
6929
+ }
6930
+
6931
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
6932
+ // Use of this source code is governed by a BSD-style
6933
+ // license that can be found in the LICENSE file.
6934
+
6935
+ // eslint-disable-next-line @angular-eslint/component-class-suffix
6936
+ class ProgramEntryFormModule {
6937
+ constructor() {
6938
+ this.config = input.required();
6939
+ this.trackedEntity = input();
6940
+ this.event = input();
6941
+ this.enrollment = input();
6942
+ this.orgUnit = input();
6943
+ this.ngZone = inject(NgZone);
6944
+ this.d2 = window.d2Web;
6945
+ this.loading = signal(false);
6946
+ this.metaData = signal(null);
6947
+ this.isFormValid = signal(true);
6948
+ this.isFormValid$ = toObservable(this.isFormValid);
6949
+ this.instance = signal(null);
6950
+ this.instanceSave = new EventEmitter();
6951
+ this.instanceSaveCompleted = new EventEmitter();
6952
+ this.instanceUpdate = new EventEmitter();
6953
+ this.formValidityUpdate = new EventEmitter();
6954
+ this.formCancel = new EventEmitter();
6955
+ this.FormLoader = () => {
6956
+ return React__default.createElement(CircularLoader$1, { small: true });
6957
+ };
6958
+ this.FormActionButtons = computed(() => {
6959
+ if (this.config().hideActionButtons) {
6960
+ return React__default.createElement(React__default.Fragment, null);
6961
+ }
6962
+ return () => {
6963
+ const [isValid, setIsValid] = useState();
6964
+ const [submitting, setSubmitting] = useState(false);
6965
+ useEffect(() => {
6966
+ const isValidSubscription = this.isFormValid$.subscribe((isValid) => {
6967
+ setIsValid(isValid);
6968
+ });
6969
+ return () => {
6970
+ isValidSubscription.unsubscribe();
6971
+ };
6972
+ }, []);
6973
+ const onSave = () => {
6974
+ setSubmitting(true);
6975
+ this.ngZone.run(async () => {
6976
+ const saveResponse = await this.#saveInstance();
6977
+ this.instanceSaveCompleted.emit(saveResponse);
6978
+ setSubmitting(false);
6979
+ });
6980
+ };
6981
+ return (React__default.createElement(ButtonStrip$1, null,
6982
+ !this.config().hideSubmitButton && (React__default.createElement(Button$1, { primary: true, disabled: !isValid, loading: submitting, onClick: onSave }, this.config().submitButtonLabel)),
6983
+ !this.config().hideCancelButton && (React__default.createElement(Button$1, { onClick: () => {
6984
+ this.ngZone.run(() => {
6985
+ this.onCancel();
6986
+ });
6987
+ } }, this.config().cancelButtonLabel))));
6988
+ };
6989
+ });
6990
+ }
6991
+ async ngOnInit() {
6992
+ this.loading.set(true);
6993
+ try {
6994
+ // Loading metadata
6995
+ const metaData = await new ProgramEntryFormMetaData()
6996
+ .setConfig(this.config())
6997
+ .get();
6998
+ this.metaData.set(metaData);
6999
+ // Load initial instance information
7000
+ const instance = await this.#getInstance();
7001
+ this.instance.set(instance);
7002
+ if (this.config().autoAssignedValues) {
7003
+ this.#updateInstanceWithAutoAssignedValues(this.config().autoAssignedValues);
7004
+ }
7005
+ this.loading.set(false);
7006
+ }
7007
+ catch (err) {
7008
+ this.loading.set(false);
7009
+ }
7010
+ }
7011
+ onFormUpdate(dataValues) {
7012
+ this.#updateInstance(dataValues);
7013
+ if (this.instance()) {
7014
+ this.instanceUpdate.emit(this.instance());
7015
+ }
7016
+ }
7017
+ onValidityUpdate(isFormValid) {
7018
+ this.isFormValid.set(isFormValid);
7019
+ this.formValidityUpdate.emit(isFormValid);
7020
+ }
7021
+ onCancel() {
7022
+ this.formCancel.emit();
7023
+ }
7024
+ #updateInstanceWithAutoAssignedValues(autoAssignedValues) {
7025
+ const assignedDataValues = autoAssignedValues.reduce((entities, assignedValue) => {
7026
+ return {
7027
+ ...entities,
7028
+ [assignedValue.field]: assignedValue.value,
7029
+ };
7030
+ }, {});
7031
+ this.#updateInstance(assignedDataValues);
7032
+ }
7033
+ #updateInstance(dataValues) {
7034
+ this.instance.update((instance) => {
7035
+ instance?.updateDataValues(dataValues);
7036
+ return instance;
7037
+ });
7038
+ }
7039
+ async #saveInstance() {
7040
+ switch (this.config().formType) {
7041
+ case 'TRACKER':
7042
+ return this.instanceQuery
7043
+ .setData(this.instance())
7044
+ .save();
7045
+ case 'EVENT':
7046
+ return this.instanceQuery
7047
+ .setData(this.instance())
7048
+ .save();
7049
+ default:
7050
+ return firstValueFrom(of(null));
7051
+ }
7052
+ }
7053
+ async #getTrackerInstance() {
7054
+ this.instanceQuery = this.d2.trackerModule.trackedEntity
7055
+ .setProgram(this.config().program)
7056
+ .setOrgUnit(this.orgUnit());
7057
+ return this.trackedEntity()
7058
+ ? (await this.instanceQuery
7059
+ .setTrackedEntity(this.trackedEntity())
7060
+ .get()).data || (await this.instanceQuery.create())
7061
+ : await this.instanceQuery.create();
7062
+ }
7063
+ async #getEventInstance() {
7064
+ this.instanceQuery = this.d2.eventModule.event
7065
+ .setProgram(this.config().program)
7066
+ .setProgramStage(this.config().programStage)
7067
+ .setEnrollment(this.enrollment())
7068
+ .setTrackedEntity(this.trackedEntity())
7069
+ .setOrgUnit(this.orgUnit());
7070
+ return this.event()
7071
+ ? (await this.instanceQuery.setEvent(this.event()).get())
7072
+ .data || (await this.instanceQuery.create())
7073
+ : await this.instanceQuery.create();
7074
+ }
7075
+ #getInstance() {
7076
+ switch (this.config().formType) {
7077
+ case 'TRACKER':
7078
+ return this.#getTrackerInstance();
7079
+ case 'EVENT':
7080
+ return this.#getEventInstance();
7081
+ default:
7082
+ return firstValueFrom(of(null));
7083
+ }
7084
+ }
7085
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: ProgramEntryFormModule, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
7086
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.8", 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 } }, 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 <ng-dhis2-ui-flat-form\n [name]=\"metaData()!.name\"\n [dataValues]=\"instance()!\"\n [rules]=\"metaData()!.rules\"\n [fields]=\"metaData()!.formFields\"\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"] }] }); }
7087
+ }
7088
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: ProgramEntryFormModule, decorators: [{
7089
+ type: Component,
7090
+ args: [{ selector: 'ng-dhis2-ui-program-entry-form', imports: [CommonModule, D2FormModule, ReactWrapperModule], 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 <ng-dhis2-ui-flat-form\n [name]=\"metaData()!.name\"\n [dataValues]=\"instance()!\"\n [rules]=\"metaData()!.rules\"\n [fields]=\"metaData()!.formFields\"\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"] }]
7091
+ }], propDecorators: { instanceSave: [{
7092
+ type: Output
7093
+ }], instanceSaveCompleted: [{
7094
+ type: Output
7095
+ }], instanceUpdate: [{
7096
+ type: Output
7097
+ }], formValidityUpdate: [{
7098
+ type: Output
7099
+ }], formCancel: [{
7100
+ type: Output
7101
+ }] } });
7102
+
7103
+ // Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
7104
+ // Use of this source code is governed by a BSD-style
7105
+ // license that can be found in the LICENSE file.
7106
+
6496
7107
  /**
6497
7108
  * Generated bundle index. Do not edit.
6498
7109
  */
6499
7110
 
6500
- export { Boolean$1 as Boolean, BreadcrumbComponent, BreadcrumbModule, ButtonComponent, ButtonModule, CheckBox, D2FormModule, DataTableUIComponent, DataTableUIModule, DateField, DateRangeValue, Dropdown, FieldConfig, FieldControlTypeUtil, FieldDropdown, FieldType, FieldUtil, FormComponent, FormConfig, FormField, FormFieldComponent, FormFieldGroup, FormFieldTypeUtil, FormMetaData, FormMetadataSection, FormUtil, FormValue, FormValueUtil, HeaderBarComponent, HeaderBarModule, LineListModule, LineListTableComponent, MetadataRule, MetadataRuleAction, OrganisationUnitSelectionConfig, OrganisationUnitSelectorComponent, OrganisationUnitSelectorModalComponent, OrganisationUnitSelectorModule, PeriodSelectorComponent, PeriodSelectorModalComponent, PeriodSelectorModule, ReactWrapperModule, RepeatableFormComponent, SectionFormComponent, SelectionFiltersComponent, SelectionFiltersUiModule, TrackerFormComponent, TrackerFormModule, TranslationUtil };
7111
+ export { Boolean$1 as Boolean, BreadcrumbComponent, BreadcrumbModule, ButtonComponent, ButtonModule, CheckBox, D2FormModule, DataTableUIComponent, DataTableUIModule, DateField, DateRangeValue, Dropdown, EventFormComponent, EventFormModule, FieldConfig, FieldControlTypeUtil, FieldDropdown, FieldType, FieldUtil, FlatFormComponent, FormComponent, FormConfig, FormField, FormFieldComponent, FormFieldGroup, FormFieldTypeUtil, FormMetaData, FormMetadataSection, FormUtil, FormValue, FormValueUtil, HeaderBarComponent, HeaderBarModule, LineListModule, LineListTableComponent, MetadataRule, MetadataRuleAction, OrganisationUnitSelectionConfig, OrganisationUnitSelectorComponent, OrganisationUnitSelectorModalComponent, OrganisationUnitSelectorModule, PeriodSelectorComponent, PeriodSelectorModalComponent, PeriodSelectorModule, ProgramEntryFormConfig, ProgramEntryFormMetaData, ProgramEntryFormModule, ProgramEntryFormSection, ReactWrapperModule, RepeatableFormComponent, SectionFormComponent, SelectionFiltersComponent, SelectionFiltersUiModule, TrackerFormComponent, TrackerFormModule, TranslationUtil };
6501
7112
  //# sourceMappingURL=iapps-ng-dhis2-ui.mjs.map