@iapps/ng-dhis2-ui 1.2.165 → 1.2.167
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 +363 -94
- package/fesm2022/iapps-ng-dhis2-ui.mjs.map +1 -1
- package/index.d.ts +17 -3
- package/package.json +1 -1
|
@@ -4300,6 +4300,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImpor
|
|
|
4300
4300
|
type: Injectable
|
|
4301
4301
|
}] });
|
|
4302
4302
|
|
|
4303
|
+
const getOptionCode = (option) => option.code ?? option.value ?? option.id;
|
|
4304
|
+
const getMultiOptionCodes = (value) => {
|
|
4305
|
+
if (Array.isArray(value)) {
|
|
4306
|
+
return value
|
|
4307
|
+
.map((item) => String(item).trim())
|
|
4308
|
+
.filter((item) => item.length > 0);
|
|
4309
|
+
}
|
|
4310
|
+
if (typeof value !== 'string') {
|
|
4311
|
+
return value == null ? [] : [String(value)];
|
|
4312
|
+
}
|
|
4313
|
+
return value
|
|
4314
|
+
.split(/[;,]/)
|
|
4315
|
+
.map((item) => item.trim())
|
|
4316
|
+
.filter((item) => item.length > 0);
|
|
4317
|
+
};
|
|
4318
|
+
const formatMultiTextOptionValue = (value, options = []) => {
|
|
4319
|
+
const optionByCode = new Map(options
|
|
4320
|
+
.map((option) => [getOptionCode(option), option])
|
|
4321
|
+
.filter(([code]) => !!code));
|
|
4322
|
+
const codes = getMultiOptionCodes(value);
|
|
4323
|
+
return codes.map((code) => optionByCode.get(code)?.name || code).join(', ');
|
|
4324
|
+
};
|
|
4325
|
+
|
|
4303
4326
|
const getTrackedEntityTableData = (response, programId, pager, metaData, searcheableDataElements, customDisplayInReportsIds, columnNameSource = 'NAME') => {
|
|
4304
4327
|
const getColumnLabel = (item) => columnNameSource === 'FORM_NAME'
|
|
4305
4328
|
? item?.formName || item?.name || 'Default'
|
|
@@ -4359,6 +4382,7 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
|
|
|
4359
4382
|
.filter((psde) => psde.dataElement && shouldIncludeDataElement(psde))
|
|
4360
4383
|
.map(({ dataElement }) => ({
|
|
4361
4384
|
id: dataElement.id,
|
|
4385
|
+
valueType: dataElement.valueType,
|
|
4362
4386
|
options: dataElement.optionSet?.options?.map((option) => ({
|
|
4363
4387
|
name: option.name,
|
|
4364
4388
|
code: option.code,
|
|
@@ -4446,13 +4470,20 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
|
|
|
4446
4470
|
}
|
|
4447
4471
|
else if (attributeMeta?.optionSetValue &&
|
|
4448
4472
|
attributeMeta?.optionSet?.options) {
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4473
|
+
if (valueType === 'MULTI_TEXT') {
|
|
4474
|
+
row[attributeId] = {
|
|
4475
|
+
value: formatMultiTextOptionValue(value, attributeMeta.optionSet.options),
|
|
4476
|
+
};
|
|
4477
|
+
}
|
|
4478
|
+
else {
|
|
4479
|
+
const matchedOption = attributeMeta.optionSet.options.find((opt) => opt.code === value);
|
|
4480
|
+
row[attributeId] = {
|
|
4481
|
+
value: matchedOption?.name || value,
|
|
4482
|
+
...(getOptionColor(matchedOption) && {
|
|
4483
|
+
style: getOptionColor(matchedOption),
|
|
4484
|
+
}),
|
|
4485
|
+
};
|
|
4486
|
+
}
|
|
4456
4487
|
}
|
|
4457
4488
|
else {
|
|
4458
4489
|
row[attributeId] = { value };
|
|
@@ -4465,13 +4496,20 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
|
|
|
4465
4496
|
if (!dataElementId || value == null)
|
|
4466
4497
|
return;
|
|
4467
4498
|
const dataElementOption = dataElementOptionMap.get(dataElementId);
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4499
|
+
if (dataElementOption?.valueType === 'MULTI_TEXT') {
|
|
4500
|
+
row[dataElementId] = {
|
|
4501
|
+
value: formatMultiTextOptionValue(value, dataElementOption.options),
|
|
4502
|
+
};
|
|
4503
|
+
}
|
|
4504
|
+
else {
|
|
4505
|
+
const matchedOption = dataElementOption?.options?.find((opt) => opt.code === value);
|
|
4506
|
+
row[dataElementId] = {
|
|
4507
|
+
value: matchedOption?.name || value,
|
|
4508
|
+
...(getOptionColor(matchedOption) && {
|
|
4509
|
+
style: getOptionColor(matchedOption),
|
|
4510
|
+
}),
|
|
4511
|
+
};
|
|
4512
|
+
}
|
|
4475
4513
|
});
|
|
4476
4514
|
const orgUnitId = enrollment.orgUnit;
|
|
4477
4515
|
const orgUnitName = orgUnitMap?.get(orgUnitId) || '-';
|
|
@@ -4615,7 +4653,6 @@ const getEvents = (response, programStageId, pager, metaData, columnNameSource =
|
|
|
4615
4653
|
? item?.formName || item?.name || 'Default'
|
|
4616
4654
|
: item?.name || item?.formName || 'Default';
|
|
4617
4655
|
const events = response.data.events;
|
|
4618
|
-
const eventsiiii = response.data;
|
|
4619
4656
|
const allDataElements = new Set();
|
|
4620
4657
|
events.forEach((event) => {
|
|
4621
4658
|
event.dataValues.forEach((dv) => allDataElements.add(dv.dataElement));
|
|
@@ -4656,10 +4693,17 @@ const getEvents = (response, programStageId, pager, metaData, columnNameSource =
|
|
|
4656
4693
|
const dataElementMeta = stageFromMetaData.programStageDataElements.find((psde) => psde.dataElement.id === dv.dataElement);
|
|
4657
4694
|
if (dataElementMeta?.dataElement.optionSet) {
|
|
4658
4695
|
const optionSet = dataElementMeta.dataElement.optionSet;
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4696
|
+
if (dataElementMeta.dataElement.valueType === 'MULTI_TEXT') {
|
|
4697
|
+
row[dv.dataElement] = {
|
|
4698
|
+
value: formatMultiTextOptionValue(dv.value, optionSet.options),
|
|
4699
|
+
};
|
|
4700
|
+
}
|
|
4701
|
+
else {
|
|
4702
|
+
const matchingOption = optionSet.options.find((option) => option.code === dv.value);
|
|
4703
|
+
row[dv.dataElement] = matchingOption
|
|
4704
|
+
? { value: matchingOption.name }
|
|
4705
|
+
: { value: dv.value };
|
|
4706
|
+
}
|
|
4663
4707
|
}
|
|
4664
4708
|
else {
|
|
4665
4709
|
row[dv.dataElement] = { value: dv.value };
|
|
@@ -4670,6 +4714,141 @@ const getEvents = (response, programStageId, pager, metaData, columnNameSource =
|
|
|
4670
4714
|
return { columns: entityColumns, data: dataElementsData };
|
|
4671
4715
|
};
|
|
4672
4716
|
|
|
4717
|
+
const getCellValue = (cell) => {
|
|
4718
|
+
if (cell === null || cell === undefined)
|
|
4719
|
+
return '';
|
|
4720
|
+
if (typeof cell === 'object') {
|
|
4721
|
+
if ('value' in cell)
|
|
4722
|
+
return cell.value;
|
|
4723
|
+
return JSON.stringify(cell);
|
|
4724
|
+
}
|
|
4725
|
+
return cell;
|
|
4726
|
+
};
|
|
4727
|
+
const getExportColumns = (columns) => columns.filter((column) => column.label !== 'Actions');
|
|
4728
|
+
const downloadLineListExcel = (columns, data, fileName = 'records') => {
|
|
4729
|
+
const exportColumns = getExportColumns(columns);
|
|
4730
|
+
const header = exportColumns.map((column) => column.label);
|
|
4731
|
+
const rows = data.map((row) => exportColumns.map((column) => getCellValue(row[column.key])));
|
|
4732
|
+
const worksheet = XLSX.utils.aoa_to_sheet([header, ...rows]);
|
|
4733
|
+
const workbook = XLSX.utils.book_new();
|
|
4734
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, 'LineListData');
|
|
4735
|
+
XLSX.writeFile(workbook, `${fileName}.xlsx`);
|
|
4736
|
+
};
|
|
4737
|
+
const downloadLineListCsv = (columns, data, fileName = 'records') => {
|
|
4738
|
+
const exportColumns = getExportColumns(columns);
|
|
4739
|
+
const escapeCsvValue = (value) => `"${String(getCellValue(value)).replace(/"/g, '""')}"`;
|
|
4740
|
+
const header = exportColumns.map((column) => escapeCsvValue(column.label));
|
|
4741
|
+
const rows = data.map((row) => exportColumns.map((column) => escapeCsvValue(row[column.key])));
|
|
4742
|
+
const csvContent = [header, ...rows].map((row) => row.join(',')).join('\n');
|
|
4743
|
+
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
|
4744
|
+
const url = URL.createObjectURL(blob);
|
|
4745
|
+
const link = document.createElement('a');
|
|
4746
|
+
link.href = url;
|
|
4747
|
+
link.setAttribute('download', `${fileName}.csv`);
|
|
4748
|
+
document.body.appendChild(link);
|
|
4749
|
+
link.click();
|
|
4750
|
+
document.body.removeChild(link);
|
|
4751
|
+
URL.revokeObjectURL(url);
|
|
4752
|
+
};
|
|
4753
|
+
|
|
4754
|
+
const applyDownloadColumnFilter = (columns, filterableColumnIds) => {
|
|
4755
|
+
if (!Array.isArray(filterableColumnIds) || filterableColumnIds.length === 0) {
|
|
4756
|
+
return columns;
|
|
4757
|
+
}
|
|
4758
|
+
const filterableColumnIdsSet = new Set(filterableColumnIds);
|
|
4759
|
+
return columns.filter((column) => filterableColumnIdsSet.has(column.key));
|
|
4760
|
+
};
|
|
4761
|
+
const fetchLineListDownloadRows = async ({ d2, metaData, programId, programStageId, orgUnit, ouMode, startDate, endDate, dataQueryFilters, enrollmentStatus, eventStatus, filterableColumnIds, searcheableDataElements, customDisplayInReportsIds, columnNameSource, fetchOrgUnits, }) => {
|
|
4762
|
+
if (!metaData) {
|
|
4763
|
+
return { columns: [], data: [] };
|
|
4764
|
+
}
|
|
4765
|
+
const isTracker = metaData.programType === 'WITH_REGISTRATION';
|
|
4766
|
+
const isEvent = metaData.programType === 'WITHOUT_REGISTRATION';
|
|
4767
|
+
const downloadPager = new Pager({ paging: false });
|
|
4768
|
+
const resolvedEndDate = endDate ?? format(addDays(new Date(), 1), 'yyyy-MM-dd');
|
|
4769
|
+
if (programStageId || isEvent) {
|
|
4770
|
+
const eventQuery = d2.eventModule.event
|
|
4771
|
+
.setEndDate(resolvedEndDate)
|
|
4772
|
+
.setStartDate(startDate)
|
|
4773
|
+
.setProgram(programId)
|
|
4774
|
+
.setOrgUnit(orgUnit)
|
|
4775
|
+
.setOuMode(ouMode)
|
|
4776
|
+
.setPagination(downloadPager);
|
|
4777
|
+
if (programStageId) {
|
|
4778
|
+
eventQuery.setProgramStage(programStageId);
|
|
4779
|
+
}
|
|
4780
|
+
const response = await eventQuery.get();
|
|
4781
|
+
const events = Array.isArray(response.data)
|
|
4782
|
+
? response.data
|
|
4783
|
+
: response.data
|
|
4784
|
+
? [response.data]
|
|
4785
|
+
: [];
|
|
4786
|
+
const eventsResponse = {
|
|
4787
|
+
events,
|
|
4788
|
+
pager: new Pager({
|
|
4789
|
+
page: 1,
|
|
4790
|
+
pageSize: events.length || 1,
|
|
4791
|
+
}),
|
|
4792
|
+
};
|
|
4793
|
+
const downloadRows = getEvents({ data: eventsResponse }, programStageId || '', eventsResponse.pager, metaData, columnNameSource);
|
|
4794
|
+
return {
|
|
4795
|
+
columns: applyDownloadColumnFilter(downloadRows.columns, filterableColumnIds),
|
|
4796
|
+
data: downloadRows.data,
|
|
4797
|
+
};
|
|
4798
|
+
}
|
|
4799
|
+
if (isTracker) {
|
|
4800
|
+
const trackerQuery = d2.trackerModule.trackedEntity
|
|
4801
|
+
.setEndDate(resolvedEndDate)
|
|
4802
|
+
.setStartDate(startDate)
|
|
4803
|
+
.setProgram(programId)
|
|
4804
|
+
.setOrgUnit(orgUnit)
|
|
4805
|
+
.setOuMode(ouMode)
|
|
4806
|
+
.setStatus(enrollmentStatus)
|
|
4807
|
+
.setFilters(dataQueryFilters)
|
|
4808
|
+
.setPagination(downloadPager)
|
|
4809
|
+
.setOrderCriterias([
|
|
4810
|
+
new DataOrderCriteria().setField('createdAt').setOrder('desc'),
|
|
4811
|
+
]);
|
|
4812
|
+
if (eventStatus?.status && eventStatus?.programStage) {
|
|
4813
|
+
trackerQuery.setEventStatus(eventStatus.status, eventStatus.programStage);
|
|
4814
|
+
}
|
|
4815
|
+
if (programStageId) {
|
|
4816
|
+
trackerQuery.setProgramStage(programStageId);
|
|
4817
|
+
}
|
|
4818
|
+
const response = await trackerQuery.get();
|
|
4819
|
+
const trackedEntityInstances = Array.isArray(response.data)
|
|
4820
|
+
? response.data
|
|
4821
|
+
: response.data
|
|
4822
|
+
? [response.data]
|
|
4823
|
+
: [];
|
|
4824
|
+
const uniqueOrgUnitIds = Array.from(new Set(trackedEntityInstances
|
|
4825
|
+
.flatMap((tei) => [
|
|
4826
|
+
tei.latestEnrollment?.orgUnit,
|
|
4827
|
+
...(tei.attributes
|
|
4828
|
+
?.filter((attr) => attr.valueType === 'ORGANISATION_UNIT')
|
|
4829
|
+
.map((attr) => attr.value) || []),
|
|
4830
|
+
])
|
|
4831
|
+
.filter((orgUnitId) => !!orgUnitId)));
|
|
4832
|
+
const fetchedOrgUnits = uniqueOrgUnitIds.length > 0
|
|
4833
|
+
? await firstValueFrom(fetchOrgUnits(uniqueOrgUnitIds))
|
|
4834
|
+
: new Map();
|
|
4835
|
+
const trackedEntityResponse = {
|
|
4836
|
+
trackedEntityInstances,
|
|
4837
|
+
pager: new Pager({
|
|
4838
|
+
page: 1,
|
|
4839
|
+
pageSize: trackedEntityInstances.length || 1,
|
|
4840
|
+
}),
|
|
4841
|
+
orgUnitsMap: fetchedOrgUnits,
|
|
4842
|
+
};
|
|
4843
|
+
const downloadRows = getTrackedEntityTableData({ data: trackedEntityResponse }, programId, trackedEntityResponse.pager, metaData, searcheableDataElements, customDisplayInReportsIds, columnNameSource);
|
|
4844
|
+
return {
|
|
4845
|
+
columns: applyDownloadColumnFilter(downloadRows.columns, filterableColumnIds),
|
|
4846
|
+
data: downloadRows.data,
|
|
4847
|
+
};
|
|
4848
|
+
}
|
|
4849
|
+
return { columns: [], data: [] };
|
|
4850
|
+
};
|
|
4851
|
+
|
|
4673
4852
|
class LineListTableComponent extends ReactWrapperModule {
|
|
4674
4853
|
constructor() {
|
|
4675
4854
|
super(...arguments);
|
|
@@ -4718,6 +4897,7 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
4718
4897
|
const [endDateState, setEndDateState] = useState(this.endDate);
|
|
4719
4898
|
const [tempEndDateState, setTempEndDateState] = useState(this.endDate);
|
|
4720
4899
|
const [loading, setLoading] = useState(false);
|
|
4900
|
+
const [downloadLoading, setDownloadLoading] = useState(false);
|
|
4721
4901
|
const [filteredColumns, setFilteredColumns] = useState();
|
|
4722
4902
|
const [inputValues, setInputValues] = useState({});
|
|
4723
4903
|
const [orgUnitLabel, setOrgUnitLabel] = useState('');
|
|
@@ -4941,47 +5121,41 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
4941
5121
|
triggerRefetch,
|
|
4942
5122
|
triggerTokenState,
|
|
4943
5123
|
]);
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
const
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
:
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
return JSON.stringify(value);
|
|
5124
|
+
//TODO: ADD DOWNLOADING SUPPORT USING ANALYTICS
|
|
5125
|
+
const handleDownload = async (format) => {
|
|
5126
|
+
try {
|
|
5127
|
+
setDownloadLoading(true);
|
|
5128
|
+
const { columns, data } = await fetchLineListDownloadRows({
|
|
5129
|
+
d2,
|
|
5130
|
+
metaData,
|
|
5131
|
+
programId: programIdState,
|
|
5132
|
+
programStageId: programStageIdState,
|
|
5133
|
+
orgUnit: orgUnitState,
|
|
5134
|
+
ouMode: this.ouMode,
|
|
5135
|
+
startDate: startDateState,
|
|
5136
|
+
endDate: endDateState,
|
|
5137
|
+
dataQueryFilters: dataQueryFiltersState,
|
|
5138
|
+
enrollmentStatus: this.enrollmentStatus,
|
|
5139
|
+
eventStatus: this.eventStatus,
|
|
5140
|
+
filterableColumnIds: this.filterableColumnIds,
|
|
5141
|
+
searcheableDataElements: this.searcheableDataElements,
|
|
5142
|
+
customDisplayInReportsIds: this.customDisplayInReportsIds,
|
|
5143
|
+
columnNameSource: this.columnNameSource,
|
|
5144
|
+
fetchOrgUnits: (orgUnitIds) => this.lineListService.fetchOrgUnits(orgUnitIds),
|
|
5145
|
+
});
|
|
5146
|
+
if (format === 'CSV') {
|
|
5147
|
+
downloadLineListCsv(columns, data);
|
|
5148
|
+
return;
|
|
4970
5149
|
}
|
|
4971
|
-
|
|
4972
|
-
}
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
link.href = url;
|
|
4981
|
-
link.setAttribute('download', 'records.csv');
|
|
4982
|
-
document.body.appendChild(link);
|
|
4983
|
-
link.click();
|
|
4984
|
-
document.body.removeChild(link);
|
|
5150
|
+
downloadLineListExcel(columns, data);
|
|
5151
|
+
}
|
|
5152
|
+
catch (error) {
|
|
5153
|
+
console.error('Failed to download line list data:', error);
|
|
5154
|
+
setError('Could not download records. Please try again.');
|
|
5155
|
+
}
|
|
5156
|
+
finally {
|
|
5157
|
+
setDownloadLoading(false);
|
|
5158
|
+
}
|
|
4985
5159
|
};
|
|
4986
5160
|
const handleInputChange = (key, value, type) => {
|
|
4987
5161
|
setInputValues((prevValues) => ({
|
|
@@ -5117,7 +5291,7 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
5117
5291
|
// Returns black for light backgrounds, white for dark backgrounds
|
|
5118
5292
|
return yiq >= 128 ? colors$1.grey700 : '#FFFFFF';
|
|
5119
5293
|
}
|
|
5120
|
-
return React__default.createElement('div',
|
|
5294
|
+
return React__default.createElement('div', { className: 'line-list-root' }, loading
|
|
5121
5295
|
? React__default.createElement('div', {
|
|
5122
5296
|
style: {
|
|
5123
5297
|
display: 'flex',
|
|
@@ -5132,22 +5306,26 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
5132
5306
|
}, 'Loading'))
|
|
5133
5307
|
: React__default.createElement('div', null, this.showDownloadButton &&
|
|
5134
5308
|
React__default.createElement('div', {
|
|
5309
|
+
className: 'line-list-download-toolbar',
|
|
5135
5310
|
style: {
|
|
5136
5311
|
paddingBottom: '1rem',
|
|
5137
|
-
display: 'flex',
|
|
5138
|
-
justifyContent: 'flex-end',
|
|
5139
5312
|
},
|
|
5140
5313
|
}, React__default.createElement(DropdownButton, {
|
|
5141
5314
|
name: 'Download',
|
|
5315
|
+
disabled: downloadLoading,
|
|
5142
5316
|
component: React__default.createElement('span', null, ' ', React__default.createElement(MenuItem$1, {
|
|
5143
|
-
label: '
|
|
5144
|
-
|
|
5317
|
+
label: 'CSV',
|
|
5318
|
+
disabled: downloadLoading,
|
|
5319
|
+
onClick: () => handleDownload('CSV'),
|
|
5145
5320
|
}), React__default.createElement(MenuItem$1, {
|
|
5146
|
-
label: '
|
|
5147
|
-
|
|
5321
|
+
label: 'Excel',
|
|
5322
|
+
disabled: downloadLoading,
|
|
5323
|
+
onClick: () => handleDownload('XLSX'),
|
|
5148
5324
|
})),
|
|
5149
5325
|
value: 'Download',
|
|
5150
|
-
},
|
|
5326
|
+
}, downloadLoading
|
|
5327
|
+
? React__default.createElement(CircularLoader$1, { small: true })
|
|
5328
|
+
: 'Download')), orgUnitModalVisible &&
|
|
5151
5329
|
React__default.createElement(OrgUnitSelector, {
|
|
5152
5330
|
hide: hide,
|
|
5153
5331
|
setHide: setHide,
|
|
@@ -5200,7 +5378,7 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
5200
5378
|
prevSelectedOrgUnit: prevSelectedOrgUnit,
|
|
5201
5379
|
setPrevSelectedOrgUnit: setPrevSelectedOrgUnit,
|
|
5202
5380
|
// filteredFilters: filteredFilters
|
|
5203
|
-
}), React__default.createElement(LineListTable, {
|
|
5381
|
+
}), React__default.createElement('div', { className: 'line-list-table-scroll' }, React__default.createElement(LineListTable, {
|
|
5204
5382
|
columns: columns,
|
|
5205
5383
|
data: data,
|
|
5206
5384
|
pager: pager,
|
|
@@ -5214,7 +5392,7 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
5214
5392
|
rowsSelected: this.rowsSelected,
|
|
5215
5393
|
showActionButtons: showActionButtons,
|
|
5216
5394
|
error: error,
|
|
5217
|
-
})));
|
|
5395
|
+
}))));
|
|
5218
5396
|
};
|
|
5219
5397
|
}
|
|
5220
5398
|
ngOnChanges(changes) {
|
|
@@ -5263,11 +5441,11 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
5263
5441
|
this.render();
|
|
5264
5442
|
}
|
|
5265
5443
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: LineListTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
5266
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.3", type: LineListTableComponent, isStandalone: false, selector: "ng-dhis2-ui-line-list", inputs: { triggerToken: "triggerToken", programId: "programId", orgUnit: "orgUnit", programStageId: "programStageId", actionOptions: "actionOptions", actionOptionOrientation: "actionOptionOrientation", attributeFilters: "attributeFilters", useOuModeWithOlderDHIS2Instance: "useOuModeWithOlderDHIS2Instance", startDate: "startDate", endDate: "endDate", dataQueryFilters: "dataQueryFilters", lineListRowActionFilterConfig: "lineListRowActionFilterConfig", hydrateForActionFiltering: "hydrateForActionFiltering", ouMode: "ouMode", isButtonLoading: "isButtonLoading", buttonFilter: "buttonFilter", filterRootOrgUnit: "filterRootOrgUnit", showFilters: "showFilters", isOptionSetNameVisible: "isOptionSetNameVisible", allowRowsSelection: "allowRowsSelection", enrollmentStatus: "enrollmentStatus", filterableColumnIds: "filterableColumnIds", triggerRefetch: "triggerRefetch", eventStatus: "eventStatus", showActionButtons: "showActionButtons", showEnrollmentDates: "showEnrollmentDates", showDownloadButton: "showDownloadButton", searcheableDataElements: "searcheableDataElements", columnNameSource: "columnNameSource", customDisplayInReportsIds: "customDisplayInReportsIds" }, outputs: { actionSelected: "actionSelected", rowsSelected: "rowsSelected" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["@charset \"UTF-8\";::ng-deep .custom-input{display:flex!important;gap:4px!important;align-items:center!important;border:1px solid #9fadba!important;border-radius:4px!important;margin:0;padding:0 0 0 8px;background-color:#fff!important}::ng-deep .custom-input div{margin:0!important}::ng-deep .custom-input label{font-size:12px;padding-right:0}::ng-deep .custom-input input{border:none!important;font-size:12px!important;display:flex;align-items:center;padding-left:4px;height:40px;outline:none!important;box-shadow:none!important}::ng-deep .custom-input input:focus{border:none!important;box-shadow:none!important}::ng-deep .custom-input [data-test=calendar-clear-button]{background-color:#f2f2f2!important;color:#870808!important;border-radius:6px!important;padding:4px 10px!important;font-size:0!important}::ng-deep .custom-input [data-test=calendar-clear-button]:before{content:\"\\2715\";font-size:14px;color:#870808}::ng-deep .custom-input [data-test=calendar-clear-button]:hover{background-color:#ddd}::ng-deep .calendar-input-wrapper{position:relative}::ng-deep .calendar-input-wrapper .custom-input{position:relative;width:100%;display:flex;align-items:center}::ng-deep .calendar-input-wrapper [data-test=calendar-clear-button]{right:8px;bottom:14px;margin:auto;display:flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:0!important;background-color:#a0adba!important;border-radius:50%;padding:2px;cursor:pointer}::ng-deep .calendar-input-wrapper [data-test=calendar-clear-button]:before{content:\"\\2715\";font-size:10px;color:#f0f0f0}::ng-deep .calendar-input-wrapper input{padding-right:40px!important;height:40px;line-height:40px;box-sizing:border-box}::ng-deep .custom-input label{color:gray!important;opacity:1}::ng-deep .table-top-toolbar{background-color:var(--colors-grey100)!important;color:var(--colors-grey900)!important}::ng-deep .custom-select-input{display:flex!important;gap:4px!important;align-items:center!important;border:1px solid #9fadba!important;border-radius:4px!important;margin:0;padding:0 0 0 8px;background-color:#fff!important}::ng-deep .custom-select-input div{margin:0!important}::ng-deep .custom-select-input [data-test=dhis2-uiwidgets-singleselectfield-label]{font-size:12px;color:gray!important}::ng-deep .custom-select-input [data-test=dhis2-uicore-select-input]{border:none!important;font-size:12px!important;display:flex;align-items:center;padding-left:4px;height:40px;outline:none!important;box-shadow:none!important}::ng-deep .custom-select-input [data-test=dhis2-uicore-select-input]:focus-within{box-shadow:none!important}::ng-deep .custom-select-input input:focus{border:none!important;box-shadow:none!important}\n"] }); }
|
|
5444
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.3", type: LineListTableComponent, isStandalone: false, selector: "ng-dhis2-ui-line-list", inputs: { triggerToken: "triggerToken", programId: "programId", orgUnit: "orgUnit", programStageId: "programStageId", actionOptions: "actionOptions", actionOptionOrientation: "actionOptionOrientation", attributeFilters: "attributeFilters", useOuModeWithOlderDHIS2Instance: "useOuModeWithOlderDHIS2Instance", startDate: "startDate", endDate: "endDate", dataQueryFilters: "dataQueryFilters", lineListRowActionFilterConfig: "lineListRowActionFilterConfig", hydrateForActionFiltering: "hydrateForActionFiltering", ouMode: "ouMode", isButtonLoading: "isButtonLoading", buttonFilter: "buttonFilter", filterRootOrgUnit: "filterRootOrgUnit", showFilters: "showFilters", isOptionSetNameVisible: "isOptionSetNameVisible", allowRowsSelection: "allowRowsSelection", enrollmentStatus: "enrollmentStatus", filterableColumnIds: "filterableColumnIds", triggerRefetch: "triggerRefetch", eventStatus: "eventStatus", showActionButtons: "showActionButtons", showEnrollmentDates: "showEnrollmentDates", showDownloadButton: "showDownloadButton", searcheableDataElements: "searcheableDataElements", columnNameSource: "columnNameSource", customDisplayInReportsIds: "customDisplayInReportsIds" }, outputs: { actionSelected: "actionSelected", rowsSelected: "rowsSelected" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["@charset \"UTF-8\";::ng-deep .line-list-root{width:100%;max-width:100%;min-width:0}::ng-deep .line-list-download-toolbar{position:sticky;left:0;z-index:2;display:flex;justify-content:flex-end;width:100%;max-width:100%;box-sizing:border-box;background:#fff}::ng-deep .line-list-table-scroll{width:100%;max-width:100%;overflow-x:auto}::ng-deep .custom-input{display:flex!important;gap:4px!important;align-items:center!important;border:1px solid #9fadba!important;border-radius:4px!important;margin:0;padding:0 0 0 8px;background-color:#fff!important}::ng-deep .custom-input div{margin:0!important}::ng-deep .custom-input label{font-size:12px;padding-right:0}::ng-deep .custom-input input{border:none!important;font-size:12px!important;display:flex;align-items:center;padding-left:4px;height:40px;outline:none!important;box-shadow:none!important}::ng-deep .custom-input input:focus{border:none!important;box-shadow:none!important}::ng-deep .custom-input [data-test=calendar-clear-button]{background-color:#f2f2f2!important;color:#870808!important;border-radius:6px!important;padding:4px 10px!important;font-size:0!important}::ng-deep .custom-input [data-test=calendar-clear-button]:before{content:\"\\2715\";font-size:14px;color:#870808}::ng-deep .custom-input [data-test=calendar-clear-button]:hover{background-color:#ddd}::ng-deep .calendar-input-wrapper{position:relative}::ng-deep .calendar-input-wrapper .custom-input{position:relative;width:100%;display:flex;align-items:center}::ng-deep .calendar-input-wrapper [data-test=calendar-clear-button]{right:8px;bottom:14px;margin:auto;display:flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:0!important;background-color:#a0adba!important;border-radius:50%;padding:2px;cursor:pointer}::ng-deep .calendar-input-wrapper [data-test=calendar-clear-button]:before{content:\"\\2715\";font-size:10px;color:#f0f0f0}::ng-deep .calendar-input-wrapper input{padding-right:40px!important;height:40px;line-height:40px;box-sizing:border-box}::ng-deep .custom-input label{color:gray!important;opacity:1}::ng-deep .table-top-toolbar{background-color:var(--colors-grey100)!important;color:var(--colors-grey900)!important}::ng-deep .custom-select-input{display:flex!important;gap:4px!important;align-items:center!important;border:1px solid #9fadba!important;border-radius:4px!important;margin:0;padding:0 0 0 8px;background-color:#fff!important}::ng-deep .custom-select-input div{margin:0!important}::ng-deep .custom-select-input [data-test=dhis2-uiwidgets-singleselectfield-label]{font-size:12px;color:gray!important}::ng-deep .custom-select-input [data-test=dhis2-uicore-select-input]{border:none!important;font-size:12px!important;display:flex;align-items:center;padding-left:4px;height:40px;outline:none!important;box-shadow:none!important}::ng-deep .custom-select-input [data-test=dhis2-uicore-select-input]:focus-within{box-shadow:none!important}::ng-deep .custom-select-input input:focus{border:none!important;box-shadow:none!important}\n"] }); }
|
|
5267
5445
|
}
|
|
5268
5446
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: LineListTableComponent, decorators: [{
|
|
5269
5447
|
type: Component,
|
|
5270
|
-
args: [{ selector: 'ng-dhis2-ui-line-list', template: '<ng-content></ng-content>', standalone: false, styles: ["@charset \"UTF-8\";::ng-deep .custom-input{display:flex!important;gap:4px!important;align-items:center!important;border:1px solid #9fadba!important;border-radius:4px!important;margin:0;padding:0 0 0 8px;background-color:#fff!important}::ng-deep .custom-input div{margin:0!important}::ng-deep .custom-input label{font-size:12px;padding-right:0}::ng-deep .custom-input input{border:none!important;font-size:12px!important;display:flex;align-items:center;padding-left:4px;height:40px;outline:none!important;box-shadow:none!important}::ng-deep .custom-input input:focus{border:none!important;box-shadow:none!important}::ng-deep .custom-input [data-test=calendar-clear-button]{background-color:#f2f2f2!important;color:#870808!important;border-radius:6px!important;padding:4px 10px!important;font-size:0!important}::ng-deep .custom-input [data-test=calendar-clear-button]:before{content:\"\\2715\";font-size:14px;color:#870808}::ng-deep .custom-input [data-test=calendar-clear-button]:hover{background-color:#ddd}::ng-deep .calendar-input-wrapper{position:relative}::ng-deep .calendar-input-wrapper .custom-input{position:relative;width:100%;display:flex;align-items:center}::ng-deep .calendar-input-wrapper [data-test=calendar-clear-button]{right:8px;bottom:14px;margin:auto;display:flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:0!important;background-color:#a0adba!important;border-radius:50%;padding:2px;cursor:pointer}::ng-deep .calendar-input-wrapper [data-test=calendar-clear-button]:before{content:\"\\2715\";font-size:10px;color:#f0f0f0}::ng-deep .calendar-input-wrapper input{padding-right:40px!important;height:40px;line-height:40px;box-sizing:border-box}::ng-deep .custom-input label{color:gray!important;opacity:1}::ng-deep .table-top-toolbar{background-color:var(--colors-grey100)!important;color:var(--colors-grey900)!important}::ng-deep .custom-select-input{display:flex!important;gap:4px!important;align-items:center!important;border:1px solid #9fadba!important;border-radius:4px!important;margin:0;padding:0 0 0 8px;background-color:#fff!important}::ng-deep .custom-select-input div{margin:0!important}::ng-deep .custom-select-input [data-test=dhis2-uiwidgets-singleselectfield-label]{font-size:12px;color:gray!important}::ng-deep .custom-select-input [data-test=dhis2-uicore-select-input]{border:none!important;font-size:12px!important;display:flex;align-items:center;padding-left:4px;height:40px;outline:none!important;box-shadow:none!important}::ng-deep .custom-select-input [data-test=dhis2-uicore-select-input]:focus-within{box-shadow:none!important}::ng-deep .custom-select-input input:focus{border:none!important;box-shadow:none!important}\n"] }]
|
|
5448
|
+
args: [{ selector: 'ng-dhis2-ui-line-list', template: '<ng-content></ng-content>', standalone: false, styles: ["@charset \"UTF-8\";::ng-deep .line-list-root{width:100%;max-width:100%;min-width:0}::ng-deep .line-list-download-toolbar{position:sticky;left:0;z-index:2;display:flex;justify-content:flex-end;width:100%;max-width:100%;box-sizing:border-box;background:#fff}::ng-deep .line-list-table-scroll{width:100%;max-width:100%;overflow-x:auto}::ng-deep .custom-input{display:flex!important;gap:4px!important;align-items:center!important;border:1px solid #9fadba!important;border-radius:4px!important;margin:0;padding:0 0 0 8px;background-color:#fff!important}::ng-deep .custom-input div{margin:0!important}::ng-deep .custom-input label{font-size:12px;padding-right:0}::ng-deep .custom-input input{border:none!important;font-size:12px!important;display:flex;align-items:center;padding-left:4px;height:40px;outline:none!important;box-shadow:none!important}::ng-deep .custom-input input:focus{border:none!important;box-shadow:none!important}::ng-deep .custom-input [data-test=calendar-clear-button]{background-color:#f2f2f2!important;color:#870808!important;border-radius:6px!important;padding:4px 10px!important;font-size:0!important}::ng-deep .custom-input [data-test=calendar-clear-button]:before{content:\"\\2715\";font-size:14px;color:#870808}::ng-deep .custom-input [data-test=calendar-clear-button]:hover{background-color:#ddd}::ng-deep .calendar-input-wrapper{position:relative}::ng-deep .calendar-input-wrapper .custom-input{position:relative;width:100%;display:flex;align-items:center}::ng-deep .calendar-input-wrapper [data-test=calendar-clear-button]{right:8px;bottom:14px;margin:auto;display:flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:0!important;background-color:#a0adba!important;border-radius:50%;padding:2px;cursor:pointer}::ng-deep .calendar-input-wrapper [data-test=calendar-clear-button]:before{content:\"\\2715\";font-size:10px;color:#f0f0f0}::ng-deep .calendar-input-wrapper input{padding-right:40px!important;height:40px;line-height:40px;box-sizing:border-box}::ng-deep .custom-input label{color:gray!important;opacity:1}::ng-deep .table-top-toolbar{background-color:var(--colors-grey100)!important;color:var(--colors-grey900)!important}::ng-deep .custom-select-input{display:flex!important;gap:4px!important;align-items:center!important;border:1px solid #9fadba!important;border-radius:4px!important;margin:0;padding:0 0 0 8px;background-color:#fff!important}::ng-deep .custom-select-input div{margin:0!important}::ng-deep .custom-select-input [data-test=dhis2-uiwidgets-singleselectfield-label]{font-size:12px;color:gray!important}::ng-deep .custom-select-input [data-test=dhis2-uicore-select-input]{border:none!important;font-size:12px!important;display:flex;align-items:center;padding-left:4px;height:40px;outline:none!important;box-shadow:none!important}::ng-deep .custom-select-input [data-test=dhis2-uicore-select-input]:focus-within{box-shadow:none!important}::ng-deep .custom-select-input input:focus{border:none!important;box-shadow:none!important}\n"] }]
|
|
5271
5449
|
}], propDecorators: { triggerToken: [{
|
|
5272
5450
|
type: Input
|
|
5273
5451
|
}], programId: [{
|
|
@@ -9067,6 +9245,42 @@ class BaseFormFieldComponent extends ReactWrapperModule {
|
|
|
9067
9245
|
// ----------------------------
|
|
9068
9246
|
useEffect(() => {
|
|
9069
9247
|
const cascade = this.#resolveCascadeForCurrentField();
|
|
9248
|
+
const dependentField = field.dependentField;
|
|
9249
|
+
if (dependentField) {
|
|
9250
|
+
const parentCtrl = this.#getControl(fg, dependentField.key || dependentField.id);
|
|
9251
|
+
if (!parentCtrl) {
|
|
9252
|
+
setFilteredOptions([]);
|
|
9253
|
+
setDisabled(baseDisabled);
|
|
9254
|
+
return undefined;
|
|
9255
|
+
}
|
|
9256
|
+
const parentOptions = dependentField.options?.length > 0
|
|
9257
|
+
? dependentField.options
|
|
9258
|
+
: dependentField.optionSet?.options ?? [];
|
|
9259
|
+
const applyDependentOptions = (parentValue) => {
|
|
9260
|
+
const parentOption = parentOptions.find((option) => {
|
|
9261
|
+
const optionValue = option?.value ?? option?.code ?? option?.key;
|
|
9262
|
+
return optionValue === parentValue;
|
|
9263
|
+
});
|
|
9264
|
+
const nextOptions = parentOption?.options ?? [];
|
|
9265
|
+
const childCtrl = this.#getCurrentFieldControl(fg);
|
|
9266
|
+
const currentChildValue = String(childCtrl?.value ?? '').trim();
|
|
9267
|
+
if (currentChildValue) {
|
|
9268
|
+
const stillValid = nextOptions.some((option) => {
|
|
9269
|
+
const optionValue = String(option?.value ?? option?.code ?? option?.key ?? '');
|
|
9270
|
+
return optionValue === currentChildValue;
|
|
9271
|
+
});
|
|
9272
|
+
if (!stillValid) {
|
|
9273
|
+
childCtrl?.setValue(null, { emitEvent: true });
|
|
9274
|
+
setValue('');
|
|
9275
|
+
}
|
|
9276
|
+
}
|
|
9277
|
+
setFilteredOptions(nextOptions);
|
|
9278
|
+
setDisabled(baseDisabled || !parentValue);
|
|
9279
|
+
};
|
|
9280
|
+
applyDependentOptions(parentCtrl.value);
|
|
9281
|
+
const sub = parentCtrl.valueChanges.subscribe((value) => applyDependentOptions(value));
|
|
9282
|
+
return () => sub.unsubscribe();
|
|
9283
|
+
}
|
|
9070
9284
|
if (!cascade || cascade.kind !== 'OPTIONS_PATH') {
|
|
9071
9285
|
setFilteredOptions(field.options ?? []);
|
|
9072
9286
|
setDisabled(baseDisabled);
|
|
@@ -9905,7 +10119,8 @@ class FormComponent {
|
|
|
9905
10119
|
if (fieldToRemove) {
|
|
9906
10120
|
const form = this.form();
|
|
9907
10121
|
const currentValue = form.get(fieldToRemove.key)?.value;
|
|
9908
|
-
|
|
10122
|
+
const shouldPreserveValue = fieldToRemove.disabled || fieldToRemove.generated;
|
|
10123
|
+
if (currentValue != null && !shouldPreserveValue) {
|
|
9909
10124
|
form.get(fieldToRemove.key)?.setValue(null);
|
|
9910
10125
|
this.onFieldUpdate(form, fieldToRemove);
|
|
9911
10126
|
}
|
|
@@ -10013,6 +10228,7 @@ class FormField {
|
|
|
10013
10228
|
this.trackedEntityType = options.trackedEntityType;
|
|
10014
10229
|
this.hasOptions = options.hasOptions;
|
|
10015
10230
|
this.dependentField = options.dependentField;
|
|
10231
|
+
this.fieldOptionsDependsOn = options.fieldOptionsDependsOn;
|
|
10016
10232
|
this.displayInList = options.displayInList;
|
|
10017
10233
|
this.displayInReports = options.displayInReports;
|
|
10018
10234
|
this.searchable = options.searchable;
|
|
@@ -10098,10 +10314,13 @@ var FieldType;
|
|
|
10098
10314
|
|
|
10099
10315
|
class FieldDropdown {
|
|
10100
10316
|
constructor(params) {
|
|
10101
|
-
|
|
10102
|
-
this.
|
|
10103
|
-
this.
|
|
10104
|
-
this.
|
|
10317
|
+
const rawParams = params;
|
|
10318
|
+
this.key = params.key ?? rawParams.id ?? rawParams.code ?? rawParams.name;
|
|
10319
|
+
this.value = params.value ?? rawParams.code ?? rawParams.name;
|
|
10320
|
+
this.label =
|
|
10321
|
+
params.label ?? rawParams.name ?? rawParams.displayName ?? rawParams.code;
|
|
10322
|
+
this.order = params.order ?? rawParams.sortOrder;
|
|
10323
|
+
this.options = params.options?.map((option) => new FieldDropdown(option));
|
|
10105
10324
|
}
|
|
10106
10325
|
toJson() {
|
|
10107
10326
|
return {
|
|
@@ -10109,6 +10328,7 @@ class FieldDropdown {
|
|
|
10109
10328
|
value: this.value,
|
|
10110
10329
|
label: this.label,
|
|
10111
10330
|
order: this.order,
|
|
10331
|
+
options: this.options?.map((option) => option.toJson()),
|
|
10112
10332
|
};
|
|
10113
10333
|
}
|
|
10114
10334
|
static getDropdownOptions(field, locale, extension) {
|
|
@@ -10140,10 +10360,11 @@ class FieldDropdown {
|
|
|
10140
10360
|
}
|
|
10141
10361
|
return sortBy((field?.optionSet?.options || []).map((option) => {
|
|
10142
10362
|
return new FieldDropdown({
|
|
10143
|
-
key: option.id,
|
|
10144
|
-
value: option.code,
|
|
10145
|
-
label: option.name,
|
|
10363
|
+
key: option.id ?? option.code ?? option.name,
|
|
10364
|
+
value: option.code ?? option.value ?? option.name,
|
|
10365
|
+
label: option.name ?? option.label ?? option.code,
|
|
10146
10366
|
order: option.sortOrder,
|
|
10367
|
+
options: option.options,
|
|
10147
10368
|
});
|
|
10148
10369
|
}), 'order');
|
|
10149
10370
|
}
|
|
@@ -10204,6 +10425,9 @@ class FieldUtil {
|
|
|
10204
10425
|
}
|
|
10205
10426
|
static getFieldControlType(valueType, hasOptions) {
|
|
10206
10427
|
if (hasOptions) {
|
|
10428
|
+
if (valueType === FieldType.MULTI_TEXT) {
|
|
10429
|
+
return 'multi-dropdown';
|
|
10430
|
+
}
|
|
10207
10431
|
return 'dropdown';
|
|
10208
10432
|
}
|
|
10209
10433
|
switch (valueType) {
|
|
@@ -12345,9 +12569,10 @@ class ProgramStageEntryFormSectionUtil {
|
|
|
12345
12569
|
// }
|
|
12346
12570
|
class ProgramEntryFormSectionUtil {
|
|
12347
12571
|
#sortedCanonicalFieldsCache = null;
|
|
12348
|
-
constructor(program, config) {
|
|
12572
|
+
constructor(program, config, customFieldConfigurations = {}) {
|
|
12349
12573
|
this.program = program;
|
|
12350
12574
|
this.config = config;
|
|
12575
|
+
this.customFieldConfigurations = customFieldConfigurations;
|
|
12351
12576
|
this.fieldUtil = new ProgramEntryFormFieldUtil(program, config);
|
|
12352
12577
|
}
|
|
12353
12578
|
// get programEntryFormSections(): IProgramEntryFormSection[] {
|
|
@@ -12570,7 +12795,12 @@ class ProgramEntryFormSectionUtil {
|
|
|
12570
12795
|
sortOrder: programTrackedEntityAttribute.sortOrder,
|
|
12571
12796
|
optionSet: tea.optionSet,
|
|
12572
12797
|
};
|
|
12573
|
-
const
|
|
12798
|
+
const customConfiguration = this.customFieldConfigurations?.[iTrackedEntityFormFieldBase.id];
|
|
12799
|
+
const fieldWithCustomConfiguration = {
|
|
12800
|
+
...iTrackedEntityFormFieldBase,
|
|
12801
|
+
...(customConfiguration || {}),
|
|
12802
|
+
};
|
|
12803
|
+
const options = FieldDropdown.getDropdownOptions(fieldWithCustomConfiguration);
|
|
12574
12804
|
const hasOptions = (options?.length ?? 0) > 0;
|
|
12575
12805
|
const fieldExtension = this.config.formFieldExtensions?.find((formFieldExtension) => formFieldExtension?.id === iTrackedEntityFormFieldBase.id);
|
|
12576
12806
|
const autoAssignedValue = this.#getAutoAssignedValue(iTrackedEntityFormFieldBase);
|
|
@@ -12579,22 +12809,24 @@ class ProgramEntryFormSectionUtil {
|
|
|
12579
12809
|
return null;
|
|
12580
12810
|
}
|
|
12581
12811
|
return new FormField({
|
|
12582
|
-
id:
|
|
12583
|
-
code:
|
|
12584
|
-
label:
|
|
12585
|
-
|
|
12586
|
-
key:
|
|
12587
|
-
? camelCase(
|
|
12588
|
-
:
|
|
12589
|
-
required:
|
|
12590
|
-
type: FieldUtil.getFieldType(
|
|
12812
|
+
id: fieldWithCustomConfiguration.id,
|
|
12813
|
+
code: fieldWithCustomConfiguration.code,
|
|
12814
|
+
label: fieldWithCustomConfiguration.formName ||
|
|
12815
|
+
fieldWithCustomConfiguration.name,
|
|
12816
|
+
key: fieldWithCustomConfiguration.code
|
|
12817
|
+
? camelCase(fieldWithCustomConfiguration.code)
|
|
12818
|
+
: fieldWithCustomConfiguration.id,
|
|
12819
|
+
required: fieldWithCustomConfiguration.mandatory,
|
|
12820
|
+
type: FieldUtil.getFieldType(fieldWithCustomConfiguration.valueType),
|
|
12591
12821
|
options,
|
|
12592
12822
|
hasOptions,
|
|
12593
|
-
disabled: this.#getDisabledStatus(iTrackedEntityFormFieldBase) ||
|
|
12594
|
-
|
|
12595
|
-
|
|
12823
|
+
disabled: this.#getDisabledStatus(iTrackedEntityFormFieldBase) ||
|
|
12824
|
+
!!tea.generated,
|
|
12825
|
+
order: fieldWithCustomConfiguration.sortOrder,
|
|
12826
|
+
controlType: FieldUtil.getFieldControlType(fieldWithCustomConfiguration.valueType, hasOptions),
|
|
12596
12827
|
allowFutureDate: programTrackedEntityAttribute.allowFutureDate === true,
|
|
12597
12828
|
extension: fieldExtension,
|
|
12829
|
+
fieldOptionsDependsOn: fieldWithCustomConfiguration.fieldOptionsDependsOn,
|
|
12598
12830
|
generated: !!tea.generated,
|
|
12599
12831
|
unique: !!tea.unique,
|
|
12600
12832
|
pattern: tea.pattern,
|
|
@@ -12618,6 +12850,18 @@ class ProgramEntryFormSectionUtil {
|
|
|
12618
12850
|
continue;
|
|
12619
12851
|
fieldsByAttributeId.set(canonicalField.id, canonicalField);
|
|
12620
12852
|
}
|
|
12853
|
+
for (const [fieldId, field] of fieldsByAttributeId.entries()) {
|
|
12854
|
+
if (!field.fieldOptionsDependsOn)
|
|
12855
|
+
continue;
|
|
12856
|
+
const dependentField = fieldsByAttributeId.get(field.fieldOptionsDependsOn);
|
|
12857
|
+
if (!dependentField)
|
|
12858
|
+
continue;
|
|
12859
|
+
fieldsByAttributeId.set(fieldId, new FormField({
|
|
12860
|
+
...field,
|
|
12861
|
+
dependentField,
|
|
12862
|
+
controlType: 'dropdown',
|
|
12863
|
+
}));
|
|
12864
|
+
}
|
|
12621
12865
|
return fieldsByAttributeId;
|
|
12622
12866
|
}
|
|
12623
12867
|
}
|
|
@@ -12628,6 +12872,7 @@ class ProgramEntryFormSectionUtil {
|
|
|
12628
12872
|
class ProgramEntryFormMetaData {
|
|
12629
12873
|
constructor() {
|
|
12630
12874
|
this.d2 = window?.d2Web;
|
|
12875
|
+
this.customFieldConfigurations = {};
|
|
12631
12876
|
}
|
|
12632
12877
|
setConfig(config) {
|
|
12633
12878
|
this.config = config;
|
|
@@ -12826,7 +13071,7 @@ class ProgramEntryFormMetaData {
|
|
|
12826
13071
|
if (displayType !== 'FLAT') {
|
|
12827
13072
|
return [];
|
|
12828
13073
|
}
|
|
12829
|
-
const baseSections = new ProgramEntryFormSectionUtil(this.program, this.config).programEntryFormSections;
|
|
13074
|
+
const baseSections = new ProgramEntryFormSectionUtil(this.program, this.config, this.customFieldConfigurations).programEntryFormSections;
|
|
12830
13075
|
const autoAssigned = this.config?.autoAssignedValues;
|
|
12831
13076
|
if (!autoAssigned?.length) {
|
|
12832
13077
|
return baseSections;
|
|
@@ -12908,13 +13153,37 @@ class ProgramEntryFormMetaData {
|
|
|
12908
13153
|
sections,
|
|
12909
13154
|
programStageSections,
|
|
12910
13155
|
rules: this.rules,
|
|
13156
|
+
customFieldConfigurations: this.customFieldConfigurations,
|
|
12911
13157
|
};
|
|
12912
13158
|
}
|
|
13159
|
+
async #getCustomFieldConfigurations() {
|
|
13160
|
+
try {
|
|
13161
|
+
const response = await this.d2.httpInstance.get('dataStore/field-extensions?fields=id,fieldOptionsDependsOn,optionSet&paging=false');
|
|
13162
|
+
const entries = response?.data?.['entries'];
|
|
13163
|
+
if (!Array.isArray(entries)) {
|
|
13164
|
+
return {};
|
|
13165
|
+
}
|
|
13166
|
+
return entries.reduce((fieldConfigurations, fieldConfiguration) => {
|
|
13167
|
+
if (!fieldConfiguration?.id) {
|
|
13168
|
+
return fieldConfigurations;
|
|
13169
|
+
}
|
|
13170
|
+
return {
|
|
13171
|
+
...fieldConfigurations,
|
|
13172
|
+
[fieldConfiguration.id]: fieldConfiguration,
|
|
13173
|
+
};
|
|
13174
|
+
}, {});
|
|
13175
|
+
}
|
|
13176
|
+
catch {
|
|
13177
|
+
return {};
|
|
13178
|
+
}
|
|
13179
|
+
}
|
|
12913
13180
|
async get() {
|
|
12914
13181
|
try {
|
|
12915
13182
|
const program = await this.#getProgramMetaData();
|
|
12916
13183
|
if (program) {
|
|
12917
13184
|
this.program = program;
|
|
13185
|
+
this.customFieldConfigurations =
|
|
13186
|
+
await this.#getCustomFieldConfigurations();
|
|
12918
13187
|
if (this.config?.formFieldExtensions &&
|
|
12919
13188
|
this.config.formFieldExtensions.length > 0 &&
|
|
12920
13189
|
this.config.formFieldExtensions[0]?.optionsSourceCode) {
|