@iapps/ng-dhis2-ui 1.1.75 → 1.1.77

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.
@@ -3577,7 +3577,7 @@ class LineListService {
3577
3577
  ? `&ouMode=${ouMode}`
3578
3578
  : `&orgUnitMode=${ouMode}`;
3579
3579
  return this.httpClient
3580
- .get(`tracker/trackedEntities.json?program=${programId}&orgUnit=${orgUnit}${ouModeIdentifier}&page=${page}&pageSize=${pageSize}&fields=trackedEntity,orgUnit,attributes[*],enrollments[*]&totalPages=true&${filterParams}&${filterParamsFromEvents}${dateFilter}&order=createdAt:desc`)
3580
+ .get(`tracker/trackedEntities.json?program=${programId}&orgUnit=${orgUnit}${ouModeIdentifier}&page=${page}&pageSize=${pageSize}&fields=trackedEntity,orgUnit,attributes[*],enrollments[*]&totalPages=true&${filterParams}${dateFilter}&order=createdAt:desc`)
3581
3581
  .pipe(switchMap((response) => {
3582
3582
  if (filterRootOrgUnit) {
3583
3583
  response.trackedEntities = response.trackedEntities.filter((tei) => tei.orgUnit !== orgUnit);
@@ -3955,7 +3955,39 @@ const getTrackedEntityData = (response, programId, pager, isOptionSetNameVisible
3955
3955
  key: attr.id,
3956
3956
  }));
3957
3957
  const searchableKeys = new Set(searchableAttributes.map((attr) => attr.key));
3958
- const filteredEntityColumns = entityColumns.filter((column) => searchableKeys.has(column.key));
3958
+ const filteredEntityColumns = Array.from(allAttributes)
3959
+ .map((attrId) => {
3960
+ const foundAttribute = teis
3961
+ .flatMap((tei) => {
3962
+ const matchingEnrollment = tei.enrollments.find((enrollment) => enrollment.program === programId);
3963
+ return matchingEnrollment
3964
+ ? matchingEnrollment.attributes
3965
+ : tei.attributes;
3966
+ })
3967
+ .find((attr) => attr.attribute === attrId);
3968
+ // Find the corresponding attribute in mappedProgramMetadataAttributes
3969
+ const mappedAttr = mappedProgramMetadataAttributes.find((attr) => attr.id === attrId);
3970
+ return {
3971
+ label: foundAttribute?.displayName || attrId,
3972
+ key: attrId,
3973
+ valueType: foundAttribute?.valueType,
3974
+ options: mappedAttr?.optionSet ?? undefined
3975
+ };
3976
+ })
3977
+ .filter((column) => {
3978
+ return mappedProgramMetadataAttributes
3979
+ .filter((attr) => attr.displayInList)
3980
+ .some((attr) => attr.id === column.key);
3981
+ })
3982
+ .sort((a, b) => {
3983
+ const sortOrderA = Number(mappedProgramMetadataAttributes.find((attr) => attr.id === a.key)
3984
+ ?.sortOrder ?? 0);
3985
+ const sortOrderB = Number(mappedProgramMetadataAttributes.find((attr) => attr.id === b.key)
3986
+ ?.sortOrder ?? 0);
3987
+ return sortOrderA - sortOrderB;
3988
+ })
3989
+ .filter((column) => searchableKeys.has(column.key));
3990
+ console.log('filtered entity columns', filteredEntityColumns);
3959
3991
  const attributesData = teis.map((tei, idx) => {
3960
3992
  const row = {
3961
3993
  trackedEntityInstance: tei.trackedEntity,
@@ -4029,6 +4061,7 @@ const getTrackedEntityData = (response, programId, pager, isOptionSetNameVisible
4029
4061
  })),
4030
4062
  ];
4031
4063
  }
4064
+ console.log('filtered entity columns', filteredEntityColumns);
4032
4065
  return {
4033
4066
  columns: entityColumns,
4034
4067
  data: attributesData,
@@ -4181,6 +4214,7 @@ class LineListTableComponent extends ReactWrapperModule {
4181
4214
  : (filteredColumns ?? []).slice(0, 2);
4182
4215
  const defaultOrgUnit = this.orgUnit;
4183
4216
  const [prevValue, setPrevValue] = useState();
4217
+ const [dateStates, setDateStates] = useState({});
4184
4218
  // Store updaters in refs for Angular to access
4185
4219
  const updateRefs = useRef({
4186
4220
  setProgramIdState,
@@ -4269,7 +4303,7 @@ class LineListTableComponent extends ReactWrapperModule {
4269
4303
  setIsButtonLoading(true);
4270
4304
  const subscription = this.lineListService
4271
4305
  .getLineListData(this.programId, this.orgUnit, this.programStageId, pager.page, 1000, this.attributeFilters, this.startDate, this.endDate, this.ouMode)
4272
- .pipe(take(1)) // Ensures the observable emits only once
4306
+ .pipe(take(1))
4273
4307
  .subscribe((response) => {
4274
4308
  if ('trackedEntities' in response.data ||
4275
4309
  'instances' in response.data) {
@@ -4285,16 +4319,16 @@ class LineListTableComponent extends ReactWrapperModule {
4285
4319
  }
4286
4320
  : null;
4287
4321
  })
4288
- .filter(Boolean); // Removes null entries
4322
+ .filter(Boolean);
4289
4323
  this.approvalSelected.emit(teiEnrollmentList);
4290
4324
  }
4291
4325
  else {
4292
- this.approvalSelected.emit([]); // Emit empty array if no TEIs
4326
+ this.approvalSelected.emit([]);
4293
4327
  }
4294
- setIsButtonLoading(false); // Stop loading after processing
4328
+ setIsButtonLoading(false);
4295
4329
  });
4296
4330
  return () => {
4297
- subscription.unsubscribe(); // Cleanup to avoid potential memory leaks
4331
+ subscription.unsubscribe();
4298
4332
  };
4299
4333
  };
4300
4334
  const handleInputChange = (key, value) => {
@@ -4312,6 +4346,27 @@ class LineListTableComponent extends ReactWrapperModule {
4312
4346
  return updatedFilters;
4313
4347
  });
4314
4348
  };
4349
+ const handleDateSelect = (key, selectedDate) => {
4350
+ const selectedDateString = selectedDate?.calendarDateString ?? ''; // Default to empty string if null
4351
+ // Update dateStates
4352
+ setDateStates((prevDateStates) => ({
4353
+ ...prevDateStates,
4354
+ [key]: selectedDateString, // Will set it to empty if date is cleared
4355
+ }));
4356
+ // Update attributeFiltersState to remove filter if date is cleared
4357
+ setAttributeFiltersState((prevFilters = []) => {
4358
+ // Remove old filter for this key if the date is empty
4359
+ const filteredFilters = prevFilters.filter((f) => f.attribute !== key);
4360
+ // Only add a filter if the date is not empty
4361
+ const updatedFilters = selectedDateString.trim()
4362
+ ? [
4363
+ ...filteredFilters,
4364
+ { attribute: key, operator: 'like', value: selectedDateString },
4365
+ ]
4366
+ : filteredFilters; // If empty, just keep the filteredFilters as they are
4367
+ return updatedFilters;
4368
+ });
4369
+ };
4315
4370
  return (React__default.createElement("div", null,
4316
4371
  React__default.createElement("div", null, valueMatch &&
4317
4372
  this.dispatchTeis &&
@@ -4367,54 +4422,52 @@ class LineListTableComponent extends ReactWrapperModule {
4367
4422
  React__default.createElement(CalendarInput, { label: "End date:", calendar: "gregory", locale: "en-GB", timeZone: "Africa/Dar_es_Salaam", className: "custom-input", date: endDateState, onDateSelect: (selectedDate) => {
4368
4423
  setEndDateState(selectedDate.calendarDateString);
4369
4424
  } }),
4370
- (visibleFilters ?? []).map(({ label, key }) => (React__default.createElement(InputField$1, { key: key, label: `${label}:`, className: "custom-input", value: inputValues[key] || '', clearable: true, onChange: (e) => {
4371
- let currentValue = '';
4372
- if ('target' in e && e.target) {
4373
- currentValue = e.target.value;
4374
- }
4375
- else if ('value' in e) {
4376
- currentValue = e.value ?? '';
4377
- }
4378
- setInputValues((prevValues) => ({
4379
- ...prevValues,
4380
- [key]: currentValue,
4381
- }));
4382
- // Trigger change immediately if the input is cleared
4383
- if (currentValue === '') {
4384
- handleInputChange(key, '');
4385
- }
4386
- },
4387
- // onChange={(
4388
- // e:
4389
- // | React.ChangeEvent<HTMLInputElement>
4390
- // | { value?: string }
4391
- // ) => {
4392
- // if ('target' in e && e.target) {
4393
- // setInputValues((prevValues) => ({
4394
- // ...prevValues,
4395
- // [key]: (e as React.ChangeEvent<HTMLInputElement>)
4396
- // .target.value,
4397
- // }));
4398
- // } else if ('value' in e) {
4399
- // setInputValues((prevValues) => ({
4400
- // ...prevValues,
4401
- // [key]: e.value ?? '',
4402
- // }));
4403
- // }
4404
- // }}
4405
- onBlur: (e) => {
4406
- let currentValue = '';
4407
- if ('target' in e && e.target) {
4408
- currentValue = e.target.value;
4409
- }
4410
- else if ('value' in e) {
4411
- currentValue = e.value ?? '';
4412
- }
4413
- if (currentValue !== '' && currentValue !== prevValue) {
4414
- handleInputChange(key, currentValue);
4415
- setPrevValue(currentValue);
4416
- }
4417
- } }))),
4425
+ (visibleFilters ?? []).map(({ label, key, valueType, options }) => {
4426
+ // Render CalendarInput for DATE fields
4427
+ if (valueType === 'DATE') {
4428
+ return (React__default.createElement(CalendarInput, { key: key, label: `${label}:`, calendar: "gregory", locale: "en-GB", timeZone: "Africa/Dar_es_Salaam", className: "custom-input", date: dateStates[key] || '', onDateSelect: (selectedDate) => handleDateSelect(key, selectedDate) }));
4429
+ }
4430
+ // Render SingleSelectField if options exist
4431
+ if (options && options.options.length > 0) {
4432
+ return (React__default.createElement(SingleSelectField, { key: key, label: `${label}:`, selected: inputValues[key] || '', className: "custom-select-input", clearable: true, onChange: ({ selected }) => {
4433
+ setInputValues((prevValues) => ({
4434
+ ...prevValues,
4435
+ [key]: selected ?? '',
4436
+ }));
4437
+ handleInputChange(key, selected ?? '');
4438
+ } }, (options.options ?? []).map((opt) => (React__default.createElement(SingleSelectOption, { key: opt.id, label: opt.name, value: opt.code })))));
4439
+ }
4440
+ // Fallback: default InputField
4441
+ return (React__default.createElement(InputField$1, { key: key, label: `${label}:`, className: "custom-input", value: inputValues[key] || '', clearable: true, onChange: (e) => {
4442
+ let currentValue = '';
4443
+ if ('target' in e && e.target) {
4444
+ currentValue = e.target.value;
4445
+ }
4446
+ else if ('value' in e) {
4447
+ currentValue = e.value ?? '';
4448
+ }
4449
+ setInputValues((prevValues) => ({
4450
+ ...prevValues,
4451
+ [key]: currentValue,
4452
+ }));
4453
+ if (currentValue === '') {
4454
+ handleInputChange(key, '');
4455
+ }
4456
+ }, onBlur: (e) => {
4457
+ let currentValue = '';
4458
+ if ('target' in e && e.target) {
4459
+ currentValue = e.target.value;
4460
+ }
4461
+ else if ('value' in e) {
4462
+ currentValue = e.value ?? '';
4463
+ }
4464
+ if (currentValue !== '' &&
4465
+ currentValue !== prevValue) {
4466
+ handleInputChange(key, currentValue);
4467
+ setPrevValue(currentValue);
4468
+ }
4469
+ } }));
4470
+ }),
4418
4471
  React__default.createElement(Button$1, { onClick: () => setShowAllFilters(!showAllFilters) }, showAllFilters ? 'Less Filters' : 'More Filters')))),
4419
4472
  React__default.createElement(DataTable, null,
4420
4473
  React__default.createElement(TableHead, null,
@@ -4484,11 +4537,11 @@ class LineListTableComponent extends ReactWrapperModule {
4484
4537
  this.render();
4485
4538
  }
4486
4539
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LineListTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
4487
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: LineListTableComponent, isStandalone: false, selector: "ng-dhis2-ui-line-list", inputs: { programId: "programId", orgUnit: "orgUnit", programStageId: "programStageId", actionOptions: "actionOptions", actionOptionOrientation: "actionOptionOrientation", attributeFilters: "attributeFilters", useOuModeWithOlderDHIS2Instance: "useOuModeWithOlderDHIS2Instance", startDate: "startDate", endDate: "endDate", filters: "filters", ouMode: "ouMode", dispatchTeis: "dispatchTeis", isButtonLoading: "isButtonLoading", buttonLabel: "buttonLabel", buttonFilter: "buttonFilter", filterRootOrgUnit: "filterRootOrgUnit", showFilters: "showFilters", isOptionSetNameVisible: "isOptionSetNameVisible" }, outputs: { actionSelected: "actionSelected", approvalSelected: "approvalSelected", firstValue: "firstValue" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["::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 label{color:gray!important;opacity:1}::ng-deep .table-top-toolbar{background-color:var(--colors-grey100)!important;color:var(--colors-grey900)!important}\n"] }); }
4540
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: LineListTableComponent, isStandalone: false, selector: "ng-dhis2-ui-line-list", inputs: { programId: "programId", orgUnit: "orgUnit", programStageId: "programStageId", actionOptions: "actionOptions", actionOptionOrientation: "actionOptionOrientation", attributeFilters: "attributeFilters", useOuModeWithOlderDHIS2Instance: "useOuModeWithOlderDHIS2Instance", startDate: "startDate", endDate: "endDate", filters: "filters", ouMode: "ouMode", dispatchTeis: "dispatchTeis", isButtonLoading: "isButtonLoading", buttonLabel: "buttonLabel", buttonFilter: "buttonFilter", filterRootOrgUnit: "filterRootOrgUnit", showFilters: "showFilters", isOptionSetNameVisible: "isOptionSetNameVisible" }, outputs: { actionSelected: "actionSelected", approvalSelected: "approvalSelected", firstValue: "firstValue" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["::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 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"] }); }
4488
4541
  }
4489
4542
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LineListTableComponent, decorators: [{
4490
4543
  type: Component,
4491
- args: [{ selector: 'ng-dhis2-ui-line-list', template: '<ng-content></ng-content>', standalone: false, styles: ["::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 label{color:gray!important;opacity:1}::ng-deep .table-top-toolbar{background-color:var(--colors-grey100)!important;color:var(--colors-grey900)!important}\n"] }]
4544
+ args: [{ selector: 'ng-dhis2-ui-line-list', template: '<ng-content></ng-content>', standalone: false, styles: ["::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 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"] }]
4492
4545
  }], propDecorators: { programId: [{
4493
4546
  type: Input
4494
4547
  }], orgUnit: [{