@fto-consult/expo-ui 6.24.2 → 6.25.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/app.config.json +1 -1
- package/babel.config.alias.js +2 -1
- package/babel.config.js +1 -1
- package/electron/utils/env.js +80 -0
- package/expo-ui-path.js +2 -2
- package/index.js +14 -13
- package/is-local-dev.js +5 -0
- package/metro.config.js +3 -2
- package/package.json +6 -3
- package/src/App.js +3 -3
- package/src/components/Datagrid/Accordion/Row.js +74 -100
- package/src/components/Datagrid/Accordion/ToogleRow.js +9 -0
- package/src/components/Datagrid/Accordion/index.js +30 -35
- package/src/components/Datagrid/Actions/index.js +12 -44
- package/src/components/Datagrid/Checkbox.js +4 -7
- package/src/components/Datagrid/Common/Common.js +112 -148
- package/src/components/Datagrid/Dashboard/index.js +2 -2
- package/src/components/Datagrid/IndexComponent.js +8 -13
- package/src/components/Datagrid/Table/index.js +53 -51
- package/src/components/Datagrid/Test/index.js +10 -3
- package/src/components/Datagrid/events/evx.js +7 -0
- package/src/components/Datagrid/events/index.js +11 -0
- package/src/components/Datagrid/hooks/Provider.js +6 -0
- package/src/components/Datagrid/hooks/context.js +5 -0
- package/src/components/Datagrid/hooks/index.js +104 -0
- package/src/components/Datagrid/utils.js +6 -4
- package/src/components/Dialog/Dialog.js +13 -12
- package/src/components/Dialog/DialogContent.js +11 -0
- package/src/components/KeyboardAvoidingView/index.js +7 -3
- package/src/components/List/Common.js +5 -3
- package/src/components/List/FlashList.js +13 -13
- package/src/components/List/Virtuoso/index.js +29 -8
- package/src/components/List/Virtuoso/index.native.js +6 -1
- package/src/components/Table/FiltersOrFooters.js +11 -3
- package/src/components/Table/Header/Cell/index.js +10 -0
- package/src/components/Table/Header/Cell/index.native.js +7 -0
- package/src/components/Table/{Header.js → Header/Component.js} +0 -4
- package/src/components/Table/{Row.js → Header/Component.native.js} +3 -3
- package/src/components/Table/Header/index.js +12 -0
- package/src/components/Table/List/index.js +3 -1
- package/src/components/Table/List/index.native.js +2 -1
- package/src/components/Table/Row/Cell/Content.js +17 -0
- package/src/components/Table/Row/Cell/Content.native.js +15 -0
- package/src/components/Table/Row/Cell/index.js +29 -0
- package/src/components/Table/Row/RowWrapper.js +7 -0
- package/src/components/Table/Row/RowWrapper.native.js +10 -0
- package/src/components/Table/Row/index.js +38 -0
- package/src/components/Table/RowTemplate/index.js +10 -0
- package/src/components/Table/RowTemplate/index.web.js +9 -0
- package/src/components/Table/ScrollNative/index.js +7 -0
- package/src/components/Table/ScrollNative/index.native.js +8 -0
- package/src/components/Table/VirtuosoTable/index.js +5 -0
- package/src/components/Table/VirtuosoTable/index.native.js +3 -0
- package/src/components/Table/hooks.js +84 -0
- package/src/components/Table/index.js +88 -247
- package/src/components/Table/styles.js +88 -0
- package/src/components/Table/utils.js +1 -0
- package/src/layouts/AppBar/index.js +11 -10
- package/src/layouts/Screen/ScreenWithoutAuthContainer.js +14 -6
- package/src/navigation/Drawer/items/index.js +2 -1
- package/src/navigation/index.js +11 -3
- package/src/screens/Help/About.js +1 -1
- package/src/screens/Help/openLibraries.js +1 -1
- package/src/test-screens/Home.js +4 -1
- package/webpack.config.js +4 -2
- package/src/components/Table/Cell.js +0 -24
|
@@ -2,7 +2,7 @@ import theme from "$theme";
|
|
|
2
2
|
import APP from "$capp";
|
|
3
3
|
import {isMobileOrTabletMedia} from "$cplatform/dimensions";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import {
|
|
5
|
+
import {ObservableComponent as AppComponent} from "$react"
|
|
6
6
|
import $session from "$session";
|
|
7
7
|
import Auth from "$cauth";
|
|
8
8
|
import Tooltip from "$ecomponents/Tooltip";
|
|
@@ -41,6 +41,7 @@ import stableHash from "stable-hash";
|
|
|
41
41
|
import * as XLSX from "xlsx";
|
|
42
42
|
import {convertToSQL} from "$ecomponents/Filter";
|
|
43
43
|
import appConfig from "$capp/config";
|
|
44
|
+
import events from "../events";
|
|
44
45
|
|
|
45
46
|
export const TIMEOUT = 100;
|
|
46
47
|
|
|
@@ -185,16 +186,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
185
186
|
this._pagination = defaultObj(rest.pagination);
|
|
186
187
|
this.hasLocalFilters = false;
|
|
187
188
|
data = (data && typeof data == 'object')? Object.toArray(data):[];
|
|
188
|
-
let sRows = {}
|
|
189
|
-
Object.map(selectedRows,(row,i)=>{
|
|
190
|
-
if(this.canSelectRow(row)){
|
|
191
|
-
sRows[this.getRowKey(row,i)] = {...row};
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
selectedRows = sRows;
|
|
195
189
|
let sData = this.getSessionData()
|
|
196
190
|
sData.showFooters = defaultVal(sData.showFooters,this.isTableData());
|
|
197
191
|
sData.fixedTable = defaultBool(sData.fixedTable,false);
|
|
192
|
+
this.rowsByKeys = {};
|
|
193
|
+
this.rowsKeysIndexes = [];
|
|
198
194
|
extendObj(this.state, {
|
|
199
195
|
data,
|
|
200
196
|
showFilters : this.isFilterable() && defaultBool(props.showFilters,(sData.showFilters? true : this.isPivotDatagrid())) || false,
|
|
@@ -236,12 +232,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
236
232
|
preparedColumns : {
|
|
237
233
|
value : {},override:false, writable:false,
|
|
238
234
|
},
|
|
239
|
-
|
|
240
|
-
value : selectedRows, override : false, writable : false,
|
|
241
|
-
},
|
|
242
|
-
selectedRowsRefs : {
|
|
243
|
-
value : {},override : false, writable : false,
|
|
244
|
-
},
|
|
235
|
+
selectedRowsKeys : {value : new Set()},
|
|
245
236
|
[footerFieldName] : {
|
|
246
237
|
value : uniqid(footerFieldName),override:false, writable: false
|
|
247
238
|
},
|
|
@@ -259,9 +250,8 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
259
250
|
emptySectionListHeaderValue : {value : uniqid("empty-section-list-header-val").toUpperCase()},
|
|
260
251
|
getSectionListHeaderProp : {value : typeof this.props.getSectionListHeader =='function'? this.props.getSectionListHeader : undefined},
|
|
261
252
|
sectionListData : {value : {}},//l'ensemble des données de sectionList
|
|
262
|
-
hasFoundSectionData : {value : {current: false}},
|
|
263
253
|
sectionListHeaderFooters : {value : {}},
|
|
264
|
-
|
|
254
|
+
sectionListDataKeys : {value : new Set()},
|
|
265
255
|
enablePointerEventsRef : {value : {current:false}},
|
|
266
256
|
chartIdPrefix : {value : uniqid("datagrid-chart-id-prefix")},
|
|
267
257
|
///la liste des fonctions d'aggregations supportées
|
|
@@ -275,7 +265,8 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
275
265
|
hidePreloaderOnRenderKey : {value : uniqid("hide-preloader-on-render")},
|
|
276
266
|
isRenderingRef : {value : {current:false}},
|
|
277
267
|
chartSeriesNamesColumnsMapping : {value : {}},//le mappage entre les index des series et les colonnes coorespondantes
|
|
278
|
-
})
|
|
268
|
+
});
|
|
269
|
+
this.setSelectedRows(selectedRows);
|
|
279
270
|
const config = extendObj(true,{},this.getSessionData("config"),this.props.chartConfig);
|
|
280
271
|
Object.map(config,(v,k)=>{
|
|
281
272
|
if(typeof v =='function'){
|
|
@@ -339,7 +330,6 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
339
330
|
windowWidth,
|
|
340
331
|
windowHeight,
|
|
341
332
|
}
|
|
342
|
-
this.selectableColumnRef = React.createRef(null);
|
|
343
333
|
this.currentDataSources = Object.toArray(this.getSessionData().selectedDataSources);
|
|
344
334
|
this.setSessionData({selectedDataSources:this.currentDataSources});
|
|
345
335
|
this.persistDisplayType(this.state.displayType);
|
|
@@ -499,10 +489,10 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
499
489
|
archive(args){
|
|
500
490
|
args = defaultObj(args);
|
|
501
491
|
let archive = defaultFunc(this.props.archive);
|
|
502
|
-
|
|
492
|
+
const d = [];
|
|
503
493
|
Object.map(args.selectedRows,(doc)=>{
|
|
504
|
-
if(
|
|
505
|
-
d.push(doc)
|
|
494
|
+
if(isObj(doc)){
|
|
495
|
+
d.push(doc);
|
|
506
496
|
}
|
|
507
497
|
});
|
|
508
498
|
args.data = d;
|
|
@@ -539,9 +529,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
539
529
|
return !!this.props.isSWRDatagrid;
|
|
540
530
|
}
|
|
541
531
|
callSRowCallback({selected,row,rowIndex,key,cb}){
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
sArg.count =
|
|
532
|
+
const count = this.getSelectedRowsCount();
|
|
533
|
+
const sArg = this.getActionsArgs(selected);
|
|
534
|
+
sArg.count = this.getSelectedRowsCount();
|
|
545
535
|
sArg.rowIndex = sArg.index = rowIndex;
|
|
546
536
|
sArg.rowKey = key;
|
|
547
537
|
if(count >0){
|
|
@@ -568,72 +558,58 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
568
558
|
cb(selected,row,rowIndex,{...sArg,context:this})
|
|
569
559
|
}
|
|
570
560
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
if(typeof update !=='boolean'){
|
|
574
|
-
update = this.selectedRowsCount && this.selectedRowsCount === this.getMaxSelectableRows() ? true : false;
|
|
575
|
-
}
|
|
576
|
-
if(update){
|
|
577
|
-
this.selectableColumnRef.current.check(false);
|
|
578
|
-
} else {
|
|
579
|
-
this.selectableColumnRef.current.uncheck(false);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
getSelectedRowsCount(){
|
|
584
|
-
return isDecimal(this.selectedRowsCount) ? this.selectedRowsCount: 0;
|
|
561
|
+
getSelectedRowsCount (){
|
|
562
|
+
return this.selectedRowsKeys.size;
|
|
585
563
|
}
|
|
586
564
|
|
|
587
565
|
//si la ligne peut être sélectionnée
|
|
588
566
|
canSelectCheckedRow(){
|
|
589
567
|
if(!this.isSelectable()) return false;
|
|
590
568
|
if(this.isSelectableMultiple()) return true;
|
|
591
|
-
return this.
|
|
569
|
+
return this.getSelectedRowsCount() <= 1 ? true : false;
|
|
570
|
+
}
|
|
571
|
+
getSelectedRowsKeys(){
|
|
572
|
+
return Array.from(this.selectedRowsKeys);
|
|
573
|
+
}
|
|
574
|
+
getSelectedRows(){
|
|
575
|
+
const ret = {};
|
|
576
|
+
this.selectedRowsKeys.forEach((rowKey)=>{
|
|
577
|
+
ret[rowKey] = this.getRowByKey(rowKey);
|
|
578
|
+
});
|
|
579
|
+
return ret;
|
|
592
580
|
}
|
|
593
581
|
/**** fonction appelée lorsque l'on clique sur la checkbox permettant de sélectionner la ligne */
|
|
594
|
-
handleRowToggle ({rowIndex,rowKey,index,
|
|
582
|
+
handleRowToggle ({rowIndex,rowKey,index,cb,callback},cb2){
|
|
595
583
|
if(!this.isValidRowKey(rowKey)) return false;
|
|
596
584
|
const row = this.getRowByKey(rowKey);
|
|
597
585
|
if(!isObj(row) || !this.canSelectRow(row)) return false;
|
|
586
|
+
const selected = !!!this.isRowSelected(rowKey);
|
|
598
587
|
let selectableMultiple = this.isSelectableMultiple();
|
|
599
588
|
rowIndex = defaultNumber(rowIndex,index);
|
|
600
589
|
cb = defaultFunc(cb,callback,cb2)
|
|
601
|
-
const size = this.
|
|
590
|
+
const size = this.getSelectedRowsCount();
|
|
602
591
|
if(selected && !this.canSelectCheckedRow()){
|
|
603
592
|
notify.warning("Vous ne pouvez sélectionner plus d'un élément");
|
|
604
593
|
return false;
|
|
605
594
|
}
|
|
606
|
-
if(!selectableMultiple){
|
|
607
|
-
this.setSelectedRows();
|
|
608
|
-
}
|
|
609
|
-
let selectedRows = this.selectedRows;
|
|
610
|
-
const sRowRef = this.selectedRowsRefs[rowKey];
|
|
611
|
-
this.selectedRowsCount = isDecimal(this.selectedRowsCount)? this.selectedRowsCount : 0;
|
|
612
|
-
if(isObj(sRowRef) && typeof sRowRef.check =='function' && typeof sRowRef.uncheck =='function'){
|
|
613
|
-
selected ? sRowRef.check() : sRowRef.uncheck();
|
|
614
|
-
sRowRef.checked = !!selected;
|
|
615
|
-
}
|
|
616
595
|
if(selected){
|
|
617
|
-
this.selectedRowsCount +=1;
|
|
618
596
|
let max = this.getMaxSelectedRows();
|
|
619
597
|
if(max && size>= max){
|
|
620
598
|
notify.warning("Vous avez atteint le nombre maximum d'éléments sélectionnable, qui est de "+max.formatNumber())
|
|
621
599
|
return false;
|
|
622
600
|
}
|
|
623
|
-
selectedRows[rowKey] = row;
|
|
624
|
-
} else {
|
|
625
|
-
this.selectedRowsCount = Math.max(this.selectedRowsCount-1,0);
|
|
626
|
-
delete selectedRows[rowKey];
|
|
627
601
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
602
|
+
if(!selectableMultiple){
|
|
603
|
+
this.setSelectedRows();
|
|
604
|
+
}
|
|
605
|
+
if(selected){
|
|
606
|
+
this.selectedRowsKeys.add(rowKey);
|
|
633
607
|
} else {
|
|
634
|
-
this.
|
|
608
|
+
this.selectedRowsKeys.delete(rowKey);
|
|
635
609
|
}
|
|
636
|
-
|
|
610
|
+
this.trigger(events.ON_ROW_TOGGLE,{selected,rowData:row,row,rowIndex,rowKey});
|
|
611
|
+
this.callSRowCallback({selected,rowData:row,row,rowIndex,rowKey,cb});
|
|
612
|
+
return !!selected;
|
|
637
613
|
}
|
|
638
614
|
canExportAskDisplayMainContent(){
|
|
639
615
|
return false;
|
|
@@ -653,8 +629,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
653
629
|
return exportTableProps;
|
|
654
630
|
}
|
|
655
631
|
onAllRowsToggle(){}
|
|
632
|
+
updateDatagridActions(cb){
|
|
633
|
+
this.trigger(events.ON_ROW_TOGGLE,null);
|
|
634
|
+
}
|
|
656
635
|
handleAllRowsToggle(update){
|
|
657
|
-
if(!defaultVal(this.props.selectableMultiple,true) && this.
|
|
636
|
+
if(!defaultVal(this.props.selectableMultiple,true) && this.getSelectedRowsCount() && this.getPaginatedData().length){
|
|
658
637
|
notify.warning("Vous ne pouvez sélectionner qu'un seul élément à la fois");
|
|
659
638
|
return;
|
|
660
639
|
}
|
|
@@ -675,9 +654,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
675
654
|
data = _d;
|
|
676
655
|
}
|
|
677
656
|
this.setSelectedRows(data);
|
|
678
|
-
|
|
679
|
-
this.datagridActionsContext.setSelectedRows(this.selectedRows);
|
|
680
|
-
}
|
|
657
|
+
this.trigger(events.ON_ALL_ROWS_TOGGLE,{selectedRows:data});
|
|
681
658
|
}
|
|
682
659
|
isAccordion(){
|
|
683
660
|
return false;
|
|
@@ -792,11 +769,12 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
792
769
|
getFooters(){
|
|
793
770
|
return this.getFootersFields();
|
|
794
771
|
}
|
|
795
|
-
getActionsArgs(selected){
|
|
772
|
+
getActionsArgs (selected){
|
|
796
773
|
const r = isObj(selected)? selected : {};
|
|
797
774
|
const ret = {
|
|
798
775
|
...dataSourceArgs,
|
|
799
776
|
rowsByKeys : this.rowsByKeys,
|
|
777
|
+
rowsKeysIndexes : this.getRowsKeysIndexes(),
|
|
800
778
|
showConfirm,
|
|
801
779
|
Preloader,
|
|
802
780
|
notify,
|
|
@@ -808,8 +786,8 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
808
786
|
rows : this.state.data,
|
|
809
787
|
allData : this.INITIAL_STATE.data,
|
|
810
788
|
props : this.props,
|
|
811
|
-
selectedRows : this.
|
|
812
|
-
selectedRowsCount : this.
|
|
789
|
+
selectedRows : this.getSelectedRows(),
|
|
790
|
+
selectedRowsCount : this.getSelectedRowsCount(),
|
|
813
791
|
context:this,
|
|
814
792
|
isMobile : isMobileOrTabletMedia(),
|
|
815
793
|
Auth,
|
|
@@ -823,13 +801,13 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
823
801
|
return ret;
|
|
824
802
|
}
|
|
825
803
|
|
|
826
|
-
copyToClipboard({selectedRows}){
|
|
804
|
+
copyToClipboard({selectedRows,...rest}){
|
|
827
805
|
let keys = Object.keys(selectedRows);
|
|
828
806
|
let row = selectedRows[keys[0]];
|
|
829
807
|
if(!isObj(row)){
|
|
830
808
|
return notify.error("Impossible de copier le premier élément sélectionné du tableau car il est invalide");
|
|
831
809
|
}
|
|
832
|
-
return copyToClipboard({data:row,fields : this.props.columns,sessionName:defaultStr(this.props.sessionName,"datagrid")});
|
|
810
|
+
return copyToClipboard({...rest,isDatagrid:true,data:row,fields : this.props.columns,sessionName:defaultStr(this.props.sessionName,"datagrid")});
|
|
833
811
|
}
|
|
834
812
|
|
|
835
813
|
/*** les actions représentes les différents menus apparaissant lorsqu'une ligne est sélectionnée
|
|
@@ -837,7 +815,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
837
815
|
*/
|
|
838
816
|
renderSelectedRowsActions(sActions){
|
|
839
817
|
let {printOptions,makePhoneCallProps,printable,print,archive,canMakePhoneCall,archivable} = this.props;
|
|
840
|
-
const
|
|
818
|
+
const size = this.getSelectedRowsCount();
|
|
841
819
|
let r = [];
|
|
842
820
|
let endActs = [];
|
|
843
821
|
if(size <=0) {
|
|
@@ -845,8 +823,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
845
823
|
};
|
|
846
824
|
let selectedR = this.props.selectedRowsActions;
|
|
847
825
|
const sArgs = this.getActionsArgs(true);
|
|
848
|
-
sArgs.size = sArgs.selectedRowsCount =
|
|
849
|
-
sArgs.selectedRowsKeys =
|
|
826
|
+
sArgs.size = sArgs.selectedRowsCount = this.getSelectedRowsCount();
|
|
827
|
+
sArgs.selectedRowsKeys = this.getSelectedRowsKeys();
|
|
828
|
+
sArgs.selectedRows = this.getSelectedRows();
|
|
850
829
|
if(isFunction(selectedR)) {
|
|
851
830
|
selectedR = selectedR.call(this,sArgs)
|
|
852
831
|
}
|
|
@@ -857,16 +836,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
857
836
|
if(printable !== false){
|
|
858
837
|
r.push({
|
|
859
838
|
icon : defaultVal(this.props.printIcon,'printer'),
|
|
860
|
-
text : defaultVal(this.props.
|
|
839
|
+
text : defaultVal(this.props.printButtonText,this.props.printText,'Imprimer'),
|
|
861
840
|
onPress : ()=>{
|
|
862
|
-
|
|
863
|
-
let d = [];
|
|
864
|
-
for(let i in selectedRows){
|
|
865
|
-
if(isDocUpdate(selectedRows[i])){
|
|
866
|
-
d.push(selectedRows[i])
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
print({title:defaultStr(this.props.title),...defaultObj(printOptions),data:d});
|
|
841
|
+
print({title:defaultStr(this.props.title),...defaultObj(printOptions),...sArgs});
|
|
870
842
|
},
|
|
871
843
|
})
|
|
872
844
|
}
|
|
@@ -903,7 +875,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
903
875
|
r.push(a);
|
|
904
876
|
})
|
|
905
877
|
if(size === 1 && canMakePhoneCall === true && canMakeCall()){
|
|
906
|
-
const rowKey =
|
|
878
|
+
const rowKey = this.getRowKeyByIndex(0), rowData = defaultObj(this.getRowByKey(rowKey));
|
|
907
879
|
const table = defaultStr(this.props.table,this.props.tableName).trim();
|
|
908
880
|
let callProps = typeof makePhoneCallProps == 'function'? makePhoneCallProps({rowData,rowKey,table,tableName:table,data:rowData,key:rowKey,context:this,props:this.props}) : makePhoneCallProps;
|
|
909
881
|
if(callProps !== false){
|
|
@@ -984,9 +956,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
984
956
|
if(typeof this.props.onSort =='function' && this.props.onSort({context:this,sort,data:this.INITIAL_STATE.data,fields:this.state.columns,columns:this.state.columns}) === false){
|
|
985
957
|
return;
|
|
986
958
|
}
|
|
987
|
-
this.
|
|
988
|
-
this.
|
|
989
|
-
|
|
959
|
+
this.setIsLoading(true,()=>{
|
|
960
|
+
this.prepareData({data:this.INITIAL_STATE.data,updateFooters:false},(state)=>{
|
|
961
|
+
this.setState(state);
|
|
962
|
+
});
|
|
963
|
+
},true);
|
|
990
964
|
}
|
|
991
965
|
|
|
992
966
|
/**** pagine l'objet data passé en parmètre de manière a retourner un objet satisfaisant aux paramètres
|
|
@@ -1848,8 +1822,6 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1848
1822
|
data.push(d);
|
|
1849
1823
|
}
|
|
1850
1824
|
}
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
1825
|
} else if(!canExportOnlyTotal) {
|
|
1854
1826
|
Object.map(cols,(col,i)=>{
|
|
1855
1827
|
const isDateField = defaultStr(col.type).toLowerCase().contains("date");
|
|
@@ -2653,13 +2625,6 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2653
2625
|
this.preparedColumns.filterableColumnsNames = filterableColumnsNames;
|
|
2654
2626
|
return this.preparedColumns;
|
|
2655
2627
|
}
|
|
2656
|
-
getPaginatedSelectedRows(data){
|
|
2657
|
-
data = isArray(data)? data : this.INITIAL_STATE.data;
|
|
2658
|
-
if(JSON.stringify(this._previousSortObj) !== JSON.stringify(this.sortRef.current) || JSON.stringify(this._previousPagination) !== JSON.stringify(this._pagination) && this.getPaginatedData().length !== data.length){
|
|
2659
|
-
return {};
|
|
2660
|
-
}
|
|
2661
|
-
return this.selectedRows;
|
|
2662
|
-
}
|
|
2663
2628
|
getFooterValues(){
|
|
2664
2629
|
return defaultObj(this.___evaluatedFootersValues);
|
|
2665
2630
|
}
|
|
@@ -2671,7 +2636,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2671
2636
|
}
|
|
2672
2637
|
/**** si le datagrid admet les sectionDatas */
|
|
2673
2638
|
hasSectionListData(){
|
|
2674
|
-
return this.
|
|
2639
|
+
return !!this.getSectionListDataSize();
|
|
2675
2640
|
}
|
|
2676
2641
|
/*** vérifie si l'on a la colonne passée en paramètre */
|
|
2677
2642
|
hasColumn(column){
|
|
@@ -2687,7 +2652,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2687
2652
|
return sectionListHeader.trim();
|
|
2688
2653
|
}
|
|
2689
2654
|
getSectionListDataSize(){
|
|
2690
|
-
return
|
|
2655
|
+
return this.sectionListDataKeys.size;
|
|
2691
2656
|
}
|
|
2692
2657
|
isValidRowKey(rowKey){
|
|
2693
2658
|
return !!(isNonNullString(rowKey) || typeof rowKey =='number');
|
|
@@ -2705,9 +2670,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2705
2670
|
const hasLocalFilter = this.props.filters !== false && this.hasLocalFilters;
|
|
2706
2671
|
const footersColumns = this.getFootersFields(),hasFootersFields = this.hasFootersFields();
|
|
2707
2672
|
const canUpdateFooters = !!(updateFooters !== false && hasFootersFields);
|
|
2708
|
-
this.
|
|
2709
|
-
this.sectionListDataSize.current = 0;
|
|
2673
|
+
this.sectionListDataKeys.clear();
|
|
2710
2674
|
this.rowsByKeys = {};
|
|
2675
|
+
this.rowsKeysIndexes = [];
|
|
2711
2676
|
const isSList = this.isSectionList(sectionListColumns);
|
|
2712
2677
|
const sortingField = isNonNullString(this.sortRef.current.column) && isObj(this.state.columns) && this.state.columns[this.sortRef.current.column] || {};
|
|
2713
2678
|
const hasSortField = Object.size(sortingField,true);
|
|
@@ -2722,7 +2687,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2722
2687
|
return getItem(item,columnName);
|
|
2723
2688
|
}
|
|
2724
2689
|
data = sortBy(data,sortConfig);//on trie tout d'abord les données
|
|
2725
|
-
}
|
|
2690
|
+
}
|
|
2726
2691
|
if(hasLocalFilter || !isArr || canUpdateFooters || isSList) {
|
|
2727
2692
|
if(canUpdateFooters){
|
|
2728
2693
|
this.___evaluatedFootersValues = {}
|
|
@@ -2751,6 +2716,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2751
2716
|
const rKey = this.getRowKey(d,i);
|
|
2752
2717
|
if(!this.isValidRowKey(rKey)) return;
|
|
2753
2718
|
this.rowsByKeys[rKey] = d;
|
|
2719
|
+
this.rowsKeysIndexes.push(rKey);
|
|
2754
2720
|
if(hasSectionColumns && this.renderSectionListIsAllowed){
|
|
2755
2721
|
let sHeader = this.getSectionListHeader({config,data:d,columnsLength : sectionListColumnsSize,fieldsSize:sectionListColumnsSize,sectionListColumnsLength:sectionListColumnsSize,sectionListColumnsSize,allData:data,rowData:d,index:i,rowIndex,context:this,columns,fields:columns});
|
|
2756
2722
|
if(sHeader === false) return;//on omet la donnée si la fonction de récupération de son header retourne false
|
|
@@ -2759,10 +2725,10 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2759
2725
|
sHeader = this.emptySectionListHeaderValue;
|
|
2760
2726
|
} else return;
|
|
2761
2727
|
}
|
|
2762
|
-
|
|
2728
|
+
const r = this.formatSectionListHeader(sHeader);
|
|
2729
|
+
this.sectionListDataKeys.add(r);
|
|
2763
2730
|
if(!Array.isArray(sectionListData[r])){
|
|
2764
2731
|
sectionListData[r] = [];
|
|
2765
|
-
this.sectionListDataSize.current++;
|
|
2766
2732
|
}
|
|
2767
2733
|
sectionListData[r].push(d);
|
|
2768
2734
|
if(canUpdateFooters){
|
|
@@ -2770,7 +2736,6 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2770
2736
|
this.sectionListHeaderFooters[r] = defaultObj(this.sectionListHeaderFooters[r]);
|
|
2771
2737
|
currentSectionListFooter = this.sectionListHeaderFooters[r];
|
|
2772
2738
|
}
|
|
2773
|
-
this.hasFoundSectionData.current = true;
|
|
2774
2739
|
}
|
|
2775
2740
|
|
|
2776
2741
|
if(canUpdateFooters){
|
|
@@ -2785,7 +2750,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2785
2750
|
newData.push(d);
|
|
2786
2751
|
//push(d,i);
|
|
2787
2752
|
});
|
|
2788
|
-
if(this.
|
|
2753
|
+
if(this.getSectionListDataSize() && hasSortField && defaultStr(sortingField.type).toLowerCase().contains("date")){
|
|
2789
2754
|
DateLib.sort(Object.keys(sectionListData)).map((k)=>{
|
|
2790
2755
|
this.sectionListData[k] = sectionListData[k];
|
|
2791
2756
|
return k;
|
|
@@ -2803,23 +2768,22 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2803
2768
|
const rowKey = this.getRowKey(d,i,rowIndex);
|
|
2804
2769
|
if(!this.isValidRowKey(rowKey)) return;
|
|
2805
2770
|
this.rowsByKeys[rowKey] = d;
|
|
2771
|
+
this.rowsKeysIndexes.push(rowKey);
|
|
2806
2772
|
newData.push(d);
|
|
2807
2773
|
});
|
|
2808
2774
|
data = newData;
|
|
2809
2775
|
}
|
|
2810
2776
|
this.INITIAL_STATE.data = data;
|
|
2811
|
-
if(this.
|
|
2777
|
+
if(this.getSectionListDataSize()){
|
|
2812
2778
|
data = [];
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
//const v = i;// === this.emptySectionListHeaderValue ? "" : i;
|
|
2816
|
-
data.push({isSectionListHeader:true,sectionListHeaderKey:i});
|
|
2779
|
+
this.sectionListDataKeys.forEach((sectionListHeaderKey)=>{
|
|
2780
|
+
data.push({isSectionListHeader:true,sectionListHeaderKey});
|
|
2817
2781
|
if(!displayOnlySectionListHeaders){
|
|
2818
|
-
this.sectionListData[
|
|
2782
|
+
this.sectionListData[sectionListHeaderKey].map((d)=>{
|
|
2819
2783
|
data.push(d);
|
|
2820
2784
|
})
|
|
2821
2785
|
}
|
|
2822
|
-
}
|
|
2786
|
+
});
|
|
2823
2787
|
}
|
|
2824
2788
|
if(!this.hasSectionListData() && this.canPaginateData()){
|
|
2825
2789
|
pagination = this.initPagination(pagination);
|
|
@@ -2889,7 +2853,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2889
2853
|
renderFlashListItem(args){
|
|
2890
2854
|
if(!this.hasSectionListData()) return null;
|
|
2891
2855
|
args = defaultObj(args);
|
|
2892
|
-
let {item,
|
|
2856
|
+
let {item,rowStyle} = args;
|
|
2893
2857
|
if(!isObj(item) || item.isSectionListHeader !== true || !isNonNullString(item.sectionListHeaderKey)) return null;
|
|
2894
2858
|
args.isAccordion = this.isAccordion();
|
|
2895
2859
|
args.columns = this.preparedColumns.visibleColumns;
|
|
@@ -2899,10 +2863,8 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2899
2863
|
const style = typeof this.props.getSectionListHeaderStyle =='function' ? this.props.getSectionListHeaderStyle(args) : null;
|
|
2900
2864
|
const cStyle = typeof this.props.getSectionListHeaderContentContainerStyle =="function" ?this.props.getSectionListHeaderContentContainerStyle(args) : undefined;
|
|
2901
2865
|
const lStyle = typeof this.props.getSectionListHeaderLabelStyle =='function' ? this.props.getSectionListHeaderLabelStyle(args) : null;
|
|
2902
|
-
|
|
2903
|
-
rowProps = defaultObj(rowProps);
|
|
2904
2866
|
const rowKey = defaultVal(args.rowIndex,args.index,args.rowCounterIndex);
|
|
2905
|
-
const testID =
|
|
2867
|
+
const testID = defaultStr(args.testID,"RN_DatagridSectionListHeader")+"_"+rowKey;
|
|
2906
2868
|
if(Array.isArray(rowStyle)){
|
|
2907
2869
|
if(style){
|
|
2908
2870
|
rowStyle.push(style);
|
|
@@ -2965,37 +2927,26 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2965
2927
|
if(isObj(rowKey)){
|
|
2966
2928
|
rowKey = this.getRowKey(rowKey,rowIndex);
|
|
2967
2929
|
}
|
|
2968
|
-
if(!this.isValidRowKey(rowKey)
|
|
2969
|
-
|
|
2930
|
+
if(!this.isValidRowKey(rowKey)){
|
|
2931
|
+
rowKey = this.getRowKeyByIndex(rowIndex);
|
|
2932
|
+
}
|
|
2933
|
+
if(!this.isValidRowKey(rowKey)) return false;
|
|
2934
|
+
return this.selectedRowsKeys.has(rowKey);
|
|
2970
2935
|
}
|
|
2971
2936
|
/*** permet de définir les lignes sélectionnées du datagrid */
|
|
2972
2937
|
setSelectedRows (rows){
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
Object.getOwnPropertyNames(obj).forEach((prop)=> {
|
|
2976
|
-
delete obj[prop];
|
|
2977
|
-
const sRowRef = this.selectedRowsRefs[prop];
|
|
2978
|
-
if(isObj(sRowRef) && sRowRef.check && sRowRef.uncheck){
|
|
2979
|
-
sRowRef.uncheck(false);
|
|
2980
|
-
}
|
|
2981
|
-
});
|
|
2938
|
+
this.selectedRowsKeys.clear();
|
|
2939
|
+
const sRows = {};
|
|
2982
2940
|
Object.map(rows,(row,i)=>{
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
this.
|
|
2986
|
-
|
|
2987
|
-
this.selectedRows[rowKey] = row;
|
|
2988
|
-
const sRowRef = this.selectedRowsRefs[rowKey];
|
|
2989
|
-
if(isObj(sRowRef) && sRowRef.check && sRowRef.uncheck){
|
|
2990
|
-
sRowRef.check(false);
|
|
2991
|
-
}
|
|
2941
|
+
const rowKey = this.getRowKey(row,i);
|
|
2942
|
+
if(this.canSelectRow(row) && this.isValidRowKey(rowKey)) {
|
|
2943
|
+
this.selectedRowsKeys.add(rowKey);
|
|
2944
|
+
sRows[rowKey] = row;
|
|
2992
2945
|
}
|
|
2993
2946
|
});
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
}
|
|
2947
|
+
return sRows;
|
|
2948
|
+
}
|
|
2997
2949
|
|
|
2998
|
-
|
|
2999
2950
|
getProgressBar(props){
|
|
3000
2951
|
if(typeof props !=='object' || !props){
|
|
3001
2952
|
props = {};
|
|
@@ -3576,8 +3527,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
3576
3527
|
cb();
|
|
3577
3528
|
}, 200);
|
|
3578
3529
|
}
|
|
3579
|
-
isAllRowsSelected(
|
|
3580
|
-
|
|
3530
|
+
isAllRowsSelected(){
|
|
3531
|
+
const count = this.getSelectedRowsCount() - this.getSectionListDataSize();
|
|
3532
|
+
return count >=0 && count >= this.getMaxSelectableRows()? true : false;
|
|
3581
3533
|
}
|
|
3582
3534
|
getDefaultPaginationRowsPerPageItems (){
|
|
3583
3535
|
return [5,10,15,20,25,30,40,50,60,80,100];
|
|
@@ -3676,11 +3628,10 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
3676
3628
|
}
|
|
3677
3629
|
return <Checkbox
|
|
3678
3630
|
testID = "RN_SelectColumnHeaderCell"
|
|
3679
|
-
|
|
3631
|
+
toggleAll
|
|
3680
3632
|
key = {this.getSelectableColumName()}
|
|
3681
3633
|
secondaryOnCheck
|
|
3682
3634
|
style = {style}
|
|
3683
|
-
ref = {this.selectableColumnRef}
|
|
3684
3635
|
onPress = {({checked})=>{
|
|
3685
3636
|
this.handleAllRowsToggle(!checked);
|
|
3686
3637
|
return;
|
|
@@ -3751,6 +3702,21 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
3751
3702
|
getRowByKey(rowKey){
|
|
3752
3703
|
return (this.isValidRowKey(rowKey)) && isObj(this.rowsByKeys[rowKey]) && this.rowsByKeys[rowKey] || null;
|
|
3753
3704
|
}
|
|
3705
|
+
getRowsKeysIndexes(){
|
|
3706
|
+
return Array.isArray(this.rowsKeysIndexes) ? this.rowsKeysIndexes : [];
|
|
3707
|
+
}
|
|
3708
|
+
getRowKeyByIndex(rowIndex){
|
|
3709
|
+
if(typeof rowIndex !='number') return undefined;
|
|
3710
|
+
const idx = this.getRowsKeysIndexes();
|
|
3711
|
+
if(rowIndex < idx.length-1 && rowIndex>=0){
|
|
3712
|
+
return idx[rowIndex];
|
|
3713
|
+
}
|
|
3714
|
+
return undefined;
|
|
3715
|
+
}
|
|
3716
|
+
getRowByIndex(rowIndex){
|
|
3717
|
+
const rowKey = this.getRowKeyByIndex(rowIndex);
|
|
3718
|
+
return rowKey !== undefined ? this.getRowByKey(rowIndex) : null;
|
|
3719
|
+
}
|
|
3754
3720
|
/*** retourne le rendu d'une cellule de la ligne du tableau
|
|
3755
3721
|
@parm, rowData, object, la ligne à afficher le rendu du contenu
|
|
3756
3722
|
@param , rowInidex, l'indice de la ligne dont on affiche le rendu en cours
|
|
@@ -3777,7 +3743,6 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
3777
3743
|
rowKey,
|
|
3778
3744
|
rowData,
|
|
3779
3745
|
checked : this.isRowSelected(rowKey,rowIndex),
|
|
3780
|
-
rowsRefs : this.selectedRowsRefs,
|
|
3781
3746
|
onPress : ({checked})=>{
|
|
3782
3747
|
return this.handleRowToggle({rowIndex,rowKey,selected:!checked});
|
|
3783
3748
|
}
|
|
@@ -3844,7 +3809,7 @@ CommonDatagridComponent.propTypes = {
|
|
|
3844
3809
|
selectedRowsActions : PropTypes.oneOfType([PropTypes.object,PropTypes.array,PropTypes.func]),
|
|
3845
3810
|
/** Les actions de la barre d'outil du datagrid : il peut s'agit d'une fonction qui lorsqu'elle est appelée retourne l'ensemble des actions du datagrid
|
|
3846
3811
|
* La fonction prend en paramètre :
|
|
3847
|
-
* selectedRows :
|
|
3812
|
+
* selectedRows : : les lignes sélectionnées
|
|
3848
3813
|
data : this.state.data : les données du datagrid
|
|
3849
3814
|
rows : this.state.data : les données du datagrid
|
|
3850
3815
|
allData : this.INITIAL_STATE.data : l'ensemble des données du datagrid
|
|
@@ -3959,7 +3924,6 @@ CommonDatagridComponent.propTypes = {
|
|
|
3959
3924
|
* title : PropTypes.node , //le titre du header
|
|
3960
3925
|
* avatar : PropTypes.string(dataUrl,src,other) || PropTypes.node, ///l'avatar,
|
|
3961
3926
|
* rowClassName : la class à appliquer à la ligne
|
|
3962
|
-
* rowProps : les props à appliquer à la ligne de la liste
|
|
3963
3927
|
* headerClassName : la class à appliquer au header de la ligne
|
|
3964
3928
|
* primaryText : //
|
|
3965
3929
|
* primaryTextRigth :
|
|
@@ -36,7 +36,7 @@ export default class DatagridDashboard extends TableData {
|
|
|
36
36
|
const testID = this.getTestID();
|
|
37
37
|
const {filterOrOperator,filterAndOperator,} = this.props;
|
|
38
38
|
const {
|
|
39
|
-
|
|
39
|
+
columnsVisibilities,
|
|
40
40
|
filteredColumns,
|
|
41
41
|
filters :headerFilters,
|
|
42
42
|
} = this.preparedColumns;
|
|
@@ -50,7 +50,7 @@ export default class DatagridDashboard extends TableData {
|
|
|
50
50
|
testID={testID+"_HeaderFilters"}
|
|
51
51
|
isLoading = {this.isLoading()}
|
|
52
52
|
filters = {headerFilters}
|
|
53
|
-
visibleColumns = {
|
|
53
|
+
visibleColumns = {columnsVisibilities}
|
|
54
54
|
filteredColumns = {filteredColumns}
|
|
55
55
|
orOperator = {filterOrOperator}
|
|
56
56
|
andOperator = {filterAndOperator}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// license that can be found in the LICENSE file.
|
|
4
4
|
|
|
5
5
|
import Accordion,{ TableData as TableDataAccordion} from "./Accordion";
|
|
6
|
-
import Dashboard from "./Dashboard";
|
|
7
6
|
import Table,{TableData as DatagridTableData} from "./Table";
|
|
8
7
|
import {isDesktopMedia,isMobileMedia} from "$cplatform/dimensions";
|
|
9
8
|
import {isFunction,defaultVal} from "$cutils";
|
|
@@ -14,19 +13,15 @@ import {getRenderType} from "./utils";
|
|
|
14
13
|
const DatagridMainComponent = React.forwardRef((props,ref)=>{
|
|
15
14
|
const isDesk = isDesktopMedia();
|
|
16
15
|
const isMob = isMobileMedia();
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const AccordionComponent = isTableDataRef.current ? TableDataAccordion : Accordion;
|
|
20
|
-
let Component = TableComponent;
|
|
16
|
+
const isTableData = typeof props.isTableData =='boolean'? props.isTableData : defaultStr(props.tableName,props.table).trim() || typeof props.fetchData ==='function'?true : false;
|
|
17
|
+
const renderType = defaultStr(getRenderType(),isDesk? "table":'accordion').trim().toLowerCase();
|
|
21
18
|
const canRenderAccordion = (isFunction(props.accordion) || (isObj(props.accordionProps) && isFunction(props.accordionProps.accordion)) || props.accordion === true);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
Component = AccordionComponent;
|
|
29
|
-
}
|
|
19
|
+
const Component = React.useMemo(()=>{
|
|
20
|
+
if((renderType == 'accordion' || (renderType !=='table' && isMob)) && canRenderAccordion){
|
|
21
|
+
return isTableData ? TableDataAccordion : Accordion;
|
|
22
|
+
}
|
|
23
|
+
return isTableData ? DatagridTableData : Table;
|
|
24
|
+
},[isTableData,renderType,canRenderAccordion,isMob])
|
|
30
25
|
return <Component
|
|
31
26
|
{...props}
|
|
32
27
|
ref = {ref}
|