@iapps/ng-dhis2-ui 1.1.2 → 1.1.3
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 +366 -16
- package/fesm2022/iapps-ng-dhis2-ui.mjs.map +1 -1
- package/index.d.ts +2 -0
- package/lib/modules/data-table-ui/components/dropdown-menu/dropdown-menu.d.ts +19 -0
- package/lib/modules/data-table-ui/components/dropdown-menu/dropdown-menu.styles.d.ts +5 -0
- package/lib/modules/data-table-ui/components/dropdown-menu/index.d.ts +1 -0
- package/lib/modules/data-table-ui/containers/data-table-ui/data-table-ui.component.d.ts +19 -0
- package/lib/modules/data-table-ui/data-table-ui.module.d.ts +10 -0
- package/lib/modules/data-table-ui/hooks/index.d.ts +1 -0
- package/lib/modules/data-table-ui/hooks/use-dynamic-styles.hook.d.ts +1 -0
- package/lib/modules/data-table-ui/index.d.ts +3 -0
- package/lib/modules/data-table-ui/models/data-table.models.d.ts +10 -0
- package/lib/modules/form/utils/field-type.util.d.ts +1 -1
- package/lib/modules/form/utils/field.util.d.ts +1 -1
- package/lib/modules/selection-filters-ui/containers/selection-filters-ui/selection-filters-ui.component.d.ts +20 -0
- package/lib/modules/selection-filters-ui/index.d.ts +2 -0
- package/lib/modules/selection-filters-ui/models/selection-filters-ui.model.d.ts +36 -0
- package/lib/modules/selection-filters-ui/selection-filters-ui.module.d.ts +10 -0
- package/package.json +1 -1
|
@@ -2948,25 +2948,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
|
|
|
2948
2948
|
// Use of this source code is governed by a BSD-style
|
|
2949
2949
|
// license that can be found in the LICENSE file.
|
|
2950
2950
|
|
|
2951
|
-
const dropdownStyles = {
|
|
2951
|
+
const dropdownStyles$1 = {
|
|
2952
2952
|
layer: {
|
|
2953
2953
|
zIndex: '1 !important',
|
|
2954
2954
|
},
|
|
2955
2955
|
};
|
|
2956
2956
|
|
|
2957
2957
|
// Helper function to generate a unique class name
|
|
2958
|
-
const generateClassName = (base) => `${base}-${Math.random().toString(36).substr(2, 9)}`;
|
|
2958
|
+
const generateClassName$1 = (base) => `${base}-${Math.random().toString(36).substr(2, 9)}`;
|
|
2959
2959
|
// Helper function to convert camelCased properties to hyphenated CSS properties
|
|
2960
|
-
const convertStylesToCSS = (className, styles) => {
|
|
2960
|
+
const convertStylesToCSS$1 = (className, styles) => {
|
|
2961
2961
|
let cssString = `.${className} {`;
|
|
2962
2962
|
for (const key in styles) {
|
|
2963
2963
|
if (typeof styles[key] === "object" && key.startsWith("@media")) {
|
|
2964
|
-
const mediaStyles = convertStylesToCSS(className, styles[key]);
|
|
2964
|
+
const mediaStyles = convertStylesToCSS$1(className, styles[key]);
|
|
2965
2965
|
cssString += `${key} { ${mediaStyles} }`;
|
|
2966
2966
|
}
|
|
2967
2967
|
else if (key.startsWith("&:")) {
|
|
2968
2968
|
const pseudoClass = key.replace("&", "");
|
|
2969
|
-
cssString += `${pseudoClass} { ${convertStylesToCSS("", styles[key])} }`;
|
|
2969
|
+
cssString += `${pseudoClass} { ${convertStylesToCSS$1("", styles[key])} }`;
|
|
2970
2970
|
}
|
|
2971
2971
|
else {
|
|
2972
2972
|
const cssKey = key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
@@ -2977,13 +2977,13 @@ const convertStylesToCSS = (className, styles) => {
|
|
|
2977
2977
|
return cssString;
|
|
2978
2978
|
};
|
|
2979
2979
|
// Custom hook for dynamic styles with generics
|
|
2980
|
-
const useDynamicStyles = (stylesObj) => {
|
|
2980
|
+
const useDynamicStyles$1 = (stylesObj) => {
|
|
2981
2981
|
const [classNames, setClassNames] = useState({});
|
|
2982
2982
|
useEffect(() => {
|
|
2983
2983
|
const convertedStyles = Object.keys(stylesObj).map((key) => {
|
|
2984
|
-
const className = generateClassName(key);
|
|
2984
|
+
const className = generateClassName$1(key);
|
|
2985
2985
|
const styleElement = document.createElement("style");
|
|
2986
|
-
styleElement.innerHTML = convertStylesToCSS(className, stylesObj[key]);
|
|
2986
|
+
styleElement.innerHTML = convertStylesToCSS$1(className, stylesObj[key]);
|
|
2987
2987
|
document.head.appendChild(styleElement);
|
|
2988
2988
|
return {
|
|
2989
2989
|
key,
|
|
@@ -3006,7 +3006,7 @@ const useDynamicStyles = (stylesObj) => {
|
|
|
3006
3006
|
return classNames;
|
|
3007
3007
|
};
|
|
3008
3008
|
|
|
3009
|
-
const useCurrentModal = () => {
|
|
3009
|
+
const useCurrentModal$1 = () => {
|
|
3010
3010
|
const [CurrentModal, setCurrentModal] = useState();
|
|
3011
3011
|
return [
|
|
3012
3012
|
CurrentModal,
|
|
@@ -3017,10 +3017,10 @@ const useCurrentModal = () => {
|
|
|
3017
3017
|
},
|
|
3018
3018
|
];
|
|
3019
3019
|
};
|
|
3020
|
-
const ContextMenu = (params) => {
|
|
3020
|
+
const ContextMenu$1 = (params) => {
|
|
3021
3021
|
const { onClose, onMenuClick, anchorRef, dropDownOptions } = params;
|
|
3022
|
-
const [CurrentModal, setCurrentModal] = useCurrentModal();
|
|
3023
|
-
const styles = useDynamicStyles(dropdownStyles);
|
|
3022
|
+
const [CurrentModal, setCurrentModal] = useCurrentModal$1();
|
|
3023
|
+
const styles = useDynamicStyles$1(dropdownStyles$1);
|
|
3024
3024
|
return (React__default.createElement(React__default.Fragment, null,
|
|
3025
3025
|
React__default.createElement(Layer$1, { onBackdropClick: (event, data) => onClose(event, data), className: styles.layer },
|
|
3026
3026
|
React__default.createElement(Popper, { reference: anchorRef, placement: "bottom-start" },
|
|
@@ -3033,13 +3033,13 @@ const ContextMenu = (params) => {
|
|
|
3033
3033
|
setCurrentModal(null);
|
|
3034
3034
|
} }))));
|
|
3035
3035
|
};
|
|
3036
|
-
const DropdownMenu = (props) => {
|
|
3036
|
+
const DropdownMenu$1 = (props) => {
|
|
3037
3037
|
const ref = useRef();
|
|
3038
3038
|
const [visible, setVisible] = useState(false);
|
|
3039
3039
|
const { dropdownOptions, onClick } = props;
|
|
3040
3040
|
return (React__default.createElement("div", { ref: ref, style: { display: "inline-block" } },
|
|
3041
3041
|
React__default.createElement(Button$1, { small: true, secondary: true, icon: React__default.createElement(IconMore24, { color: colors$1.grey600 }), onClick: () => setVisible(true) }),
|
|
3042
|
-
visible && (React__default.createElement(ContextMenu, { dropDownOptions: dropdownOptions, anchorRef: ref, onClose: () => setVisible(false), onMenuClick: (dropDownOption) => {
|
|
3042
|
+
visible && (React__default.createElement(ContextMenu$1, { dropDownOptions: dropdownOptions, anchorRef: ref, onClose: () => setVisible(false), onMenuClick: (dropDownOption) => {
|
|
3043
3043
|
onClick(dropDownOption);
|
|
3044
3044
|
} }))));
|
|
3045
3045
|
};
|
|
@@ -3397,7 +3397,7 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
3397
3397
|
} }, "Loading"))) : (React__default.createElement(DataTable, null,
|
|
3398
3398
|
React__default.createElement(TableHead, null,
|
|
3399
3399
|
React__default.createElement(DataTableRow, null, columns.map((col) => (React__default.createElement(DataTableColumnHeader, { key: col.key }, col.label))))),
|
|
3400
|
-
React__default.createElement(TableBody, null, data.map((row) => (React__default.createElement(DataTableRow, { key: row.index }, columns.map((col) => (React__default.createElement(DataTableCell, { key: col.key }, col.key === 'actions' ? (React__default.createElement(DropdownMenu, { dropdownOptions: getDropdownOptions(row), onClick: (option) => option.onClick?.() })) : (row[col.key])))))))),
|
|
3400
|
+
React__default.createElement(TableBody, null, data.map((row) => (React__default.createElement(DataTableRow, { key: row.index }, columns.map((col) => (React__default.createElement(DataTableCell, { key: col.key }, col.key === 'actions' ? (React__default.createElement(DropdownMenu$1, { dropdownOptions: getDropdownOptions(row), onClick: (option) => option.onClick?.() })) : (row[col.key])))))))),
|
|
3401
3401
|
React__default.createElement(TableFoot, null,
|
|
3402
3402
|
React__default.createElement(DataTableRow, null,
|
|
3403
3403
|
React__default.createElement(DataTableCell, { colSpan: columns.length.toString() },
|
|
@@ -3484,6 +3484,186 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
|
|
|
3484
3484
|
}]
|
|
3485
3485
|
}] });
|
|
3486
3486
|
|
|
3487
|
+
const dropdownStyles = {
|
|
3488
|
+
layer: {
|
|
3489
|
+
zIndex: '1 !important',
|
|
3490
|
+
},
|
|
3491
|
+
};
|
|
3492
|
+
|
|
3493
|
+
// Helper function to generate a unique class name
|
|
3494
|
+
const generateClassName = (base) => `${base}-${Math.random().toString(36).substr(2, 9)}`;
|
|
3495
|
+
// Helper function to convert camelCased properties to hyphenated CSS properties
|
|
3496
|
+
const convertStylesToCSS = (className, styles) => {
|
|
3497
|
+
let cssString = `.${className} {`;
|
|
3498
|
+
for (const key in styles) {
|
|
3499
|
+
if (typeof styles[key] === "object" && key.startsWith("@media")) {
|
|
3500
|
+
const mediaStyles = convertStylesToCSS(className, styles[key]);
|
|
3501
|
+
cssString += `${key} { ${mediaStyles} }`;
|
|
3502
|
+
}
|
|
3503
|
+
else if (key.startsWith("&:")) {
|
|
3504
|
+
const pseudoClass = key.replace("&", "");
|
|
3505
|
+
cssString += `${pseudoClass} { ${convertStylesToCSS("", styles[key])} }`;
|
|
3506
|
+
}
|
|
3507
|
+
else {
|
|
3508
|
+
const cssKey = key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
3509
|
+
cssString += `${cssKey}: ${styles[key]}; `;
|
|
3510
|
+
}
|
|
3511
|
+
}
|
|
3512
|
+
cssString += "}";
|
|
3513
|
+
return cssString;
|
|
3514
|
+
};
|
|
3515
|
+
// Custom hook for dynamic styles with generics
|
|
3516
|
+
const useDynamicStyles = (stylesObj) => {
|
|
3517
|
+
const [classNames, setClassNames] = useState({});
|
|
3518
|
+
useEffect(() => {
|
|
3519
|
+
const convertedStyles = Object.keys(stylesObj).map((key) => {
|
|
3520
|
+
const className = generateClassName(key);
|
|
3521
|
+
const styleElement = document.createElement("style");
|
|
3522
|
+
styleElement.innerHTML = convertStylesToCSS(className, stylesObj[key]);
|
|
3523
|
+
document.head.appendChild(styleElement);
|
|
3524
|
+
return {
|
|
3525
|
+
key,
|
|
3526
|
+
className,
|
|
3527
|
+
styleElement,
|
|
3528
|
+
};
|
|
3529
|
+
});
|
|
3530
|
+
setClassNames(convertedStyles.reduce((classNameEntity, convertedStyle) => {
|
|
3531
|
+
return {
|
|
3532
|
+
...classNameEntity,
|
|
3533
|
+
[convertedStyle.key]: convertedStyle.className,
|
|
3534
|
+
};
|
|
3535
|
+
}, {}));
|
|
3536
|
+
return () => {
|
|
3537
|
+
convertedStyles.forEach((convertedStyle) => {
|
|
3538
|
+
document.head.removeChild(convertedStyle.styleElement);
|
|
3539
|
+
});
|
|
3540
|
+
};
|
|
3541
|
+
}, []);
|
|
3542
|
+
return classNames;
|
|
3543
|
+
};
|
|
3544
|
+
|
|
3545
|
+
const useCurrentModal = () => {
|
|
3546
|
+
const [CurrentModal, setCurrentModal] = useState();
|
|
3547
|
+
return [
|
|
3548
|
+
CurrentModal,
|
|
3549
|
+
(Modal) => {
|
|
3550
|
+
// As setState supports functional updates, we can't pass functional
|
|
3551
|
+
// components directly
|
|
3552
|
+
setCurrentModal(() => Modal);
|
|
3553
|
+
},
|
|
3554
|
+
];
|
|
3555
|
+
};
|
|
3556
|
+
const ContextMenu = (params) => {
|
|
3557
|
+
const { onClose, onMenuClick, anchorRef, dropDownOptions } = params;
|
|
3558
|
+
const [CurrentModal, setCurrentModal] = useCurrentModal();
|
|
3559
|
+
const styles = useDynamicStyles(dropdownStyles);
|
|
3560
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
3561
|
+
React__default.createElement(Layer$1, { onBackdropClick: (event, data) => onClose(event, data), className: styles.layer },
|
|
3562
|
+
React__default.createElement(Popper, { reference: anchorRef, placement: "bottom-start" },
|
|
3563
|
+
React__default.createElement(FlyoutMenu, null, dropDownOptions.map((dropDownOption, index) => (React__default.createElement(MenuItem$1, { key: index, destructive: dropDownOption.destructive, label: dropDownOption.label, icon: dropDownOption.icon, onClick: () => {
|
|
3564
|
+
onMenuClick(dropDownOption);
|
|
3565
|
+
onClose();
|
|
3566
|
+
}, dense: true })))))),
|
|
3567
|
+
CurrentModal && (React__default.createElement(CurrentModal, { onClose: () => {
|
|
3568
|
+
onClose();
|
|
3569
|
+
setCurrentModal(null);
|
|
3570
|
+
} }))));
|
|
3571
|
+
};
|
|
3572
|
+
const DropdownMenu = (props) => {
|
|
3573
|
+
const ref = useRef();
|
|
3574
|
+
const [visible, setVisible] = useState(false);
|
|
3575
|
+
const { dropdownOptions, onClick } = props;
|
|
3576
|
+
return (React__default.createElement("div", { ref: ref, style: { display: "inline-block" } },
|
|
3577
|
+
React__default.createElement(Button$1, { small: true, secondary: true, icon: React__default.createElement(IconMore24, { color: colors$1.grey600 }), onClick: () => setVisible(true) }),
|
|
3578
|
+
visible && (React__default.createElement(ContextMenu, { dropDownOptions: dropdownOptions, anchorRef: ref, onClose: () => setVisible(false), onMenuClick: (dropDownOption) => {
|
|
3579
|
+
onClick(dropDownOption);
|
|
3580
|
+
} }))));
|
|
3581
|
+
};
|
|
3582
|
+
|
|
3583
|
+
class DataTableUIComponent extends ReactWrapperModule {
|
|
3584
|
+
constructor() {
|
|
3585
|
+
super(...arguments);
|
|
3586
|
+
this.actionSelected = new EventEmitter();
|
|
3587
|
+
this.DataTableUI = () => {
|
|
3588
|
+
const [columns, setColumns] = useState([]);
|
|
3589
|
+
const [tableData, setTableData] = useState([]);
|
|
3590
|
+
useEffect(() => {
|
|
3591
|
+
if (!this.data || !this.columnDefinitions)
|
|
3592
|
+
return;
|
|
3593
|
+
const filteredColumns = this.columnDefinitions.filter((col) => col.visible !== false);
|
|
3594
|
+
const sortedColumns = filteredColumns.sort((a, b) => {
|
|
3595
|
+
const indexA = Number(a.index) || 0;
|
|
3596
|
+
const indexB = Number(b.index) || 0;
|
|
3597
|
+
return indexA - indexB;
|
|
3598
|
+
});
|
|
3599
|
+
setColumns(sortedColumns);
|
|
3600
|
+
setTableData(this.data);
|
|
3601
|
+
}, [this.data, this.columnDefinitions]);
|
|
3602
|
+
const getDropdownOptions = (row) => {
|
|
3603
|
+
return (this.actionOptions || []).map((option) => ({
|
|
3604
|
+
...option,
|
|
3605
|
+
onClick: () => {
|
|
3606
|
+
// Ensure the onClick is called with the correct context
|
|
3607
|
+
if (option.onClick) {
|
|
3608
|
+
option.onClick(row); // Passing row to the handler
|
|
3609
|
+
}
|
|
3610
|
+
this.actionSelected.emit({ action: option.label, row }); // Emit action and row details
|
|
3611
|
+
},
|
|
3612
|
+
}));
|
|
3613
|
+
};
|
|
3614
|
+
return (React__default.createElement("div", null,
|
|
3615
|
+
React__default.createElement(DataTable, null,
|
|
3616
|
+
React__default.createElement(TableHead, null,
|
|
3617
|
+
React__default.createElement(DataTableRow, null,
|
|
3618
|
+
columns.map((col) => (React__default.createElement(DataTableColumnHeader, { key: col.column }, col.display))),
|
|
3619
|
+
this.actionOptions && this.actionOptions.length > 0 && (React__default.createElement(DataTableColumnHeader, null, "Actions")))),
|
|
3620
|
+
React__default.createElement(TableBody, null, tableData.map((row, rowIndex) => (React__default.createElement(DataTableRow, { key: rowIndex },
|
|
3621
|
+
columns.map((col) => (React__default.createElement(DataTableCell, { key: col.column }, row[col.column] || '-'))),
|
|
3622
|
+
this.actionOptions && this.actionOptions.length > 0 && (React__default.createElement(DataTableCell, null,
|
|
3623
|
+
React__default.createElement(DropdownMenu, { dropdownOptions: getDropdownOptions(row), onClick: (option) => option.onClick?.(row) }))))))),
|
|
3624
|
+
React__default.createElement(TableFoot, null,
|
|
3625
|
+
React__default.createElement(DataTableRow, null,
|
|
3626
|
+
React__default.createElement(DataTableCell, { colSpan: columns.length + 1 }))))));
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3629
|
+
async ngAfterViewInit() {
|
|
3630
|
+
if (!this.elementRef)
|
|
3631
|
+
throw new Error('No element ref');
|
|
3632
|
+
this.reactDomRoot = ReactDOM.createRoot(this.elementRef.nativeElement);
|
|
3633
|
+
this.component = this.DataTableUI;
|
|
3634
|
+
this.render();
|
|
3635
|
+
}
|
|
3636
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: DataTableUIComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
3637
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: DataTableUIComponent, isStandalone: false, selector: "app-data-table-ui", inputs: { data: "data", columnDefinitions: "columnDefinitions", actionOptions: "actionOptions" }, outputs: { actionSelected: "actionSelected" }, usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: [""] }); }
|
|
3638
|
+
}
|
|
3639
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: DataTableUIComponent, decorators: [{
|
|
3640
|
+
type: Component,
|
|
3641
|
+
args: [{ selector: 'app-data-table-ui', standalone: false, template: '<ng-content></ng-content>' }]
|
|
3642
|
+
}], propDecorators: { data: [{
|
|
3643
|
+
type: Input
|
|
3644
|
+
}], columnDefinitions: [{
|
|
3645
|
+
type: Input
|
|
3646
|
+
}], actionOptions: [{
|
|
3647
|
+
type: Input
|
|
3648
|
+
}], actionSelected: [{
|
|
3649
|
+
type: Output
|
|
3650
|
+
}] } });
|
|
3651
|
+
|
|
3652
|
+
class DataTableUIModule {
|
|
3653
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: DataTableUIModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
3654
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.8", ngImport: i0, type: DataTableUIModule, declarations: [DataTableUIComponent], imports: [CommonModule, SharedDhis2UiModule, ReactWrapperModule], exports: [DataTableUIComponent] }); }
|
|
3655
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: DataTableUIModule, imports: [CommonModule, SharedDhis2UiModule] }); }
|
|
3656
|
+
}
|
|
3657
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: DataTableUIModule, decorators: [{
|
|
3658
|
+
type: NgModule,
|
|
3659
|
+
args: [{
|
|
3660
|
+
declarations: [DataTableUIComponent],
|
|
3661
|
+
exports: [DataTableUIComponent],
|
|
3662
|
+
imports: [CommonModule, SharedDhis2UiModule, ReactWrapperModule],
|
|
3663
|
+
providers: [],
|
|
3664
|
+
}]
|
|
3665
|
+
}] });
|
|
3666
|
+
|
|
3487
3667
|
class FormField {
|
|
3488
3668
|
constructor(options = {}) {
|
|
3489
3669
|
this.value = options.value || '';
|
|
@@ -5154,6 +5334,175 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
|
|
|
5154
5334
|
// Use of this source code is governed by a BSD-style
|
|
5155
5335
|
// license that can be found in the LICENSE file.
|
|
5156
5336
|
|
|
5337
|
+
class SelectionFiltersComponent extends ReactWrapperModule {
|
|
5338
|
+
constructor() {
|
|
5339
|
+
super(...arguments);
|
|
5340
|
+
this.actionOptions = [];
|
|
5341
|
+
this.attributeFilters = [];
|
|
5342
|
+
this.dataElementFilters = [];
|
|
5343
|
+
this.actionSelected = new EventEmitter();
|
|
5344
|
+
this.SelectionFiltersUI = () => {
|
|
5345
|
+
const [filters, setFilters] = useState({
|
|
5346
|
+
attributeFilters: this.attributeFilters || [],
|
|
5347
|
+
dataElementFilters: this.dataElementFilters || [],
|
|
5348
|
+
});
|
|
5349
|
+
useEffect(() => {
|
|
5350
|
+
setFilters({
|
|
5351
|
+
attributeFilters: this.attributeFilters,
|
|
5352
|
+
dataElementFilters: this.dataElementFilters,
|
|
5353
|
+
});
|
|
5354
|
+
}, [this.attributeFilters, this.dataElementFilters]);
|
|
5355
|
+
const handleAttributeChange = (index, selectedValue) => {
|
|
5356
|
+
setFilters((prevFilters) => {
|
|
5357
|
+
const updatedFilters = [...prevFilters.attributeFilters];
|
|
5358
|
+
updatedFilters[index] = { ...updatedFilters[index], value: selectedValue };
|
|
5359
|
+
return { ...prevFilters, attributeFilters: updatedFilters };
|
|
5360
|
+
});
|
|
5361
|
+
};
|
|
5362
|
+
const handleDataElementChange = (index, selectedValue) => {
|
|
5363
|
+
setFilters((prevFilters) => {
|
|
5364
|
+
const updatedFilters = [...prevFilters.dataElementFilters];
|
|
5365
|
+
updatedFilters[index] = { ...updatedFilters[index], value: selectedValue };
|
|
5366
|
+
return { ...prevFilters, dataElementFilters: updatedFilters };
|
|
5367
|
+
});
|
|
5368
|
+
};
|
|
5369
|
+
const handleSearch = () => {
|
|
5370
|
+
this.actionSelected.emit(filters);
|
|
5371
|
+
};
|
|
5372
|
+
// Grid Column Span Logic for Attribute Filters
|
|
5373
|
+
const getAttributeColumnSpan = (index) => {
|
|
5374
|
+
const totalItems = filters.attributeFilters.length;
|
|
5375
|
+
if (totalItems <= 4) {
|
|
5376
|
+
// If 1 to 4 items, place them in a single row (span all columns if there's only one item)
|
|
5377
|
+
if (totalItems === 1) {
|
|
5378
|
+
return 'span 4'; // One item spans all four columns
|
|
5379
|
+
}
|
|
5380
|
+
if (totalItems === 2) {
|
|
5381
|
+
return 'span 2'; // Two items, each spans 2 columns
|
|
5382
|
+
}
|
|
5383
|
+
if (totalItems === 3) {
|
|
5384
|
+
return 'span 1'; // Three items, each spans one column
|
|
5385
|
+
}
|
|
5386
|
+
if (totalItems === 4) {
|
|
5387
|
+
return 'span 1'; // Four items, each spans one column
|
|
5388
|
+
}
|
|
5389
|
+
}
|
|
5390
|
+
else {
|
|
5391
|
+
// More than 4 items, recursively adjust the placement
|
|
5392
|
+
const rowIndex = Math.floor(index / 2); // Calculate row by pairs
|
|
5393
|
+
if (index % 2 === 0) {
|
|
5394
|
+
// For first item in each row, span 2 columns
|
|
5395
|
+
return 'span 2';
|
|
5396
|
+
}
|
|
5397
|
+
else if (index === totalItems - 1) {
|
|
5398
|
+
// Last item, spans the full row (4 columns)
|
|
5399
|
+
return 'span 4';
|
|
5400
|
+
}
|
|
5401
|
+
else {
|
|
5402
|
+
// For other items, span 2 columns
|
|
5403
|
+
return 'span 2';
|
|
5404
|
+
}
|
|
5405
|
+
}
|
|
5406
|
+
return 'span 1'; // Default behavior
|
|
5407
|
+
};
|
|
5408
|
+
// Grid Column Span Logic for Data Element Filters
|
|
5409
|
+
const getDataElementColumnSpan = (index) => {
|
|
5410
|
+
const totalItems = filters.dataElementFilters.length;
|
|
5411
|
+
if (totalItems <= 4) {
|
|
5412
|
+
// If 1 to 4 items, place them in a single row (span all columns if there's only one item)
|
|
5413
|
+
if (totalItems === 1) {
|
|
5414
|
+
return 'span 4'; // One item spans all four columns
|
|
5415
|
+
}
|
|
5416
|
+
if (totalItems === 2) {
|
|
5417
|
+
return 'span 2'; // Two items, each spans 2 columns
|
|
5418
|
+
}
|
|
5419
|
+
if (totalItems === 3) {
|
|
5420
|
+
return 'span 1'; // Three items, each spans one column
|
|
5421
|
+
}
|
|
5422
|
+
if (totalItems === 4) {
|
|
5423
|
+
return 'span 1'; // Four items, each spans one column
|
|
5424
|
+
}
|
|
5425
|
+
}
|
|
5426
|
+
else {
|
|
5427
|
+
// More than 4 items, recursively adjust the placement
|
|
5428
|
+
const rowIndex = Math.floor(index / 2); // Calculate row by pairs
|
|
5429
|
+
if (index % 2 === 0) {
|
|
5430
|
+
// For first item in each row, span 2 columns
|
|
5431
|
+
return 'span 2';
|
|
5432
|
+
}
|
|
5433
|
+
else if (index === totalItems - 1) {
|
|
5434
|
+
// Last item, spans the full row (4 columns)
|
|
5435
|
+
return 'span 4';
|
|
5436
|
+
}
|
|
5437
|
+
else {
|
|
5438
|
+
// For other items, span 2 columns
|
|
5439
|
+
return 'span 2';
|
|
5440
|
+
}
|
|
5441
|
+
}
|
|
5442
|
+
return 'span 1'; // Default behavior
|
|
5443
|
+
};
|
|
5444
|
+
return (React__default.createElement("div", { style: {
|
|
5445
|
+
fontFamily: 'Arial, sans-serif',
|
|
5446
|
+
padding: '20px',
|
|
5447
|
+
backgroundColor: '#f9f9f9',
|
|
5448
|
+
borderRadius: '8px',
|
|
5449
|
+
boxShadow: '0 4px 8px rgba(0, 0, 0, 0.1)',
|
|
5450
|
+
} },
|
|
5451
|
+
React__default.createElement("div", { style: {
|
|
5452
|
+
display: 'grid',
|
|
5453
|
+
gridTemplateColumns: 'repeat(4, 1fr)',
|
|
5454
|
+
gap: '16px',
|
|
5455
|
+
} }, filters.attributeFilters.map((filter, index) => (React__default.createElement("div", { key: index, style: { gridColumn: getAttributeColumnSpan(index) } }, filter.hasOptions && filter.options.length > 0 ? (React__default.createElement(SingleSelectField, { className: "single-select", label: filter.name || 'Select Option', selected: filter.value, onChange: (event) => handleAttributeChange(index, event.selected) }, filter.options.map((option, i) => (React__default.createElement(SingleSelectOption, { key: i, label: option.name, value: option.id }))))) : (React__default.createElement(InputField$1, { className: "input-field", label: filter.name || 'Program name', value: filter.value, onChange: (event) => handleAttributeChange(index, event.value) })))))),
|
|
5456
|
+
React__default.createElement("div", { style: {
|
|
5457
|
+
display: 'grid',
|
|
5458
|
+
gridTemplateColumns: 'repeat(4, 1fr)',
|
|
5459
|
+
gap: '16px',
|
|
5460
|
+
} }, filters.dataElementFilters.map((filter, index) => (React__default.createElement("div", { key: index, style: { gridColumn: getDataElementColumnSpan(index) } }, filter.hasOptions && filter.options.length > 0 ? (React__default.createElement(SingleSelectField, { className: "single-select", label: filter.name || 'Aggregation type', selected: filter.value, onChange: (event) => handleDataElementChange(index, event.selected) }, filter.options.map((option, i) => (React__default.createElement(SingleSelectOption, { key: i, label: option.name, value: option.id }))))) : (React__default.createElement(InputField$1, { className: "input-field", label: filter.name || 'Program name', value: filter.value, onChange: (event) => handleDataElementChange(index, event.value) })))))),
|
|
5461
|
+
React__default.createElement("div", { style: { textAlign: 'right', marginTop: '16px' } },
|
|
5462
|
+
React__default.createElement(Button$1, { onClick: handleSearch }, "Search"))));
|
|
5463
|
+
};
|
|
5464
|
+
}
|
|
5465
|
+
async ngAfterViewInit() {
|
|
5466
|
+
if (!this.elementRef)
|
|
5467
|
+
throw new Error('No element ref');
|
|
5468
|
+
this.reactDomRoot = ReactDOM.createRoot(this.elementRef.nativeElement);
|
|
5469
|
+
this.component = this.SelectionFiltersUI;
|
|
5470
|
+
this.render();
|
|
5471
|
+
}
|
|
5472
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: SelectionFiltersComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
5473
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: SelectionFiltersComponent, isStandalone: false, selector: "app-selection-filters-ui", inputs: { actionOptions: "actionOptions", attributeFilters: "attributeFilters", dataElementFilters: "dataElementFilters", startDate: "startDate", endDate: "endDate" }, outputs: { actionSelected: "actionSelected" }, usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: [".react-filters-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:20px;margin-bottom:20px}.input-field,.single-select{width:100%}\n"] }); }
|
|
5474
|
+
}
|
|
5475
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: SelectionFiltersComponent, decorators: [{
|
|
5476
|
+
type: Component,
|
|
5477
|
+
args: [{ selector: 'app-selection-filters-ui', template: '<ng-content></ng-content>', standalone: false, styles: [".react-filters-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:20px;margin-bottom:20px}.input-field,.single-select{width:100%}\n"] }]
|
|
5478
|
+
}], propDecorators: { actionOptions: [{
|
|
5479
|
+
type: Input
|
|
5480
|
+
}], attributeFilters: [{
|
|
5481
|
+
type: Input
|
|
5482
|
+
}], dataElementFilters: [{
|
|
5483
|
+
type: Input
|
|
5484
|
+
}], startDate: [{
|
|
5485
|
+
type: Input
|
|
5486
|
+
}], endDate: [{
|
|
5487
|
+
type: Input
|
|
5488
|
+
}], actionSelected: [{
|
|
5489
|
+
type: Output
|
|
5490
|
+
}] } });
|
|
5491
|
+
|
|
5492
|
+
class SelectionFiltersUiModule {
|
|
5493
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: SelectionFiltersUiModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
5494
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.8", ngImport: i0, type: SelectionFiltersUiModule, declarations: [SelectionFiltersComponent], imports: [CommonModule, SharedDhis2UiModule, ReactWrapperModule], exports: [SelectionFiltersComponent] }); }
|
|
5495
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: SelectionFiltersUiModule, imports: [CommonModule, SharedDhis2UiModule] }); }
|
|
5496
|
+
}
|
|
5497
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: SelectionFiltersUiModule, decorators: [{
|
|
5498
|
+
type: NgModule,
|
|
5499
|
+
args: [{
|
|
5500
|
+
declarations: [SelectionFiltersComponent],
|
|
5501
|
+
imports: [CommonModule, SharedDhis2UiModule, ReactWrapperModule],
|
|
5502
|
+
exports: [SelectionFiltersComponent],
|
|
5503
|
+
}]
|
|
5504
|
+
}] });
|
|
5505
|
+
|
|
5157
5506
|
class TrackerFormComponent {
|
|
5158
5507
|
constructor() {
|
|
5159
5508
|
this.program = input.required();
|
|
@@ -5162,6 +5511,7 @@ class TrackerFormComponent {
|
|
|
5162
5511
|
async ngOnInit() {
|
|
5163
5512
|
this.trackerQuery = this.d2.trackerModule.trackedEntity.setProgram(this.program());
|
|
5164
5513
|
const program = await this.trackerQuery.getMetaData();
|
|
5514
|
+
const instance = await this.trackerQuery.create();
|
|
5165
5515
|
if (program) {
|
|
5166
5516
|
this.formMetaData = new FormMetaData({
|
|
5167
5517
|
programs: [program],
|
|
@@ -5200,5 +5550,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
|
|
|
5200
5550
|
* Generated bundle index. Do not edit.
|
|
5201
5551
|
*/
|
|
5202
5552
|
|
|
5203
|
-
export { Boolean$1 as Boolean, ButtonComponent, ButtonModule, CheckBox, D2FormModule, DateField, DateRangeValue, Dropdown, FieldConfig, FieldControlTypeUtil, FieldDropdown, FieldType, FieldUtil, FormComponent, FormConfig, FormField, FormFieldComponent, FormFieldGroup, FormFieldTypeUtil, FormMetaData, FormMetadataSection, FormUtil, FormValue, FormValueUtil, HeaderBarComponent, HeaderBarModule, LineListModule, LineListTableComponent, MetadataRule, MetadataRuleAction, OrganisationUnitSelectionConfig, OrganisationUnitSelectorComponent, OrganisationUnitSelectorModalComponent, OrganisationUnitSelectorModule, PeriodSelectorComponent, PeriodSelectorModalComponent, PeriodSelectorModule, ReactWrapperModule, RepeatableFormComponent, SectionFormComponent, TrackerFormComponent, TrackerFormModule, TranslationUtil };
|
|
5553
|
+
export { Boolean$1 as Boolean, ButtonComponent, ButtonModule, CheckBox, D2FormModule, DataTableUIComponent, DataTableUIModule, DateField, DateRangeValue, Dropdown, FieldConfig, FieldControlTypeUtil, FieldDropdown, FieldType, FieldUtil, FormComponent, FormConfig, FormField, FormFieldComponent, FormFieldGroup, FormFieldTypeUtil, FormMetaData, FormMetadataSection, FormUtil, FormValue, FormValueUtil, HeaderBarComponent, HeaderBarModule, LineListModule, LineListTableComponent, MetadataRule, MetadataRuleAction, OrganisationUnitSelectionConfig, OrganisationUnitSelectorComponent, OrganisationUnitSelectorModalComponent, OrganisationUnitSelectorModule, PeriodSelectorComponent, PeriodSelectorModalComponent, PeriodSelectorModule, ReactWrapperModule, RepeatableFormComponent, SectionFormComponent, SelectionFiltersComponent, SelectionFiltersUiModule, TrackerFormComponent, TrackerFormModule, TranslationUtil };
|
|
5204
5554
|
//# sourceMappingURL=iapps-ng-dhis2-ui.mjs.map
|