@iapps/ng-dhis2-ui 1.1.42 → 1.1.44
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.
- package/fesm2022/iapps-ng-dhis2-ui.mjs +64 -47
- package/fesm2022/iapps-ng-dhis2-ui.mjs.map +1 -1
- package/lib/modules/form/models/form-field.model.d.ts +2 -1
- package/lib/modules/form/models/form-metadata.model.d.ts +2 -0
- package/lib/modules/tracker-form/tracker-form.component.d.ts +2 -1
- package/package.json +1 -1
|
@@ -3888,6 +3888,8 @@ class FormField {
|
|
|
3888
3888
|
options.max || (this.controlType === 'date' ? new Date() : undefined);
|
|
3889
3889
|
this.maxLength = options.maxLength;
|
|
3890
3890
|
this.hidden = options.hidden || false;
|
|
3891
|
+
this.unique = options.unique || false;
|
|
3892
|
+
this.generated = options.generated || false;
|
|
3891
3893
|
this.isDataElement = options.isDataElement;
|
|
3892
3894
|
this.isAttribute = options.isAttribute;
|
|
3893
3895
|
this.isOrgUnit = options.isOrgUnit;
|
|
@@ -4520,6 +4522,9 @@ class FormMetaData {
|
|
|
4520
4522
|
}
|
|
4521
4523
|
#getSectionFromPrograms(programs) {
|
|
4522
4524
|
const sections = flatten(programs.map((program) => {
|
|
4525
|
+
if (this.params.programStage) {
|
|
4526
|
+
return this.#getProgramStageSections(program, this.params.programStage);
|
|
4527
|
+
}
|
|
4523
4528
|
return [
|
|
4524
4529
|
...(this.params.splitRegistrationSection
|
|
4525
4530
|
? [
|
|
@@ -4528,43 +4533,7 @@ class FormMetaData {
|
|
|
4528
4533
|
this.#getRegistrationSection(program),
|
|
4529
4534
|
]
|
|
4530
4535
|
: [this.#getMergedRegistrationSection(program)]),
|
|
4531
|
-
...(program
|
|
4532
|
-
return new FormMetadataSection({
|
|
4533
|
-
section: {
|
|
4534
|
-
id: programStage.id,
|
|
4535
|
-
name: programStage.name,
|
|
4536
|
-
fieldGroups: (programStage.programStageSections || []).length > 0
|
|
4537
|
-
? programStage.programStageSections.map((programStageSection) => {
|
|
4538
|
-
return {
|
|
4539
|
-
id: programStageSection.id,
|
|
4540
|
-
name: programStageSection.name,
|
|
4541
|
-
dataKey: camelCase(programStage.code),
|
|
4542
|
-
repeatableStage: programStage.repeatable
|
|
4543
|
-
? programStage.id
|
|
4544
|
-
: undefined,
|
|
4545
|
-
sortOrder: programStageSection.sortOrder,
|
|
4546
|
-
fields: programStageSection.dataElements,
|
|
4547
|
-
};
|
|
4548
|
-
})
|
|
4549
|
-
: [
|
|
4550
|
-
{
|
|
4551
|
-
id: programStage.id,
|
|
4552
|
-
dataKey: camelCase(programStage.code),
|
|
4553
|
-
repeatableStage: programStage.repeatable
|
|
4554
|
-
? programStage.id
|
|
4555
|
-
: undefined,
|
|
4556
|
-
fields: (programStage.programStageDataElements || []).map((programStageDataElement) => {
|
|
4557
|
-
return {
|
|
4558
|
-
id: programStageDataElement.dataElement?.id,
|
|
4559
|
-
};
|
|
4560
|
-
}),
|
|
4561
|
-
},
|
|
4562
|
-
],
|
|
4563
|
-
},
|
|
4564
|
-
program,
|
|
4565
|
-
locale: this.params.locale,
|
|
4566
|
-
}).toJson();
|
|
4567
|
-
}),
|
|
4536
|
+
...this.#getProgramStageSections(program),
|
|
4568
4537
|
];
|
|
4569
4538
|
}));
|
|
4570
4539
|
if (sections.length === 0) {
|
|
@@ -4572,6 +4541,52 @@ class FormMetaData {
|
|
|
4572
4541
|
}
|
|
4573
4542
|
return sections;
|
|
4574
4543
|
}
|
|
4544
|
+
#getProgramStageSections(program, programStageId) {
|
|
4545
|
+
const programStages = programStageId
|
|
4546
|
+
? (program.programStages || []).filter((programStage) => programStage.id === programStageId)
|
|
4547
|
+
: this.params.includeAllProgramStages
|
|
4548
|
+
? program.programStages
|
|
4549
|
+
: program.useFirstStageDuringRegistration
|
|
4550
|
+
? [(program.programStages || [])[0]]
|
|
4551
|
+
: [];
|
|
4552
|
+
return (programStages || []).map((programStage) => {
|
|
4553
|
+
return new FormMetadataSection({
|
|
4554
|
+
section: {
|
|
4555
|
+
id: programStage.id,
|
|
4556
|
+
name: programStage.name,
|
|
4557
|
+
fieldGroups: (programStage.programStageSections || []).length > 0
|
|
4558
|
+
? programStage.programStageSections.map((programStageSection) => {
|
|
4559
|
+
return {
|
|
4560
|
+
id: programStageSection.id,
|
|
4561
|
+
name: programStageSection.name,
|
|
4562
|
+
dataKey: camelCase(programStage.code),
|
|
4563
|
+
repeatableStage: programStage.repeatable
|
|
4564
|
+
? programStage.id
|
|
4565
|
+
: undefined,
|
|
4566
|
+
sortOrder: programStageSection.sortOrder,
|
|
4567
|
+
fields: programStageSection.dataElements,
|
|
4568
|
+
};
|
|
4569
|
+
})
|
|
4570
|
+
: [
|
|
4571
|
+
{
|
|
4572
|
+
id: programStage.id,
|
|
4573
|
+
dataKey: camelCase(programStage.code),
|
|
4574
|
+
repeatableStage: programStage.repeatable
|
|
4575
|
+
? programStage.id
|
|
4576
|
+
: undefined,
|
|
4577
|
+
fields: (programStage.programStageDataElements || []).map((programStageDataElement) => {
|
|
4578
|
+
return {
|
|
4579
|
+
id: programStageDataElement.dataElement?.id,
|
|
4580
|
+
};
|
|
4581
|
+
}),
|
|
4582
|
+
},
|
|
4583
|
+
],
|
|
4584
|
+
},
|
|
4585
|
+
program,
|
|
4586
|
+
locale: this.params.locale,
|
|
4587
|
+
}).toJson();
|
|
4588
|
+
});
|
|
4589
|
+
}
|
|
4575
4590
|
#getRegisteringUnitSection(program) {
|
|
4576
4591
|
return new FormMetadataSection({
|
|
4577
4592
|
section: {
|
|
@@ -4724,7 +4739,7 @@ class FormMetaData {
|
|
|
4724
4739
|
: [
|
|
4725
4740
|
{
|
|
4726
4741
|
id: 'registration',
|
|
4727
|
-
name: '',
|
|
4742
|
+
name: 'Registration',
|
|
4728
4743
|
sortOrder: 1,
|
|
4729
4744
|
fields: (program.programTrackedEntityAttributes || []).map((programTrackedEntityAttribute) => {
|
|
4730
4745
|
return {
|
|
@@ -4913,7 +4928,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
|
|
|
4913
4928
|
}, [hasError]);
|
|
4914
4929
|
switch (this.field().controlType) {
|
|
4915
4930
|
case 'textarea':
|
|
4916
|
-
return (React__default.createElement(TextAreaField, { 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, onChange: (event) => {
|
|
4931
|
+
return (React__default.createElement(TextAreaField, { 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(), disabled: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, readOnly: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, placeholder: this.placeholder(), value: value, onChange: (event) => {
|
|
4917
4932
|
this.ngZone.run(() => {
|
|
4918
4933
|
(this.form().get(this.field().id) ||
|
|
4919
4934
|
this.form().get(this.field().key))?.setValue(event.value);
|
|
@@ -4931,7 +4946,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
|
|
|
4931
4946
|
} }));
|
|
4932
4947
|
case 'org-unit':
|
|
4933
4948
|
return (React__default.createElement(React__default.Fragment, null,
|
|
4934
|
-
React__default.createElement(InputField$1, { error: hasError, validationText: validationError, type: this.field().type, prefixIcon: React__default.createElement(IconDimensionOrgUnit16, null), required: this.field().required, name: this.field().id, label: this.label(), placeholder: this.placeholder(), value: displayValue, readOnly: false, onFocus: () => {
|
|
4949
|
+
React__default.createElement(InputField$1, { error: hasError, validationText: validationError, type: this.field().type, prefixIcon: React__default.createElement(IconDimensionOrgUnit16, null), required: this.field().required, name: this.field().id, label: this.label(), placeholder: this.placeholder(), value: displayValue, disabled: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, readOnly: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, onFocus: () => {
|
|
4935
4950
|
setShowOrgUnit(true);
|
|
4936
4951
|
}, onBlur: () => {
|
|
4937
4952
|
this.ngZone.run(() => {
|
|
@@ -4957,7 +4972,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
|
|
|
4957
4972
|
}
|
|
4958
4973
|
} }))));
|
|
4959
4974
|
case 'transfer':
|
|
4960
|
-
return (React__default.createElement(Transfer, { filterable: true, filterPlaceholder: "Search", selected: selected, error: hasError, validationText: validationError, type: this.field().type, inputWidth: this.fieldConfig()?.inputWidth, required: this.field().required, name: this.field().id, label: this.label(), placeholder: this.placeholder(), value: selected, leftHeader: React__default.createElement("div", { style: {
|
|
4975
|
+
return (React__default.createElement(Transfer, { filterable: true, filterPlaceholder: "Search", selected: selected, error: hasError, validationText: validationError, type: this.field().type, inputWidth: this.fieldConfig()?.inputWidth, disabled: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, readOnly: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, required: this.field().required, name: this.field().id, label: this.label(), placeholder: this.placeholder(), value: selected, leftHeader: React__default.createElement("div", { style: {
|
|
4961
4976
|
fontSize: 14,
|
|
4962
4977
|
padding: '8px 4px',
|
|
4963
4978
|
} }, this.field().availableOptionsLabel), rightHeader: React__default.createElement("div", { style: {
|
|
@@ -4974,7 +4989,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
|
|
|
4974
4989
|
this.update.emit({ form: this.form(), value });
|
|
4975
4990
|
} }));
|
|
4976
4991
|
case 'checkbox':
|
|
4977
|
-
return (React__default.createElement(Checkbox, { checked: Boolean(value), error: hasError, label: this.label(), name: this.field().id, onChange: (event) => {
|
|
4992
|
+
return (React__default.createElement(Checkbox, { checked: Boolean(value), error: hasError, label: this.label(), name: this.field().id, disabled: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, readOnly: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, onChange: (event) => {
|
|
4978
4993
|
this.ngZone.run(() => {
|
|
4979
4994
|
(this.form().get(this.field().id) ||
|
|
4980
4995
|
this.form().get(this.field().key))?.setValue(event.checked);
|
|
@@ -4987,7 +5002,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
|
|
|
4987
5002
|
});
|
|
4988
5003
|
} }));
|
|
4989
5004
|
case 'dropdown':
|
|
4990
|
-
return (React__default.createElement(SingleSelectField, { filterable: (this.field().options || []).length > 5, clearable: true, error: hasError, validationText: validationError, inputWidth: this.fieldConfig()?.inputWidth, required: this.field().required, name: this.field().id, className: "select", label: this.label(), selected: value, onChange: (event) => {
|
|
5005
|
+
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 || this.field()?.generated || this.field()?.unique || false, readOnly: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, required: this.field().required, name: this.field().id, className: "select", label: this.label(), selected: value, onChange: (event) => {
|
|
4991
5006
|
this.ngZone.run(() => {
|
|
4992
5007
|
(this.form().get(this.field().id) ||
|
|
4993
5008
|
this.form().get(this.field().key))?.setValue(event.selected);
|
|
@@ -5000,7 +5015,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
|
|
|
5000
5015
|
setTouched(true);
|
|
5001
5016
|
} }, (this.field().options || []).map((option) => (React__default.createElement(SingleSelectOption, { key: crypto.randomUUID() || option.key, label: option.label, value: option.value })))));
|
|
5002
5017
|
case 'multi-dropdown':
|
|
5003
|
-
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, label: this.label(), name: this.field().id, required: this.field().required, loadingText: "Loading options", noMatchText: "No options found", onChange: (event) => {
|
|
5018
|
+
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 || this.field()?.generated || this.field()?.unique || false, readOnly: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, label: this.label(), name: this.field().id, required: this.field().required, loadingText: "Loading options", noMatchText: "No options found", onChange: (event) => {
|
|
5004
5019
|
const selectedValue = (event.selected || []).join(',');
|
|
5005
5020
|
this.ngZone.run(() => {
|
|
5006
5021
|
(this.form().get(this.field().id) ||
|
|
@@ -5014,7 +5029,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
|
|
|
5014
5029
|
setTouched(true);
|
|
5015
5030
|
}, selected: arrayValue }, (this.field().options || []).map((option) => (React__default.createElement(MultiSelectOption, { key: option.key, label: option.label, value: option.value })))));
|
|
5016
5031
|
case 'file':
|
|
5017
|
-
return (React__default.createElement(FileInputField, { accept: "*", buttonLabel: "Upload a file", label: this.label(), name: this.field().id, files: this.uploadedFiles, onChange: (event) => {
|
|
5032
|
+
return (React__default.createElement(FileInputField, { accept: "*", buttonLabel: "Upload a file", label: this.label(), name: this.field().id, disabled: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, readOnly: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, files: this.uploadedFiles, onChange: (event) => {
|
|
5018
5033
|
this.uploadedFiles.push((event?.files || [])[0]);
|
|
5019
5034
|
this.ngZone.run(() => {
|
|
5020
5035
|
this.form().get(this.field().id) ||
|
|
@@ -5036,7 +5051,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
|
|
|
5036
5051
|
});
|
|
5037
5052
|
}, removeText: "Remove" })))));
|
|
5038
5053
|
default:
|
|
5039
|
-
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: this.field().
|
|
5054
|
+
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 || this.field()?.generated || this.field()?.unique || false, readOnly: this.field()?.disabled || this.field()?.generated || this.field()?.unique || false, onChange: (event) => {
|
|
5040
5055
|
this.ngZone.run(() => {
|
|
5041
5056
|
(this.form().get(this.field().id) ||
|
|
5042
5057
|
this.form().get(this.field().key))?.setValue(event.value);
|
|
@@ -5987,6 +6002,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
|
|
|
5987
6002
|
class TrackerFormComponent {
|
|
5988
6003
|
constructor() {
|
|
5989
6004
|
this.program = input.required();
|
|
6005
|
+
this.programStage = input();
|
|
5990
6006
|
this.trackedEntity = input();
|
|
5991
6007
|
this.d2 = window.d2Web;
|
|
5992
6008
|
}
|
|
@@ -6001,6 +6017,7 @@ class TrackerFormComponent {
|
|
|
6001
6017
|
if (program) {
|
|
6002
6018
|
this.formMetaData = new FormMetaData({
|
|
6003
6019
|
programs: [program],
|
|
6020
|
+
programStage: this.programStage(),
|
|
6004
6021
|
}).toJson();
|
|
6005
6022
|
console.log(this.formMetaData, this.instance.enrollmentDate);
|
|
6006
6023
|
}
|
|
@@ -6008,7 +6025,7 @@ class TrackerFormComponent {
|
|
|
6008
6025
|
onSave(event) { }
|
|
6009
6026
|
onCancel() { }
|
|
6010
6027
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: TrackerFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
6011
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.8", type: TrackerFormComponent, isStandalone: false, selector: "ng-dhis2-ui-tracker-form", inputs: { program: { classPropertyName: "program", publicName: "program", isSignal: true, isRequired: true, transformFunction: null }, trackedEntity: { classPropertyName: "trackedEntity", publicName: "trackedEntity", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if(formMetaData) {\n<ng-dhis2-ui-section-form\n [formMetaData]=\"formMetaData\"\n [dataValueEntities]=\"instance\"\n (save)=\"onSave($event)\"\n (cancel)=\"onCancel()\"\n/>\n}\n", dependencies: [{ kind: "component", type: SectionFormComponent, selector: "ng-dhis2-ui-section-form", inputs: ["loading", "formMetaData", "dataValueEntities"], outputs: ["save", "formUpdate", "cancel"] }] }); }
|
|
6028
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.8", type: TrackerFormComponent, isStandalone: false, selector: "ng-dhis2-ui-tracker-form", inputs: { program: { classPropertyName: "program", publicName: "program", isSignal: true, isRequired: true, transformFunction: null }, programStage: { classPropertyName: "programStage", publicName: "programStage", isSignal: true, isRequired: false, transformFunction: null }, trackedEntity: { classPropertyName: "trackedEntity", publicName: "trackedEntity", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if(formMetaData) {\n<ng-dhis2-ui-section-form\n [formMetaData]=\"formMetaData\"\n [dataValueEntities]=\"instance\"\n (save)=\"onSave($event)\"\n (cancel)=\"onCancel()\"\n/>\n}\n", dependencies: [{ kind: "component", type: SectionFormComponent, selector: "ng-dhis2-ui-section-form", inputs: ["loading", "formMetaData", "dataValueEntities"], outputs: ["save", "formUpdate", "cancel"] }] }); }
|
|
6012
6029
|
}
|
|
6013
6030
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: TrackerFormComponent, decorators: [{
|
|
6014
6031
|
type: Component,
|