@fto-consult/expo-ui 6.68.1 → 6.69.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "6.68.1",
3
+ "version": "6.69.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "main",
6
6
  "scripts": {
@@ -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
- setTimeout(()=>{
3461
- return this.fetchData({force:defaultBool(force,true)}).then((data)=>{
3462
- if(isFunction(cb)){
3463
- cb(data);
3464
- }
3465
- if(typeof this.props.onRefreshDatagrid ==='function'){
3466
- this.props.onRefreshDatagrid({context:this,force});
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.node,
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
- if(!this._isMounted()) return;
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 = {