@iapps/ng-dhis2-ui 1.0.8 → 1.0.9
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 +378 -4
- package/fesm2022/iapps-ng-dhis2-ui.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/lib/modules/line-list/components/dropdown-menu/dropdown-menu.d.ts +19 -0
- package/lib/modules/line-list/components/dropdown-menu/dropdown-menu.styles.d.ts +5 -0
- package/lib/modules/line-list/components/dropdown-menu/index.d.ts +1 -0
- package/lib/modules/line-list/containers/line-list.component.d.ts +20 -0
- package/lib/modules/line-list/hooks/index.d.ts +1 -0
- package/lib/modules/line-list/hooks/use-dynamic-styles.hook.d.ts +1 -0
- package/lib/modules/line-list/index.d.ts +2 -0
- package/lib/modules/line-list/line-list.module.d.ts +9 -0
- package/lib/modules/line-list/models/attribute-filter.model.d.ts +9 -0
- package/lib/modules/line-list/models/line-list.models.d.ts +70 -0
- package/lib/modules/line-list/services/line-list.service.d.ts +16 -0
- package/lib/modules/line-list/utils/filter-builder.d.ts +2 -0
- package/lib/modules/line-list/utils/line-list-utils.d.ts +14 -0
- package/lib/shared/utils/predefinedDimensions.d.ts +6 -6
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommonModule } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { NgModule, Directive, Input, ContentChild, Component, EventEmitter, Output } from '@angular/core';
|
|
4
|
-
import { IconEdit16, spacers, colors, theme, Tooltip, Button as Button$1, IconDimensionData16, IconClock16, IconDimensionOrgUnit16, 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 } from '@dhis2/ui';
|
|
3
|
+
import { NgModule, Directive, Input, ContentChild, Component, EventEmitter, Output, Injectable, inject } from '@angular/core';
|
|
4
|
+
import { IconEdit16, spacers, colors, theme, Tooltip, Button as Button$1, IconDimensionData16, IconClock16, IconDimensionOrgUnit16, 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, DataTable, TableHead, DataTableRow, DataTableColumnHeader, TableBody, DataTableCell, TableFoot, Pagination } from '@dhis2/ui';
|
|
5
5
|
import cx from 'classnames';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import * as React from 'react';
|
|
@@ -27,6 +27,7 @@ import { MenuItem, MenuDivider } from '@dhis2-ui/menu';
|
|
|
27
27
|
import parse from 'html-react-parser';
|
|
28
28
|
import { getNowInCalendar, generateFixedPeriods } from '@dhis2/multi-calendar-dates';
|
|
29
29
|
import { isObject, isString } from 'lodash';
|
|
30
|
+
import { switchMap, map as map$1 } from 'rxjs/operators';
|
|
30
31
|
|
|
31
32
|
const TransferOption = ({ disabled, label, highlighted, selected, onClick, onDoubleClick, value, icon, active, tooltipText, dataTest, onEditClick, }) => {
|
|
32
33
|
const renderContent = () => (React__default.createElement("div", { className: cx('chip', {
|
|
@@ -1179,7 +1180,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImpor
|
|
|
1179
1180
|
type: Directive,
|
|
1180
1181
|
args: [{
|
|
1181
1182
|
selector: 'ng-dhis2-ui-wrapper',
|
|
1182
|
-
standalone: false
|
|
1183
|
+
standalone: false,
|
|
1183
1184
|
}]
|
|
1184
1185
|
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { props: [{
|
|
1185
1186
|
type: Input
|
|
@@ -2963,9 +2964,382 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImpor
|
|
|
2963
2964
|
// Use of this source code is governed by a BSD-style
|
|
2964
2965
|
// license that can be found in the LICENSE file.
|
|
2965
2966
|
|
|
2967
|
+
function buildFilters(filters) {
|
|
2968
|
+
return filters
|
|
2969
|
+
.map(({ attribute, operator, value }) => `filter=${attribute}:${operator}:${value}`)
|
|
2970
|
+
.join('&');
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2973
|
+
class LineListService {
|
|
2974
|
+
constructor(httpClient) {
|
|
2975
|
+
this.httpClient = httpClient;
|
|
2976
|
+
}
|
|
2977
|
+
getProgramMetadata(programId) {
|
|
2978
|
+
return this.httpClient.get(`programs/${programId}.json?fields=programType,programStages[id,name,programStageDataElements[dataElement[id,name]]],organisationUnits[id,name]`);
|
|
2979
|
+
}
|
|
2980
|
+
getTrackedEntityInstances(programId, orgUnit, page, pageSize, filters = [], startDate, endDate) {
|
|
2981
|
+
const filterParams = buildFilters(filters);
|
|
2982
|
+
const dateFilter = startDate && endDate ? `&programStartDate=${startDate}&programEndDate=${endDate}` : '';
|
|
2983
|
+
return this.httpClient.get(`trackedEntityInstances.json?program=${programId}&ou=${orgUnit}&page=${page}&pageSize=${pageSize}&fields=trackedEntityInstance,attributes[*],enrollments[*]&totalPages=true&${filterParams}${dateFilter}`);
|
|
2984
|
+
}
|
|
2985
|
+
getEvents(programId, orgUnit, page, pageSize) {
|
|
2986
|
+
return this.httpClient.get(`events.json?program=${programId}&orgUnit=${orgUnit}&page=${page}&pageSize=${pageSize}&fields=event,programStage,dataValues[dataElement,value]&totalPages=true`);
|
|
2987
|
+
}
|
|
2988
|
+
getEventsByProgramStage(programStageId, orgUnit, page, pageSize) {
|
|
2989
|
+
return this.httpClient.get(`events.json?programStage=${programStageId}&orgUnit=${orgUnit}&page=${page}&pageSize=${pageSize}&fields=event,dataValues[dataElement,value]&totalPages=true`);
|
|
2990
|
+
}
|
|
2991
|
+
getLineListData(programId, orgUnit = '', programStageId, page = 1, pageSize = 10, filters = [], startDate, endDate) {
|
|
2992
|
+
return this.getProgramMetadata(programId).pipe(switchMap((programMetadata) => {
|
|
2993
|
+
if (programStageId) {
|
|
2994
|
+
return this.getEventsByProgramStage(programStageId, orgUnit, page, pageSize).pipe(map$1((events) => ({
|
|
2995
|
+
metadata: programMetadata,
|
|
2996
|
+
data: events,
|
|
2997
|
+
})));
|
|
2998
|
+
}
|
|
2999
|
+
if (programMetadata.programType === 'WITH_REGISTRATION') {
|
|
3000
|
+
return this.getTrackedEntityInstances(programId, orgUnit, page, pageSize, filters, startDate, endDate).pipe(map$1((teis) => ({
|
|
3001
|
+
metadata: programMetadata,
|
|
3002
|
+
data: teis,
|
|
3003
|
+
})));
|
|
3004
|
+
}
|
|
3005
|
+
else {
|
|
3006
|
+
return this.getEvents(programId, orgUnit, page, pageSize).pipe(map$1((events) => ({
|
|
3007
|
+
metadata: programMetadata,
|
|
3008
|
+
data: events,
|
|
3009
|
+
})));
|
|
3010
|
+
}
|
|
3011
|
+
}));
|
|
3012
|
+
}
|
|
3013
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: LineListService, deps: [{ token: i1.NgxDhis2HttpClientService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3014
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: LineListService }); }
|
|
3015
|
+
}
|
|
3016
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: LineListService, decorators: [{
|
|
3017
|
+
type: Injectable
|
|
3018
|
+
}], ctorParameters: () => [{ type: i1.NgxDhis2HttpClientService }] });
|
|
3019
|
+
|
|
3020
|
+
const dropdownStyles = {
|
|
3021
|
+
layer: {
|
|
3022
|
+
zIndex: '1 !important',
|
|
3023
|
+
},
|
|
3024
|
+
};
|
|
3025
|
+
|
|
3026
|
+
// Helper function to generate a unique class name
|
|
3027
|
+
const generateClassName = (base) => `${base}-${Math.random().toString(36).substr(2, 9)}`;
|
|
3028
|
+
// Helper function to convert camelCased properties to hyphenated CSS properties
|
|
3029
|
+
const convertStylesToCSS = (className, styles) => {
|
|
3030
|
+
let cssString = `.${className} {`;
|
|
3031
|
+
for (const key in styles) {
|
|
3032
|
+
if (typeof styles[key] === "object" && key.startsWith("@media")) {
|
|
3033
|
+
const mediaStyles = convertStylesToCSS(className, styles[key]);
|
|
3034
|
+
cssString += `${key} { ${mediaStyles} }`;
|
|
3035
|
+
}
|
|
3036
|
+
else if (key.startsWith("&:")) {
|
|
3037
|
+
const pseudoClass = key.replace("&", "");
|
|
3038
|
+
cssString += `${pseudoClass} { ${convertStylesToCSS("", styles[key])} }`;
|
|
3039
|
+
}
|
|
3040
|
+
else {
|
|
3041
|
+
const cssKey = key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
3042
|
+
cssString += `${cssKey}: ${styles[key]}; `;
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
cssString += "}";
|
|
3046
|
+
return cssString;
|
|
3047
|
+
};
|
|
3048
|
+
// Custom hook for dynamic styles with generics
|
|
3049
|
+
const useDynamicStyles = (stylesObj) => {
|
|
3050
|
+
const [classNames, setClassNames] = useState({});
|
|
3051
|
+
useEffect(() => {
|
|
3052
|
+
const convertedStyles = Object.keys(stylesObj).map((key) => {
|
|
3053
|
+
const className = generateClassName(key);
|
|
3054
|
+
const styleElement = document.createElement("style");
|
|
3055
|
+
styleElement.innerHTML = convertStylesToCSS(className, stylesObj[key]);
|
|
3056
|
+
document.head.appendChild(styleElement);
|
|
3057
|
+
return {
|
|
3058
|
+
key,
|
|
3059
|
+
className,
|
|
3060
|
+
styleElement,
|
|
3061
|
+
};
|
|
3062
|
+
});
|
|
3063
|
+
setClassNames(convertedStyles.reduce((classNameEntity, convertedStyle) => {
|
|
3064
|
+
return {
|
|
3065
|
+
...classNameEntity,
|
|
3066
|
+
[convertedStyle.key]: convertedStyle.className,
|
|
3067
|
+
};
|
|
3068
|
+
}, {}));
|
|
3069
|
+
return () => {
|
|
3070
|
+
convertedStyles.forEach((convertedStyle) => {
|
|
3071
|
+
document.head.removeChild(convertedStyle.styleElement);
|
|
3072
|
+
});
|
|
3073
|
+
};
|
|
3074
|
+
}, []);
|
|
3075
|
+
return classNames;
|
|
3076
|
+
};
|
|
3077
|
+
|
|
3078
|
+
const useCurrentModal = () => {
|
|
3079
|
+
const [CurrentModal, setCurrentModal] = useState();
|
|
3080
|
+
return [
|
|
3081
|
+
CurrentModal,
|
|
3082
|
+
(Modal) => {
|
|
3083
|
+
// As setState supports functional updates, we can't pass functional
|
|
3084
|
+
// components directly
|
|
3085
|
+
setCurrentModal(() => Modal);
|
|
3086
|
+
},
|
|
3087
|
+
];
|
|
3088
|
+
};
|
|
3089
|
+
const ContextMenu = (params) => {
|
|
3090
|
+
const { onClose, onMenuClick, anchorRef, dropDownOptions } = params;
|
|
3091
|
+
const [CurrentModal, setCurrentModal] = useCurrentModal();
|
|
3092
|
+
const styles = useDynamicStyles(dropdownStyles);
|
|
3093
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
3094
|
+
React__default.createElement(Layer$1, { onBackdropClick: onClose, className: styles.layer },
|
|
3095
|
+
React__default.createElement(Popper, { reference: anchorRef, placement: "bottom-start" },
|
|
3096
|
+
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: () => {
|
|
3097
|
+
// onMenuClick(dropDownOption);
|
|
3098
|
+
//onClose();
|
|
3099
|
+
}, dense: true })))))),
|
|
3100
|
+
CurrentModal && (React__default.createElement(CurrentModal, { onClose: () => {
|
|
3101
|
+
onClose();
|
|
3102
|
+
setCurrentModal(null);
|
|
3103
|
+
} }))));
|
|
3104
|
+
};
|
|
3105
|
+
const DropdownMenu = (props) => {
|
|
3106
|
+
const ref = useRef();
|
|
3107
|
+
const [visible, setVisible] = useState(false);
|
|
3108
|
+
const { dropdownOptions, onClick } = props;
|
|
3109
|
+
return (React__default.createElement("div", { ref: ref, style: { display: "inline-block" } },
|
|
3110
|
+
React__default.createElement(Button$1, { small: true, secondary: true, icon: React__default.createElement(IconMore24, { color: colors.grey600 }), onClick: () => setVisible(true) }),
|
|
3111
|
+
visible && (React__default.createElement(ContextMenu, { dropDownOptions: dropdownOptions, anchorRef: ref, onClose: () => setVisible(false), onMenuClick: (dropDownOption) => {
|
|
3112
|
+
onClick(dropDownOption);
|
|
3113
|
+
} }))));
|
|
3114
|
+
};
|
|
3115
|
+
|
|
3116
|
+
const getProgramStageData = (response, programStageId, pager) => {
|
|
3117
|
+
const events = response.data.events;
|
|
3118
|
+
const allDataElements = new Set();
|
|
3119
|
+
events.forEach((event) => {
|
|
3120
|
+
event.dataValues.forEach((dv) => allDataElements.add(dv.dataElement));
|
|
3121
|
+
});
|
|
3122
|
+
const stageFromMetaData = response.metadata.programStages.find((stage) => stage.id === programStageId);
|
|
3123
|
+
if (!stageFromMetaData) {
|
|
3124
|
+
throw new Error(`Program stage with ID ${programStageId} not found`);
|
|
3125
|
+
}
|
|
3126
|
+
const entityColumns = Array.from(allDataElements).map((dataElementId) => ({
|
|
3127
|
+
label: stageFromMetaData.programStageDataElements.find((psde) => psde.dataElement.id === dataElementId)?.dataElement.name || dataElementId,
|
|
3128
|
+
key: dataElementId,
|
|
3129
|
+
}));
|
|
3130
|
+
const dataElementsData = events.map((event, idx) => {
|
|
3131
|
+
let row = {
|
|
3132
|
+
event: event.event,
|
|
3133
|
+
index: (pager.page - 1) * pager.pageSize + idx + 1,
|
|
3134
|
+
};
|
|
3135
|
+
allDataElements.forEach((dataElementId) => (row[dataElementId] = ''));
|
|
3136
|
+
event.dataValues.forEach((dv) => (row[dv.dataElement] = dv.value));
|
|
3137
|
+
return row;
|
|
3138
|
+
});
|
|
3139
|
+
return { columns: entityColumns, data: dataElementsData };
|
|
3140
|
+
};
|
|
3141
|
+
const getTrackedEntityData = (response, programId, pager) => {
|
|
3142
|
+
const teis = response.data.trackedEntityInstances;
|
|
3143
|
+
const allAttributes = new Set();
|
|
3144
|
+
teis.forEach((tei) => {
|
|
3145
|
+
const matchingEnrollment = tei.enrollments.find((enrollment) => enrollment.program === programId);
|
|
3146
|
+
const attributes = matchingEnrollment
|
|
3147
|
+
? matchingEnrollment.attributes
|
|
3148
|
+
: tei.attributes;
|
|
3149
|
+
attributes.forEach((attr) => allAttributes.add(attr.attribute));
|
|
3150
|
+
});
|
|
3151
|
+
const entityColumns = Array.from(allAttributes).map((attrId) => {
|
|
3152
|
+
const foundAttribute = teis
|
|
3153
|
+
.flatMap((tei) => {
|
|
3154
|
+
const matchingEnrollment = tei.enrollments.find((enrollment) => enrollment.program === programId);
|
|
3155
|
+
return matchingEnrollment
|
|
3156
|
+
? matchingEnrollment.attributes
|
|
3157
|
+
: tei.attributes;
|
|
3158
|
+
})
|
|
3159
|
+
.find((attr) => attr.attribute === attrId);
|
|
3160
|
+
return {
|
|
3161
|
+
label: foundAttribute?.displayName || attrId,
|
|
3162
|
+
key: attrId,
|
|
3163
|
+
};
|
|
3164
|
+
});
|
|
3165
|
+
const attributesData = teis.map((tei, idx) => {
|
|
3166
|
+
let row = {
|
|
3167
|
+
trackedEntityInstance: tei.trackedEntityInstance,
|
|
3168
|
+
index: (pager.page - 1) * pager.pageSize + idx + 1,
|
|
3169
|
+
};
|
|
3170
|
+
allAttributes.forEach((attrId) => (row[attrId] = ''));
|
|
3171
|
+
const matchingEnrollment = tei.enrollments.find((enrollment) => enrollment.program === programId);
|
|
3172
|
+
const attributesToUse = matchingEnrollment
|
|
3173
|
+
? matchingEnrollment.attributes
|
|
3174
|
+
: tei.attributes;
|
|
3175
|
+
attributesToUse.forEach((attr) => (row[attr.attribute] = attr.value));
|
|
3176
|
+
return row;
|
|
3177
|
+
});
|
|
3178
|
+
return { columns: entityColumns, data: attributesData };
|
|
3179
|
+
};
|
|
3180
|
+
const getEventData = (response, pager) => {
|
|
3181
|
+
const events = response.data.events;
|
|
3182
|
+
const uniqueDataElements = new Set();
|
|
3183
|
+
events.forEach((event) => {
|
|
3184
|
+
event.dataValues.forEach((dv) => uniqueDataElements.add(dv.dataElement));
|
|
3185
|
+
});
|
|
3186
|
+
const entityColumns = Array.from(uniqueDataElements).map((dataElement) => ({
|
|
3187
|
+
label: response.metadata.programStages[0].programStageDataElements.find((psde) => psde.dataElement.id === dataElement)?.dataElement.name || dataElement,
|
|
3188
|
+
key: dataElement,
|
|
3189
|
+
}));
|
|
3190
|
+
const dataElementsData = events.map((event, idx) => {
|
|
3191
|
+
let row = {
|
|
3192
|
+
event: event.event,
|
|
3193
|
+
index: (pager.page - 1) * pager.pageSize + idx + 1,
|
|
3194
|
+
};
|
|
3195
|
+
uniqueDataElements.forEach((dataElement) => (row[dataElement] = ''));
|
|
3196
|
+
event.dataValues.forEach((dv) => (row[dv.dataElement] = dv.value));
|
|
3197
|
+
return row;
|
|
3198
|
+
});
|
|
3199
|
+
return { columns: entityColumns, data: dataElementsData };
|
|
3200
|
+
};
|
|
3201
|
+
const addActionsColumn = (columns, actionOptions) => {
|
|
3202
|
+
return [
|
|
3203
|
+
...columns,
|
|
3204
|
+
...(actionOptions && actionOptions.length > 0
|
|
3205
|
+
? [{ label: 'Actions', key: 'actions' }]
|
|
3206
|
+
: []),
|
|
3207
|
+
];
|
|
3208
|
+
};
|
|
3209
|
+
|
|
3210
|
+
class LineListTableComponent extends ReactWrapperComponent {
|
|
3211
|
+
constructor() {
|
|
3212
|
+
super(...arguments);
|
|
3213
|
+
this.lineListService = inject(LineListService);
|
|
3214
|
+
this.LineList = () => {
|
|
3215
|
+
const [columns, setColumns] = useState([]);
|
|
3216
|
+
const [data, setData] = useState([]);
|
|
3217
|
+
const [pager, setPager] = useState({
|
|
3218
|
+
page: 1,
|
|
3219
|
+
pageSize: 10,
|
|
3220
|
+
total: 0,
|
|
3221
|
+
pageCount: 1,
|
|
3222
|
+
});
|
|
3223
|
+
const paginationRef = useRef(null);
|
|
3224
|
+
useEffect(() => {
|
|
3225
|
+
setTimeout(() => {
|
|
3226
|
+
const paginationContainer = document.querySelector('[data-test="dhis2-uiwidgets-pagination"]');
|
|
3227
|
+
if (paginationContainer) {
|
|
3228
|
+
paginationContainer.style.setProperty('display', 'flex', 'important');
|
|
3229
|
+
paginationContainer.style.setProperty('flex-direction', 'row', 'important');
|
|
3230
|
+
paginationContainer.style.setProperty('justify-content', 'space-between', 'important');
|
|
3231
|
+
paginationContainer.style.setProperty('align-items', 'center', 'important');
|
|
3232
|
+
}
|
|
3233
|
+
}, 1000);
|
|
3234
|
+
if (paginationRef.current) {
|
|
3235
|
+
paginationRef.current.style.setProperty('display', 'flex', 'important');
|
|
3236
|
+
paginationRef.current.style.setProperty('flex-direction', 'row', 'important');
|
|
3237
|
+
}
|
|
3238
|
+
this.lineListService
|
|
3239
|
+
.getLineListData(this.programId, this.orgUnit, this.programStageId, pager.page, pager.pageSize, this.attributeFilters, this.startDate, this.endDate)
|
|
3240
|
+
.subscribe((response) => {
|
|
3241
|
+
let entityColumns = [];
|
|
3242
|
+
let responsePager;
|
|
3243
|
+
let entityData = [];
|
|
3244
|
+
if (this.programStageId) {
|
|
3245
|
+
responsePager = response.data.pager;
|
|
3246
|
+
const { columns, data } = getProgramStageData(response, this.programStageId, pager);
|
|
3247
|
+
entityColumns = columns;
|
|
3248
|
+
entityData = data;
|
|
3249
|
+
}
|
|
3250
|
+
else if ('trackedEntityInstances' in response.data) {
|
|
3251
|
+
responsePager = response.data
|
|
3252
|
+
.pager;
|
|
3253
|
+
const { columns, data } = getTrackedEntityData(response, this.programId, pager);
|
|
3254
|
+
entityColumns = columns;
|
|
3255
|
+
entityData = data;
|
|
3256
|
+
}
|
|
3257
|
+
else {
|
|
3258
|
+
responsePager = response.data.pager;
|
|
3259
|
+
const { columns, data } = getEventData(response, pager);
|
|
3260
|
+
entityColumns = columns;
|
|
3261
|
+
entityData = data;
|
|
3262
|
+
}
|
|
3263
|
+
const finalColumns = addActionsColumn([{ label: '#', key: 'index' }, ...entityColumns], this.actionOptions);
|
|
3264
|
+
setColumns(finalColumns);
|
|
3265
|
+
setData(entityData);
|
|
3266
|
+
setPager(responsePager);
|
|
3267
|
+
});
|
|
3268
|
+
}, [pager.page, pager.pageSize]);
|
|
3269
|
+
console.log('columns', columns);
|
|
3270
|
+
console.log('data', data);
|
|
3271
|
+
const getDropdownOptions = (row) => {
|
|
3272
|
+
return (this.actionOptions || []).map((option) => ({
|
|
3273
|
+
...option,
|
|
3274
|
+
onClick: () => option.onClick?.(row),
|
|
3275
|
+
}));
|
|
3276
|
+
};
|
|
3277
|
+
return (React__default.createElement("div", null,
|
|
3278
|
+
React__default.createElement(DataTable, null,
|
|
3279
|
+
React__default.createElement(TableHead, null,
|
|
3280
|
+
React__default.createElement(DataTableRow, null, columns.map((col) => (React__default.createElement(DataTableColumnHeader, { key: col.key }, col.label))))),
|
|
3281
|
+
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])))))))),
|
|
3282
|
+
React__default.createElement(TableFoot, null,
|
|
3283
|
+
React__default.createElement(DataTableRow, null,
|
|
3284
|
+
React__default.createElement(DataTableCell, { colSpan: columns.length },
|
|
3285
|
+
React__default.createElement("div", null,
|
|
3286
|
+
React__default.createElement(Pagination, { page: pager.page, pageCount: pager.pageCount, pageSize: pager.pageSize, total: pager.total, onPageChange: (page) => setPager((prev) => ({ ...prev, page })), onPageSizeChange: (pageSize) => {
|
|
3287
|
+
const newPageSize = Number(pageSize);
|
|
3288
|
+
setPager((prev) => ({
|
|
3289
|
+
...prev,
|
|
3290
|
+
page: 1,
|
|
3291
|
+
pageSize: newPageSize,
|
|
3292
|
+
}));
|
|
3293
|
+
}, pageSizes: ['5', '10', '20', '50'] }))))))));
|
|
3294
|
+
};
|
|
3295
|
+
}
|
|
3296
|
+
async ngAfterViewInit() {
|
|
3297
|
+
if (!this.elementRef)
|
|
3298
|
+
throw new Error('No element ref');
|
|
3299
|
+
this.reactDomRoot = ReactDOM.createRoot(this.elementRef.nativeElement);
|
|
3300
|
+
this.component = this.LineList;
|
|
3301
|
+
this.render();
|
|
3302
|
+
}
|
|
3303
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: LineListTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
3304
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.7", type: LineListTableComponent, isStandalone: false, selector: "app-line-list", inputs: { programId: "programId", orgUnit: "orgUnit", programStageId: "programStageId", actionOptions: "actionOptions", attributeFilters: "attributeFilters", startDate: "startDate", endDate: "endDate" }, usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: [""] }); }
|
|
3305
|
+
}
|
|
3306
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: LineListTableComponent, decorators: [{
|
|
3307
|
+
type: Component,
|
|
3308
|
+
args: [{ selector: 'app-line-list', template: '<ng-content></ng-content>', standalone: false }]
|
|
3309
|
+
}], propDecorators: { programId: [{
|
|
3310
|
+
type: Input
|
|
3311
|
+
}], orgUnit: [{
|
|
3312
|
+
type: Input
|
|
3313
|
+
}], programStageId: [{
|
|
3314
|
+
type: Input
|
|
3315
|
+
}], actionOptions: [{
|
|
3316
|
+
type: Input
|
|
3317
|
+
}], attributeFilters: [{
|
|
3318
|
+
type: Input
|
|
3319
|
+
}], startDate: [{
|
|
3320
|
+
type: Input
|
|
3321
|
+
}], endDate: [{
|
|
3322
|
+
type: Input
|
|
3323
|
+
}] } });
|
|
3324
|
+
|
|
3325
|
+
class LineListModule {
|
|
3326
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: LineListModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
3327
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.7", ngImport: i0, type: LineListModule, declarations: [LineListTableComponent], imports: [CommonModule, SharedDhis2UiModule], exports: [LineListTableComponent] }); }
|
|
3328
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: LineListModule, providers: [LineListService], imports: [CommonModule, SharedDhis2UiModule] }); }
|
|
3329
|
+
}
|
|
3330
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: LineListModule, decorators: [{
|
|
3331
|
+
type: NgModule,
|
|
3332
|
+
args: [{
|
|
3333
|
+
declarations: [LineListTableComponent],
|
|
3334
|
+
exports: [LineListTableComponent],
|
|
3335
|
+
imports: [CommonModule, SharedDhis2UiModule],
|
|
3336
|
+
providers: [LineListService],
|
|
3337
|
+
}]
|
|
3338
|
+
}] });
|
|
3339
|
+
|
|
2966
3340
|
/**
|
|
2967
3341
|
* Generated bundle index. Do not edit.
|
|
2968
3342
|
*/
|
|
2969
3343
|
|
|
2970
|
-
export { ButtonComponent, ButtonModule, HeaderBarComponent, HeaderBarModule, OrganisationUnitSelectionConfig, OrganisationUnitSelectorComponent, OrganisationUnitSelectorModalComponent, OrganisationUnitSelectorModule, PeriodSelectorComponent, PeriodSelectorModalComponent, PeriodSelectorModule, ReactWrapperComponent, ReactWrapperModule };
|
|
3344
|
+
export { ButtonComponent, ButtonModule, HeaderBarComponent, HeaderBarModule, LineListModule, LineListTableComponent, OrganisationUnitSelectionConfig, OrganisationUnitSelectorComponent, OrganisationUnitSelectorModalComponent, OrganisationUnitSelectorModule, PeriodSelectorComponent, PeriodSelectorModalComponent, PeriodSelectorModule, ReactWrapperComponent, ReactWrapperModule };
|
|
2971
3345
|
//# sourceMappingURL=iapps-ng-dhis2-ui.mjs.map
|