@fto-consult/expo-ui 6.68.2 → 6.69.1
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
@@ -268,6 +268,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
268
268
|
chartRef : {value : {current:null}},
|
269
269
|
layoutRef : {value : {}},
|
270
270
|
hidePreloaderOnRenderKey : {value : uniqid("hide-preloader-on-render")},
|
271
|
+
canRenderProgressBarKey : {value : uniqid("can-render-pgroessbar")},
|
271
272
|
chartSeriesNamesColumnsMapping : {value : {}},//le mappage entre les index des series et les colonnes coorespondantes
|
272
273
|
});
|
273
274
|
this.setSelectedRows(selectedRows);
|
@@ -3030,6 +3031,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
3030
3031
|
}
|
3031
3032
|
|
3032
3033
|
renderProgressBar(props){
|
3034
|
+
if(this.props.renderProgressBar === false || !this.canRenderProgressBar()) return null;
|
3033
3035
|
if(typeof props !=='object' || !props || Array.isArray(props)){
|
3034
3036
|
props = {};
|
3035
3037
|
}
|
@@ -3215,8 +3217,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
3215
3217
|
example common[articles], dans ce cas, la fonction fetchData, aura pour rôle de chercher toutes les données qui match
|
3216
3218
|
la table dans la base common.
|
3217
3219
|
Elle pourra éventuellement passer directement la limite et les filtres à la fonction fetchdata
|
3220
|
+
si renderProgressBar est à false alors la progression ne sera pas affiché
|
3218
3221
|
*/
|
3219
|
-
fetchData ({cb,callback,force,fetchOptions,...rest}){
|
3222
|
+
fetchData ({cb,callback,force,renderProgressBar,fetchOptions,...rest}){
|
3220
3223
|
const sData = this.INITIAL_STATE.data || (!this.isTableData() || typeof this.props.fetchData !='function') ? this.props.data : this.state.data;
|
3221
3224
|
if(!this._isMounted()) return Promise.resolve(sData);
|
3222
3225
|
if(this.isFetchingData) {
|
@@ -3227,6 +3230,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
3227
3230
|
};
|
3228
3231
|
this.isFetchingData = true;
|
3229
3232
|
cb = typeof cb =='function'? cb : typeof callback =='function'? callback : undefined;
|
3233
|
+
this.toggleCanRenderProgressBar(renderProgressBar);
|
3230
3234
|
this.fetchingPromiseData = new Promise((resolve,reject)=>{
|
3231
3235
|
setTimeout(()=>{
|
3232
3236
|
if(typeof cb === 'boolean'){
|
@@ -3450,23 +3454,28 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
3450
3454
|
}
|
3451
3455
|
return maxHeight;
|
3452
3456
|
}
|
3457
|
+
/***
|
3458
|
+
@param {boolean|object}
|
3459
|
+
@param {function|object}
|
3460
|
+
*/
|
3453
3461
|
refresh (force,cb){
|
3462
|
+
const opts = isObj(force)? force : isObj(cb)? cb : {};
|
3454
3463
|
if(isFunction(force)){
|
3455
3464
|
let t = cb;
|
3456
3465
|
cb = force;
|
3457
3466
|
force = isBool(t)? t : true;
|
3458
3467
|
}
|
3468
|
+
opts.onSuccess = cb = typeof cb =="function"? cb : typeof opts.onSuccess =='function'? opts.onSuccess : undefined;
|
3469
|
+
opts.force = defaultBool(force,opts.force,true)
|
3459
3470
|
return new Promise((resolve,reject)=>{
|
3460
|
-
|
3461
|
-
|
3462
|
-
|
3463
|
-
|
3464
|
-
|
3465
|
-
|
3466
|
-
|
3467
|
-
|
3468
|
-
}).then(resolve).catch(reject);
|
3469
|
-
},100);
|
3471
|
+
return this.fetchData(opts).then((data)=>{
|
3472
|
+
if(isFunction(cb)){
|
3473
|
+
cb(data,{...opts,context:this});
|
3474
|
+
}
|
3475
|
+
if(typeof this.props.onRefresh ==='function'){
|
3476
|
+
this.props.onRefresh({...opts,context:this});
|
3477
|
+
}
|
3478
|
+
}).then(resolve).catch(reject);
|
3470
3479
|
})
|
3471
3480
|
}
|
3472
3481
|
onResizePage(){
|
@@ -3549,6 +3558,14 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
3549
3558
|
const cH = this[this.hidePreloaderOnRenderKey];
|
3550
3559
|
return typeof cH =='boolean'? cH : true;
|
3551
3560
|
}
|
3561
|
+
toggleCanRenderProgressBar(toggle){
|
3562
|
+
toggle = typeof toggle =='boolean'? toggle : true;
|
3563
|
+
this[this.canRenderProgressBarKey] = toggle;
|
3564
|
+
return toggle;
|
3565
|
+
}
|
3566
|
+
canRenderProgressBar(){
|
3567
|
+
return this[this.canRenderProgressBarKey] !== false;
|
3568
|
+
}
|
3552
3569
|
toggleHidePreloaderOnRender(toggle){
|
3553
3570
|
this[this.hidePreloaderOnRenderKey] = !!toggle;
|
3554
3571
|
}
|
@@ -3967,7 +3984,11 @@ CommonDatagridComponent.propTypes = {
|
|
3967
3984
|
*/
|
3968
3985
|
filter : PropTypes.func,
|
3969
3986
|
/*** la barre de progression */
|
3970
|
-
renderProgressBar : PropTypes.
|
3987
|
+
renderProgressBar : PropTypes.oneOfType([
|
3988
|
+
PropTypes.node,
|
3989
|
+
PropTypes.bool, //si false, alors le progress bar ne sera pas rendu
|
3990
|
+
PropTypes.element,
|
3991
|
+
]),
|
3971
3992
|
/*** fonction permettant de retourner l'unique clé des éléments du tableau */
|
3972
3993
|
getRowKey : PropTypes.func,
|
3973
3994
|
///la fonction utilisée pour l'impression du datagrid
|
@@ -4080,6 +4101,7 @@ CommonDatagridComponent.propTypes = {
|
|
4080
4101
|
PropTypes.func,
|
4081
4102
|
PropTypes.bool,
|
4082
4103
|
]),
|
4104
|
+
onRefresh : PropTypes.func,//lorsque la fonction refresh est appelée
|
4083
4105
|
displayType : chartDisplayType,
|
4084
4106
|
/*** les types d'afichates supportés par l'application */
|
4085
4107
|
displayTypes : PropTypes.arrayOf(chartDisplayType),
|
@@ -26,11 +26,7 @@ export default class CommonTableDatagrid extends CommonDatagrid{
|
|
26
26
|
|
27
27
|
/*** lorsque la données est modifiée */
|
28
28
|
onUpsertData =(arg) =>{
|
29
|
-
|
30
|
-
this.isDataJustComeToUpsert = true; ///on empêche d'afficher le progress bar
|
31
|
-
this.fetchData({force:true}).finally(()=>{
|
32
|
-
this.isDataJustComeToUpsert = undefined;
|
33
|
-
});
|
29
|
+
return this.refresh({force:true,renderProgressBar:false});
|
34
30
|
}
|
35
31
|
|
36
32
|
componentDidMount(){
|
@@ -57,10 +53,6 @@ export default class CommonTableDatagrid extends CommonDatagrid{
|
|
57
53
|
isTableData(){
|
58
54
|
return true;
|
59
55
|
}
|
60
|
-
renderProgressBar(props){
|
61
|
-
if(this.isDataJustComeToUpsert) return null;
|
62
|
-
return super.renderProgressBar(props);
|
63
|
-
}
|
64
56
|
}
|
65
57
|
|
66
58
|
CommonTableDatagrid.propTypes = {
|
@@ -193,15 +193,27 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
|
|
193
193
|
opts.showError = false;
|
194
194
|
}
|
195
195
|
if(typeof fetcher =='function'){
|
196
|
-
return fetcher(url,opts)
|
196
|
+
return fetcher(url,opts).then((r)=>{
|
197
|
+
showProgressRef.current = false;
|
198
|
+
return r;
|
199
|
+
}).catch((r)=>{
|
200
|
+
showProgressRef.current = false;
|
201
|
+
return r;
|
202
|
+
});
|
197
203
|
}
|
198
|
-
return apiFetch(url,opts)
|
204
|
+
return apiFetch(url,opts).then((r)=>{
|
205
|
+
showProgressRef.current = false;
|
206
|
+
return r;
|
207
|
+
}).catch((r)=>{
|
208
|
+
showProgressRef.current = false;
|
209
|
+
return r;
|
210
|
+
});
|
199
211
|
},
|
200
212
|
swrOptions : getSWROptions(swrConfig.refreshTimeout)
|
201
213
|
});
|
202
214
|
const dataRef = React.useRef(null);
|
203
215
|
const totalRef = React.useRef(0);
|
204
|
-
const loading = (customIsLoading === true || isLoading || isValidating);
|
216
|
+
const loading = (customIsLoading === true || isLoading || (isValidating && showProgressRef.current));
|
205
217
|
const {data,total} = React.useMemo(()=>{
|
206
218
|
if((loading && customIsLoading !== false) || !isObjOrArray(result)){
|
207
219
|
return {data:dataRef.current,total:totalRef.current};
|
@@ -228,7 +240,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
|
|
228
240
|
},500);
|
229
241
|
},[error]);
|
230
242
|
const doRefresh = (showProgress)=>{
|
231
|
-
showProgressRef.current = showProgress ? typeof showProgress ==='boolean' :
|
243
|
+
showProgressRef.current = showProgress ? typeof showProgress ==='boolean' : showProgressRef.current;
|
232
244
|
refresh();
|
233
245
|
}
|
234
246
|
const canPaginate = ()=>{
|
@@ -391,7 +403,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
|
|
391
403
|
handleQueryLimit = {false}
|
392
404
|
handlePagination = {false}
|
393
405
|
autoSort = {canSortRemotely()? false : true}
|
394
|
-
isLoading = {loading
|
406
|
+
isLoading = {loading && showProgressRef.current || false}
|
395
407
|
beforeFetchData = {(args)=>{
|
396
408
|
if(typeof beforeFetchData =="function" && beforeFetchData(args)==false) return;
|
397
409
|
let {fetchOptions:opts,force} = args;
|