@iapps/ng-dhis2-ui 1.2.155 → 1.2.157

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.
@@ -4300,7 +4300,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImpor
4300
4300
  type: Injectable
4301
4301
  }] });
4302
4302
 
4303
- const getTrackedEntityTableData = (response, programId, pager, metaData, searcheableDataElements) => {
4303
+ const getTrackedEntityTableData = (response, programId, pager, metaData, searcheableDataElements, customDisplayInReportsIds, columnNameSource = 'NAME') => {
4304
+ const getColumnLabel = (item) => columnNameSource === 'FORM_NAME'
4305
+ ? item?.formName || item?.name || 'Default'
4306
+ : item?.name || item?.formName || 'Default';
4304
4307
  const teisRaw = response.data
4305
4308
  .trackedEntityInstances;
4306
4309
  const teis = Array.isArray(teisRaw)
@@ -4312,16 +4315,19 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
4312
4315
  const attributeColumns = metaData.displayInListTrackedEntityAttributes
4313
4316
  .sort((a, b) => a.sortOrder - b.sortOrder)
4314
4317
  .map((trackedEntityAttribute) => ({
4315
- label: trackedEntityAttribute.name ?? trackedEntityAttribute.formName,
4318
+ label: getColumnLabel(trackedEntityAttribute),
4316
4319
  key: trackedEntityAttribute.id,
4317
4320
  }));
4321
+ const shouldIncludeDataElement = (psde) => customDisplayInReportsIds !== undefined
4322
+ ? customDisplayInReportsIds.includes(psde.dataElement?.id)
4323
+ : psde.displayInReports === true;
4318
4324
  const tableSearcheableDataElements = metaData
4319
4325
  .programStages.sort((a, b) => a.sortOrder - b.sortOrder)
4320
4326
  .flatMap((stage) => stage
4321
- .programStageDataElements.filter((psde) => psde.displayInReports)
4327
+ .programStageDataElements.filter(shouldIncludeDataElement)
4322
4328
  .sort((a, b) => a.sortOrder - b.sortOrder)
4323
4329
  .map((psde) => ({
4324
- label: psde.dataElement.name || psde.dataElement.formName || 'default',
4330
+ label: getColumnLabel(psde.dataElement),
4325
4331
  key: psde.dataElement.id,
4326
4332
  valueType: psde.dataElement.valueType,
4327
4333
  options: psde.dataElement.optionSet,
@@ -4331,19 +4337,32 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
4331
4337
  const dataElementColumns = metaData
4332
4338
  .programStages.sort((a, b) => a.sortOrder - b.sortOrder)
4333
4339
  .flatMap((stage) => stage
4334
- .programStageDataElements.filter((psde) => psde.displayInReports)
4340
+ .programStageDataElements.filter(shouldIncludeDataElement)
4335
4341
  .sort((a, b) => a.sortOrder - b.sortOrder)
4336
4342
  .map((psde) => ({
4337
- label: psde.dataElement.name || psde.dataElement.formName || 'default',
4343
+ label: getColumnLabel(psde.dataElement),
4338
4344
  key: psde.dataElement.id,
4339
4345
  })));
4340
- const dataElementOptions = metaData.displayInListDataElements.map((element) => ({
4341
- id: element.id,
4342
- options: element.optionSet?.options.map((opt) => ({
4343
- name: opt.name,
4344
- code: opt.code,
4345
- color: opt.style?.color,
4346
- })),
4346
+ // const dataElementOptions = metaData.displayInListDataElements.map(
4347
+ // (element) => ({
4348
+ // id: element.id,
4349
+ // options: element.optionSet?.options.map((opt) => ({
4350
+ // name: opt.name,
4351
+ // code: opt.code,
4352
+ // color: opt.style?.color,
4353
+ // })),
4354
+ // })
4355
+ // );
4356
+ const dataElementOptions = (metaData.programStages ?? [])
4357
+ .flatMap((stage) => stage.programStageDataElements ?? [])
4358
+ .filter((psde) => psde.dataElement && shouldIncludeDataElement(psde))
4359
+ .map(({ dataElement }) => ({
4360
+ id: dataElement.id,
4361
+ options: dataElement.optionSet?.options?.map((option) => ({
4362
+ name: option.name,
4363
+ code: option.code,
4364
+ color: option.style?.color,
4365
+ })) ?? [],
4347
4366
  }));
4348
4367
  const tableColumns = [
4349
4368
  {
@@ -4356,7 +4375,8 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
4356
4375
  const tableFilters = metaData.searchableTrackedEntityAttributes
4357
4376
  .sort((a, b) => a.sortOrder - b.sortOrder)
4358
4377
  .map((attr) => ({
4359
- label: attr.name,
4378
+ // label: attr.name,
4379
+ label: getColumnLabel(attr),
4360
4380
  key: attr.id,
4361
4381
  valueType: attr.valueType,
4362
4382
  options: attr.optionSet ?? undefined,
@@ -4576,7 +4596,10 @@ const addActionsColumn = (columns, actionOptions) => {
4576
4596
  ];
4577
4597
  };
4578
4598
 
4579
- const getEvents = (response, programStageId, pager, metaData) => {
4599
+ const getEvents = (response, programStageId, pager, metaData, columnNameSource = 'NAME') => {
4600
+ const getColumnLabel = (item) => columnNameSource === 'FORM_NAME'
4601
+ ? item?.formName || item?.name || 'Default'
4602
+ : item?.name || item?.formName || 'Default';
4580
4603
  const events = response.data.events;
4581
4604
  const eventsiiii = response.data;
4582
4605
  const allDataElements = new Set();
@@ -4596,7 +4619,9 @@ const getEvents = (response, programStageId, pager, metaData) => {
4596
4619
  const entityColumns = Array.from(allDataElements).map((dataElementId) => {
4597
4620
  const dataElementMeta = stageFromMetaData.programStageDataElements.find((psde) => psde.dataElement.id === dataElementId);
4598
4621
  return {
4599
- label: dataElementMeta?.dataElement.name || dataElementId,
4622
+ label: dataElementMeta
4623
+ ? getColumnLabel(dataElementMeta.dataElement)
4624
+ : dataElementId,
4600
4625
  key: dataElementId,
4601
4626
  };
4602
4627
  });
@@ -4646,6 +4671,7 @@ class LineListTableComponent extends ReactWrapperModule {
4646
4671
  this.showEnrollmentDates = true;
4647
4672
  this.showDownloadButton = false;
4648
4673
  this.searcheableDataElements = [];
4674
+ this.columnNameSource = 'NAME';
4649
4675
  this.reactStateUpdaters = null;
4650
4676
  this.setReactStateUpdaters = (updaters) => {
4651
4677
  this.reactStateUpdaters = updaters;
@@ -4771,7 +4797,7 @@ class LineListTableComponent extends ReactWrapperModule {
4771
4797
  pager: pager,
4772
4798
  // orgUnitsMap: fetchedOrgUnits,
4773
4799
  };
4774
- const { columns, data } = getEvents({ data: eventsResponse }, this.programStageId, pager, metaData);
4800
+ const { columns, data } = getEvents({ data: eventsResponse }, this.programStageId, pager, metaData, this.columnNameSource);
4775
4801
  // const filterableColumnIdsSet = new Set(
4776
4802
  // this.filterableColumnIds
4777
4803
  // );
@@ -4851,7 +4877,7 @@ class LineListTableComponent extends ReactWrapperModule {
4851
4877
  pager: pager,
4852
4878
  orgUnitsMap: fetchedOrgUnits,
4853
4879
  };
4854
- const { columns, data, filteredEntityColumns, orgUnitLabel } = getTrackedEntityTableData({ data: trackedEntityResponse }, this.programId, pager, metaData, this.searcheableDataElements);
4880
+ const { columns, data, filteredEntityColumns, orgUnitLabel } = getTrackedEntityTableData({ data: trackedEntityResponse }, this.programId, pager, metaData, this.searcheableDataElements, this.customDisplayInReportsIds, this.columnNameSource);
4855
4881
  setFilteredColumns((prev) => filteredEntityColumns.length > 0 ? filteredEntityColumns : prev);
4856
4882
  let updatedFilterableColumnIds;
4857
4883
  if (Array.isArray(this.filterableColumnIds) &&
@@ -5220,7 +5246,7 @@ class LineListTableComponent extends ReactWrapperModule {
5220
5246
  this.render();
5221
5247
  }
5222
5248
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: LineListTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
5223
- 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" }, 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"] }); }
5249
+ 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"] }); }
5224
5250
  }
5225
5251
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: LineListTableComponent, decorators: [{
5226
5252
  type: Component,
@@ -5285,6 +5311,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImpor
5285
5311
  type: Input
5286
5312
  }], searcheableDataElements: [{
5287
5313
  type: Input
5314
+ }], columnNameSource: [{
5315
+ type: Input
5316
+ }], customDisplayInReportsIds: [{
5317
+ type: Input
5288
5318
  }] } });
5289
5319
 
5290
5320
  class LineListModule {