@fto-consult/expo-ui 2.17.0 → 2.18.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 +1 -1
- package/src/components/Datagrid/Accordion/index.js +1 -0
- package/src/components/Datagrid/Common/Common.js +190 -64
- package/src/components/Datagrid/Footer/index.js +21 -20
- package/src/components/Datagrid/RenderTypes/index.web.js +2 -2
- package/src/components/Datagrid/Table/index.js +3 -2
package/package.json
CHANGED
|
@@ -35,6 +35,7 @@ import stableHash from "stable-hash";
|
|
|
35
35
|
import DatagridProgressBar from "./ProgressBar";
|
|
36
36
|
import {Flag} from "$ecomponents/Countries"
|
|
37
37
|
import View from "$ecomponents/View";
|
|
38
|
+
import {Menu} from "$ecomponents/BottomSheet";
|
|
38
39
|
|
|
39
40
|
export const arrayValueSeparator = ", ";
|
|
40
41
|
|
|
@@ -54,7 +55,6 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
54
55
|
let {
|
|
55
56
|
data,
|
|
56
57
|
selectedRows,
|
|
57
|
-
sectionListColumns : cSectionListColumns,//les colonnes à utiliser pour le rendue des sectionList
|
|
58
58
|
...rest
|
|
59
59
|
} = props;
|
|
60
60
|
if(this.bindResizeEvents()){
|
|
@@ -69,7 +69,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
69
69
|
data = (data && typeof data == 'object')? Object.toArray(data):[];
|
|
70
70
|
let sRows = {}
|
|
71
71
|
Object.map(selectedRows,(row,i)=>{
|
|
72
|
-
if(
|
|
72
|
+
if(this.canSelectRow(row)){
|
|
73
73
|
sRows[this.getRowKey(row,i)] = {...row};
|
|
74
74
|
}
|
|
75
75
|
});
|
|
@@ -113,6 +113,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
113
113
|
getSectionListHeaderProp : {value : typeof this.props.getSectionListHeader =='function'? this.props.getSectionListHeader : undefined},
|
|
114
114
|
sectionListData : {value : {}},//l'ensemble des données de sectionList
|
|
115
115
|
hasFoundSectionData : {value : {current: false}},
|
|
116
|
+
sectionListHeaderFooters : {value : {}},
|
|
117
|
+
sectionListDataSize : {value : {current : 0}},
|
|
118
|
+
sectionListColumnsSize : {value : {current:0}}, //la taille du nombre d'éléments de section dans les colonnes
|
|
116
119
|
})
|
|
117
120
|
this.isLoading = this.isLoading.bind(this);
|
|
118
121
|
this.getProgressBar = this.getProgressBar.bind(this);
|
|
@@ -192,15 +195,26 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
192
195
|
this.currentDataSources = Object.toArray(this.currentDataSources);
|
|
193
196
|
}
|
|
194
197
|
}
|
|
198
|
+
/*** si une ligne peut être selectionable */
|
|
199
|
+
canSelectRow(row){
|
|
200
|
+
return isObj(row) && row.isSectionListHeader !== true ? true : false;
|
|
201
|
+
}
|
|
195
202
|
prepareSectionListColumns(props){
|
|
196
203
|
props = defaultObj(props,this.props);
|
|
197
|
-
|
|
204
|
+
const l = {};
|
|
205
|
+
(Array.isArray(props.sectionListColumns) ? props.sectionListColumns : []).map((col)=>{
|
|
206
|
+
if(isNonNullString(col)){
|
|
207
|
+
l[col.trim()] = {};
|
|
208
|
+
}
|
|
209
|
+
})
|
|
210
|
+
return l;
|
|
198
211
|
}
|
|
199
212
|
/*** 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(
|
|
201
|
-
if(
|
|
202
|
-
|
|
203
|
-
|
|
213
|
+
getSectionListColumns(){
|
|
214
|
+
if(!isObj(this.state.sectionListColumns)){
|
|
215
|
+
return this.prepareSectionListColumns();
|
|
216
|
+
}
|
|
217
|
+
return this.state.sectionListColumns;
|
|
204
218
|
}
|
|
205
219
|
bindResizeEvents(){
|
|
206
220
|
return false;
|
|
@@ -383,6 +397,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
383
397
|
}
|
|
384
398
|
/**** fonction appelée lorsque l'on clique sur la checkbox permettant de sélectionner la ligne */
|
|
385
399
|
handleRowToggle ({row,rowIndex,rowData,rowKey,index, selected,cb,callback},cb2){
|
|
400
|
+
if(!this.canSelectRow(row)) return ;
|
|
386
401
|
if(typeof rowKey !=='string' && typeof rowKey !=='number') return;
|
|
387
402
|
let selectableMultiple = defaultVal(this.props.selectableMultiple,true);
|
|
388
403
|
rowIndex = defaultNumber(rowIndex,index);
|
|
@@ -493,6 +508,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
493
508
|
isSelectableColumn(columnDef,columnField){
|
|
494
509
|
return isObj(columnDef) && defaultStr(columnDef.field,columnField) === this.getSelectableColumName();
|
|
495
510
|
}
|
|
511
|
+
isIndexColumn(columnDef,columnField){
|
|
512
|
+
return isObj(columnDef) && defaultStr(columnDef.field,columnField) === this.getIndexColumnName();
|
|
513
|
+
}
|
|
496
514
|
initColumnsCallback(){}
|
|
497
515
|
initColumns (columns){
|
|
498
516
|
this.state.columns = {};
|
|
@@ -532,7 +550,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
532
550
|
const headerCol = Object.clone(headerCol1);
|
|
533
551
|
if(isAccordion && headerCol.accordion === false) return null;
|
|
534
552
|
let header = {...headerCol};
|
|
535
|
-
header.field = header.field
|
|
553
|
+
header.field = defaultStr(header.field, headerIndex)
|
|
536
554
|
/**** pour ignorer une colonne du datagrid, il suffit de passer le paramètre datagrid à false */
|
|
537
555
|
if(!isNonNullString(header.field) || header.datagrid === false) {
|
|
538
556
|
return;
|
|
@@ -742,7 +760,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
742
760
|
if(typeof this.props.onSort =='function' && this.props.onSort({...sort,context:this,sort,data:this.INITIAL_STATE.data,fields:this.state.columns,columns:this.state.columns}) === false){
|
|
743
761
|
return;
|
|
744
762
|
}
|
|
745
|
-
this.prepareData({data:this.
|
|
763
|
+
this.prepareData({data:this.INITIAL_STATE.data,updateFooters:false},(state)=>{
|
|
746
764
|
this.setState(state);
|
|
747
765
|
});
|
|
748
766
|
}
|
|
@@ -962,21 +980,80 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
962
980
|
}
|
|
963
981
|
return null;
|
|
964
982
|
}
|
|
983
|
+
toggleColumnInSectionList(columnName){
|
|
984
|
+
if(!isNonNullString(columnName) || !isObj(this.state.columns[columnName])) return;
|
|
985
|
+
if(!isObj(this.state.sectionListColumns) || !Array.isArray(this.preparedColumns?.sectionListColumnsMenuItems))return;
|
|
986
|
+
const menuItems = this.preparedColumns?.sectionListColumnsMenuItems;
|
|
987
|
+
if(!menuItems.length) return;
|
|
988
|
+
const sectionListColumns = {...this.state.sectionListColumns};
|
|
989
|
+
if(isObj(sectionListColumns[columnName])){
|
|
990
|
+
delete sectionListColumns[columnName];
|
|
991
|
+
} else {
|
|
992
|
+
sectionListColumns[columnName] = {};
|
|
993
|
+
}
|
|
994
|
+
const {sectionListColumns:pSListColumns} = this.prepareColumns({sectionListColumns});
|
|
995
|
+
this.setIsLoading(true,()=>{
|
|
996
|
+
this.prepareData({data:this.INITIAL_STATE.data,sectionListColumns:pSListColumns},(state)=>{
|
|
997
|
+
this.setState({...state,sectionListColumns:pSListColumns},()=>{
|
|
998
|
+
this.setIsLoading(false);
|
|
999
|
+
});
|
|
1000
|
+
});
|
|
1001
|
+
})
|
|
1002
|
+
}
|
|
1003
|
+
removeAllColumnsInSectionList(){
|
|
1004
|
+
const {sectionListColumns} = this.prepareColumns({sectionListColumns:{}});
|
|
1005
|
+
this.setIsLoading(true,()=>{
|
|
1006
|
+
this.prepareData({data:this.INITIAL_STATE.data,sectionListColumns},(state)=>{
|
|
1007
|
+
this.setState({...state,sectionListColumns},()=>{
|
|
1008
|
+
this.setIsLoading(false);
|
|
1009
|
+
});
|
|
1010
|
+
});
|
|
1011
|
+
})
|
|
1012
|
+
}
|
|
1013
|
+
/*** permet d'effectuer le rendu des colonnes groupable dans le menu item */
|
|
1014
|
+
renderSectionListMenu(){
|
|
1015
|
+
const m = Array.isArray(this.preparedColumns?.sectionListColumnsMenuItems)? this.preparedColumns?.sectionListColumnsMenuItems : [];
|
|
1016
|
+
if(!m.length){
|
|
1017
|
+
return null;
|
|
1018
|
+
}
|
|
1019
|
+
const isMobile = isMobileOrTabletMedia();
|
|
1020
|
+
return <Menu
|
|
1021
|
+
title = {"Grouper les données du tableau"}
|
|
1022
|
+
testID = {"RN_DatagridSectionListMenu"}
|
|
1023
|
+
anchor = {(props)=>{
|
|
1024
|
+
return <Icon {...props} name='format-list-group' title={"Grouper les éléments du tableau"}></Icon>
|
|
1025
|
+
}}
|
|
1026
|
+
items = {[
|
|
1027
|
+
!isMobile && {
|
|
1028
|
+
text : "Grouper par",
|
|
1029
|
+
icon : "group",
|
|
1030
|
+
closeOnPress : false,
|
|
1031
|
+
divider : true,
|
|
1032
|
+
},
|
|
1033
|
+
this.sectionListColumnsSize.current && {
|
|
1034
|
+
text : "Supprimer les groupes",
|
|
1035
|
+
icon: "ungroup",
|
|
1036
|
+
divider : true,
|
|
1037
|
+
onPress : ()=>{
|
|
1038
|
+
setTimeout(()=>{
|
|
1039
|
+
this.removeAllColumnsInSectionList();
|
|
1040
|
+
},300)
|
|
1041
|
+
}
|
|
1042
|
+
},
|
|
1043
|
+
...m,
|
|
1044
|
+
]}
|
|
1045
|
+
/>
|
|
1046
|
+
}
|
|
965
1047
|
prepareColumns (args){
|
|
966
1048
|
this.beforePrepareColumns();
|
|
967
1049
|
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
|
-
});
|
|
1050
|
+
const sectionListColumns = {};
|
|
1051
|
+
const sListColumns = isObj(args.sectionListColumns) ? args.sectionListColumns : this.getSectionListColumns();
|
|
976
1052
|
const filteredColumns = isObjOrArray(args.filteredColumns)?args.filteredColumns : isObjOrArray(this.state.filteredColumns) ? this.state.filteredColumns : {};
|
|
977
1053
|
const columns = args.columns || this.state.columns;
|
|
978
1054
|
const currentSortedColumn = isObj(args.sortedColumn) && args.sortedColumn.column? args.sortedColumn : defaultObj(this.sortRef.current);
|
|
979
1055
|
const visibleColumns = [],headerFilters = [],visibleColumnsNames={};
|
|
1056
|
+
const sectionListColumnsMenuItems = [];
|
|
980
1057
|
const sortable = defaultBool(this.props.sortable,true);
|
|
981
1058
|
const sortedColumns = {};
|
|
982
1059
|
let sortedColumnsLength = 0;
|
|
@@ -989,6 +1066,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
989
1066
|
const widths = {};
|
|
990
1067
|
let totalWidths = 0;
|
|
991
1068
|
let columnIndex = 0,visibleColumnIndex=0;
|
|
1069
|
+
this.sectionListColumnsSize.current = 0;
|
|
992
1070
|
Object.map(columns,(header,headerIndex) => {
|
|
993
1071
|
let {
|
|
994
1072
|
field,
|
|
@@ -1035,7 +1113,12 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1035
1113
|
const title = header.text = header.text || header.label || header.title||header.field
|
|
1036
1114
|
visibleColumnsNames[header.field] = visible ? true : false;
|
|
1037
1115
|
visibleColumns.push({
|
|
1038
|
-
onPress : ()=>{
|
|
1116
|
+
onPress : ()=>{
|
|
1117
|
+
setTimeout(() => {
|
|
1118
|
+
this.toggleColumnVisibility(header.field);
|
|
1119
|
+
},300);
|
|
1120
|
+
return false;
|
|
1121
|
+
},
|
|
1039
1122
|
title : title,
|
|
1040
1123
|
icon : visible?CHECKED_ICON_NAME : null,
|
|
1041
1124
|
});
|
|
@@ -1062,9 +1145,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1062
1145
|
sortedColumns[field] = restCol.label;
|
|
1063
1146
|
sortedColumnsLength++;
|
|
1064
1147
|
}
|
|
1065
|
-
|
|
1066
|
-
sectionListColumns.push(field);///les colonnes de sections
|
|
1067
|
-
}
|
|
1148
|
+
|
|
1068
1149
|
colFilter = colFilter && filters !== false ? true : false;
|
|
1069
1150
|
const sortedProps = isColumnSorted ? {...sortedColumn} : {};
|
|
1070
1151
|
let filterProps = {};
|
|
@@ -1121,6 +1202,30 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1121
1202
|
key : header.field,
|
|
1122
1203
|
filter :colFilter,
|
|
1123
1204
|
},headerFilters)
|
|
1205
|
+
|
|
1206
|
+
if(this.props.groupable !== false && header.groupable !== false && !this.isSelectableColumn(header,header.field) && !this.isIndexColumn(header,header.field)){
|
|
1207
|
+
const isInSectionListHeader = isObj(sListColumns[field]);
|
|
1208
|
+
if(isInSectionListHeader){
|
|
1209
|
+
sectionListColumns[field] = {
|
|
1210
|
+
...header,
|
|
1211
|
+
width,
|
|
1212
|
+
type,
|
|
1213
|
+
...sListColumns[field],
|
|
1214
|
+
};///les colonnes de sections
|
|
1215
|
+
this.sectionListColumnsSize.current++;
|
|
1216
|
+
}
|
|
1217
|
+
sectionListColumnsMenuItems.push({
|
|
1218
|
+
field,
|
|
1219
|
+
onPress : ()=>{
|
|
1220
|
+
setTimeout(()=>{
|
|
1221
|
+
this.toggleColumnInSectionList(field);
|
|
1222
|
+
},300)
|
|
1223
|
+
return false;
|
|
1224
|
+
},
|
|
1225
|
+
title : title,
|
|
1226
|
+
icon : isInSectionListHeader?CHECKED_ICON_NAME : null,
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1124
1229
|
columnIndex++;
|
|
1125
1230
|
visibleColumnIndex++;
|
|
1126
1231
|
|
|
@@ -1135,6 +1240,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1135
1240
|
this.preparedColumns.widths = widths;
|
|
1136
1241
|
this.preparedColumns.totalWidths = totalWidths;
|
|
1137
1242
|
this.preparedColumns.sectionListColumns = sectionListColumns;
|
|
1243
|
+
this.preparedColumns.sectionListColumnsMenuItems = sectionListColumnsMenuItems;
|
|
1138
1244
|
return this.preparedColumns;
|
|
1139
1245
|
}
|
|
1140
1246
|
getPaginatedSelectedRows(data){
|
|
@@ -1149,8 +1255,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1149
1255
|
}
|
|
1150
1256
|
|
|
1151
1257
|
/**** s'il s'agit d'une section list */
|
|
1152
|
-
isSectionList(){
|
|
1153
|
-
|
|
1258
|
+
isSectionList(sectionListColumns){
|
|
1259
|
+
sectionListColumns = isObj(sectionListColumns) ? sectionListColumns : this.state.sectionListColumns;
|
|
1260
|
+
return !this.isPivotDatagrid() && isObj(sectionListColumns) && Object.size(sectionListColumns,true) ? true : false;
|
|
1154
1261
|
}
|
|
1155
1262
|
/**** si le datagrid admet les sectionDatas */
|
|
1156
1263
|
hasSectionListData(){
|
|
@@ -1169,45 +1276,44 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1169
1276
|
}
|
|
1170
1277
|
return sectionListHeader.trim();
|
|
1171
1278
|
}
|
|
1279
|
+
getSectionListDataSize(){
|
|
1280
|
+
return defaultNumber(this.sectionListDataSize.current)
|
|
1281
|
+
}
|
|
1172
1282
|
prepareData(args,cb){
|
|
1173
|
-
let {pagination,data,force,updateFooters} = defaultObj(args);
|
|
1283
|
+
let {pagination,data,force,sectionListColumns,updateFooters} = defaultObj(args);
|
|
1174
1284
|
cb = typeof cb ==='function'? cb : typeof args.cb == 'function'? args.cb : undefined;
|
|
1285
|
+
sectionListColumns = isObj(sectionListColumns) ? sectionListColumns : this.state.sectionListColumns;
|
|
1175
1286
|
let isArr = Array.isArray(data);
|
|
1176
1287
|
//let push = (d,index) => isArr ? newData.push(d) : newData[index] = d;
|
|
1177
1288
|
const hasLocalFilter = this.props.filters !== false && this.hasLocalFilters;
|
|
1178
1289
|
let footersColumns = this.getFooterFields(),hasFooterFields = Object.size(footersColumns,true);
|
|
1179
1290
|
const canUpdateFooters = !!(updateFooters !== false && hasFooterFields);
|
|
1180
1291
|
this.hasFoundSectionData.current = false;
|
|
1181
|
-
|
|
1292
|
+
this.sectionListDataSize.current = 0;
|
|
1293
|
+
const isSList = this.isSectionList(sectionListColumns);
|
|
1294
|
+
if(hasLocalFilter || !isArr || canUpdateFooters || isSList) {
|
|
1182
1295
|
if(canUpdateFooters){
|
|
1183
1296
|
this.___evaluatedFootersValues = {}
|
|
1184
1297
|
}
|
|
1185
1298
|
const newData = [];
|
|
1186
|
-
const columns =
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
if(
|
|
1299
|
+
const columns = sectionListColumns;
|
|
1300
|
+
const sectionListColumnsSize = this.sectionListColumnsSize.current;
|
|
1301
|
+
const hasSectionColumns = this.sectionListColumnsSize.current > 0;
|
|
1302
|
+
if(isSList){
|
|
1190
1303
|
Object.map(this.sectionListData,(v,i)=>{
|
|
1191
1304
|
delete this.sectionListData[i];
|
|
1192
1305
|
});
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
hasSectionColumns = true;
|
|
1197
|
-
sectionListColumnsSize++;
|
|
1198
|
-
}
|
|
1306
|
+
//on réinnitialise tous les footes
|
|
1307
|
+
Object.map(this.sectionListHeaderFooters,(v,i)=>{
|
|
1308
|
+
delete this.sectionListHeaderFooters[i];
|
|
1199
1309
|
})
|
|
1200
1310
|
}
|
|
1311
|
+
let currentSectionListFooter = null;
|
|
1201
1312
|
const sectionListData = this.sectionListData;//l'ensemble des données de sectionList
|
|
1202
1313
|
Object.map(data,(d,i,rowIndex)=>{
|
|
1203
1314
|
if(!isObj(d) || (hasLocalFilter && this.doLocalFilter({rowData:d,rowIndex:i}) === false)){
|
|
1204
1315
|
return;
|
|
1205
1316
|
}
|
|
1206
|
-
if(canUpdateFooters){
|
|
1207
|
-
Object.map(footersColumns,(columnDef,field)=>{
|
|
1208
|
-
evalSingleValue({data:d,columnDef,field,result:this.___evaluatedFootersValues,displayLabel:false})
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1211
1317
|
if(hasSectionColumns){
|
|
1212
1318
|
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
1319
|
if(sHeader === false) return;//on omet la donnée si la fonction de récupération de son header retourne false
|
|
@@ -1217,20 +1323,35 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1217
1323
|
} else return;
|
|
1218
1324
|
}
|
|
1219
1325
|
let r = this.formatSectionListHeader(sHeader);
|
|
1220
|
-
|
|
1326
|
+
if(!Array.isArray(sectionListData[r])){
|
|
1327
|
+
sectionListData[r] = [];
|
|
1328
|
+
this.sectionListDataSize.current++;
|
|
1329
|
+
}
|
|
1221
1330
|
sectionListData[r].push(d);
|
|
1331
|
+
if(canUpdateFooters){
|
|
1332
|
+
this.sectionListHeaderFooters[r] = defaultObj(this.sectionListHeaderFooters[r]);
|
|
1333
|
+
currentSectionListFooter = this.sectionListHeaderFooters[r];
|
|
1334
|
+
}
|
|
1222
1335
|
this.hasFoundSectionData.current = true;
|
|
1223
1336
|
}
|
|
1337
|
+
if(canUpdateFooters){
|
|
1338
|
+
const result = [this.___evaluatedFootersValues]
|
|
1339
|
+
if(currentSectionListFooter){
|
|
1340
|
+
result.push(currentSectionListFooter);
|
|
1341
|
+
}
|
|
1342
|
+
Object.map(footersColumns,(columnDef,field)=>{
|
|
1343
|
+
evalSingleValue({data:d,columnDef,field,result,displayLabel:false})
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1224
1346
|
newData.push(d);
|
|
1225
1347
|
//push(d,i);
|
|
1226
1348
|
});
|
|
1227
1349
|
data = newData;
|
|
1228
|
-
}
|
|
1229
|
-
let sortConfig = null;
|
|
1350
|
+
}
|
|
1230
1351
|
if(this.canAutoSort() && isNonNullString(this.sortRef.current.column)){
|
|
1231
1352
|
if(isObj(this.state.columns) && this.state.columns[this.sortRef.current.column]){
|
|
1232
1353
|
let field = this.state.columns[this.sortRef.current.column];
|
|
1233
|
-
sortConfig = Object.assign({},this.sortRef.current);
|
|
1354
|
+
const sortConfig = Object.assign({},this.sortRef.current);
|
|
1234
1355
|
sortConfig.getItem = (item,columnName,{getItem})=>{
|
|
1235
1356
|
if(isObj(item) && (field.type =='decimal' || field.type =="number")){
|
|
1236
1357
|
const v = item[columnName];
|
|
@@ -1238,25 +1359,21 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1238
1359
|
}
|
|
1239
1360
|
return getItem(item,columnName);
|
|
1240
1361
|
}
|
|
1241
|
-
|
|
1362
|
+
data = sortBy(data,sortConfig);//on trie tout d'abord les données
|
|
1242
1363
|
}
|
|
1243
1364
|
}
|
|
1365
|
+
this.INITIAL_STATE.data = data;
|
|
1244
1366
|
if(this.hasFoundSectionData.current){
|
|
1245
1367
|
data = [];
|
|
1246
1368
|
for(let i in this.sectionListData){
|
|
1247
|
-
this.sectionListData[i] = sortConfig ? sortBy(this.sectionListData[i],sortConfig):this.sectionListData[i];
|
|
1369
|
+
//this.sectionListData[i] = sortConfig ? sortBy(this.sectionListData[i],sortConfig):this.sectionListData[i];
|
|
1248
1370
|
//const v = i;// === this.emptySectionListHeaderValue ? "" : i;
|
|
1249
1371
|
data.push({isSectionListHeader:true,sectionListHeaderKey:i});
|
|
1250
1372
|
this.sectionListData[i].map((d)=>{
|
|
1251
1373
|
data.push(d);
|
|
1252
1374
|
})
|
|
1253
1375
|
}
|
|
1254
|
-
}
|
|
1255
|
-
if(sortConfig){
|
|
1256
|
-
data = sortBy(data,sortConfig);
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
this.INITIAL_STATE.data = data;
|
|
1376
|
+
}
|
|
1260
1377
|
if(!this.hasSectionListData() && this.canPaginateData()){
|
|
1261
1378
|
pagination = this.initPagination(pagination);
|
|
1262
1379
|
pagination.rows = data.length;
|
|
@@ -1290,10 +1407,10 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1290
1407
|
if(sectionListColumnsSize == 1){
|
|
1291
1408
|
d.push(txt);
|
|
1292
1409
|
} else {
|
|
1293
|
-
d.push("{0} : {
|
|
1410
|
+
d.push("{0} : {1}".sprintf(defaultStr(field.label,field.txt),txt))
|
|
1294
1411
|
}
|
|
1295
|
-
})
|
|
1296
|
-
return d.length ? d.join(
|
|
1412
|
+
});
|
|
1413
|
+
return d.length ? d.join(arrayValueSeparator) : undefined;
|
|
1297
1414
|
}
|
|
1298
1415
|
/*** retourne le type d'item à rendre à la fonction flashlist
|
|
1299
1416
|
* @see : https://shopify.github.io/flash-list/docs/guides/section-list
|
|
@@ -1306,23 +1423,29 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1306
1423
|
if(!this.hasSectionListData()) return null;
|
|
1307
1424
|
args = defaultObj(args);
|
|
1308
1425
|
let {item,rowProps,rowStyle} = args;
|
|
1309
|
-
if(!isObj(item) || item.isSectionListHeader !== true) return null;
|
|
1426
|
+
if(!isObj(item) || item.isSectionListHeader !== true || !isNonNullString(item.sectionListHeaderKey)) return null;
|
|
1310
1427
|
args.isAccordion = this.isAccordion();
|
|
1311
1428
|
args.columns = this.preparedColumns.visibleColumns;
|
|
1312
1429
|
args.columnsNames = this.preparedColumns.visibleColumnsNames;
|
|
1313
|
-
const
|
|
1430
|
+
const key = item.sectionListHeaderKey;
|
|
1431
|
+
const label = key === this.emptySectionListHeaderValue ? defaultStr(this.props.sectionListHeaderEmptyValue,"N/A") : key;
|
|
1314
1432
|
const style = typeof this.props.getSectionListHeaderStyle =='function' ? this.props.getSectionListHeaderStyle(args) : null;
|
|
1433
|
+
const cStyle = typeof this.props.getSectionListHeaderContentContainerStyle =="function" ?this.props.getSectionListHeaderContentContainerStyle(args) : undefined;
|
|
1434
|
+
const lStyle = typeof this.props.getSectionListHeaderLabelStyle =='function' ? this.props.getSectionListHeaderLabelStyle(args) : null;
|
|
1435
|
+
|
|
1315
1436
|
rowProps = defaultObj(rowProps);
|
|
1316
|
-
rowProps.testID = "
|
|
1437
|
+
const testID = rowProps.testID = defaultStr(args.testID,"RN_DatagridSectionListHeader")+"_"+defaultVal(args.rowIndex,args.index)
|
|
1317
1438
|
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
1439
|
if(style){
|
|
1322
1440
|
rowStyle.push(style);
|
|
1323
1441
|
}
|
|
1324
1442
|
}
|
|
1325
|
-
|
|
1443
|
+
if(isObj(this.sectionListHeaderFooters[key])){
|
|
1444
|
+
console.log(this.sectionListHeaderFooters[key]," is value of keyeees");
|
|
1445
|
+
}
|
|
1446
|
+
return <View testID={testID+"_ContentContainer"} style={[theme.styles.w100,theme.styles,theme.styles.justifyContentCenter,theme.styles.pt1,theme.styles.pb1,theme.styles.alignItemsCenter,theme.styles.ml1,theme.styles.mr1,cStyle]}>
|
|
1447
|
+
<Label testID={testID+"_Label"} splitText numberOfLines={3} textBold style={[theme.styles.w100,lStyle]}>{label}</Label>
|
|
1448
|
+
</View>
|
|
1326
1449
|
}
|
|
1327
1450
|
isRowSelected(rowKey,rowIndex){
|
|
1328
1451
|
if(isObj(rowKey)){
|
|
@@ -1344,7 +1467,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1344
1467
|
}
|
|
1345
1468
|
});
|
|
1346
1469
|
Object.map(rows,(row,i)=>{
|
|
1347
|
-
if(
|
|
1470
|
+
if(this.canSelectRow(row)) {
|
|
1348
1471
|
const rowKey = this.getRowKey(row,i);
|
|
1349
1472
|
this.selectedRowsCount++;
|
|
1350
1473
|
this.selectedRows[rowKey] = row;
|
|
@@ -1626,7 +1749,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1626
1749
|
if(this.state.data && typeof this.state.data.length ==='number'){
|
|
1627
1750
|
max = max ? Math.min(max,this.state.data.length,max) : this.state.data.length;
|
|
1628
1751
|
}
|
|
1629
|
-
return max;
|
|
1752
|
+
return Math.max(max-this.getSectionListDataSize(),0);
|
|
1630
1753
|
}
|
|
1631
1754
|
canSetIsLoading(){
|
|
1632
1755
|
return isObj(this.progressBarRef.current) && typeof this.progressBarRef.current.setIsLoading =='function' ? true : false;
|
|
@@ -2168,8 +2291,11 @@ CommonDatagridComponent.propTypes = {
|
|
|
2168
2291
|
PropTypes.arrayOf(PropTypes.object),
|
|
2169
2292
|
PropTypes.objectOf(PropTypes.object),
|
|
2170
2293
|
]),
|
|
2294
|
+
sectionListHeaderEmptyValue : PropTypes.string, //la valeur vide par défaut à afficher dans les entêtes du table
|
|
2171
2295
|
ignoreCaseOnSectionListHeader : PropTypes.bool,//si l'on ignorera la casse dans le sectionlISThEADER
|
|
2172
2296
|
sectoonListHeaderUpperCase : PropTypes.bool, //si le sectionListHeader sera en majuscule
|
|
2297
|
+
getSectionListHeaderLabelStyle : PropTypes.func,//la fonction permettant de récupérer les styles à appliquer sur le composant label de la section header
|
|
2298
|
+
getSectionListHeaderContentContainerStyle : PropTypes.func, //retourne les styles à appliquer sur le contentContainer de la sectionListHeader
|
|
2173
2299
|
getSectionListHeaderStyle : PropTypes.func, // la fonction permettant de récupérer les propriétés particulières à appliquer au style passé en paramètre
|
|
2174
2300
|
/*** spécifie si le datagrid est groupable et si l'on utilisera les sectionList du composant FLashList pour le rendu du tableau
|
|
2175
2301
|
* si une colonne n'est pas groupable alors elle ne peut pas apparaître dans les sectionList
|
|
@@ -3,9 +3,9 @@ import View from "$ecomponents/View";
|
|
|
3
3
|
import React from "$react";
|
|
4
4
|
import memoize from "$react/memoize";
|
|
5
5
|
export {default as FooterItem} from "./Footer";
|
|
6
|
+
import {parseDecimal} from "$utils";
|
|
6
7
|
|
|
7
|
-
export const evalSingleValue = ({data,columnDef,field,result,
|
|
8
|
-
result = defaultObj(result)
|
|
8
|
+
export const evalSingleValue = ({data,columnDef,field,result,displayLabel,onlyVisible})=>{
|
|
9
9
|
data = data || {}
|
|
10
10
|
if(!isNonNullString(field) || !isObj(columnDef)) return result;
|
|
11
11
|
onlyVisible = defaultBool(onlyVisible,true);
|
|
@@ -17,25 +17,26 @@ export const evalSingleValue = ({data,columnDef,field,result,result2,displayLabe
|
|
|
17
17
|
if(!isDecimal(val)){
|
|
18
18
|
return result;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
label,
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
val = parseDecimal(val.toFixed(10));
|
|
21
|
+
(Array.isArray(result) ? result : [result]).map((currentResult)=>{
|
|
22
|
+
currentResult = defaultObj(currentResult);
|
|
23
|
+
if(!isObj(currentResult[field])){
|
|
24
|
+
let label = defaultStr(columnDef.label,columnDef.text);
|
|
25
|
+
if(!label && displayLabel !== false) return currentResult;
|
|
26
|
+
currentResult[field] = {
|
|
27
|
+
label,
|
|
28
|
+
visible : columnDef.visible,
|
|
29
|
+
format : defaultStr(columnDef.format).toLowerCase()
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if(isObj(result2)){
|
|
37
|
-
result2[field] = defaultObj(result2[field]);
|
|
38
|
-
}
|
|
32
|
+
const obj = currentResult[field];
|
|
33
|
+
obj.max = isDecimal(obj.max) ? Math.max(obj.max,val) : val;
|
|
34
|
+
obj.min = isDecimal(obj.min) ? Math.min(obj.min,val) : val;
|
|
35
|
+
obj.count = isDecimal(obj.count) ? (obj.count = obj.count +1) : 1;
|
|
36
|
+
obj.sum = isDecimal(obj.sum) ? (parseDecimal((obj.sum+val).toFixed(10))) : val;
|
|
37
|
+
obj.average = obj.sum / obj.count;
|
|
38
|
+
return currentResult;
|
|
39
|
+
})
|
|
39
40
|
return result;
|
|
40
41
|
}
|
|
41
42
|
export const evalValues = memoize(({data,columns,onlyVisible,displayLabel})=>{
|
|
@@ -4,10 +4,10 @@ export default {
|
|
|
4
4
|
code:'fixed',icon:fixedIcon,
|
|
5
5
|
label:'Tableau virtuel optimisé',
|
|
6
6
|
desktop:true,
|
|
7
|
-
|
|
7
|
+
tooltip : "Les éléments de liste s'affichent dans un tableau virtuel optimisé",
|
|
8
8
|
},
|
|
9
9
|
virtual : {code:'virtual',icon:virtualIcon,
|
|
10
10
|
label:'Tableau virtuel',
|
|
11
|
-
|
|
11
|
+
tooltip : "Les éléments de liste s'affichent dans un tableau virtuel", desktop:true
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -175,14 +175,14 @@ const DatagridFactory = (Factory)=>{
|
|
|
175
175
|
restItems = [
|
|
176
176
|
...this.renderCustomMenu(),
|
|
177
177
|
...(selectableMultiple ? [{
|
|
178
|
-
label : "
|
|
178
|
+
label : "Sélectionner "+max.formatNumber(),
|
|
179
179
|
icon : "select-all",
|
|
180
180
|
onPress : (x,event)=>{
|
|
181
181
|
this.handleAllRowsToggle(true);
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
184
|
{
|
|
185
|
-
label : "Tout
|
|
185
|
+
label : "Tout désélectionner",
|
|
186
186
|
onPress : (x,event)=>{
|
|
187
187
|
this.handleAllRowsToggle(false);
|
|
188
188
|
},
|
|
@@ -278,6 +278,7 @@ const DatagridFactory = (Factory)=>{
|
|
|
278
278
|
] : visibleColumns}
|
|
279
279
|
|
|
280
280
|
/>
|
|
281
|
+
{this.renderSectionListMenu()}
|
|
281
282
|
<View testID={testID+"_HeaderPagination"} style = {styles.paginationItem}>
|
|
282
283
|
<BottomSheetMenu
|
|
283
284
|
testID={testID+"_HeaderMenus"}
|