@fto-consult/expo-ui 2.48.6 → 2.49.3

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.48.6",
3
+ "version": "2.49.3",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1748,9 +1748,6 @@ export default class CommonDatagridComponent extends AppComponent {
1748
1748
  defaultValue : 0,
1749
1749
  type : "switch",
1750
1750
  } : null,
1751
- addEmptyRowAfterTotal : {
1752
-
1753
- },
1754
1751
  },
1755
1752
  actions : [{text:'Exporter',icon : "check"}],
1756
1753
  onSuccess:({data:config})=>{
@@ -237,6 +237,13 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
237
237
  cb();
238
238
  }
239
239
  },[isValidating,customIsLoading])
240
+ React.useEffect(()=>{
241
+ setTimeout(x=>{
242
+ if(error && innerRef.current && innerRef.current.isLoading && innerRef.current.isLoading()){
243
+ innerRef.current.setIsLoading(false,false);
244
+ }
245
+ },500)
246
+ },[error])
240
247
  const doRefresh = (showProgress)=>{
241
248
  showProgressRef.current = showProgress ? typeof showProgress ==='boolean' : false;
242
249
  if(isFetchingRef.current) return;
@@ -12,6 +12,7 @@ import fetch from "$capi"
12
12
  import {willConvertFiltersToSQL} from "$ecomponents/Datagrid/utils";
13
13
  import React from "$react";
14
14
  import appConfig from "$appConfig";
15
+ import {isJSON,parseJSON} from "$utils/json";
15
16
 
16
17
  /*** la tabledataSelectField permet de faire des requêtes distantes pour rechercher les données
17
18
  * Elle doit prendre en paramètre et de manière requis : les props suivante :
@@ -19,19 +20,21 @@ import appConfig from "$appConfig";
19
20
  * foreignKeyTable : la tableData dans laquelle effectuer les donées de la requêtes
20
21
  * foreignKeyLabel : Le libélé dans la table étrangère
21
22
  */
22
- const TableDataSelectField = React.forwardRef(({foreignKeyColumn,foreignKeyTable,fetchItemsPath,foreignKeyLabel,dropdownActions,fields,fetchItems:customFetchItem,convertFiltersToSQL,mutateFetchedItems,getForeignKeyTable,onFetchItems,isFilter,isUpdate,isDocEditing,items,onAddProps,fetchDataOpts,...props},ref)=>{
23
+ const TableDataSelectField = React.forwardRef(({foreignKeyColumn,foreignKeyTable,fetchItemsPath,foreignKeyLabel,foreignKeyLabelIndex,dropdownActions,fields,fetchItems:customFetchItem,convertFiltersToSQL,mutateFetchedItems,getForeignKeyTable,onFetchItems,isFilter,isUpdate,isDocEditing,items,onAddProps,fetchDataOpts,...props},ref)=>{
23
24
  props.data = defaultObj(props.data);
24
25
  if(isNonNullString(foreignKeyColumn)){
25
26
  foreignKeyColumn = foreignKeyColumn.trim();
26
27
  }
28
+ if(isNonNullString(foreignKeyLabel)){
29
+ foreignKeyLabel = foreignKeyLabel.trim();
30
+ foreignKeyLabel = foreignKeyLabel.ltrim("[").rtrim("]").split(",");
31
+ }
27
32
  convertFiltersToSQL = defaultVal(convertFiltersToSQL,willConvertFiltersToSQL());
28
33
  getForeignKeyTable = getForeignKeyTable || appConfig.getTableData;
29
34
  let fKeyTable = typeof getForeignKeyTable =='function' ? getForeignKeyTable(foreignKeyTable,props) : undefined;
30
35
  fetchItemsPath = defaultStr(fetchItemsPath).trim();
31
36
 
32
37
  if(!fetchItemsPath && (!isObj(fKeyTable) || !(defaultStr(fKeyTable.tableName,fKeyTable.table)))){
33
- console.log(appConfig.getTableData,fKeyTable,fetchItemsPath,getForeignKeyTable,"i s fkeddd for ",foreignKeyColumn,foreignKeyTable,props)
34
-
35
38
  console.error("type de données invalide pour la foreignKeyTable ",fKeyTable," composant SelectTableData",foreignKeyColumn,foreignKeyTable,props);
36
39
  return null;
37
40
  }
@@ -69,6 +72,13 @@ const TableDataSelectField = React.forwardRef(({foreignKeyColumn,foreignKeyTable
69
72
  isUpdate = false;
70
73
  }
71
74
  const defaultFields = Array.isArray(foreignKeyColumn)? foreignKeyColumn : [foreignKeyColumn];
75
+ if(Array.isArray(foreignKeyLabel)){
76
+ foreignKeyLabel.map(f=>{
77
+ if(isNonNullString(f)){
78
+ defaultFields.push(f);
79
+ }
80
+ })
81
+ }
72
82
  if(isNonNullString(foreignKeyLabel)){
73
83
  foreignKeyLabel = foreignKeyLabel.trim();
74
84
  defaultFields.push(foreignKeyLabel);
@@ -187,11 +197,12 @@ const TableDataSelectField = React.forwardRef(({foreignKeyColumn,foreignKeyTable
187
197
  const rItem = (p)=>{
188
198
  if(!isObj(p) || !isObj(p.item)) return null;
189
199
  let itemLabel = typeof foreignKeyLabel =='function'? foreignKeyLabel(p) : undefined;
190
- if(typeof foreignKeyLabel ==='array'){
200
+ if(Array.isArray(foreignKeyLabel)){
191
201
  let itl = "";
192
202
  foreignKeyLabel.map(fk=>{
203
+ if(!fk) return;
193
204
  const itv = p.item[fk];
194
- itL+= (itl?", ":"")+ (typeof itv =='number' && itv || defaultStr(itv))
205
+ itl+= (itl?" ":"")+ (typeof itv =='number' && itv || defaultStr(itv))
195
206
  })
196
207
  if(itl){
197
208
  itemLabel = itl;
@@ -266,15 +277,20 @@ TableDataSelectField.propTypes = {
266
277
  foreignKeyTable : PropTypes.string, //le nom de la fKeyTable data à laquelle se reporte le champ
267
278
  fetchItemsPath : PropTypes.string, //le chemin d'api pour récupérer les items des données étrangères en utilisant la fonction fetch
268
279
  beforeFetchItems : PropTypes.func, //appelée immédiatement avant l'exécution de la requête fetch
269
- foreignKeyColumn : PropTypes.oneOfType(
280
+ foreignKeyColumn : PropTypes.oneOfType([
270
281
  PropTypes.string,
271
282
  //PropTypes.arrayOf(PropTypes.string)
272
- ).isRequired,//le nom de la clé étrangère à laquelle fait référence la colone dans la fKeyTable
283
+ ]).isRequired,//le nom de la clé étrangère à laquelle fait référence la colone dans la fKeyTable
273
284
  foreignKeyLabel : PropTypes.oneOfType([
274
285
  PropTypes.string,
275
286
  PropTypes.arrayOf(PropTypes.string), ///si c'est un tableau, il s'agit des colonnes qui seront utilisées pour le rendu du foreignKey
276
287
  PropTypes.func, //s'il s'agit d'une fonciton qui sera appelée
277
288
  ]),
289
+ /***les séparateurs de label */
290
+ foreignKeyLabelIndex : PropTypes.oneOfType([
291
+ PropTypes.string,
292
+ PropTypes.func, //s'il s'agit d'une fonciton qui sera appelée
293
+ ]),
278
294
  onFetchItems : PropTypes.func,
279
295
  fetchDataOpts : PropTypes.shape({
280
296
  fields : PropTypes.oneOfType([
@@ -33,24 +33,26 @@ export default class FormDataActionComponent extends FormData {
33
33
  let subtitle = (isEditing?'Modifier':this.getNewElementLabel());
34
34
  let title = React.getTextContent(defaultVal(appBarProps.title,mainProps.title,this.props.title));
35
35
  const cArgs = {...mainProps,isEditing,isDocUpdate:isEditing,isUpdate:isEditing,data};
36
+ let hasFoundTitle = false,hasFoundSubtitle = false;
36
37
  if(typeof this.props.getAppBarTitle =='function'){
37
- title = defaultStr(this.props.getAppBarTitle(cArgs),title)
38
+ const t = defaultStr(this.props.getAppBarTitle(cArgs))
39
+ hasFoundTitle = isNonNullString(t);
40
+ if(hasFoundTitle){
41
+ title = t;
42
+ }
38
43
  }
39
- let hasFoundSubtitle = false;
40
44
  if(typeof this.props.getAppBarSubtitle =='function'){
41
45
  const st = this.props.getAppBarSubtitle(cArgs);
42
46
  hasFoundSubtitle = st === false || isNonNullString(st);
43
47
  subtitle = hasFoundSubtitle ? st : subtitle;
44
48
  }
45
- if(!hasFoundSubtitle){
46
- if(isEditing){
47
- let _title = this.getPrimaryKeysFieldsValueText(data);
48
- if(isNonNullString(_title)){
49
- subtitle+= " ["+_title+"]"
50
- }
51
- } else {
52
- subtitle = " ["+subtitle+"]";
49
+ if(isEditing){
50
+ let _title = this.getPrimaryKeysFieldsValueText(data);
51
+ if(!hasFoundSubtitle && isNonNullString(_title)){
52
+ subtitle+= " ["+_title+"]"
53
53
  }
54
+ } else if(!hasFoundSubtitle) {
55
+ subtitle = " ["+subtitle+"]";
54
56
  }
55
57
  if(this.props.title !== false && mainProps.title !== false) {
56
58
  appBarProps.title = title;
@@ -280,7 +280,6 @@ export default class TableDataScreenComponent extends FormDataScreen{
280
280
  if(isObj(customFields)){
281
281
  extendObj(true,fields,customFields);
282
282
  }
283
- console.log(this.primaryKeyFields," is pkeyFields heeeee");
284
283
  ///on effectue une mutator sur le champ en cours de modification
285
284
  if(typeof prepareField =='function'){
286
285
  Object.map(fields,(field,i,counterIndex)=>{