@iapps/ng-dhis2-ui 1.2.99 → 1.2.100
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 +31 -24
- 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/line-list/containers/line-list.component.d.ts +1 -1
- package/lib/modules/organisation-unit-selector/containers/organisation-unit-selector/organisation-unit-selector.component.d.ts +2 -3
- package/lib/modules/organisation-unit-selector/models/organisation-unit-config.model.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2891,6 +2891,7 @@ class OrganisationUnitSelectionConfig {
|
|
|
2891
2891
|
this.allowSingleSelection = params?.allowSingleSelection || false;
|
|
2892
2892
|
this.batchSize = params?.batchSize;
|
|
2893
2893
|
this.additionalQueryFields = params?.additionalQueryFields;
|
|
2894
|
+
this.allowCaching = params?.allowCaching;
|
|
2894
2895
|
}
|
|
2895
2896
|
}
|
|
2896
2897
|
|
|
@@ -2899,10 +2900,10 @@ class OrganisationUnitSelectionConfig {
|
|
|
2899
2900
|
// license that can be found in the LICENSE file.
|
|
2900
2901
|
|
|
2901
2902
|
class OrganisationUnitSelectorComponent extends ReactWrapperModule {
|
|
2902
|
-
constructor(elementRef,
|
|
2903
|
+
constructor(elementRef, ngZone) {
|
|
2903
2904
|
super(elementRef);
|
|
2904
|
-
this.httpClient = httpClient;
|
|
2905
2905
|
this.ngZone = ngZone;
|
|
2906
|
+
this.d2 = window.d2Web;
|
|
2906
2907
|
this.selectedOrgUnits = [];
|
|
2907
2908
|
this.orgUnitSelectionConfig = new OrganisationUnitSelectionConfig();
|
|
2908
2909
|
this.selectOrgUnits = new EventEmitter();
|
|
@@ -2918,18 +2919,23 @@ class OrganisationUnitSelectorComponent extends ReactWrapperModule {
|
|
|
2918
2919
|
this.reactDomRoot = ReactDOM.createRoot(this.elementRef.nativeElement);
|
|
2919
2920
|
const rootOrgUnits = await this.getRootOrgUnits();
|
|
2920
2921
|
const config = await this.getAppConfig();
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2922
|
+
if (config) {
|
|
2923
|
+
this.component = () => (React__default.createElement(Provider, { config: config, plugin: false, parentAlertsAdd: undefined, showAlertsInPlugin: false }, React__default.createElement(OrgUnitDimension, { selected: this.selectedOrgUnits, hideGroupSelect: this.orgUnitSelectionConfig.hideGroupSelect, hideLevelSelect: this.orgUnitSelectionConfig.hideLevelSelect, hideUserOrgUnits: this.orgUnitSelectionConfig.hideUserOrgUnits, onSelect: (selectionEvent) => this.ngZone.run(() => {
|
|
2924
|
+
this.onSelectItems(selectionEvent);
|
|
2925
|
+
}), orgUnitGroupPromise: this.getOrgUnitGroups(), orgUnitLevelPromise: this.getOrgUnitLevels(), roots: rootOrgUnits })));
|
|
2926
|
+
this.render();
|
|
2927
|
+
}
|
|
2925
2928
|
}
|
|
2926
2929
|
async getAppConfig() {
|
|
2927
|
-
const systemInfo =
|
|
2930
|
+
const systemInfo = this.d2.systemInfo;
|
|
2931
|
+
if (!systemInfo) {
|
|
2932
|
+
return systemInfo;
|
|
2933
|
+
}
|
|
2928
2934
|
return {
|
|
2929
|
-
baseUrl:
|
|
2935
|
+
baseUrl: document?.location?.host?.includes('localhost')
|
|
2930
2936
|
? `${document.location.protocol}//${document.location.host}`
|
|
2931
|
-
: systemInfo
|
|
2932
|
-
apiVersion:
|
|
2937
|
+
: systemInfo.contextPath,
|
|
2938
|
+
apiVersion: systemInfo.apiVersion,
|
|
2933
2939
|
};
|
|
2934
2940
|
}
|
|
2935
2941
|
getOrgUnitAttributeByUsage(usageType) {
|
|
@@ -2942,26 +2948,27 @@ class OrganisationUnitSelectorComponent extends ReactWrapperModule {
|
|
|
2942
2948
|
return 'organisationUnits';
|
|
2943
2949
|
}
|
|
2944
2950
|
}
|
|
2945
|
-
getRootOrgUnits() {
|
|
2951
|
+
async getRootOrgUnits() {
|
|
2946
2952
|
const orgUnitAttribute = this.getOrgUnitAttributeByUsage(this.orgUnitSelectionConfig.usageType);
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
.pipe(map((user) => (user ? user[orgUnitAttribute] : []).map((orgUnit) => orgUnit.id))));
|
|
2953
|
+
const currentUser = this.d2?.currentUser;
|
|
2954
|
+
return (currentUser ? currentUser[orgUnitAttribute] : []).map((orgUnit) => orgUnit.id);
|
|
2950
2955
|
}
|
|
2951
|
-
getOrgUnitGroups() {
|
|
2952
|
-
|
|
2953
|
-
.
|
|
2954
|
-
|
|
2956
|
+
async getOrgUnitGroups() {
|
|
2957
|
+
const orgUnitGroupResponse = await this.d2?.httpInstance?.get('organisationUnitGroups.json?fields=id,displayName,name&paging=false', {
|
|
2958
|
+
useIndexDb: this.orgUnitSelectionConfig?.allowCaching,
|
|
2959
|
+
});
|
|
2960
|
+
return orgUnitGroupResponse?.data?.['organisationUnitGroups'] ?? [];
|
|
2955
2961
|
}
|
|
2956
|
-
getOrgUnitLevels() {
|
|
2957
|
-
|
|
2958
|
-
.
|
|
2959
|
-
|
|
2962
|
+
async getOrgUnitLevels() {
|
|
2963
|
+
const orgUnitLevelResponse = await this.d2?.httpInstance?.get('organisationUnitLevels.json?fields=id,level,displayName,name&paging=false', {
|
|
2964
|
+
useIndexDb: this.orgUnitSelectionConfig?.allowCaching,
|
|
2965
|
+
});
|
|
2966
|
+
return orgUnitLevelResponse?.data?.['organisationUnitLevels'] ?? [];
|
|
2960
2967
|
}
|
|
2961
2968
|
onSelectItems(selectionEvent) {
|
|
2962
2969
|
this.selectOrgUnits.emit(selectionEvent.items);
|
|
2963
2970
|
}
|
|
2964
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: OrganisationUnitSelectorComponent, deps: [{ token: i0.ElementRef }, { token:
|
|
2971
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: OrganisationUnitSelectorComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2965
2972
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: OrganisationUnitSelectorComponent, isStandalone: false, selector: "ng-dhis2-ui-org-unit-selector", inputs: { selectedOrgUnits: "selectedOrgUnits", orgUnitSelectionConfig: "orgUnitSelectionConfig" }, outputs: { selectOrgUnits: "selectOrgUnits" }, usesInheritance: true, ngImport: i0, template: '<ng-container><ng-container>', isInline: true }); }
|
|
2966
2973
|
}
|
|
2967
2974
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: OrganisationUnitSelectorComponent, decorators: [{
|
|
@@ -2971,7 +2978,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
|
|
|
2971
2978
|
template: '<ng-container><ng-container>',
|
|
2972
2979
|
standalone: false,
|
|
2973
2980
|
}]
|
|
2974
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }, { type:
|
|
2981
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.NgZone }], propDecorators: { selectedOrgUnits: [{
|
|
2975
2982
|
type: Input
|
|
2976
2983
|
}], orgUnitSelectionConfig: [{
|
|
2977
2984
|
type: Input
|