@fto-consult/expo-ui 2.34.4 → 2.35.0
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/package.json
CHANGED
|
@@ -166,6 +166,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
166
166
|
let {
|
|
167
167
|
data,
|
|
168
168
|
selectedRows,
|
|
169
|
+
chartAllowedPerm,
|
|
170
|
+
exportToPDFAllowedPerm,
|
|
171
|
+
exportToExcelAllowedPerm,
|
|
169
172
|
...rest
|
|
170
173
|
} = props;
|
|
171
174
|
if(this.bindResizeEvents()){
|
|
@@ -196,15 +199,27 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
196
199
|
});
|
|
197
200
|
const disTypes = {};
|
|
198
201
|
let hasFoundDisplayTypes = false;
|
|
202
|
+
const perm = isNonNullString(chartAllowedPerm)? Auth.isAllowedFromStr(chartAllowedPerm) : true;
|
|
203
|
+
const ePDFIsAllowed = isNonNullString(exportToPDFAllowedPerm)? Auth.isAllowedFromStr(exportToPDFAllowedPerm) : true;
|
|
204
|
+
const eExcelISAllowed = isNonNullString(exportToExcelAllowedPerm)? Auth.isAllowedFromStr(exportToExcelAllowedPerm) : true;
|
|
199
205
|
Object.map(this.props.displayTypes,(dType,v)=>{
|
|
200
206
|
if(isNonNullString(dType)){
|
|
201
207
|
dType = dType.toLowerCase().trim();
|
|
202
208
|
if(displayTypes[dType]){
|
|
209
|
+
const dp = displayTypes[dType];
|
|
210
|
+
if(dp.isChart && !perm){
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
hasFoundDisplayTypes = true;
|
|
203
214
|
disTypes[dType] = Object.clone(displayTypes[dType]);
|
|
204
215
|
}
|
|
205
|
-
hasFoundDisplayTypes = true;
|
|
206
216
|
}
|
|
207
217
|
});
|
|
218
|
+
const allowedDisplayTypes = {};
|
|
219
|
+
Object.map(displayTypes,(t,i)=>{
|
|
220
|
+
if(t.isChart && !perm) return;
|
|
221
|
+
allowedDisplayTypes[i] = Object.clone(t);
|
|
222
|
+
})
|
|
208
223
|
Object.defineProperties(this,{
|
|
209
224
|
layoutRef : {
|
|
210
225
|
value : React.createRef(null),
|
|
@@ -230,6 +245,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
230
245
|
isLoadingRef : {
|
|
231
246
|
value : {current:false}
|
|
232
247
|
},
|
|
248
|
+
isChartAllowed : {value : perm},
|
|
249
|
+
isExcellExportAllowed : {value:eExcelISAllowed},
|
|
250
|
+
isPDFExportAllowed : {value: ePDFIsAllowed},
|
|
233
251
|
currentFilteringColumns : {value:{}},
|
|
234
252
|
emptySectionListHeaderValue : {value : uniqid("empty-section-list-header-val").toUpperCase()},
|
|
235
253
|
getSectionListHeaderProp : {value : typeof this.props.getSectionListHeader =='function'? this.props.getSectionListHeader : undefined},
|
|
@@ -242,7 +260,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
242
260
|
///la liste des fonctions d'aggregations supportées
|
|
243
261
|
aggregatorFunctions : {value : extendAggreagatorFunctions(this.props.aggregatorFunctions)},
|
|
244
262
|
///les types d'affichage
|
|
245
|
-
displayTypes : {value : hasFoundDisplayTypes ? disTypes :
|
|
263
|
+
displayTypes : {value : hasFoundDisplayTypes ? disTypes : allowedDisplayTypes},
|
|
246
264
|
dateFields : {value : {}},
|
|
247
265
|
sectionListColumnsSize : {value : {current:0}}, //la taille du nombre d'éléments de section dans les colonnes
|
|
248
266
|
chartRef : {value : {current:null}},
|
|
@@ -372,6 +390,12 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
372
390
|
}
|
|
373
391
|
return this.state.sectionListColumns;
|
|
374
392
|
}
|
|
393
|
+
canExportToPDF(){
|
|
394
|
+
return this.isPDFExportAllowed;
|
|
395
|
+
}
|
|
396
|
+
canExportToExcel (){
|
|
397
|
+
return this.isExcellExportAllowed;
|
|
398
|
+
}
|
|
375
399
|
bindResizeEvents(){
|
|
376
400
|
return false;
|
|
377
401
|
}
|
|
@@ -3533,6 +3557,12 @@ CommonDatagridComponent.propTypes = {
|
|
|
3533
3557
|
/**** les series à utiliser pour l'affichage des données lorsque les colonnes sont groupées, ie les montant de totalisation sont utilisés */
|
|
3534
3558
|
sectionListHeadersSeries : PropTypes.arrayOf(PropTypes.string),
|
|
3535
3559
|
}),
|
|
3560
|
+
/*** la permission autorisée pour l'export en pdf */
|
|
3561
|
+
exportToPDFAllowedPerm : PropTypes.string,
|
|
3562
|
+
/*** la permission autorisée pour l'export en excel*/
|
|
3563
|
+
exportToExcelAllowedPerm : PropTypes.string,
|
|
3564
|
+
/*** la permission que doit avoir l'utilisateur pour pouvoir visualiser les graphes à partir du diagrame */
|
|
3565
|
+
chartAllowedPerm : PropTypes.string,
|
|
3536
3566
|
displayType : chartDisplayType,
|
|
3537
3567
|
/*** les types d'afichates supportés par l'application */
|
|
3538
3568
|
displayTypes : PropTypes.arrayOf(chartDisplayType),
|
|
@@ -18,7 +18,7 @@ import fetch from "$capi/fetch";
|
|
|
18
18
|
import Auth from "$auth";
|
|
19
19
|
import Icon from "$ecomponents/Icon";
|
|
20
20
|
|
|
21
|
-
export default function DatabaseStatisticContainer ({dashboardProps,fetchDataProps,table,fetchCount,index,testID,title,icon,onPress:customOnPress,columns,fetchData,withDashboard,...props}){
|
|
21
|
+
export default function DatabaseStatisticContainer ({dashboardProps,onRefreshAll,fetchDataProps,table,fetchCount,index,testID,title,icon,onPress:customOnPress,columns,fetchData,withDashboard,...props}){
|
|
22
22
|
dashboardProps = defaultObj(dashboardProps);
|
|
23
23
|
const [count,setCount] = React.useState(0);
|
|
24
24
|
const datagridRef = React.useRef(null);
|
|
@@ -44,6 +44,11 @@ export default function DatabaseStatisticContainer ({dashboardProps,fetchDataPro
|
|
|
44
44
|
}
|
|
45
45
|
const refreshingRef = React.useRef(null);
|
|
46
46
|
const isMounted = React.useIsMounted();
|
|
47
|
+
const onRefreshAllItem = typeof onRefreshAll =='function'? {
|
|
48
|
+
text : "Tout actualiser",
|
|
49
|
+
onPress : onRefreshAll,
|
|
50
|
+
icon : "refresh-circle"
|
|
51
|
+
} : {}
|
|
47
52
|
|
|
48
53
|
const [isLoading,setIsLoading] = React.useState(withDashboard?false:true);
|
|
49
54
|
const refresh = ()=>{
|
|
@@ -148,7 +153,7 @@ export default function DatabaseStatisticContainer ({dashboardProps,fetchDataPro
|
|
|
148
153
|
</View>
|
|
149
154
|
<Menu
|
|
150
155
|
testID={testID+"_Menu"}
|
|
151
|
-
items = {context.renderMenu()}
|
|
156
|
+
items = {[...context.renderMenu(),onRefreshAllItem]}
|
|
152
157
|
anchor = {(p)=><Pressable {...p} style={[theme.styles.pl1]} testID={testID+"_MenuAnchor"}>
|
|
153
158
|
<Label
|
|
154
159
|
textCenter
|
|
@@ -177,7 +182,8 @@ export default function DatabaseStatisticContainer ({dashboardProps,fetchDataPro
|
|
|
177
182
|
icon : "refresh",
|
|
178
183
|
onPress : refresh,
|
|
179
184
|
text : "Actualiser"
|
|
180
|
-
}
|
|
185
|
+
},
|
|
186
|
+
onRefreshAllItem,
|
|
181
187
|
]}
|
|
182
188
|
anchor = {(p)=><Avatar suffix={index} {...aProps} {...p} icon= {icon} size={40} label={title}/>}
|
|
183
189
|
/>
|
|
@@ -5,6 +5,7 @@ import React from "$react";
|
|
|
5
5
|
import DatabaseStatistic from "./DatabaseStatistic";
|
|
6
6
|
import theme from "$theme";
|
|
7
7
|
import PropTypes from "prop-types";
|
|
8
|
+
import Auth from "$cauth";
|
|
8
9
|
|
|
9
10
|
export const title = 'Statistiques en BD';
|
|
10
11
|
export default function DatabaseStatisticScreen ({withScreen,fetchDataProps,tableFilter,fetchCount,fetchData,title:customTitle,contentProps,containerProps,tables,Component,...props}){
|
|
@@ -12,6 +13,7 @@ export default function DatabaseStatisticScreen ({withScreen,fetchDataProps,tabl
|
|
|
12
13
|
containerProps = defaultObj(containerProps);
|
|
13
14
|
const title = containerProps.title = defaultStr(containerProps.title,DatabaseStatisticScreen.title);
|
|
14
15
|
contentProps = defaultObj(contentProps);
|
|
16
|
+
const forceRender = React.useForceRender();
|
|
15
17
|
if(Component == Cell){
|
|
16
18
|
containerProps.desktopSize = defaultNumber(containerProps.desktopSize,12);
|
|
17
19
|
containerProps.tabletSize = defaultNumber(containerProps.tabletSize,8);
|
|
@@ -28,6 +30,8 @@ export default function DatabaseStatisticScreen ({withScreen,fetchDataProps,tabl
|
|
|
28
30
|
table = t;
|
|
29
31
|
}
|
|
30
32
|
if(table.databaseStatistic === false || table.databaseStatistics === false) return null;
|
|
33
|
+
const chartAllowedPerm = defaultStr(table.chartAllowedPerm);
|
|
34
|
+
if(chartAllowedPerm && !Auth.isAllowedFromStr(chartAllowedPerm || !Auth.isTableDataAllowed({table:tableName}))) return null;
|
|
31
35
|
content.push(<Cell elevation = {5} withSurface mobileSize={12} desktopSize={3} tabletSize={4} {...contentProps} key = {index} >
|
|
32
36
|
<DatabaseStatistic
|
|
33
37
|
icon = {table.icon}
|