@iapps/ng-dhis2-ui 1.1.37 → 1.1.40

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.
@@ -25,7 +25,7 @@ import { Layer } from '@dhis2-ui/layer';
25
25
  import { CircularLoader } from '@dhis2-ui/loader';
26
26
  import { MenuItem, MenuDivider } from '@dhis2-ui/menu';
27
27
  import parse from 'html-react-parser';
28
- import { Button as Button$1, IconDimensionData16, IconClock16, IconDimensionOrgUnit16, spacers as spacers$1, colors as colors$1, IconEdit16, theme as theme$1, Tooltip, SingleSelectField, SingleSelectOption, InputField as InputField$1, TabBar, Tab, Transfer, Modal as Modal$1, ModalTitle as ModalTitle$1, ModalContent as ModalContent$1, ModalActions as ModalActions$1, ButtonStrip as ButtonStrip$1, Checkbox, OrganisationUnitTree, MultiSelect, MultiSelectOption, IconWarningFilled16, Layer as Layer$1, Popper, FlyoutMenu, MenuItem as MenuItem$1, IconMore24, CircularLoader as CircularLoader$1, DataTable, TableHead, DataTableRow, DataTableColumnHeader, TableBody, DataTableCell, TableFoot, Pagination, FileInputField, FileListItem, MultiSelectField, TextAreaField } from '@dhis2/ui';
28
+ import { Button as Button$1, IconDimensionData16, IconClock16, IconDimensionOrgUnit16, spacers as spacers$1, colors as colors$1, IconEdit16, theme as theme$1, Tooltip, SingleSelectField, SingleSelectOption, InputField as InputField$1, TabBar, Tab, Transfer, Modal as Modal$1, ModalTitle as ModalTitle$1, ModalContent as ModalContent$1, ModalActions as ModalActions$1, ButtonStrip as ButtonStrip$1, Checkbox, OrganisationUnitTree, MultiSelect, MultiSelectOption, IconWarningFilled16, Layer as Layer$1, Popper, FlyoutMenu, MenuItem as MenuItem$1, IconMore24, CircularLoader as CircularLoader$1, IconFilter16, DataTable, TableHead, DataTableRow, DataTableColumnHeader, TableBody, DataTableCell, TableFoot, Pagination, FileInputField, FileListItem, MultiSelectField, TextAreaField } from '@dhis2/ui';
29
29
  import { getNowInCalendar, generateFixedPeriods } from '@dhis2/multi-calendar-dates';
30
30
  import { isObject, isString, sortBy, isArray, find, camelCase, flatten, head, isEmpty } from 'lodash';
31
31
  import cx from 'classnames';
@@ -3327,7 +3327,8 @@ const addActionsColumn = (columns, actionOptions) => {
3327
3327
  class LineListTableComponent extends ReactWrapperModule {
3328
3328
  constructor() {
3329
3329
  super(...arguments);
3330
- this.showApprovalButton = false;
3330
+ this.dispatchTeis = false;
3331
+ this.showFilterButton = false;
3331
3332
  this.actionSelected = new EventEmitter();
3332
3333
  this.reactStateUpdaters = null;
3333
3334
  this.approvalSelected = new EventEmitter();
@@ -3357,6 +3358,7 @@ class LineListTableComponent extends ReactWrapperModule {
3357
3358
  const [isButtonLoading, setIsButtonLoading] = useState(this.isButtonLoading);
3358
3359
  const [filteredColumns, setFilteredColumns] = useState();
3359
3360
  const [inputValues, setInputValues] = useState({});
3361
+ const [filters, setFilters] = useState(false);
3360
3362
  // Store updaters in refs for Angular to access
3361
3363
  const updateRefs = useRef({
3362
3364
  setProgramIdState,
@@ -3476,15 +3478,6 @@ class LineListTableComponent extends ReactWrapperModule {
3476
3478
  }
3477
3479
  });
3478
3480
  };
3479
- // const handleInputChange = (key: string, value: string) => {
3480
- // setInputValues((prevValues) => ({
3481
- // ...prevValues,
3482
- // [key]: value ?? '', // Ensure no undefined values
3483
- // }));
3484
- // };
3485
- // if (!filteredColumns || filteredColumns.length === 0) {
3486
- // return <div>No fields available</div>;
3487
- // }
3488
3481
  const handleInputChange = (key, value) => {
3489
3482
  setInputValues((prevValues) => ({
3490
3483
  ...prevValues,
@@ -3500,42 +3493,9 @@ class LineListTableComponent extends ReactWrapperModule {
3500
3493
  // console.log(`Updated Filters:`, updatedFilters); // Debugging
3501
3494
  return updatedFilters;
3502
3495
  });
3503
- // setAttributeFiltersState((prevFilters = []) => {
3504
- // // Check if attribute already exists
3505
- // const existingFilterIndex = prevFilters.findIndex(
3506
- // (f) => f.attribute === key
3507
- // );
3508
- // // Create a new filter object
3509
- // const newFilter = { attribute: key, operator: 'like', value };
3510
- // if (existingFilterIndex !== -1) {
3511
- // // If attribute exists, update its value
3512
- // const updatedFilters = [...prevFilters];
3513
- // updatedFilters[existingFilterIndex] = newFilter;
3514
- // console.log(`Updated Filters:`, updatedFilters); // Log updated filter list
3515
- // return updatedFilters;
3516
- // } else {
3517
- // // If attribute doesn't exist, add a new object
3518
- // return [...prevFilters, newFilter];
3519
- // }
3520
- // });
3521
3496
  };
3522
- // console.log(
3523
- // 'these are the filtered columns which have the attributes neede',
3524
- // filteredColumns
3525
- // );
3526
3497
  return (React__default.createElement("div", null,
3527
- React__default.createElement("div", { style: { display: 'flex', gap: '10px', flexWrap: 'wrap' } }, (filteredColumns ?? []).map(({ label, key }) => (React__default.createElement(InputField$1, { key: key, label: label, value: inputValues[key] || '', onChange: (e) => {
3528
- // console.log(`Event for key "${key}":`, e);
3529
- // Check if it's a standard event with target.value
3530
- if ('target' in e && e.target) {
3531
- handleInputChange(key, e.target.value);
3532
- }
3533
- // Check if it's a DHIS2 UI event with direct value
3534
- else if ('value' in e) {
3535
- handleInputChange(key, e.value ?? '');
3536
- }
3537
- } })))),
3538
- this.showApprovalButton && (React__default.createElement("div", { style: {
3498
+ React__default.createElement("div", { style: {
3539
3499
  width: '100%',
3540
3500
  display: 'flex',
3541
3501
  justifyContent: 'flex-end',
@@ -3543,7 +3503,45 @@ class LineListTableComponent extends ReactWrapperModule {
3543
3503
  gap: 8,
3544
3504
  padding: 8,
3545
3505
  marginBottom: 16,
3546
- } }, isButtonLoading ? (React__default.createElement(CircularLoader$1, { small: true })) : (React__default.createElement(Button$1, { className: "bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600", onClick: handleApprovalClick, primary: true }, this.buttonLabel)))),
3506
+ } },
3507
+ this.dispatchTeis &&
3508
+ (isButtonLoading ? (React__default.createElement(CircularLoader$1, { small: true })) : (React__default.createElement(Button$1, { style: {
3509
+ backgroundColor: '#3b82f6', // Blue color
3510
+ color: 'white',
3511
+ padding: '8px 16px',
3512
+ borderRadius: '4px',
3513
+ cursor: 'pointer',
3514
+ }, onClick: handleApprovalClick, primary: true }, this.buttonLabel))),
3515
+ this.showFilterButton && (React__default.createElement(Button$1, { style: {
3516
+ backgroundColor: '#6b7280', // Gray color
3517
+ color: 'white',
3518
+ padding: '8px 16px',
3519
+ borderRadius: '4px',
3520
+ cursor: 'pointer',
3521
+ display: 'flex',
3522
+ alignItems: 'center',
3523
+ gap: 8,
3524
+ }, onClick: () => {
3525
+ setFilters(!filters);
3526
+ }, secondary: true },
3527
+ React__default.createElement(IconFilter16, null),
3528
+ filters ? 'Hide Filters' : 'Show Filters'))),
3529
+ filters && (React__default.createElement("div", { style: {
3530
+ display: 'flex',
3531
+ gap: '10px',
3532
+ flexWrap: 'wrap',
3533
+ paddingBottom: '16px',
3534
+ } }, (filteredColumns ?? []).map(({ label, key }) => (React__default.createElement(InputField$1, { key: key, label: label, value: inputValues[key] || '', onChange: (e) => {
3535
+ console.log(`Event for key "${key}":`, e);
3536
+ // Check if it's a standard event with target.value
3537
+ if ('target' in e && e.target) {
3538
+ handleInputChange(key, e.target.value);
3539
+ }
3540
+ // Check if it's an event with direct value
3541
+ else if ('value' in e) {
3542
+ handleInputChange(key, e.value ?? '');
3543
+ }
3544
+ } }))))),
3547
3545
  loading ? (React__default.createElement("div", { style: {
3548
3546
  display: 'flex',
3549
3547
  alignItems: 'center',
@@ -3611,7 +3609,7 @@ class LineListTableComponent extends ReactWrapperModule {
3611
3609
  this.render();
3612
3610
  }
3613
3611
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LineListTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
3614
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: LineListTableComponent, isStandalone: false, selector: "app-line-list", inputs: { programId: "programId", orgUnit: "orgUnit", programStageId: "programStageId", actionOptions: "actionOptions", attributeFilters: "attributeFilters", startDate: "startDate", endDate: "endDate", filters: "filters", ouMode: "ouMode", showApprovalButton: "showApprovalButton", isButtonLoading: "isButtonLoading", buttonLabel: "buttonLabel" }, outputs: { actionSelected: "actionSelected", approvalSelected: "approvalSelected" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["[data-test=dhis2-uiwidgets-pagination]{display:flex!important;flex-direction:row!important;justify-content:space-between!important;align-items:center!important}\n"] }); }
3612
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: LineListTableComponent, isStandalone: false, selector: "app-line-list", inputs: { programId: "programId", orgUnit: "orgUnit", programStageId: "programStageId", actionOptions: "actionOptions", attributeFilters: "attributeFilters", startDate: "startDate", endDate: "endDate", filters: "filters", ouMode: "ouMode", dispatchTeis: "dispatchTeis", showFilterButton: "showFilterButton", isButtonLoading: "isButtonLoading", buttonLabel: "buttonLabel" }, outputs: { actionSelected: "actionSelected", approvalSelected: "approvalSelected" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["[data-test=dhis2-uiwidgets-pagination]{display:flex!important;flex-direction:row!important;justify-content:space-between!important;align-items:center!important}\n"] }); }
3615
3613
  }
3616
3614
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LineListTableComponent, decorators: [{
3617
3615
  type: Component,
@@ -3634,7 +3632,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
3634
3632
  type: Input
3635
3633
  }], ouMode: [{
3636
3634
  type: Input
3637
- }], showApprovalButton: [{
3635
+ }], dispatchTeis: [{
3636
+ type: Input
3637
+ }], showFilterButton: [{
3638
3638
  type: Input
3639
3639
  }], actionSelected: [{
3640
3640
  type: Output