@fto-consult/expo-ui 2.48.6 → 2.49.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
|
@@ -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(
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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;
|