@iapps/ng-dhis2-ui 1.1.7 → 1.1.8
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 +171 -31
- package/fesm2022/iapps-ng-dhis2-ui.mjs.map +1 -1
- 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 +22 -2
- package/lib/modules/selection-filters-ui/models/selection-filters-ui.models.d.ts +10 -0
- package/lib/modules/selection-filters-ui/selection-filters-ui.module.d.ts +2 -1
- package/package.json +1 -1
|
@@ -5403,105 +5403,163 @@ class SelectionFiltersComponent extends ReactWrapperModule {
|
|
|
5403
5403
|
this.attributeFilters = [];
|
|
5404
5404
|
this.dataElementFilters = [];
|
|
5405
5405
|
this.actionSelected = new EventEmitter();
|
|
5406
|
+
this.httpClient = inject(NgxDhis2HttpClientService);
|
|
5407
|
+
this.ngZone = inject(NgZone);
|
|
5408
|
+
this.FieldOrgUnitSelector = (props) => {
|
|
5409
|
+
const { onSelectOrgUnit, onCancelOrgUnit } = props;
|
|
5410
|
+
const [selected, setSelected] = useState([]);
|
|
5411
|
+
const [rootOrgUnits, setRootOrgUnits] = useState();
|
|
5412
|
+
const [config, setConfig] = useState();
|
|
5413
|
+
useEffect(() => {
|
|
5414
|
+
zip(this.getAppConfig(), this.getRootOrgUnits()).subscribe({
|
|
5415
|
+
next: ([appConfig, rootOrgUnits]) => {
|
|
5416
|
+
setConfig(appConfig);
|
|
5417
|
+
setRootOrgUnits(rootOrgUnits);
|
|
5418
|
+
},
|
|
5419
|
+
error: (error) => console.error(error),
|
|
5420
|
+
});
|
|
5421
|
+
}, []);
|
|
5422
|
+
return config ? (React__default.createElement(Provider, { config: config, plugin: false, parentAlertsAdd: undefined, showAlertsInPlugin: false }, React__default.createElement(Modal$1, { position: "middle", large: true },
|
|
5423
|
+
React__default.createElement(ModalTitle$1, null, "Organisation unit"),
|
|
5424
|
+
React__default.createElement(ModalContent$1, null,
|
|
5425
|
+
React__default.createElement(OrgUnitDimension, { selected: selected, hideGroupSelect: this.orgUnitSelectionConfig.hideGroupSelect, hideLevelSelect: this.orgUnitSelectionConfig.hideLevelSelect, hideUserOrgUnits: this.orgUnitSelectionConfig.hideUserOrgUnits, onSelect: (selectionEvent) => {
|
|
5426
|
+
setSelected(selectionEvent.items);
|
|
5427
|
+
}, orgUnitGroupPromise: this.getOrgUnitGroups(), orgUnitLevelPromise: this.getOrgUnitLevels(), roots: rootOrgUnits })),
|
|
5428
|
+
React__default.createElement(ModalActions$1, null,
|
|
5429
|
+
React__default.createElement(ButtonStrip$1, { end: true },
|
|
5430
|
+
React__default.createElement(Button$1, { onClick: () => {
|
|
5431
|
+
onCancelOrgUnit();
|
|
5432
|
+
} }, "Cancel"),
|
|
5433
|
+
React__default.createElement(Button$1, { primary: true, disabled: selected.length === 0, onClick: () => {
|
|
5434
|
+
onSelectOrgUnit(selected);
|
|
5435
|
+
} }, "Confirm")))))) : (React__default.createElement(CircularLoader$1, { small: true }));
|
|
5436
|
+
};
|
|
5437
|
+
this.showOrgUnitTree = signal(false);
|
|
5438
|
+
this.orgUnitSelectionConfig = {
|
|
5439
|
+
hideGroupSelect: true,
|
|
5440
|
+
hideLevelSelect: true,
|
|
5441
|
+
hideUserOrgUnits: true,
|
|
5442
|
+
allowSingleSelection: true,
|
|
5443
|
+
usageType: 'DATA_ENTRY',
|
|
5444
|
+
};
|
|
5445
|
+
this.selectedOrgUnit = signal(null);
|
|
5446
|
+
this.selectedOrgUnit$ = toObservable(this.selectedOrgUnit);
|
|
5406
5447
|
this.SelectionFiltersUI = () => {
|
|
5407
5448
|
const [filters, setFilters] = useState({
|
|
5408
5449
|
attributeFilters: this.attributeFilters || [],
|
|
5409
5450
|
dataElementFilters: this.dataElementFilters || [],
|
|
5451
|
+
organizationUnitId: '',
|
|
5452
|
+
startDate: this.startDate || '',
|
|
5453
|
+
endDate: this.endDate || '',
|
|
5410
5454
|
});
|
|
5455
|
+
const [displayValue, setDisplayValue] = useState(null);
|
|
5456
|
+
const [selected, setSelected] = useState();
|
|
5457
|
+
const [selectedOrganisationUnit, setSelectedOrganisationUnit] = useState();
|
|
5458
|
+
const [touched, setTouched] = useState(false);
|
|
5459
|
+
const [showOrgUnit, setShowOrgUnit] = useState(false);
|
|
5460
|
+
const [value, setValue] = useState(null);
|
|
5411
5461
|
useEffect(() => {
|
|
5412
5462
|
setFilters({
|
|
5413
5463
|
attributeFilters: this.attributeFilters,
|
|
5414
5464
|
dataElementFilters: this.dataElementFilters,
|
|
5465
|
+
organizationUnitId: '',
|
|
5466
|
+
startDate: this.startDate || '',
|
|
5467
|
+
endDate: this.endDate || '',
|
|
5415
5468
|
});
|
|
5416
|
-
}, [
|
|
5469
|
+
}, [
|
|
5470
|
+
this.attributeFilters,
|
|
5471
|
+
this.dataElementFilters,
|
|
5472
|
+
this.startDate,
|
|
5473
|
+
this.endDate,
|
|
5474
|
+
]);
|
|
5417
5475
|
const handleAttributeChange = (index, selectedValue) => {
|
|
5418
5476
|
setFilters((prevFilters) => {
|
|
5419
5477
|
const updatedFilters = [...prevFilters.attributeFilters];
|
|
5420
|
-
updatedFilters[index] = {
|
|
5478
|
+
updatedFilters[index] = {
|
|
5479
|
+
...updatedFilters[index],
|
|
5480
|
+
value: selectedValue,
|
|
5481
|
+
};
|
|
5421
5482
|
return { ...prevFilters, attributeFilters: updatedFilters };
|
|
5422
5483
|
});
|
|
5423
5484
|
};
|
|
5424
5485
|
const handleDataElementChange = (index, selectedValue) => {
|
|
5425
5486
|
setFilters((prevFilters) => {
|
|
5426
5487
|
const updatedFilters = [...prevFilters.dataElementFilters];
|
|
5427
|
-
updatedFilters[index] = {
|
|
5488
|
+
updatedFilters[index] = {
|
|
5489
|
+
...updatedFilters[index],
|
|
5490
|
+
value: selectedValue,
|
|
5491
|
+
};
|
|
5428
5492
|
return { ...prevFilters, dataElementFilters: updatedFilters };
|
|
5429
5493
|
});
|
|
5430
5494
|
};
|
|
5431
5495
|
const handleSearch = () => {
|
|
5432
|
-
this.actionSelected.emit(
|
|
5496
|
+
this.actionSelected.emit({
|
|
5497
|
+
...filters,
|
|
5498
|
+
organizationUnit: selectedOrganisationUnit,
|
|
5499
|
+
organizationUnitId: selectedOrganisationUnit,
|
|
5500
|
+
startDate: filters.startDate,
|
|
5501
|
+
endDate: filters.endDate,
|
|
5502
|
+
});
|
|
5433
5503
|
};
|
|
5434
|
-
// Grid Column Span Logic for Attribute Filters
|
|
5435
5504
|
const getAttributeColumnSpan = (index) => {
|
|
5436
5505
|
const totalItems = filters.attributeFilters.length;
|
|
5437
5506
|
if (totalItems <= 4) {
|
|
5438
|
-
// If 1 to 4 items, place them in a single row (span all columns if there's only one item)
|
|
5439
5507
|
if (totalItems === 1) {
|
|
5440
|
-
return 'span 4';
|
|
5508
|
+
return 'span 4';
|
|
5441
5509
|
}
|
|
5442
5510
|
if (totalItems === 2) {
|
|
5443
|
-
return 'span 2';
|
|
5511
|
+
return 'span 2';
|
|
5444
5512
|
}
|
|
5445
5513
|
if (totalItems === 3) {
|
|
5446
|
-
return 'span 1';
|
|
5514
|
+
return 'span 1';
|
|
5447
5515
|
}
|
|
5448
5516
|
if (totalItems === 4) {
|
|
5449
|
-
return 'span 1';
|
|
5517
|
+
return 'span 1';
|
|
5450
5518
|
}
|
|
5451
5519
|
}
|
|
5452
5520
|
else {
|
|
5453
|
-
|
|
5454
|
-
const rowIndex = Math.floor(index / 2); // Calculate row by pairs
|
|
5521
|
+
const rowIndex = Math.floor(index / 2);
|
|
5455
5522
|
if (index % 2 === 0) {
|
|
5456
|
-
// For first item in each row, span 2 columns
|
|
5457
5523
|
return 'span 2';
|
|
5458
5524
|
}
|
|
5459
5525
|
else if (index === totalItems - 1) {
|
|
5460
|
-
// Last item, spans the full row (4 columns)
|
|
5461
5526
|
return 'span 4';
|
|
5462
5527
|
}
|
|
5463
5528
|
else {
|
|
5464
|
-
// For other items, span 2 columns
|
|
5465
5529
|
return 'span 2';
|
|
5466
5530
|
}
|
|
5467
5531
|
}
|
|
5468
|
-
return 'span 1';
|
|
5532
|
+
return 'span 1';
|
|
5469
5533
|
};
|
|
5470
|
-
// Grid Column Span Logic for Data Element Filters
|
|
5471
5534
|
const getDataElementColumnSpan = (index) => {
|
|
5472
5535
|
const totalItems = filters.dataElementFilters.length;
|
|
5473
5536
|
if (totalItems <= 4) {
|
|
5474
|
-
// If 1 to 4 items, place them in a single row (span all columns if there's only one item)
|
|
5475
5537
|
if (totalItems === 1) {
|
|
5476
|
-
return 'span 4';
|
|
5538
|
+
return 'span 4';
|
|
5477
5539
|
}
|
|
5478
5540
|
if (totalItems === 2) {
|
|
5479
|
-
return 'span 2';
|
|
5541
|
+
return 'span 2';
|
|
5480
5542
|
}
|
|
5481
5543
|
if (totalItems === 3) {
|
|
5482
|
-
return 'span 1';
|
|
5544
|
+
return 'span 1';
|
|
5483
5545
|
}
|
|
5484
5546
|
if (totalItems === 4) {
|
|
5485
|
-
return 'span 1';
|
|
5547
|
+
return 'span 1';
|
|
5486
5548
|
}
|
|
5487
5549
|
}
|
|
5488
5550
|
else {
|
|
5489
|
-
|
|
5490
|
-
const rowIndex = Math.floor(index / 2); // Calculate row by pairs
|
|
5551
|
+
const rowIndex = Math.floor(index / 2);
|
|
5491
5552
|
if (index % 2 === 0) {
|
|
5492
|
-
// For first item in each row, span 2 columns
|
|
5493
5553
|
return 'span 2';
|
|
5494
5554
|
}
|
|
5495
5555
|
else if (index === totalItems - 1) {
|
|
5496
|
-
// Last item, spans the full row (4 columns)
|
|
5497
5556
|
return 'span 4';
|
|
5498
5557
|
}
|
|
5499
5558
|
else {
|
|
5500
|
-
// For other items, span 2 columns
|
|
5501
5559
|
return 'span 2';
|
|
5502
5560
|
}
|
|
5503
5561
|
}
|
|
5504
|
-
return 'span 1';
|
|
5562
|
+
return 'span 1';
|
|
5505
5563
|
};
|
|
5506
5564
|
return (React__default.createElement("div", { style: {
|
|
5507
5565
|
fontFamily: 'Arial, sans-serif',
|
|
@@ -5510,6 +5568,45 @@ class SelectionFiltersComponent extends ReactWrapperModule {
|
|
|
5510
5568
|
borderRadius: '8px',
|
|
5511
5569
|
boxShadow: '0 4px 8px rgba(0, 0, 0, 0.1)',
|
|
5512
5570
|
} },
|
|
5571
|
+
React__default.createElement("div", { style: {
|
|
5572
|
+
display: 'grid',
|
|
5573
|
+
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
5574
|
+
gap: '16px',
|
|
5575
|
+
marginBottom: '16px',
|
|
5576
|
+
} },
|
|
5577
|
+
React__default.createElement(React__default.Fragment, null,
|
|
5578
|
+
React__default.createElement(InputField$1, { value: displayValue, label: "Organization Unit", readOnly: false, onFocus: () => {
|
|
5579
|
+
setShowOrgUnit(true);
|
|
5580
|
+
}, onBlur: () => {
|
|
5581
|
+
this.ngZone.run(() => {
|
|
5582
|
+
console.log('THIS IS IT::: ');
|
|
5583
|
+
});
|
|
5584
|
+
setTouched(true);
|
|
5585
|
+
} }),
|
|
5586
|
+
showOrgUnit && (React__default.createElement(this.FieldOrgUnitSelector, { onCancelOrgUnit: () => {
|
|
5587
|
+
setShowOrgUnit(false);
|
|
5588
|
+
setTouched(true);
|
|
5589
|
+
}, onSelectOrgUnit: (selectedOrgUnits) => {
|
|
5590
|
+
if ((selectedOrgUnits || [])[0]) {
|
|
5591
|
+
const selectedOrgUnit = selectedOrgUnits[0];
|
|
5592
|
+
setDisplayValue(selectedOrgUnit.name);
|
|
5593
|
+
setSelected(selectedOrgUnit.id);
|
|
5594
|
+
setSelectedOrganisationUnit(selectedOrgUnit.id);
|
|
5595
|
+
setValue(selectedOrgUnit.id);
|
|
5596
|
+
setShowOrgUnit(false);
|
|
5597
|
+
setTouched(true);
|
|
5598
|
+
// this.ngZone.run(() => {
|
|
5599
|
+
// setDisplayValue(selectedOrgUnit.name);
|
|
5600
|
+
// setSelected(selectedOrgUnit.id)
|
|
5601
|
+
// setSelectedOrganisationUnit(selectedOrgUnit.id)
|
|
5602
|
+
// setValue(selectedOrgUnit.id);
|
|
5603
|
+
// setShowOrgUnit(false);
|
|
5604
|
+
// setTouched(true);
|
|
5605
|
+
// });
|
|
5606
|
+
}
|
|
5607
|
+
} }))),
|
|
5608
|
+
React__default.createElement(InputField$1, { className: "input-field", label: "Start Date", type: "date", value: filters.startDate, onChange: (event) => setFilters({ ...filters, startDate: event.value }) }),
|
|
5609
|
+
React__default.createElement(InputField$1, { className: "input-field", label: "End Date", type: "date", value: filters.endDate, onChange: (event) => setFilters({ ...filters, endDate: event.value }) })),
|
|
5513
5610
|
React__default.createElement("div", { style: {
|
|
5514
5611
|
display: 'grid',
|
|
5515
5612
|
gridTemplateColumns: 'repeat(4, 1fr)',
|
|
@@ -5524,6 +5621,49 @@ class SelectionFiltersComponent extends ReactWrapperModule {
|
|
|
5524
5621
|
React__default.createElement(Button$1, { onClick: handleSearch }, "Search"))));
|
|
5525
5622
|
};
|
|
5526
5623
|
}
|
|
5624
|
+
getAppConfig() {
|
|
5625
|
+
return this.httpClient.systemInfo().pipe(map((response) => {
|
|
5626
|
+
const systemInfo = response;
|
|
5627
|
+
return {
|
|
5628
|
+
baseUrl: (document?.location?.host?.includes('localhost')
|
|
5629
|
+
? `${document.location.protocol}//${document.location.host}`
|
|
5630
|
+
: systemInfo['contextPath']),
|
|
5631
|
+
apiVersion: Number(((systemInfo['version'] || '')?.split('.') || [])[1]),
|
|
5632
|
+
};
|
|
5633
|
+
}));
|
|
5634
|
+
}
|
|
5635
|
+
getRootOrgUnits() {
|
|
5636
|
+
const orgUnitAttribute = this.getOrgUnitAttributeByUsage(this.orgUnitSelectionConfig.usageType);
|
|
5637
|
+
return this.httpClient
|
|
5638
|
+
.me()
|
|
5639
|
+
.pipe(map((user) => (user ? user[orgUnitAttribute] : []).map((orgUnit) => orgUnit.id)));
|
|
5640
|
+
}
|
|
5641
|
+
getOrgUnitLevels() {
|
|
5642
|
+
return firstValueFrom(this.httpClient
|
|
5643
|
+
.get('organisationUnitLevels.json?fields=id,level,displayName,name&paging=false')
|
|
5644
|
+
.pipe(map((res) => res?.['organisationUnitLevels'])));
|
|
5645
|
+
}
|
|
5646
|
+
onSelectOrgUnit(selectedOrgUnits) {
|
|
5647
|
+
this.showOrgUnitTree.set(false);
|
|
5648
|
+
if ((selectedOrgUnits || [])[0]) {
|
|
5649
|
+
this.selectedOrgUnit.set(selectedOrgUnits[0]);
|
|
5650
|
+
}
|
|
5651
|
+
}
|
|
5652
|
+
getOrgUnitGroups() {
|
|
5653
|
+
return firstValueFrom(this.httpClient
|
|
5654
|
+
.get('organisationUnitGroups.json?fields=id,displayName,name&paging=false')
|
|
5655
|
+
.pipe(map((res) => res?.['organisationUnitGroups'])));
|
|
5656
|
+
}
|
|
5657
|
+
getOrgUnitAttributeByUsage(usageType) {
|
|
5658
|
+
switch (usageType) {
|
|
5659
|
+
case 'DATA_ENTRY':
|
|
5660
|
+
return 'organisationUnits';
|
|
5661
|
+
case 'DATA_VIEW':
|
|
5662
|
+
return 'dataViewOrganisationUnits';
|
|
5663
|
+
default:
|
|
5664
|
+
return 'organisationUnits';
|
|
5665
|
+
}
|
|
5666
|
+
}
|
|
5527
5667
|
async ngAfterViewInit() {
|
|
5528
5668
|
if (!this.elementRef)
|
|
5529
5669
|
throw new Error('No element ref');
|
|
@@ -5553,14 +5693,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
|
|
|
5553
5693
|
|
|
5554
5694
|
class SelectionFiltersUiModule {
|
|
5555
5695
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: SelectionFiltersUiModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
5556
|
-
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] }); }
|
|
5557
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: SelectionFiltersUiModule, imports: [CommonModule, SharedDhis2UiModule] }); }
|
|
5696
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.8", ngImport: i0, type: SelectionFiltersUiModule, declarations: [SelectionFiltersComponent], imports: [CommonModule, SharedDhis2UiModule, ReactWrapperModule, OrganisationUnitSelectorModule], exports: [SelectionFiltersComponent] }); }
|
|
5697
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: SelectionFiltersUiModule, imports: [CommonModule, SharedDhis2UiModule, OrganisationUnitSelectorModule] }); }
|
|
5558
5698
|
}
|
|
5559
5699
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: SelectionFiltersUiModule, decorators: [{
|
|
5560
5700
|
type: NgModule,
|
|
5561
5701
|
args: [{
|
|
5562
5702
|
declarations: [SelectionFiltersComponent],
|
|
5563
|
-
imports: [CommonModule, SharedDhis2UiModule, ReactWrapperModule],
|
|
5703
|
+
imports: [CommonModule, SharedDhis2UiModule, ReactWrapperModule, OrganisationUnitSelectorModule],
|
|
5564
5704
|
exports: [SelectionFiltersComponent],
|
|
5565
5705
|
}]
|
|
5566
5706
|
}] });
|