@fto-consult/expo-ui 2.16.11 → 2.17.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 +2 -2
- package/src/components/Countries/resources/countries-normalized.json +1987 -1987
- package/src/components/Countries/resources/countries-with-not-extra.json +1211 -1211
- package/src/components/Countries/resources/countries.sql +243 -243
- package/src/components/Datagrid/Accordion/index.js +15 -1
- package/src/components/Datagrid/Common/Common.js +193 -19
- package/src/components/Datagrid/Footer/index.js +4 -1
- package/src/components/Datagrid/Table/index.js +3 -0
- package/src/components/Label/index.js +1 -1
- package/src/components/List/FlashList.js +2 -0
- package/src/components/Table/index.js +12 -9
|
@@ -13,7 +13,7 @@ import Image from "$ecomponents/Image";
|
|
|
13
13
|
import Icon,{COPY_ICON} from "$ecomponents/Icon";
|
|
14
14
|
import filterUtils from "$cfilters";
|
|
15
15
|
import Hashtag from "$ecomponents/Hashtag";
|
|
16
|
-
import {sortBy,isDecimal,extendObj,isObjOrArray,
|
|
16
|
+
import {sortBy,isDecimal,extendObj,isObjOrArray,isObj,defaultNumber,defaultStr,isFunction,defaultBool,defaultArray,defaultObj,isNonNullString,defaultDecimal} from "$utils";
|
|
17
17
|
import {Datagrid as DatagridContentLoader} from "$ecomponents/ContentLoader";
|
|
18
18
|
import React from "$react";
|
|
19
19
|
import DateLib from "$lib/date";
|
|
@@ -54,6 +54,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
54
54
|
let {
|
|
55
55
|
data,
|
|
56
56
|
selectedRows,
|
|
57
|
+
sectionListColumns : cSectionListColumns,//les colonnes à utiliser pour le rendue des sectionList
|
|
57
58
|
...rest
|
|
58
59
|
} = props;
|
|
59
60
|
if(this.bindResizeEvents()){
|
|
@@ -107,7 +108,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
107
108
|
isLoadingRef : {
|
|
108
109
|
value : {current:false}
|
|
109
110
|
},
|
|
110
|
-
currentFilteringColumns : {value:{}}
|
|
111
|
+
currentFilteringColumns : {value:{}},
|
|
112
|
+
emptySectionListHeaderValue : {value : uniqid("empty-section-list-header-val").toUpperCase()},
|
|
113
|
+
getSectionListHeaderProp : {value : typeof this.props.getSectionListHeader =='function'? this.props.getSectionListHeader : undefined},
|
|
114
|
+
sectionListData : {value : {}},//l'ensemble des données de sectionList
|
|
115
|
+
hasFoundSectionData : {value : {current: false}},
|
|
111
116
|
})
|
|
112
117
|
this.isLoading = this.isLoading.bind(this);
|
|
113
118
|
this.getProgressBar = this.getProgressBar.bind(this);
|
|
@@ -137,7 +142,8 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
137
142
|
})
|
|
138
143
|
this.state.filteredColumns = defaultObj(this.getSessionData("filteredColumns"+this.getSessionNameKey()),this.props.filters);
|
|
139
144
|
this.filtersSelectors = {selector:this.getFilters()};
|
|
140
|
-
this.prepareColumns();
|
|
145
|
+
const {sectionListColumns} = this.prepareColumns();
|
|
146
|
+
this.state.sectionListColumns = sectionListColumns;
|
|
141
147
|
if(this.canHandleColumnResize()){
|
|
142
148
|
this.state.columnsWidths = this.preparedColumns.widths;
|
|
143
149
|
}
|
|
@@ -186,6 +192,16 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
186
192
|
this.currentDataSources = Object.toArray(this.currentDataSources);
|
|
187
193
|
}
|
|
188
194
|
}
|
|
195
|
+
prepareSectionListColumns(props){
|
|
196
|
+
props = defaultObj(props,this.props);
|
|
197
|
+
return Array.isArray(props.sectionListColumns) ? props.sectionListColumns : [];
|
|
198
|
+
}
|
|
199
|
+
/*** récupère la liste des colonnes à utiliser pour le rendu des sectionList, ces colonnes doivent figurer dans la liste des colonnes du tableu */
|
|
200
|
+
getSectionListColumns(prepared){
|
|
201
|
+
if(Array.isArray(this.state.sectionListColumns) && this.state.sectionListColumns.length) return this.state.sectionListColumns;
|
|
202
|
+
if(prepared === false) return [];
|
|
203
|
+
return this.prepareSectionListColumns();
|
|
204
|
+
}
|
|
189
205
|
bindResizeEvents(){
|
|
190
206
|
return false;
|
|
191
207
|
}
|
|
@@ -949,6 +965,14 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
949
965
|
prepareColumns (args){
|
|
950
966
|
this.beforePrepareColumns();
|
|
951
967
|
args = defaultObj(args);
|
|
968
|
+
const sectionListColumns = [];
|
|
969
|
+
const sListColumns = this.getSectionListColumns();
|
|
970
|
+
const allSlistColumns = {};
|
|
971
|
+
Object.map(sListColumns,(i)=>{
|
|
972
|
+
if(isNonNullString(i)){
|
|
973
|
+
allSlistColumns[i.trim()] = true;
|
|
974
|
+
}
|
|
975
|
+
});
|
|
952
976
|
const filteredColumns = isObjOrArray(args.filteredColumns)?args.filteredColumns : isObjOrArray(this.state.filteredColumns) ? this.state.filteredColumns : {};
|
|
953
977
|
const columns = args.columns || this.state.columns;
|
|
954
978
|
const currentSortedColumn = isObj(args.sortedColumn) && args.sortedColumn.column? args.sortedColumn : defaultObj(this.sortRef.current);
|
|
@@ -1016,6 +1040,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1016
1040
|
icon : visible?CHECKED_ICON_NAME : null,
|
|
1017
1041
|
});
|
|
1018
1042
|
restCol.field = header.field;
|
|
1043
|
+
|
|
1019
1044
|
restCol.label = defaultStr(header.text,header.label) ;
|
|
1020
1045
|
restCol.type = type;
|
|
1021
1046
|
if(!restCol.label){
|
|
@@ -1037,6 +1062,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1037
1062
|
sortedColumns[field] = restCol.label;
|
|
1038
1063
|
sortedColumnsLength++;
|
|
1039
1064
|
}
|
|
1065
|
+
if(this.props.groupable !== false && header.groupable !== false && allSlistColumns[field]){
|
|
1066
|
+
sectionListColumns.push(field);///les colonnes de sections
|
|
1067
|
+
}
|
|
1040
1068
|
colFilter = colFilter && filters !== false ? true : false;
|
|
1041
1069
|
const sortedProps = isColumnSorted ? {...sortedColumn} : {};
|
|
1042
1070
|
let filterProps = {};
|
|
@@ -1106,6 +1134,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1106
1134
|
this.preparedColumns.filteredColumns = filteredColumns;
|
|
1107
1135
|
this.preparedColumns.widths = widths;
|
|
1108
1136
|
this.preparedColumns.totalWidths = totalWidths;
|
|
1137
|
+
this.preparedColumns.sectionListColumns = sectionListColumns;
|
|
1109
1138
|
return this.preparedColumns;
|
|
1110
1139
|
}
|
|
1111
1140
|
getPaginatedSelectedRows(data){
|
|
@@ -1118,6 +1147,28 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1118
1147
|
getFooterValues(){
|
|
1119
1148
|
return defaultObj(this.___evaluatedFootersValues);
|
|
1120
1149
|
}
|
|
1150
|
+
|
|
1151
|
+
/**** s'il s'agit d'une section list */
|
|
1152
|
+
isSectionList(){
|
|
1153
|
+
return !this.isPivotDatagrid() && Array.isArray(this.state.sectionListColumns) && this.state.sectionListColumns.length ? true : false;
|
|
1154
|
+
}
|
|
1155
|
+
/**** si le datagrid admet les sectionDatas */
|
|
1156
|
+
hasSectionListData(){
|
|
1157
|
+
return this.hasFoundSectionData.current;
|
|
1158
|
+
}
|
|
1159
|
+
/*** vérifie si l'on a la colonne passée en paramètre */
|
|
1160
|
+
hasColumn(column){
|
|
1161
|
+
column = isObj(column)? defaultStr(column.field) : defaultStr(column);
|
|
1162
|
+
if(!column) return false;
|
|
1163
|
+
return isObj(this.state.columns) && this.state.columns[column]&& true || false;
|
|
1164
|
+
}
|
|
1165
|
+
formatSectionListHeader(sectionListHeader){
|
|
1166
|
+
if(!isNonNullString(sectionListHeader)) return "";
|
|
1167
|
+
if(this.props.sectoonListHeaderUpperCase !== false){
|
|
1168
|
+
sectionListHeader = sectionListHeader.toUpperCase();
|
|
1169
|
+
}
|
|
1170
|
+
return sectionListHeader.trim();
|
|
1171
|
+
}
|
|
1121
1172
|
prepareData(args,cb){
|
|
1122
1173
|
let {pagination,data,force,updateFooters} = defaultObj(args);
|
|
1123
1174
|
cb = typeof cb ==='function'? cb : typeof args.cb == 'function'? args.cb : undefined;
|
|
@@ -1126,12 +1177,29 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1126
1177
|
const hasLocalFilter = this.props.filters !== false && this.hasLocalFilters;
|
|
1127
1178
|
let footersColumns = this.getFooterFields(),hasFooterFields = Object.size(footersColumns,true);
|
|
1128
1179
|
const canUpdateFooters = !!(updateFooters !== false && hasFooterFields);
|
|
1129
|
-
|
|
1180
|
+
this.hasFoundSectionData.current = false;
|
|
1181
|
+
if(hasLocalFilter || !isArr || canUpdateFooters || this.isSectionList()) {
|
|
1130
1182
|
if(canUpdateFooters){
|
|
1131
1183
|
this.___evaluatedFootersValues = {}
|
|
1132
1184
|
}
|
|
1133
1185
|
const newData = [];
|
|
1134
|
-
|
|
1186
|
+
const columns = {};
|
|
1187
|
+
let hasSectionColumns = false;
|
|
1188
|
+
let sectionListColumnsSize = 0;
|
|
1189
|
+
if(this.isSectionList()){
|
|
1190
|
+
Object.map(this.sectionListData,(v,i)=>{
|
|
1191
|
+
delete this.sectionListData[i];
|
|
1192
|
+
});
|
|
1193
|
+
Object.map(this.getSectionListColumns(false),(col)=>{
|
|
1194
|
+
if(this.hasColumn(col)){
|
|
1195
|
+
columns[col]= this.state.columns[col];
|
|
1196
|
+
hasSectionColumns = true;
|
|
1197
|
+
sectionListColumnsSize++;
|
|
1198
|
+
}
|
|
1199
|
+
})
|
|
1200
|
+
}
|
|
1201
|
+
const sectionListData = this.sectionListData;//l'ensemble des données de sectionList
|
|
1202
|
+
Object.map(data,(d,i,rowIndex)=>{
|
|
1135
1203
|
if(!isObj(d) || (hasLocalFilter && this.doLocalFilter({rowData:d,rowIndex:i}) === false)){
|
|
1136
1204
|
return;
|
|
1137
1205
|
}
|
|
@@ -1140,27 +1208,56 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1140
1208
|
evalSingleValue({data:d,columnDef,field,result:this.___evaluatedFootersValues,displayLabel:false})
|
|
1141
1209
|
});
|
|
1142
1210
|
}
|
|
1211
|
+
if(hasSectionColumns){
|
|
1212
|
+
let sHeader = this.getSectionListHeader({data:d,columnsLength : sectionListColumnsSize,fieldsSize:sectionListColumnsSize,sectionListColumnsLength:sectionListColumnsSize,sectionListColumnsSize,allData:data,rowData:d,index:i,rowIndex,context:this,columns,fields:columns});
|
|
1213
|
+
if(sHeader === false) return;//on omet la donnée si la fonction de récupération de son header retourne false
|
|
1214
|
+
if(!isNonNullString(sHeader)){
|
|
1215
|
+
if(this.props.ignoreEmptySectionListHeader !== false){
|
|
1216
|
+
sHeader = this.emptySectionListHeaderValue;
|
|
1217
|
+
} else return;
|
|
1218
|
+
}
|
|
1219
|
+
let r = this.formatSectionListHeader(sHeader);
|
|
1220
|
+
sectionListData[r] = defaultArray(sectionListData[r]);
|
|
1221
|
+
sectionListData[r].push(d);
|
|
1222
|
+
this.hasFoundSectionData.current = true;
|
|
1223
|
+
}
|
|
1143
1224
|
newData.push(d);
|
|
1144
1225
|
//push(d,i);
|
|
1145
1226
|
});
|
|
1146
1227
|
data = newData;
|
|
1147
1228
|
}
|
|
1229
|
+
let sortConfig = null;
|
|
1148
1230
|
if(this.canAutoSort() && isNonNullString(this.sortRef.current.column)){
|
|
1149
1231
|
if(isObj(this.state.columns) && this.state.columns[this.sortRef.current.column]){
|
|
1150
1232
|
let field = this.state.columns[this.sortRef.current.column];
|
|
1151
|
-
|
|
1152
|
-
|
|
1233
|
+
sortConfig = Object.assign({},this.sortRef.current);
|
|
1234
|
+
sortConfig.getItem = (item,columnName,{getItem})=>{
|
|
1153
1235
|
if(isObj(item) && (field.type =='decimal' || field.type =="number")){
|
|
1154
1236
|
const v = item[columnName];
|
|
1155
1237
|
return isDecimal(v)? v : isNonNullString(v)? parseDecimal(v) : 0;
|
|
1156
1238
|
}
|
|
1157
1239
|
return getItem(item,columnName);
|
|
1158
1240
|
}
|
|
1159
|
-
data = sortBy(data,
|
|
1241
|
+
//data = sortBy(data,sortConfig);//on trie tout d'abord les données
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
if(this.hasFoundSectionData.current){
|
|
1245
|
+
data = [];
|
|
1246
|
+
for(let i in this.sectionListData){
|
|
1247
|
+
this.sectionListData[i] = sortConfig ? sortBy(this.sectionListData[i],sortConfig):this.sectionListData[i];
|
|
1248
|
+
//const v = i;// === this.emptySectionListHeaderValue ? "" : i;
|
|
1249
|
+
data.push({isSectionListHeader:true,sectionListHeaderKey:i});
|
|
1250
|
+
this.sectionListData[i].map((d)=>{
|
|
1251
|
+
data.push(d);
|
|
1252
|
+
})
|
|
1253
|
+
}
|
|
1254
|
+
} else {
|
|
1255
|
+
if(sortConfig){
|
|
1256
|
+
data = sortBy(data,sortConfig);
|
|
1160
1257
|
}
|
|
1161
1258
|
}
|
|
1162
1259
|
this.INITIAL_STATE.data = data;
|
|
1163
|
-
if(this.canPaginateData()){
|
|
1260
|
+
if(!this.hasSectionListData() && this.canPaginateData()){
|
|
1164
1261
|
pagination = this.initPagination(pagination);
|
|
1165
1262
|
pagination.rows = data.length;
|
|
1166
1263
|
this._pagination = pagination;
|
|
@@ -1175,6 +1272,58 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1175
1272
|
}
|
|
1176
1273
|
return state;
|
|
1177
1274
|
}
|
|
1275
|
+
getSectionListHeader(args){
|
|
1276
|
+
if(this.getSectionListHeaderProp){
|
|
1277
|
+
return this.getSectionListHeaderProp(args);
|
|
1278
|
+
}
|
|
1279
|
+
const {fields,sectionListColumnsSize,data} = args;
|
|
1280
|
+
const d = [];
|
|
1281
|
+
Object.map(fields,(field,i)=>{
|
|
1282
|
+
const txt = this.renderRowCell({
|
|
1283
|
+
...args,
|
|
1284
|
+
columnDef : field,
|
|
1285
|
+
renderRowCell : false,
|
|
1286
|
+
isSectionListHeader : true,
|
|
1287
|
+
columnField : defaultStr(field.field,i),
|
|
1288
|
+
});
|
|
1289
|
+
if(!isNonNullString(txt) && typeof txt !=='number') return;
|
|
1290
|
+
if(sectionListColumnsSize == 1){
|
|
1291
|
+
d.push(txt);
|
|
1292
|
+
} else {
|
|
1293
|
+
d.push("{0} : {0}".sprintf(defaultStr(field.label,field.txt),txt))
|
|
1294
|
+
}
|
|
1295
|
+
})
|
|
1296
|
+
return d.length ? d.join(",") : undefined;
|
|
1297
|
+
}
|
|
1298
|
+
/*** retourne le type d'item à rendre à la fonction flashlist
|
|
1299
|
+
* @see : https://shopify.github.io/flash-list/docs/guides/section-list
|
|
1300
|
+
*/
|
|
1301
|
+
getFlashListItemType(item){
|
|
1302
|
+
return typeof item === "string" || isObj(item) && item.isSectionListHeader === true ? "sectionHeader" : "row";;
|
|
1303
|
+
}
|
|
1304
|
+
/****permet de faire le rendu flashlist */
|
|
1305
|
+
renderFlashListItem(args){
|
|
1306
|
+
if(!this.hasSectionListData()) return null;
|
|
1307
|
+
args = defaultObj(args);
|
|
1308
|
+
let {item,rowProps,rowStyle} = args;
|
|
1309
|
+
if(!isObj(item) || item.isSectionListHeader !== true) return null;
|
|
1310
|
+
args.isAccordion = this.isAccordion();
|
|
1311
|
+
args.columns = this.preparedColumns.visibleColumns;
|
|
1312
|
+
args.columnsNames = this.preparedColumns.visibleColumnsNames;
|
|
1313
|
+
const label = item.sectionListHeaderKey === this.emptySectionListHeaderValue ? "Valeur vide" : item.sectionListHeaderKey;
|
|
1314
|
+
const style = typeof this.props.getSectionListHeaderStyle =='function' ? this.props.getSectionListHeaderStyle(args) : null;
|
|
1315
|
+
rowProps = defaultObj(rowProps);
|
|
1316
|
+
rowProps.testID = "RN_DatagridSectionListHeder_"+defaultVal(args.rowIndex,args.index)
|
|
1317
|
+
if(Array.isArray(rowStyle)){
|
|
1318
|
+
rowStyle.push(theme.styles.justifyContentCenter);
|
|
1319
|
+
rowStyle.push(theme.styles.alignItemsCenter);
|
|
1320
|
+
rowStyle.push(theme.styles.ml1,theme.styles.mr1);
|
|
1321
|
+
if(style){
|
|
1322
|
+
rowStyle.push(style);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
return <Label textBold fontSize={16} testID={"RN_DatagridSectionListHeader_"+args.index} style={[theme.styles.w100]}>{label}</Label>
|
|
1326
|
+
}
|
|
1178
1327
|
isRowSelected(rowKey,rowIndex){
|
|
1179
1328
|
if(isObj(rowKey)){
|
|
1180
1329
|
rowKey = this.getRowKey(rowKey,rowIndex);
|
|
@@ -1626,6 +1775,10 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1626
1775
|
}
|
|
1627
1776
|
canScrollTo(){
|
|
1628
1777
|
return this.state.data.length? true :false;
|
|
1778
|
+
}
|
|
1779
|
+
/**** permet d'afficher le menu item lié aux champs triables */
|
|
1780
|
+
getSortableMenuMenuItem(){
|
|
1781
|
+
|
|
1629
1782
|
}
|
|
1630
1783
|
renderSelectableCheckboxCell(props){
|
|
1631
1784
|
const {containerProps} = props;
|
|
@@ -1652,14 +1805,16 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1652
1805
|
différent du td d'un table et ne doit pas être un TableColumn de md
|
|
1653
1806
|
*/
|
|
1654
1807
|
renderRowCell (arg){
|
|
1655
|
-
let {rowData,rowKey,handleSelectableColumn,rowIndex,index,rowCounterIndex,columnDef,columnField} = arg;
|
|
1808
|
+
let {rowData,renderRowCell:customRenderRowCell,isSectionListHeader,rowKey,handleSelectableColumn,rowIndex,index,rowCounterIndex,columnDef,columnField} = arg;
|
|
1809
|
+
const renderText = isSectionListHeader === true || customRenderRowCell === false ? true : false;
|
|
1656
1810
|
rowIndex = isDecimal(rowIndex)? rowIndex : isDecimal(index)? index : undefined;
|
|
1657
1811
|
rowCounterIndex = isDecimal(rowCounterIndex) ? rowCounterIndex : isDecimal(rowIndex)? rowIndex+1 : defaultDecimal(rowCounterIndex);
|
|
1658
|
-
if(!isObj(rowData)) return {render:null,extra:{}};
|
|
1812
|
+
if(!isObj(rowData)) return renderText ? null : {render:null,extra:{}};
|
|
1659
1813
|
let _render = null;
|
|
1660
1814
|
columnDef = defaultObj(columnDef);
|
|
1661
1815
|
let _type = defaultStr(columnDef.jsType,columnDef.type).trim().toLowerCase();
|
|
1662
1816
|
if(this.isSelectableColumn(columnDef,columnField)){
|
|
1817
|
+
if(renderText) return null;
|
|
1663
1818
|
rowKey = rowKey ? rowKey : this.getRowKey(rowData,rowIndex);
|
|
1664
1819
|
return {render :handleSelectableColumn === false ? null : this.renderSelectableCheckboxCell({
|
|
1665
1820
|
...arg,
|
|
@@ -1671,7 +1826,8 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1671
1826
|
this.handleRowToggle({row:rowData,rowData,rowIndex,rowKey,selected:checked})
|
|
1672
1827
|
}
|
|
1673
1828
|
}),style:{},extra:{style:{}}};
|
|
1674
|
-
} else if(columnField == this.getIndexColumnName()){
|
|
1829
|
+
} else if((columnField == this.getIndexColumnName())){
|
|
1830
|
+
if(renderText) return null;
|
|
1675
1831
|
return {render : rowCounterIndex.formatNumber(),style:{},extra:{}};
|
|
1676
1832
|
}
|
|
1677
1833
|
let renderProps = undefined;
|
|
@@ -1679,7 +1835,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1679
1835
|
renderProps = columnDef.datagrid.renderProps;
|
|
1680
1836
|
}
|
|
1681
1837
|
const style = Object.assign({},StyleSheet.flatten(columnDef.style));
|
|
1682
|
-
if(columnDef.visible === false){
|
|
1838
|
+
if(!renderText && columnDef.visible === false){
|
|
1683
1839
|
style.display = "none";
|
|
1684
1840
|
}
|
|
1685
1841
|
let extra = {style},renderArgs = arg;
|
|
@@ -1694,7 +1850,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1694
1850
|
_render = defaultDecimal(columnDef.multiplicater({...renderArgs,value:rowData[columnField]}),rowData[columnField]);
|
|
1695
1851
|
} else {
|
|
1696
1852
|
_render = defaultValue;
|
|
1697
|
-
if(defaultStr(columnDef.format).toLowerCase() === 'hashtag'){
|
|
1853
|
+
if(!renderText && defaultStr(columnDef.format).toLowerCase() === 'hashtag'){
|
|
1698
1854
|
_render = <Hashtag>{_render}</Hashtag>
|
|
1699
1855
|
} else if(typeof columnDef.render === "function"){
|
|
1700
1856
|
_render = columnDef.render.call(this,renderArgs);
|
|
@@ -1714,11 +1870,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1714
1870
|
_render = checkedLabel;
|
|
1715
1871
|
} else _render = uncheckedLabel;
|
|
1716
1872
|
}
|
|
1717
|
-
else if(_type =='select_country' || _type =='selectcountry'){
|
|
1873
|
+
else if(!renderText && (_type =='select_country' || _type =='selectcountry')){
|
|
1718
1874
|
_render = <Flag withCode {...columnDef} length={undefined} width={undefined} height={undefined} code={defaultValue}/>
|
|
1719
1875
|
}
|
|
1720
1876
|
///le lien vers le table data se fait via la colonne ayant la propriété foreignKeyTable de type chaine de caractère non nulle
|
|
1721
|
-
else if(isNonNullString(columnDef.foreignKeyTable) || columnDef.primaryKey === true || arrayValueExists(['id','piece'],_type)){
|
|
1877
|
+
else if(!renderText && (isNonNullString(columnDef.foreignKeyTable) || columnDef.primaryKey === true || arrayValueExists(['id','piece'],_type))){
|
|
1722
1878
|
const id = rowData[columnField]?.toString();
|
|
1723
1879
|
if(isNonNullString(id)){
|
|
1724
1880
|
_render = <TableLink
|
|
@@ -1772,6 +1928,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1772
1928
|
}
|
|
1773
1929
|
}
|
|
1774
1930
|
} else if(_type == 'image'){
|
|
1931
|
+
if(renderText) return null;
|
|
1775
1932
|
columnDef = defaultObj(columnDef)
|
|
1776
1933
|
columnDef = {...columnDef,...defaultObj(columnDef.datagrid)};
|
|
1777
1934
|
columnDef.size = defaultDecimal(columnDef.size,50);
|
|
@@ -1825,7 +1982,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1825
1982
|
_render = _render.formatNumber();
|
|
1826
1983
|
//}
|
|
1827
1984
|
}
|
|
1828
|
-
if(_render && isObj(renderProps)){
|
|
1985
|
+
if(!renderText && _render && isObj(renderProps)){
|
|
1829
1986
|
let Component = defaultVal(renderProps.Component,Label);
|
|
1830
1987
|
delete renderProps.Component;
|
|
1831
1988
|
_render = <Component {...renderProps}>{_render}</Component>
|
|
@@ -1833,9 +1990,13 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1833
1990
|
if(typeof _render =='boolean'){
|
|
1834
1991
|
_render = _render ? "Oui" : "Non";
|
|
1835
1992
|
}
|
|
1836
|
-
if(
|
|
1993
|
+
if(renderText){
|
|
1994
|
+
return React.getTextContent(_render);
|
|
1995
|
+
}
|
|
1996
|
+
if((typeof _render ==='string' || typeof _render =='number')){
|
|
1837
1997
|
_render = <Label selectable>{_render}</Label>
|
|
1838
1998
|
}
|
|
1999
|
+
|
|
1839
2000
|
_render = React.isValidElement(_render)|| Array.isArray(_render)?_render:null;
|
|
1840
2001
|
return {render:_render,style,extra,key};
|
|
1841
2002
|
}
|
|
@@ -1986,7 +2147,7 @@ CommonDatagridComponent.propTypes = {
|
|
|
1986
2147
|
* si c'est un objet, alors il peut être de la forme :
|
|
1987
2148
|
* {
|
|
1988
2149
|
* title : PropTypes.node , //le titre du header
|
|
1989
|
-
* avatar : PropTypes.string(dataUrl,src,other) ||
|
|
2150
|
+
* avatar : PropTypes.string(dataUrl,src,other) || PropTypes.node, ///l'avatar,
|
|
1990
2151
|
* rowClassName : la class à appliquer à la ligne
|
|
1991
2152
|
* rowProps : les props à appliquer à la ligne de la liste
|
|
1992
2153
|
* headerClassName : la class à appliquer au header de la ligne
|
|
@@ -2007,6 +2168,19 @@ CommonDatagridComponent.propTypes = {
|
|
|
2007
2168
|
PropTypes.arrayOf(PropTypes.object),
|
|
2008
2169
|
PropTypes.objectOf(PropTypes.object),
|
|
2009
2170
|
]),
|
|
2171
|
+
ignoreCaseOnSectionListHeader : PropTypes.bool,//si l'on ignorera la casse dans le sectionlISThEADER
|
|
2172
|
+
sectoonListHeaderUpperCase : PropTypes.bool, //si le sectionListHeader sera en majuscule
|
|
2173
|
+
getSectionListHeaderStyle : PropTypes.func, // la fonction permettant de récupérer les propriétés particulières à appliquer au style passé en paramètre
|
|
2174
|
+
/*** spécifie si le datagrid est groupable et si l'on utilisera les sectionList du composant FLashList pour le rendu du tableau
|
|
2175
|
+
* si une colonne n'est pas groupable alors elle ne peut pas apparaître dans les sectionList
|
|
2176
|
+
*/
|
|
2177
|
+
groupable : PropTypes.bool,
|
|
2178
|
+
/*la fonction permettant de récupérer l'entête de la sectionList pour la données passée en paramètre
|
|
2179
|
+
@param {object : {data:{object},context:{this},allData:[]}}
|
|
2180
|
+
@return {string}
|
|
2181
|
+
*/
|
|
2182
|
+
getSectionListHeader : PropTypes.func,
|
|
2183
|
+
ignoreEmptySectionListHeader : PropTypes.bool, // si l'on ignorera les sectionList data dont l'entête, le sectionListHeader est empty
|
|
2010
2184
|
/**** la fonction permettant de faire le rendu dun contenu paginé, personalisé */
|
|
2011
2185
|
renderCustomPagination : PropTypes.func,
|
|
2012
2186
|
getActionsArgs : PropTypes.func,//fonction permettant de récupérer les props supplémentaires à passer aux actions du datagrid
|
|
@@ -4,7 +4,7 @@ import React from "$react";
|
|
|
4
4
|
import memoize from "$react/memoize";
|
|
5
5
|
export {default as FooterItem} from "./Footer";
|
|
6
6
|
|
|
7
|
-
export const evalSingleValue = ({data,columnDef,field,result,displayLabel,onlyVisible})=>{
|
|
7
|
+
export const evalSingleValue = ({data,columnDef,field,result,result2,displayLabel,onlyVisible})=>{
|
|
8
8
|
result = defaultObj(result)
|
|
9
9
|
data = data || {}
|
|
10
10
|
if(!isNonNullString(field) || !isObj(columnDef)) return result;
|
|
@@ -33,6 +33,9 @@ export const evalSingleValue = ({data,columnDef,field,result,displayLabel,onlyVi
|
|
|
33
33
|
obj.count = isDecimal(obj.count) ? (obj.count = obj.count +1) : 1;
|
|
34
34
|
obj.sum = isDecimal(obj.sum) ? (parseFloat((obj.sum+val).toFixed(10))) : val;
|
|
35
35
|
obj.average = obj.sum / obj.count;
|
|
36
|
+
if(isObj(result2)){
|
|
37
|
+
result2[field] = defaultObj(result2[field]);
|
|
38
|
+
}
|
|
36
39
|
return result;
|
|
37
40
|
}
|
|
38
41
|
export const evalValues = memoize(({data,columns,onlyVisible,displayLabel})=>{
|
|
@@ -28,6 +28,7 @@ const DatagridFactory = (Factory)=>{
|
|
|
28
28
|
return true;
|
|
29
29
|
}
|
|
30
30
|
renderRowCell(args){
|
|
31
|
+
if(args.renderRowCell === false || args.isSectionListHeader === true) return super.renderRowCell(args);
|
|
31
32
|
const {render} = super.renderRowCell(args);
|
|
32
33
|
return render;
|
|
33
34
|
}
|
|
@@ -321,6 +322,8 @@ const DatagridFactory = (Factory)=>{
|
|
|
321
322
|
<Table
|
|
322
323
|
ref = {this.listRef}
|
|
323
324
|
{...rest}
|
|
325
|
+
getItemType = {this.getFlashListItemType.bind(this)}
|
|
326
|
+
renderItem = {this.renderFlashListItem.bind(this)}
|
|
324
327
|
hasFooters = {hasFooterFields}
|
|
325
328
|
showFilters = {showFilters}
|
|
326
329
|
showFooters = {showFooters}
|
|
@@ -104,7 +104,7 @@ LabelComponentExported.propTypes = {
|
|
|
104
104
|
primary : PropTypes.bool,
|
|
105
105
|
error : PropTypes.bool,///si le label est liée à une text field sur laquelle il y a erreur
|
|
106
106
|
secondary : PropTypes.bool,
|
|
107
|
-
color : PropTypes.
|
|
107
|
+
color : PropTypes.string,
|
|
108
108
|
selectable : PropTypes.bool, //si le texte est sélectionnable
|
|
109
109
|
underlined : PropTypes.bool,//si le style underlined sera appliqué au label
|
|
110
110
|
splitText : PropTypes.bool,///si le texte lorsqu'il est long sera splité
|
|
@@ -12,6 +12,8 @@ const FlashListComponent = React.forwardRef((props,ref)=>{
|
|
|
12
12
|
ListHeaderComponent={() => (
|
|
13
13
|
<View testID={(testID||'RN_FlashListComponent')+"_Header"}>{props.children}</View>
|
|
14
14
|
)}
|
|
15
|
+
disableAutoLayout
|
|
16
|
+
disableHorizontalListHeightMeasurement = {props.horizontal?undefined : true}
|
|
15
17
|
{...props}
|
|
16
18
|
contentContainerStyle = {undefined}
|
|
17
19
|
style = {undefined}
|
|
@@ -43,7 +43,7 @@ const getOnScrollCb = (refs,pos,cb2)=>{
|
|
|
43
43
|
return isMobileNative()? cb : debounce(cb,200);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const TableComponent = React.forwardRef(({containerProps,renderEmpty,isRowSelected,headerScrollViewProps,footerScrollViewProps,scrollViewProps,showFooters,renderFooterCell,footerCellContainerProps,filterCellContainerProps,headerContainerProps,headerCellContainerProps,headerProps,rowProps:customRowProps,renderCell,cellContainerProps,hasFooters,renderHeaderCell,renderFilterCell,columnProps,getRowKey,columnsWidths,colsWidths,footerContainerProps,showFilters,columns,data,testID,...props},tableRef)=>{
|
|
46
|
+
const TableComponent = React.forwardRef(({containerProps,renderEmpty,renderItem,isRowSelected,headerScrollViewProps,footerScrollViewProps,scrollViewProps,showFooters,renderFooterCell,footerCellContainerProps,filterCellContainerProps,headerContainerProps,headerCellContainerProps,headerProps,rowProps:customRowProps,renderCell,cellContainerProps,hasFooters,renderHeaderCell,renderFilterCell,columnProps,getRowKey,columnsWidths,colsWidths,footerContainerProps,showFilters,columns,data,testID,...props},tableRef)=>{
|
|
47
47
|
containerProps = defaultObj(containerProps);
|
|
48
48
|
testID = defaultStr(testID,"RN_TableComponent");
|
|
49
49
|
cellContainerProps = defaultObj(cellContainerProps);
|
|
@@ -263,7 +263,6 @@ const TableComponent = React.forwardRef(({containerProps,renderEmpty,isRowSelect
|
|
|
263
263
|
>
|
|
264
264
|
<FlashList
|
|
265
265
|
containerProps = {{style:[cStyle]}}
|
|
266
|
-
//prepareItems = {Array.isArray(items)? false : undefined}
|
|
267
266
|
estimatedItemSize = {200}
|
|
268
267
|
{...props}
|
|
269
268
|
onContentSizeChange = {(width,height)=>{
|
|
@@ -311,7 +310,14 @@ const TableComponent = React.forwardRef(({containerProps,renderEmpty,isRowSelect
|
|
|
311
310
|
})}
|
|
312
311
|
renderItem = {(arg)=>{
|
|
313
312
|
const item = arg.item, data = arg.item,allData=Array.isArray(item.items)? item.items : data;
|
|
314
|
-
|
|
313
|
+
arg.allData = arg.allData;arg.isTable = true; arg.isAccordion = false;
|
|
314
|
+
arg.columns = visibleColumns;
|
|
315
|
+
const selected = typeof isRowSelected=='function'? isRowSelected(item,arg.index):undefined;
|
|
316
|
+
const rowArgs = {...arg,selected,isTable:true,allData,row:data,rowData:data,rowIndex:arg.index};
|
|
317
|
+
const rProps = getRowProps ? getRowProps(rowArgs) : {};
|
|
318
|
+
const rowStyle = getRowStyle(rowArgs);
|
|
319
|
+
const sItem = typeof renderItem == 'function'? renderItem({...arg,rowProps:rProps,rowStyle}) : undefined;
|
|
320
|
+
const cells = sItem && React.isValidElement(sItem) ? sItem : !isObj(item) ? null : visibleColumns.map((i,index)=>{
|
|
315
321
|
const cellValue = data[i];
|
|
316
322
|
const col = defaultObj(cols[i]);
|
|
317
323
|
const cellArgs = {...col,...arg,containerProps:{},columnIndex:col.index,style:{width:col.width},cellValue,data,rowData:data,row:data,rowIndex:arg.index};
|
|
@@ -328,13 +334,9 @@ const TableComponent = React.forwardRef(({containerProps,renderEmpty,isRowSelect
|
|
|
328
334
|
{content}
|
|
329
335
|
</View>);
|
|
330
336
|
});
|
|
331
|
-
|
|
332
|
-
const rowArgs = {...arg,selected,isTable:true,allData,row:data,cells,rowData:data,rowIndex:arg.index};
|
|
333
|
-
const rProps = getRowProps ? getRowProps(rowArgs) : {};
|
|
334
|
-
const rowStyle = getRowStyle(rowArgs);
|
|
335
|
-
return <View testID={testID+"_Row_"+arg.index} {...rowProps} {...rProps} style={[styles.row,rowProps.style,rowStyle,styles.rowNoPadding,rProps.style]}>
|
|
337
|
+
return cells ? <View testID={testID+"_Row_"+arg.index} {...rowProps} {...rProps} style={[styles.row,rowProps.style,rowStyle,styles.rowNoPadding,rProps.style]}>
|
|
336
338
|
{cells}
|
|
337
|
-
</View
|
|
339
|
+
</View> : null
|
|
338
340
|
}}
|
|
339
341
|
/>
|
|
340
342
|
<AbsoluteScrollView
|
|
@@ -490,6 +492,7 @@ TableComponent.popTypes = {
|
|
|
490
492
|
PropTypes.func,
|
|
491
493
|
PropTypes.object
|
|
492
494
|
]),
|
|
495
|
+
renderItem : PropTypes.func,//la fonction permettant de gérer le rendu des item
|
|
493
496
|
headerScrollViewProps : PropTypes.object,
|
|
494
497
|
footerScrollViewProps : PropTypes.object,
|
|
495
498
|
}
|