@iapps/ng-dhis2-ui 1.2.99 → 1.2.101
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 +75 -62
- 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/containers/organisation-unit-selector-modal/organisation-unit-selector-modal.component-modal.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
|
|
@@ -2980,9 +2987,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
|
|
|
2980
2987
|
}] } });
|
|
2981
2988
|
|
|
2982
2989
|
class OrganisationUnitSelectorModalComponent extends ReactWrapperModule {
|
|
2983
|
-
constructor(elementRef
|
|
2990
|
+
constructor(elementRef) {
|
|
2984
2991
|
super(elementRef);
|
|
2985
|
-
this.
|
|
2992
|
+
this.d2 = window.d2Web;
|
|
2986
2993
|
this.selectedOrgUnits = [];
|
|
2987
2994
|
this.orgUnitSelectionConfig = new OrganisationUnitSelectionConfig();
|
|
2988
2995
|
this.selectOrgUnits = new EventEmitter();
|
|
@@ -3000,24 +3007,26 @@ class OrganisationUnitSelectorModalComponent extends ReactWrapperModule {
|
|
|
3000
3007
|
this.reactDomRoot = ReactDOM.createRoot(this.elementRef.nativeElement);
|
|
3001
3008
|
const rootOrgUnits = await this.getRootOrgUnits();
|
|
3002
3009
|
const config = await this.getAppConfig();
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
React__default.createElement(
|
|
3007
|
-
|
|
3008
|
-
React__default.createElement(
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
React__default.createElement(
|
|
3013
|
-
React__default.createElement(
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3010
|
+
if (config) {
|
|
3011
|
+
this.component = () => {
|
|
3012
|
+
const [selected, setSelected] = useState(this.selectedOrgUnits);
|
|
3013
|
+
return (React__default.createElement(Provider, { config: config, plugin: false, parentAlertsAdd: undefined, showAlertsInPlugin: false }, React__default.createElement(Modal$1, { position: "middle", large: true },
|
|
3014
|
+
React__default.createElement(ModalTitle$1, null, "Organisation unit"),
|
|
3015
|
+
React__default.createElement(ModalContent$1, null,
|
|
3016
|
+
React__default.createElement(OrgUnitDimension, { selected: selected, hideGroupSelect: this.orgUnitSelectionConfig.hideGroupSelect, hideLevelSelect: this.orgUnitSelectionConfig.hideLevelSelect, hideUserOrgUnits: this.orgUnitSelectionConfig.hideUserOrgUnits, onSelect: (selectionEvent) => {
|
|
3017
|
+
setSelected(selectionEvent.items);
|
|
3018
|
+
}, orgUnitGroupPromise: this.getOrgUnitGroups(), orgUnitLevelPromise: this.getOrgUnitLevels(), roots: rootOrgUnits })),
|
|
3019
|
+
React__default.createElement(ModalActions$1, null,
|
|
3020
|
+
React__default.createElement(ButtonStrip$1, { end: true },
|
|
3021
|
+
React__default.createElement(Button$1, { onClick: () => {
|
|
3022
|
+
this.onCancel();
|
|
3023
|
+
} }, "Cancel"),
|
|
3024
|
+
React__default.createElement(Button$1, { primary: true, disabled: selected.length === 0, onClick: () => {
|
|
3025
|
+
this.onConfirm(selected);
|
|
3026
|
+
} }, "Confirm"))))));
|
|
3027
|
+
};
|
|
3028
|
+
this.render();
|
|
3029
|
+
}
|
|
3021
3030
|
}
|
|
3022
3031
|
onCancel() {
|
|
3023
3032
|
this.cancel.emit();
|
|
@@ -3026,12 +3035,15 @@ class OrganisationUnitSelectorModalComponent extends ReactWrapperModule {
|
|
|
3026
3035
|
this.confirm.emit(selectedItems);
|
|
3027
3036
|
}
|
|
3028
3037
|
async getAppConfig() {
|
|
3029
|
-
const systemInfo =
|
|
3038
|
+
const systemInfo = this.d2.systemInfo;
|
|
3039
|
+
if (!systemInfo) {
|
|
3040
|
+
return systemInfo;
|
|
3041
|
+
}
|
|
3030
3042
|
return {
|
|
3031
|
-
baseUrl:
|
|
3043
|
+
baseUrl: document?.location?.host?.includes('localhost')
|
|
3032
3044
|
? `${document.location.protocol}//${document.location.host}`
|
|
3033
|
-
: systemInfo
|
|
3034
|
-
apiVersion:
|
|
3045
|
+
: systemInfo.contextPath,
|
|
3046
|
+
apiVersion: systemInfo.apiVersion,
|
|
3035
3047
|
};
|
|
3036
3048
|
}
|
|
3037
3049
|
getOrgUnitAttributeByUsage(usageType) {
|
|
@@ -3044,32 +3056,33 @@ class OrganisationUnitSelectorModalComponent extends ReactWrapperModule {
|
|
|
3044
3056
|
return 'organisationUnits';
|
|
3045
3057
|
}
|
|
3046
3058
|
}
|
|
3047
|
-
getRootOrgUnits() {
|
|
3059
|
+
async getRootOrgUnits() {
|
|
3048
3060
|
const orgUnitAttribute = this.getOrgUnitAttributeByUsage(this.orgUnitSelectionConfig.usageType);
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
.pipe(map((user) => (user ? user[orgUnitAttribute] : []).map((orgUnit) => orgUnit.id))));
|
|
3061
|
+
const currentUser = this.d2?.currentUser;
|
|
3062
|
+
return (currentUser ? currentUser[orgUnitAttribute] : []).map((orgUnit) => orgUnit.id);
|
|
3052
3063
|
}
|
|
3053
|
-
getOrgUnitGroups() {
|
|
3054
|
-
|
|
3055
|
-
.
|
|
3056
|
-
|
|
3064
|
+
async getOrgUnitGroups() {
|
|
3065
|
+
const orgUnitGroupResponse = await this.d2?.httpInstance?.get('organisationUnitGroups.json?fields=id,displayName,name&paging=false', {
|
|
3066
|
+
useIndexDb: this.orgUnitSelectionConfig?.allowCaching,
|
|
3067
|
+
});
|
|
3068
|
+
return orgUnitGroupResponse?.data?.['organisationUnitGroups'] ?? [];
|
|
3057
3069
|
}
|
|
3058
|
-
getOrgUnitLevels() {
|
|
3059
|
-
|
|
3060
|
-
.
|
|
3061
|
-
|
|
3070
|
+
async getOrgUnitLevels() {
|
|
3071
|
+
const orgUnitLevelResponse = await this.d2?.httpInstance?.get('organisationUnitLevels.json?fields=id,level,displayName,name&paging=false', {
|
|
3072
|
+
useIndexDb: this.orgUnitSelectionConfig?.allowCaching,
|
|
3073
|
+
});
|
|
3074
|
+
return orgUnitLevelResponse?.data?.['organisationUnitLevels'] ?? [];
|
|
3062
3075
|
}
|
|
3063
3076
|
onSelectItems(selectionEvent) {
|
|
3064
3077
|
this.selectOrgUnits.emit(selectionEvent.items);
|
|
3065
3078
|
}
|
|
3066
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: OrganisationUnitSelectorModalComponent, deps: [{ token: i0.ElementRef }
|
|
3079
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: OrganisationUnitSelectorModalComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3067
3080
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: OrganisationUnitSelectorModalComponent, isStandalone: false, selector: "ng-dhis2-ui-org-unit-selector-modal", inputs: { selectedOrgUnits: "selectedOrgUnits", orgUnitSelectionConfig: "orgUnitSelectionConfig" }, outputs: { selectOrgUnits: "selectOrgUnits", cancel: "cancel", confirm: "confirm" }, usesInheritance: true, ngImport: i0, template: '<ng-container><ng-container>', isInline: true, styles: ["::ng-deep .layer{z-index:2!important}\n"] }); }
|
|
3068
3081
|
}
|
|
3069
3082
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: OrganisationUnitSelectorModalComponent, decorators: [{
|
|
3070
3083
|
type: Component,
|
|
3071
3084
|
args: [{ selector: 'ng-dhis2-ui-org-unit-selector-modal', template: '<ng-container><ng-container>', standalone: false, styles: ["::ng-deep .layer{z-index:2!important}\n"] }]
|
|
3072
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }
|
|
3085
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { selectedOrgUnits: [{
|
|
3073
3086
|
type: Input
|
|
3074
3087
|
}], orgUnitSelectionConfig: [{
|
|
3075
3088
|
type: Input
|