@fto-consult/expo-ui 2.23.8 → 2.23.10

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": "2.23.8",
3
+ "version": "2.23.10",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -974,28 +974,26 @@ export default class CommonDatagridComponent extends AppComponent {
974
974
  isFilterable(){
975
975
  return this.props.filterable !== false && this.props.filters !== false ? true : false;
976
976
  }
977
- showFilters(){
978
- if(!this._isMounted() || !this.isFilterable()) {
977
+ toggleFilters(showFilters,cb){
978
+ if(!this._isMounted() || !this.isFilterable()) {
979
979
  this.isUpdating = false;
980
980
  return;
981
- }
982
- if(this.isUpdating) return false;
983
- this.isUpdating = true;
984
- this.setState( {showFilters:true},()=>{
985
- this.isUpdating = false;
986
- this.setSessionData({showFilters:true});
987
- })
981
+ }
982
+ if(typeof showFilters !=='boolean' || showFilters === this.state.showFilters) return;
983
+ if(this.isUpdating) return false;
984
+ this.isUpdating = true;
985
+ setTimeout(()=>{
986
+ this.setState( {showFilters},()=>{
987
+ this.isUpdating = false;
988
+ this.setSessionData({showFilters});
989
+ })
990
+ },100);
988
991
  }
989
- hideFilters (){
990
- if(!this._isMounted() || !this.isFilterable()) {
991
- this.isUpdating = false;
992
- return;
993
- }
994
- if(this.isUpdating) return false;
995
- this.setState({showFilters:false},()=>{
996
- this.isUpdating = false;
997
- this.setSessionData({showFilters:false})
998
- })
992
+ showFilters(){
993
+ return this.toggleFilters(true);
994
+ }
995
+ hideFilters (){
996
+ return this.toggleFilters(false);
999
997
  }
1000
998
 
1001
999
  toggleFooters(showOrHide){
@@ -2355,10 +2353,17 @@ export default class CommonDatagridComponent extends AppComponent {
2355
2353
  willConvertFiltersToSQL(){
2356
2354
  return !!defaultVal(this.props.convertFiltersToSQL,willConvertFiltersToSQL());;
2357
2355
  }
2358
- getFilters(){
2359
- this.filters = extendObj(true,{},this.filteredValues,this.filters)
2360
- const preparedFilters = prepareFilters(this.filters,{filter:this.canHandleFilterVal.bind(this),convertToSQL:this.willConvertFiltersToSQL()});
2361
- return preparedFilters;
2356
+ /*** récupère les filtres en cours du datagrid
2357
+ * @param {boolean} prepare si les filtres seront apprêtés grace à la méthode prepareFilters de $cFilters
2358
+ * @param {boolean} convertFiltersToSQL si les filtres seront convertis au formatSQL
2359
+ */
2360
+ getFilters(args){
2361
+ args = defaultObj(args);
2362
+ const prepare = typeof args.prepare =='boolean'? args.prepare : typeof args.prepareFilters =='boolean' ? args.prepareFilters : true;
2363
+ this.filters = extendObj(true,{},this.filteredValues,this.filters);
2364
+ const convertFiltersToSQL = typeof args.convertToSQL =="boolean"? args.convertToSQL : typeof args.convertFiltersToSQL =="boolean"? args.convertFiltersToSQL : false;
2365
+ if(prepare === false) return this.filters;
2366
+ return prepareFilters(this.filters,{filter:this.canHandleFilterVal.bind(this),convertToSQL:convertFiltersToSQL});
2362
2367
  }
2363
2368
  onChangeDataSources(args){
2364
2369
  let {dataSources,server} = args;
@@ -3164,6 +3169,8 @@ CommonDatagridComponent.propTypes = {
3164
3169
  displayTypes : PropTypes.arrayOf(chartDisplayType),
3165
3170
  /***le code de la fonction d'aggregation à utilier par défaut, dans la liste des fonctions d'aggrégations du composant */
3166
3171
  aggregatorFunction : PropTypes.string,
3172
+ /*** permet de faire une mutation sur les options de la recherche, immédiatement avant le lancement de la recherche */
3173
+ fetchOptionsMutator : PropTypes.func,
3167
3174
  }
3168
3175
 
3169
3176
  const styles = StyleSheet.create({
@@ -1,7 +1,12 @@
1
1
  import CommonDatagrid from "./Common";
2
2
  import {defaultObj,extendObj,defaultStr,isNonNullString,isFunction,isPromise} from "$utils";
3
3
  import PropTypes from "prop-types";
4
-
4
+ import {convertToSQL} from "$ecomponents/Filter";
5
+ /****
6
+ * la fonction fetchOptionsMutator permet éventuellemnt de faire une mutations sur les options fetchOptions avant qu'elle ne soit appliquée pour la recherche. elle
7
+ * est appelée avant que la fonction convertToSQL ne soit appelée, bien évidemement si la props convertToSQL est active pour le datagrid
8
+ * la fonction beforeFetchData est appelée immédiatement avant l'execution de la requête fetch et après que la fonction converttoSQL soit appelée
9
+ */
5
10
  export default class CommonTableDatagrid extends CommonDatagrid{
6
11
  constructor(props){
7
12
  super(props);
@@ -76,8 +81,9 @@ export default class CommonTableDatagrid extends CommonDatagrid{
76
81
  force = cb;
77
82
  cb = undefined;
78
83
  }
79
- const fetchFilters = this.getFilters();
80
- fetchOptions = isObj(fetchOptions)?Object.clone(fetchOptions):{};
84
+ const fetchFilters = this.getFilters({convertToSQL:false});
85
+ fetchOptions = defaultObj(fetchOptions);
86
+ fetchOptions = Object.clone(fetchOptions);
81
87
  fetchOptions.selector = defaultObj(fetchOptions.selector);
82
88
  fetchOptions.dataSources = this.currentDataSources;
83
89
  fetchOptions = extendObj(true,true,{},fetchOptions,{selector : fetchFilters});
@@ -91,7 +97,14 @@ export default class CommonTableDatagrid extends CommonDatagrid{
91
97
  delete fetchOptions.limit
92
98
  }
93
99
  }
100
+ if(typeof this.props.fetchOptionsMutator =='function' && this.props.fetchOptionsMutator(fetchOptions) === false){
101
+ this.isFetchingData = false;
102
+ return resolve(this.state.data);
103
+ }
94
104
  this.beforeFetchData(fetchOptions);
105
+ if(this.willConvertFiltersToSQL()){
106
+ fetchOptions.selector = convertToSQL(fetchOptions.selector);
107
+ }
95
108
  if(typeof this.props.beforeFetchData =='function' && this.props.beforeFetchData({...rest,context:this,force,fetchOptions,options:fetchOptions}) === false){
96
109
  this.isFetchingData = false;
97
110
  return resolve(this.state.data);
@@ -105,7 +118,7 @@ export default class CommonTableDatagrid extends CommonDatagrid{
105
118
  fetchData = this.props.fetchData.call(this,fetchOptions);
106
119
  }
107
120
  fetchData = isFunction(fetchData)? fetchData.call(this,fetchOptions) : fetchData;
108
- this.updateProgress(true,()=>{
121
+ this.setIsLoading(true,()=>{
109
122
  if(isPromise(fetchData)){
110
123
  return fetchData.then(data=>{
111
124
  return this.resolveFetchedDataPromise({cb,data,force}).then((data)=>{
@@ -133,7 +146,7 @@ export default class CommonTableDatagrid extends CommonDatagrid{
133
146
  reject(e);
134
147
  });
135
148
  }
136
- });
149
+ },true);
137
150
  },1);
138
151
  })
139
152
  return this.fetchingPromiseData;
@@ -153,6 +166,7 @@ export default class CommonTableDatagrid extends CommonDatagrid{
153
166
  }
154
167
  resolve(data);
155
168
  this.isFetchingData = undefined;
169
+ this.setIsLoading(false,false);
156
170
  })
157
171
  });
158
172
  })
@@ -393,8 +393,8 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
393
393
  autoSort = {canSortRemotely()? false : true}
394
394
  isLoading = {loading && !error && showProgressRef.current && true || false}
395
395
  beforeFetchData = {(args)=>{
396
+ if(typeof beforeFetchData =="function" && beforeFetchData(args)==false) return;
396
397
  let {fetchOptions:opts,force} = args;
397
- if(typeof beforeFetchData =="function" && beforeFetchData(fetchData)==false) return;
398
398
  opts.fields = fetchFields;
399
399
  opts = getFetchOptions({showError:showProgressRef.current,...opts});
400
400
  isInitializedRef.current = true;
@@ -12,6 +12,7 @@ import {renderActions} from "$ecomponents/Dialog/utils";
12
12
  import {handleBeforeSaveCallback} from "./utils";
13
13
  import componentsTypes from "./componentsTypes";
14
14
  import { keyboardShortcuts } from "../utils";
15
+ import {getScreenProps} from "$cnavigation";
15
16
 
16
17
  export default class FormDataComponent extends AppComponent{
17
18
  constructor(props){
@@ -63,9 +64,9 @@ export default class FormDataComponent extends AppComponent{
63
64
  return true;
64
65
  }
65
66
  getAppBarActionsProps(props){
66
- let {data,onCancel,perm,beforeSaveArgumentsMutator,beforeSave,actions,saveDataMutator,...rest} = defaultObj(props,this.props);
67
- const onSave = typeof this.props.onSave =='function'? this.props.onSave : props.onSave;
68
- beforeSave = defaultFunc(beforeSave);
67
+ let {data,onCancel,perm,beforeSaveArgumentsMutator,beforeSave,actions,saveDataMutator,...rest} = getScreenProps(defaultObj(props,this.props));
68
+ const onSave = typeof props.onSave ==='function'? props.onSave : this.props.onSave ;
69
+ beforeSave = typeof beforeSave =='function'? beforeSave : x=>true;
69
70
  return getAppBarActionsProps({
70
71
  ...defaultObj(rest),
71
72
  ...this.getAppBarProps(),
@@ -151,6 +151,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
151
151
  printProp : {value : typeof mainProps.print =='function' && mainProps.print || undefined},
152
152
  archiveProp : {value : typeof mainProps.archive =='function' && mainProps.archive || undefined },
153
153
  testIDProp : {value : defaultStr(mainProps.testID)},
154
+ showPreloaderOnUpsert : {value : mainProps.showPreloaderOnUpsert},
154
155
  isDocEditingProp : {value : typeof mainProps.isDocEditing =='function'? mainProps.isDocEditing : typeof mainProps.isDocUpdate =='function'? mainProps.isDocUpdate : undefined}
155
156
  });
156
157
  this.hidePreloader = this.hidePreloader.bind(this);
@@ -360,6 +361,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
360
361
  return true;
361
362
  }
362
363
  componentWillRender(rActionsArg){
364
+ rActionsArg.context = this;
363
365
  const rActions = renderActions.call(this,rActionsArg);
364
366
  const renderedActs = this.renderActions(rActionsArg);
365
367
  if(!rActionsArg.archived){
@@ -591,7 +593,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
591
593
  return Object.assign({},this.getCurrentData());
592
594
  }
593
595
  getAppBarActionsProps(props){
594
- return super.getAppBarActionsProps({...props,data:this.getCurrentData()})
596
+ return {...super.getAppBarActionsProps(props),data:this.getCurrentData()}
595
597
  }
596
598
  /**** cette fonction est appelée immédiatement lorsque l'on clique sur le bouton enregistrer de l'un des actions du formulaire */
597
599
  onPressToSaveFormData(args){
@@ -636,7 +638,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
636
638
  const isUpdated = this.isDocEditing(data);
637
639
  let isPOpened = true;
638
640
  const closePreloader = ()=>{
639
- if(isPOpened){
641
+ if(isPOpened && this.showPreloaderOnUpsert !==false){
640
642
  hidePreloader();
641
643
  }
642
644
  isPOpened = false;
@@ -648,7 +650,9 @@ export default class TableDataScreenComponent extends FormDataScreen{
648
650
  goBack(true);
649
651
  }
650
652
  }
651
- showPreloader(this.getConfirmTitle()+"\n"+(isUpdated?'Modification':'Enregistrement')+" en cours...");
653
+ if(this.showPreloaderOnUpsert !== false){
654
+ showPreloader(this.getConfirmTitle()+"\n"+(isUpdated?'Modification':'Enregistrement')+" en cours...");
655
+ }
652
656
  const hasManyData = this.hasManyData();
653
657
  const context = this;
654
658
  const tableName = this.tableName;
@@ -851,6 +855,7 @@ TableDataScreenComponent.propTypes = {
851
855
  PropTypes.node,
852
856
  PropTypes.element,
853
857
  ]),
858
+ showPreloaderOnUpsert : PropTypes.bool,//Si le preloader sera afficher en cas d'insertion/modification
854
859
  autoSetDefaultValue : PropTypes.bool,//si la valeur par défaut sera définie pour les champs de types date et time
855
860
  }
856
861