@iapps/ng-dhis2-ui 1.2.5 → 1.2.7
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 +166 -36
- package/fesm2022/iapps-ng-dhis2-ui.mjs.map +1 -1
- package/lib/modules/form/models/form-metadata-section.model.d.ts +0 -1
- package/lib/modules/form/utils/field-type.util.d.ts +1 -1
- package/lib/modules/form/utils/field.util.d.ts +1 -1
- package/lib/modules/line-list/models/filter-config.model.d.ts +6 -0
- package/lib/modules/line-list/models/line-list.models.d.ts +1 -1
- package/lib/modules/line-list/utils/event-table-table-util.d.ts +6 -0
- package/lib/modules/program-entry-form/models/program-entry-form.config.d.ts +2 -0
- package/lib/modules/program-entry-form/program-entry-form.component.d.ts +1 -1
- package/lib/modules/program-entry-form/utils/program-entry-form-field.util.d.ts +18 -2
- package/package.json +1 -1
|
@@ -3314,15 +3314,14 @@ const FilterToolbar = ({ orgUnitLabel, selectedOrgUnit, setSelectedOrgUnit, setO
|
|
|
3314
3314
|
setOrgUnitState(defaultOrgUnit);
|
|
3315
3315
|
} }),
|
|
3316
3316
|
React__default.createElement(CalendarInput, { label: "Start date:", calendar: "gregory", locale: "en-GB", timeZone: "Africa/Dar_es_Salaam", className: "custom-input", clearable: !!startDateState, date: startDateState, onDateSelect: (selectedDate) => {
|
|
3317
|
-
if (!(selectedDate.calendarDateString === null)) {
|
|
3318
|
-
|
|
3319
|
-
}
|
|
3320
|
-
console.log(selectedDate.calendarDateString);
|
|
3317
|
+
// if (!(selectedDate.calendarDateString === null)) {
|
|
3318
|
+
setStartDateState(selectedDate.calendarDateString);
|
|
3319
|
+
//}
|
|
3321
3320
|
} }),
|
|
3322
3321
|
React__default.createElement(CalendarInput, { label: "End date:", calendar: "gregory", locale: "en-GB", timeZone: "Africa/Dar_es_Salaam", className: "custom-input", clearable: !!endDateState, date: endDateState, onDateSelect: (selectedDate) => {
|
|
3323
|
-
if (!(selectedDate.calendarDateString === null)) {
|
|
3324
|
-
|
|
3325
|
-
}
|
|
3322
|
+
// if (!(selectedDate.calendarDateString === null)) {
|
|
3323
|
+
setEndDateState(selectedDate.calendarDateString);
|
|
3324
|
+
//}
|
|
3326
3325
|
} }),
|
|
3327
3326
|
(visibleFilters ?? []).map(({ label, key, valueType, options }) => {
|
|
3328
3327
|
if (valueType === 'DATE') {
|
|
@@ -3535,6 +3534,7 @@ const DataTableActions = (props) => {
|
|
|
3535
3534
|
// license that can be found in the LICENSE file.
|
|
3536
3535
|
|
|
3537
3536
|
const TableCell = ({ cell, getTextColorFromBackGround, }) => {
|
|
3537
|
+
console.log('cel value', cell);
|
|
3538
3538
|
if (cell?.style && cell?.style !== 'default-value') {
|
|
3539
3539
|
return (React__default.createElement(DataTableCell, null,
|
|
3540
3540
|
React__default.createElement("div", { style: { display: 'flex', justifyContent: 'center' } },
|
|
@@ -3787,15 +3787,15 @@ const getTrackedEntityTableData = (response, programId, pager, metaData) => {
|
|
|
3787
3787
|
.orgUnitsMap;
|
|
3788
3788
|
const attributeColumns = metaData.displayInListTrackedEntityAttributes
|
|
3789
3789
|
.sort((a, b) => a.sortOrder - b.sortOrder)
|
|
3790
|
-
.map((
|
|
3791
|
-
label:
|
|
3792
|
-
key:
|
|
3790
|
+
.map((trackedEntityAttribute) => ({
|
|
3791
|
+
label: trackedEntityAttribute.formName ?? trackedEntityAttribute.name,
|
|
3792
|
+
key: trackedEntityAttribute.id,
|
|
3793
3793
|
}));
|
|
3794
3794
|
const dataElementColumns = metaData.displayInListDataElements
|
|
3795
3795
|
.sort((a, b) => a.sortOrder - b.sortOrder)
|
|
3796
|
-
.map((
|
|
3797
|
-
label:
|
|
3798
|
-
key:
|
|
3796
|
+
.map((dataElement) => ({
|
|
3797
|
+
label: dataElement.formName || dataElement.name,
|
|
3798
|
+
key: dataElement.id,
|
|
3799
3799
|
}));
|
|
3800
3800
|
const dataElementOptions = metaData.displayInListDataElements.map((element) => ({
|
|
3801
3801
|
id: element.id,
|
|
@@ -3843,7 +3843,17 @@ const getTrackedEntityTableData = (response, programId, pager, metaData) => {
|
|
|
3843
3843
|
return attr;
|
|
3844
3844
|
});
|
|
3845
3845
|
attributesData.forEach((attr) => {
|
|
3846
|
-
|
|
3846
|
+
const attributeMeta = metaData.programTrackedEntityAttributes?.find((metadata) => metadata.trackedEntityAttribute.id === attr.attribute);
|
|
3847
|
+
if (attributeMeta?.trackedEntityAttribute.optionSetValue) {
|
|
3848
|
+
const optionSet = attributeMeta?.trackedEntityAttribute?.optionSet;
|
|
3849
|
+
const option = optionSet?.options?.find((option) => option.code === attr.value);
|
|
3850
|
+
row[attr.attribute] = option
|
|
3851
|
+
? { value: option?.name }
|
|
3852
|
+
: { value: attr.value };
|
|
3853
|
+
}
|
|
3854
|
+
else {
|
|
3855
|
+
row[attr.attribute] = { value: attr.value };
|
|
3856
|
+
}
|
|
3847
3857
|
});
|
|
3848
3858
|
dataElementsData.forEach((element) => {
|
|
3849
3859
|
// Find the matching data element in dataElementOptions by ID
|
|
@@ -3887,6 +3897,58 @@ const addActionsColumn = (columns, actionOptions) => {
|
|
|
3887
3897
|
];
|
|
3888
3898
|
};
|
|
3889
3899
|
|
|
3900
|
+
const getEvents = (response, programStageId, pager, metaData) => {
|
|
3901
|
+
const events = response.data.events;
|
|
3902
|
+
const eventsiiii = response.data;
|
|
3903
|
+
const allDataElements = new Set();
|
|
3904
|
+
events.forEach((event) => {
|
|
3905
|
+
event.dataValues.forEach((dv) => allDataElements.add(dv.dataElement));
|
|
3906
|
+
});
|
|
3907
|
+
let stageFromMetaData;
|
|
3908
|
+
if (programStageId) {
|
|
3909
|
+
stageFromMetaData = metaData.programStages.find((stage) => stage.id === programStageId);
|
|
3910
|
+
}
|
|
3911
|
+
else if (metaData.programType === 'WITHOUT_REGISTRATION') {
|
|
3912
|
+
stageFromMetaData = metaData.programStages[0];
|
|
3913
|
+
}
|
|
3914
|
+
if (!stageFromMetaData) {
|
|
3915
|
+
throw new Error(`Program stage with ID ${programStageId} not found`);
|
|
3916
|
+
}
|
|
3917
|
+
const entityColumns = Array.from(allDataElements).map((dataElementId) => {
|
|
3918
|
+
const dataElementMeta = stageFromMetaData.programStageDataElements.find((psde) => psde.dataElement.id === dataElementId);
|
|
3919
|
+
return {
|
|
3920
|
+
label: dataElementMeta?.dataElement.name || dataElementId,
|
|
3921
|
+
key: dataElementId,
|
|
3922
|
+
};
|
|
3923
|
+
});
|
|
3924
|
+
const dataElementsData = events.map((event, idx) => {
|
|
3925
|
+
const row = {
|
|
3926
|
+
event: { value: event.event },
|
|
3927
|
+
index: {
|
|
3928
|
+
value: (pager.page - 1) * pager.pageSize + idx + 1,
|
|
3929
|
+
},
|
|
3930
|
+
};
|
|
3931
|
+
allDataElements.forEach((dataElementId) => {
|
|
3932
|
+
row[dataElementId] = { value: '' };
|
|
3933
|
+
});
|
|
3934
|
+
event.dataValues.forEach((dv) => {
|
|
3935
|
+
const dataElementMeta = stageFromMetaData.programStageDataElements.find((psde) => psde.dataElement.id === dv.dataElement);
|
|
3936
|
+
if (dataElementMeta?.dataElement.optionSet) {
|
|
3937
|
+
const optionSet = dataElementMeta.dataElement.optionSet;
|
|
3938
|
+
const matchingOption = optionSet.options.find((option) => option.code === dv.value);
|
|
3939
|
+
row[dv.dataElement] = matchingOption
|
|
3940
|
+
? { value: matchingOption.name }
|
|
3941
|
+
: { value: dv.value };
|
|
3942
|
+
}
|
|
3943
|
+
else {
|
|
3944
|
+
row[dv.dataElement] = { value: dv.value };
|
|
3945
|
+
}
|
|
3946
|
+
});
|
|
3947
|
+
return row;
|
|
3948
|
+
});
|
|
3949
|
+
return { columns: entityColumns, data: dataElementsData };
|
|
3950
|
+
};
|
|
3951
|
+
|
|
3890
3952
|
// src/app/line-list-table.component.ts
|
|
3891
3953
|
class LineListTableComponent extends ReactWrapperModule {
|
|
3892
3954
|
constructor() {
|
|
@@ -3974,10 +4036,36 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
3974
4036
|
if (!metaData) {
|
|
3975
4037
|
return undefined;
|
|
3976
4038
|
}
|
|
3977
|
-
setLoading(true);
|
|
3978
4039
|
const isTracker = metaData.programType === 'WITH_REGISTRATION';
|
|
4040
|
+
const isEvent = metaData.programType === 'WITHOUT_REGISTRATION';
|
|
3979
4041
|
const endDate = endDateState ?? new Date().toISOString().split('T')[0];
|
|
3980
|
-
if (
|
|
4042
|
+
if (this.programStageId || isEvent) {
|
|
4043
|
+
setLoading(true);
|
|
4044
|
+
d2.eventModule.event
|
|
4045
|
+
.setProgram(this.programId)
|
|
4046
|
+
.setProgramStage(this.programStageId)
|
|
4047
|
+
.setPagination(new Pager({
|
|
4048
|
+
pageSize: pager.pageSize,
|
|
4049
|
+
page: pager.page,
|
|
4050
|
+
}))
|
|
4051
|
+
.get()
|
|
4052
|
+
.then((response) => {
|
|
4053
|
+
const eventsResponse = {
|
|
4054
|
+
events: response.data,
|
|
4055
|
+
pager: pager,
|
|
4056
|
+
// orgUnitsMap: fetchedOrgUnits,
|
|
4057
|
+
};
|
|
4058
|
+
const { columns, data } = getEvents({ data: eventsResponse }, this.programStageId, pager, metaData);
|
|
4059
|
+
const finalColumns = addActionsColumn([{ label: '#', key: 'index' }, ...columns], this.actionOptions);
|
|
4060
|
+
const pagerResponse = response.pagination;
|
|
4061
|
+
setLoading(false);
|
|
4062
|
+
setColumns(finalColumns);
|
|
4063
|
+
setData(data);
|
|
4064
|
+
setPager(new Pager(pagerResponse || {}));
|
|
4065
|
+
});
|
|
4066
|
+
}
|
|
4067
|
+
else if (isTracker) {
|
|
4068
|
+
setLoading(true);
|
|
3981
4069
|
d2.trackerModule.trackedEntity
|
|
3982
4070
|
.setEndDate(endDate)
|
|
3983
4071
|
.setStartDate(startDateState)
|
|
@@ -4028,9 +4116,6 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
4028
4116
|
});
|
|
4029
4117
|
});
|
|
4030
4118
|
}
|
|
4031
|
-
else {
|
|
4032
|
-
//TODO: TO IMPLEMEMNT EVENT QUERY FOR FILTERING EVENTS WHEN PROGRAM STAGE IS PASSED OR DEALING WITH EVENT PROGRAM USING TRACKER SDK QUERY
|
|
4033
|
-
}
|
|
4034
4119
|
}, [
|
|
4035
4120
|
metaData,
|
|
4036
4121
|
programIdState,
|
|
@@ -5009,7 +5094,9 @@ class FormFieldGroup {
|
|
|
5009
5094
|
...field,
|
|
5010
5095
|
id: field.id,
|
|
5011
5096
|
code: fieldMetaData['code'],
|
|
5012
|
-
label: (fieldMetaData['formName'] ??
|
|
5097
|
+
label: (fieldMetaData['formName'] ??
|
|
5098
|
+
fieldMetaData['name'] ??
|
|
5099
|
+
field['label']),
|
|
5013
5100
|
key: camelCase(fieldMetaData['code']) || field.id,
|
|
5014
5101
|
required: (fieldMetaData['mandatory'] ??
|
|
5015
5102
|
fieldMetaData['required']),
|
|
@@ -5140,7 +5227,6 @@ class FormMetadataSection {
|
|
|
5140
5227
|
return programTrackedEntityAttributes.map((programTrackedEntityAttribute) => {
|
|
5141
5228
|
return {
|
|
5142
5229
|
...programTrackedEntityAttribute['trackedEntityAttribute'],
|
|
5143
|
-
formName: (programTrackedEntityAttribute['trackedEntityAttribute'] || {})['name'],
|
|
5144
5230
|
sortOrder: programTrackedEntityAttribute['sortOrder'],
|
|
5145
5231
|
mandatory: programTrackedEntityAttribute['mandatory'],
|
|
5146
5232
|
allowFutureDate: programTrackedEntityAttribute['allowFutureDate'],
|
|
@@ -6625,6 +6711,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
|
|
|
6625
6711
|
class FlatFormComponent extends BaseFormWrapperComponent {
|
|
6626
6712
|
ngOnInit() {
|
|
6627
6713
|
this.formGroup = FormUtil.getFormGroup(this.fields(), this.dataValues());
|
|
6714
|
+
this.onFormUpdate();
|
|
6628
6715
|
}
|
|
6629
6716
|
onFormUpdate() {
|
|
6630
6717
|
this.updateDataValues(this.formGroup.getRawValue());
|
|
@@ -7048,7 +7135,7 @@ class TrackerFormComponent {
|
|
|
7048
7135
|
programs: [program],
|
|
7049
7136
|
programStage: this.programStage(),
|
|
7050
7137
|
disableEnrollmentDate: true,
|
|
7051
|
-
excludeInheritedAttributes:
|
|
7138
|
+
excludeInheritedAttributes: false,
|
|
7052
7139
|
}).toJson();
|
|
7053
7140
|
}
|
|
7054
7141
|
}
|
|
@@ -7185,8 +7272,11 @@ class ProgramEntryFormFieldUtil {
|
|
|
7185
7272
|
});
|
|
7186
7273
|
}
|
|
7187
7274
|
get dataElements() {
|
|
7188
|
-
|
|
7189
|
-
|
|
7275
|
+
const programStages = this.config.programStage
|
|
7276
|
+
? this.program.programStages?.filter((programStage) => programStage.id === this.config.programStage)
|
|
7277
|
+
: this.program.programStages;
|
|
7278
|
+
return flatten((programStages || []).map((programStage) => {
|
|
7279
|
+
const dataElements = (programStage.programStageDataElements || []).map((stageDataElement) => {
|
|
7190
7280
|
return {
|
|
7191
7281
|
...stageDataElement.dataElement,
|
|
7192
7282
|
sortOrder: stageDataElement.sortOrder,
|
|
@@ -7196,6 +7286,28 @@ class ProgramEntryFormFieldUtil {
|
|
|
7196
7286
|
metaType: 'DATA_ELEMENT',
|
|
7197
7287
|
};
|
|
7198
7288
|
});
|
|
7289
|
+
const eventDateName = programStage.executionDateLabel ||
|
|
7290
|
+
`Reporting date - ${programStage.name}`;
|
|
7291
|
+
return [
|
|
7292
|
+
{
|
|
7293
|
+
id: 'occurredAt',
|
|
7294
|
+
code: 'OCCURRED_AT',
|
|
7295
|
+
formName: eventDateName,
|
|
7296
|
+
name: eventDateName,
|
|
7297
|
+
shortName: eventDateName,
|
|
7298
|
+
displayName: eventDateName,
|
|
7299
|
+
sortOrder: 1,
|
|
7300
|
+
mandatory: true,
|
|
7301
|
+
stepId: programStage.id,
|
|
7302
|
+
valueType: 'DATE',
|
|
7303
|
+
metaType: 'EVENT_DATE',
|
|
7304
|
+
domainType: 'TRACKER',
|
|
7305
|
+
aggregationType: 'NONE',
|
|
7306
|
+
lastUpdated: '',
|
|
7307
|
+
created: '',
|
|
7308
|
+
},
|
|
7309
|
+
...dataElements,
|
|
7310
|
+
];
|
|
7199
7311
|
}));
|
|
7200
7312
|
}
|
|
7201
7313
|
#getOrgUniField() {
|
|
@@ -7214,7 +7326,7 @@ class ProgramEntryFormFieldUtil {
|
|
|
7214
7326
|
});
|
|
7215
7327
|
}
|
|
7216
7328
|
#getEnrollmentDateField() {
|
|
7217
|
-
if (this.config.hideEnrollmentDate) {
|
|
7329
|
+
if (this.config.hideEnrollmentDate || this.config.programStage) {
|
|
7218
7330
|
return null;
|
|
7219
7331
|
}
|
|
7220
7332
|
return new FormField({
|
|
@@ -7229,7 +7341,7 @@ class ProgramEntryFormFieldUtil {
|
|
|
7229
7341
|
});
|
|
7230
7342
|
}
|
|
7231
7343
|
#getIncidentDateField() {
|
|
7232
|
-
if (!this.program.displayIncidentDate) {
|
|
7344
|
+
if (!this.program.displayIncidentDate || this.config.programStage) {
|
|
7233
7345
|
return null;
|
|
7234
7346
|
}
|
|
7235
7347
|
return new DateField({
|
|
@@ -7340,7 +7452,6 @@ class ProgramEntryFormMetaData {
|
|
|
7340
7452
|
.with(this.d2.programModule.trackedEntityTypeAttribute.select([
|
|
7341
7453
|
'trackedEntityAttribute',
|
|
7342
7454
|
])), 'ToOne')
|
|
7343
|
-
.with(this.d2.programModule.programTrackedEntityAttribute.with(this.d2.programModule.trackedEntityAttribute.with(this.d2.optionSetModule.optionSet.with(this.d2.optionSetModule.option), 'ToOne'), 'ToOne'))
|
|
7344
7455
|
.with(this.d2.programModule.programRuleVariable
|
|
7345
7456
|
.with(this.d2.dataElementModule.dataElement.select([
|
|
7346
7457
|
'id',
|
|
@@ -7353,13 +7464,17 @@ class ProgramEntryFormMetaData {
|
|
|
7353
7464
|
'name',
|
|
7354
7465
|
]), 'ToOne'))
|
|
7355
7466
|
.byId(program);
|
|
7467
|
+
if (!this.config.programStage) {
|
|
7468
|
+
programQuery.with(this.d2.programModule.programTrackedEntityAttribute.with(this.d2.programModule.trackedEntityAttribute.with(this.d2.optionSetModule.optionSet.with(this.d2.optionSetModule.option), 'ToOne'), 'ToOne'));
|
|
7469
|
+
}
|
|
7356
7470
|
if (this.config.displayType === 'FLAT') {
|
|
7357
7471
|
programQuery.with(this.d2.programModule.programSection.with(this.d2.programModule.trackedEntityAttribute.select(['id'])));
|
|
7358
7472
|
}
|
|
7359
|
-
if (!this.config.excludeProgramStages) {
|
|
7360
|
-
|
|
7473
|
+
if (!this.config.excludeProgramStages || this.config.programStage) {
|
|
7474
|
+
const programStageQuery = this.d2.programModule.programStage
|
|
7361
7475
|
.with(this.d2.programModule.programStageSection)
|
|
7362
|
-
.with(this.d2.programModule.programStageDataElement.with(this.d2.dataElementModule.dataElement.with(this.d2.optionSetModule.optionSet.with(this.d2.optionSetModule.option), 'ToOne'), 'ToOne'))
|
|
7476
|
+
.with(this.d2.programModule.programStageDataElement.with(this.d2.dataElementModule.dataElement.with(this.d2.optionSetModule.optionSet.with(this.d2.optionSetModule.option), 'ToOne'), 'ToOne'));
|
|
7477
|
+
programQuery.with(programStageQuery);
|
|
7363
7478
|
}
|
|
7364
7479
|
return programQuery.get();
|
|
7365
7480
|
}
|
|
@@ -7577,14 +7692,22 @@ class ProgramEntryFormModule {
|
|
|
7577
7692
|
}
|
|
7578
7693
|
async #saveInstance() {
|
|
7579
7694
|
switch (this.config().formType) {
|
|
7580
|
-
case 'TRACKER':
|
|
7695
|
+
case 'TRACKER': {
|
|
7696
|
+
if (this.config().autoComplete) {
|
|
7697
|
+
this.instance().complete();
|
|
7698
|
+
}
|
|
7581
7699
|
return this.instanceQuery
|
|
7582
7700
|
.setData(this.instance())
|
|
7583
7701
|
.save();
|
|
7584
|
-
|
|
7702
|
+
}
|
|
7703
|
+
case 'EVENT': {
|
|
7704
|
+
if (this.config().autoComplete) {
|
|
7705
|
+
this.instance().complete();
|
|
7706
|
+
}
|
|
7585
7707
|
return this.instanceQuery
|
|
7586
7708
|
.setData(this.instance())
|
|
7587
7709
|
.save();
|
|
7710
|
+
}
|
|
7588
7711
|
default:
|
|
7589
7712
|
return firstValueFrom(of(null));
|
|
7590
7713
|
}
|
|
@@ -7614,10 +7737,17 @@ class ProgramEntryFormModule {
|
|
|
7614
7737
|
.setEnrollment(this.enrollment())
|
|
7615
7738
|
.setTrackedEntity(this.trackedEntity())
|
|
7616
7739
|
.setOrgUnit(this.orgUnit());
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7740
|
+
if (!this.event()) {
|
|
7741
|
+
return await this.instanceQuery.create();
|
|
7742
|
+
}
|
|
7743
|
+
const instance = (await this.instanceQuery.setEvent(this.event()).get()).data;
|
|
7744
|
+
if (!instance) {
|
|
7745
|
+
return await this.instanceQuery.create();
|
|
7746
|
+
}
|
|
7747
|
+
if (this.metaData()?.program) {
|
|
7748
|
+
instance.setFields(this.metaData().program);
|
|
7749
|
+
}
|
|
7750
|
+
return instance;
|
|
7621
7751
|
}
|
|
7622
7752
|
#getInstance() {
|
|
7623
7753
|
switch (this.config().formType) {
|