@fto-consult/expo-ui 6.24.2 → 6.25.1

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.
Files changed (69) hide show
  1. package/app.config.json +1 -1
  2. package/babel.config.alias.js +2 -1
  3. package/babel.config.js +1 -1
  4. package/electron/utils/env.js +80 -0
  5. package/expo-ui-path.js +2 -2
  6. package/index.js +14 -13
  7. package/is-local-dev.js +5 -0
  8. package/metro.config.js +3 -2
  9. package/package.json +7 -4
  10. package/readChart.txt +4 -1
  11. package/src/App.js +3 -3
  12. package/src/components/Datagrid/Accordion/Row.js +74 -100
  13. package/src/components/Datagrid/Accordion/ToogleRow.js +9 -0
  14. package/src/components/Datagrid/Accordion/index.js +30 -35
  15. package/src/components/Datagrid/Actions/index.js +12 -44
  16. package/src/components/Datagrid/Checkbox.js +4 -7
  17. package/src/components/Datagrid/Common/Common.js +121 -152
  18. package/src/components/Datagrid/Dashboard/index.js +2 -2
  19. package/src/components/Datagrid/IndexComponent.js +8 -13
  20. package/src/components/Datagrid/Table/index.js +53 -51
  21. package/src/components/Datagrid/Test/index.js +10 -3
  22. package/src/components/Datagrid/events/evx.js +7 -0
  23. package/src/components/Datagrid/events/index.js +11 -0
  24. package/src/components/Datagrid/hooks/Provider.js +6 -0
  25. package/src/components/Datagrid/hooks/context.js +5 -0
  26. package/src/components/Datagrid/hooks/index.js +104 -0
  27. package/src/components/Datagrid/utils.js +8 -5
  28. package/src/components/Dialog/Dialog.js +13 -12
  29. package/src/components/Dialog/DialogContent.js +11 -0
  30. package/src/components/KeyboardAvoidingView/index.js +7 -3
  31. package/src/components/Label/index.js +8 -4
  32. package/src/components/List/Common.js +5 -3
  33. package/src/components/List/FlashList.js +13 -13
  34. package/src/components/List/Virtuoso/index.js +68 -10
  35. package/src/components/List/Virtuoso/index.native.js +6 -1
  36. package/src/components/Table/Header/Cell/index.js +10 -0
  37. package/src/components/Table/Header/Cell/index.native.js +7 -0
  38. package/src/components/Table/Header/index.js +34 -0
  39. package/src/components/Table/List/index.js +3 -1
  40. package/src/components/Table/List/index.native.js +2 -1
  41. package/src/components/Table/Row/Cell/Content.js +16 -0
  42. package/src/components/Table/Row/Cell/Content.native.js +15 -0
  43. package/src/components/Table/Row/Cell/index.js +30 -0
  44. package/src/components/Table/Row/RowWrapper.js +7 -0
  45. package/src/components/Table/Row/RowWrapper.native.js +11 -0
  46. package/src/components/Table/Row/index.js +38 -0
  47. package/src/components/Table/RowTemplate/index.js +10 -0
  48. package/src/components/Table/RowTemplate/index.web.js +9 -0
  49. package/src/components/Table/ScrollNative/index.js +7 -0
  50. package/src/components/Table/ScrollNative/index.native.js +8 -0
  51. package/src/components/Table/VirtuosoTable/index.js +5 -0
  52. package/src/components/Table/VirtuosoTable/index.native.js +3 -0
  53. package/src/components/Table/hooks.js +84 -0
  54. package/src/components/Table/index.js +92 -250
  55. package/src/components/Table/styles.js +104 -0
  56. package/src/components/Table/utils.js +1 -0
  57. package/src/context/Provider.js +16 -2
  58. package/src/layouts/AppBar/index.js +11 -10
  59. package/src/layouts/Screen/ScreenWithoutAuthContainer.js +14 -6
  60. package/src/navigation/Drawer/items/index.js +2 -1
  61. package/src/navigation/index.js +11 -3
  62. package/src/screens/Help/About.js +1 -1
  63. package/src/screens/Help/openLibraries.js +1 -1
  64. package/src/test-screens/Home.js +4 -1
  65. package/webpack.config.js +4 -2
  66. package/src/components/Table/Cell.js +0 -24
  67. package/src/components/Table/FiltersOrFooters.js +0 -18
  68. package/src/components/Table/Header.js +0 -25
  69. package/src/components/Table/Row.js +0 -21
@@ -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 {Component as AppComponent} from "$react"
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
- selectedRows : {
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
- sectionListDataSize : {value : {current : 0}},
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
- let d = [];
492
+ const d = [];
503
493
  Object.map(args.selectedRows,(doc)=>{
504
- if(isDocUpdate(doc)){
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
- let count = Object.size(this.selectedRows);
543
- let sArg = this.getActionsArgs(selected);
544
- sArg.count = sArg.selectedRowsCount = 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
- toggleSelectableColumnCheckbox(update){
572
- if(isObj(this.selectableColumnRef) && isObj(this.selectableColumnRef.current) && typeof this.selectableColumnRef.current.check =='function' && typeof this.selectableColumnRef.current.uncheck =='function'){
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.selectedRowsCount <= 1 ? true : false;
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, selected,cb,callback},cb2){
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.selectedRowsCount;
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
- this.toggleSelectableColumnCheckbox();
629
- if(isObj(this.datagridActionsContext) && isFunction(this.datagridActionsContext.setSelectedRows)){
630
- this.datagridActionsContext.setSelectedRows(selectedRows,x =>{
631
- this.callSRowCallback({selected,row,rowIndex,rowKey,cb})
632
- });
602
+ if(!selectableMultiple){
603
+ this.setSelectedRows();
604
+ }
605
+ if(selected){
606
+ this.selectedRowsKeys.add(rowKey);
633
607
  } else {
634
- this.callSRowCallback({selected,rowData:row,row,rowIndex,rowKey,cb});
608
+ this.selectedRowsKeys.delete(rowKey);
635
609
  }
636
- return true;
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.selectedRowsCount && this.getPaginatedData().length){
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
- if(isObj(this.datagridActionsContext) && isFunction(this.datagridActionsContext.setSelectedRows)){
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.selectedRows,
812
- selectedRowsCount : this.selectedRowsCount,
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 {size} = sActions;
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 = Object.size(sArgs.selectedRows);
849
- sArgs.selectedRowsKeys = Object.keys(sArgs.selectedRows);
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.printButton,this.props.printText,'Imprimer'),
839
+ text : defaultVal(this.props.printButtonText,this.props.printText,'Imprimer'),
861
840
  onPress : ()=>{
862
- let {selectedRows}= sArgs;
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 = Object.keys(this.selectedRows)[0], rowData = defaultObj(this.selectedRows[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,16 @@ 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.prepareData({data:this.INITIAL_STATE.data,updateFooters:false},(state)=>{
988
- this.setState(state);
989
- });
959
+ const call = ()=>{
960
+ this.prepareData({data:this.INITIAL_STATE.data,updateFooters:false},(state)=>{
961
+ this.setState(state);
962
+ });
963
+ };
964
+ const max = isMobileOrTabletMedia()? 1000 : 5000;
965
+ if(this.INITIAL_STATE.data.length > max){
966
+ return this.setIsLoading(true,call,true);
967
+ }
968
+ return call();
990
969
  }
991
970
 
992
971
  /**** pagine l'objet data passé en parmètre de manière a retourner un objet satisfaisant aux paramètres
@@ -1848,8 +1827,6 @@ export default class CommonDatagridComponent extends AppComponent {
1848
1827
  data.push(d);
1849
1828
  }
1850
1829
  }
1851
-
1852
-
1853
1830
  } else if(!canExportOnlyTotal) {
1854
1831
  Object.map(cols,(col,i)=>{
1855
1832
  const isDateField = defaultStr(col.type).toLowerCase().contains("date");
@@ -2653,13 +2630,6 @@ export default class CommonDatagridComponent extends AppComponent {
2653
2630
  this.preparedColumns.filterableColumnsNames = filterableColumnsNames;
2654
2631
  return this.preparedColumns;
2655
2632
  }
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
2633
  getFooterValues(){
2664
2634
  return defaultObj(this.___evaluatedFootersValues);
2665
2635
  }
@@ -2671,7 +2641,7 @@ export default class CommonDatagridComponent extends AppComponent {
2671
2641
  }
2672
2642
  /**** si le datagrid admet les sectionDatas */
2673
2643
  hasSectionListData(){
2674
- return this.hasFoundSectionData.current;
2644
+ return !!this.getSectionListDataSize();
2675
2645
  }
2676
2646
  /*** vérifie si l'on a la colonne passée en paramètre */
2677
2647
  hasColumn(column){
@@ -2687,7 +2657,7 @@ export default class CommonDatagridComponent extends AppComponent {
2687
2657
  return sectionListHeader.trim();
2688
2658
  }
2689
2659
  getSectionListDataSize(){
2690
- return defaultNumber(this.sectionListDataSize.current)
2660
+ return this.sectionListDataKeys.size;
2691
2661
  }
2692
2662
  isValidRowKey(rowKey){
2693
2663
  return !!(isNonNullString(rowKey) || typeof rowKey =='number');
@@ -2705,9 +2675,9 @@ export default class CommonDatagridComponent extends AppComponent {
2705
2675
  const hasLocalFilter = this.props.filters !== false && this.hasLocalFilters;
2706
2676
  const footersColumns = this.getFootersFields(),hasFootersFields = this.hasFootersFields();
2707
2677
  const canUpdateFooters = !!(updateFooters !== false && hasFootersFields);
2708
- this.hasFoundSectionData.current = false;
2709
- this.sectionListDataSize.current = 0;
2678
+ this.sectionListDataKeys.clear();
2710
2679
  this.rowsByKeys = {};
2680
+ this.rowsKeysIndexes = [];
2711
2681
  const isSList = this.isSectionList(sectionListColumns);
2712
2682
  const sortingField = isNonNullString(this.sortRef.current.column) && isObj(this.state.columns) && this.state.columns[this.sortRef.current.column] || {};
2713
2683
  const hasSortField = Object.size(sortingField,true);
@@ -2722,7 +2692,7 @@ export default class CommonDatagridComponent extends AppComponent {
2722
2692
  return getItem(item,columnName);
2723
2693
  }
2724
2694
  data = sortBy(data,sortConfig);//on trie tout d'abord les données
2725
- }
2695
+ }
2726
2696
  if(hasLocalFilter || !isArr || canUpdateFooters || isSList) {
2727
2697
  if(canUpdateFooters){
2728
2698
  this.___evaluatedFootersValues = {}
@@ -2751,6 +2721,7 @@ export default class CommonDatagridComponent extends AppComponent {
2751
2721
  const rKey = this.getRowKey(d,i);
2752
2722
  if(!this.isValidRowKey(rKey)) return;
2753
2723
  this.rowsByKeys[rKey] = d;
2724
+ this.rowsKeysIndexes.push(rKey);
2754
2725
  if(hasSectionColumns && this.renderSectionListIsAllowed){
2755
2726
  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
2727
  if(sHeader === false) return;//on omet la donnée si la fonction de récupération de son header retourne false
@@ -2759,10 +2730,10 @@ export default class CommonDatagridComponent extends AppComponent {
2759
2730
  sHeader = this.emptySectionListHeaderValue;
2760
2731
  } else return;
2761
2732
  }
2762
- let r = this.formatSectionListHeader(sHeader);
2733
+ const r = this.formatSectionListHeader(sHeader);
2734
+ this.sectionListDataKeys.add(r);
2763
2735
  if(!Array.isArray(sectionListData[r])){
2764
2736
  sectionListData[r] = [];
2765
- this.sectionListDataSize.current++;
2766
2737
  }
2767
2738
  sectionListData[r].push(d);
2768
2739
  if(canUpdateFooters){
@@ -2770,7 +2741,6 @@ export default class CommonDatagridComponent extends AppComponent {
2770
2741
  this.sectionListHeaderFooters[r] = defaultObj(this.sectionListHeaderFooters[r]);
2771
2742
  currentSectionListFooter = this.sectionListHeaderFooters[r];
2772
2743
  }
2773
- this.hasFoundSectionData.current = true;
2774
2744
  }
2775
2745
 
2776
2746
  if(canUpdateFooters){
@@ -2785,7 +2755,7 @@ export default class CommonDatagridComponent extends AppComponent {
2785
2755
  newData.push(d);
2786
2756
  //push(d,i);
2787
2757
  });
2788
- if(this.hasFoundSectionData.current && hasSortField && defaultStr(sortingField.type).toLowerCase().contains("date")){
2758
+ if(this.getSectionListDataSize() && hasSortField && defaultStr(sortingField.type).toLowerCase().contains("date")){
2789
2759
  DateLib.sort(Object.keys(sectionListData)).map((k)=>{
2790
2760
  this.sectionListData[k] = sectionListData[k];
2791
2761
  return k;
@@ -2803,23 +2773,22 @@ export default class CommonDatagridComponent extends AppComponent {
2803
2773
  const rowKey = this.getRowKey(d,i,rowIndex);
2804
2774
  if(!this.isValidRowKey(rowKey)) return;
2805
2775
  this.rowsByKeys[rowKey] = d;
2776
+ this.rowsKeysIndexes.push(rowKey);
2806
2777
  newData.push(d);
2807
2778
  });
2808
2779
  data = newData;
2809
2780
  }
2810
2781
  this.INITIAL_STATE.data = data;
2811
- if(this.hasFoundSectionData.current){
2782
+ if(this.getSectionListDataSize()){
2812
2783
  data = [];
2813
- for(let i in this.sectionListData){
2814
- //this.sectionListData[i] = sortConfig ? sortBy(this.sectionListData[i],sortConfig):this.sectionListData[i];
2815
- //const v = i;// === this.emptySectionListHeaderValue ? "" : i;
2816
- data.push({isSectionListHeader:true,sectionListHeaderKey:i});
2784
+ this.sectionListDataKeys.forEach((sectionListHeaderKey)=>{
2785
+ data.push({isSectionListHeader:true,sectionListHeaderKey});
2817
2786
  if(!displayOnlySectionListHeaders){
2818
- this.sectionListData[i].map((d)=>{
2787
+ this.sectionListData[sectionListHeaderKey].map((d)=>{
2819
2788
  data.push(d);
2820
2789
  })
2821
2790
  }
2822
- }
2791
+ });
2823
2792
  }
2824
2793
  if(!this.hasSectionListData() && this.canPaginateData()){
2825
2794
  pagination = this.initPagination(pagination);
@@ -2889,7 +2858,7 @@ export default class CommonDatagridComponent extends AppComponent {
2889
2858
  renderFlashListItem(args){
2890
2859
  if(!this.hasSectionListData()) return null;
2891
2860
  args = defaultObj(args);
2892
- let {item,rowProps,rowStyle} = args;
2861
+ let {item,rowStyle} = args;
2893
2862
  if(!isObj(item) || item.isSectionListHeader !== true || !isNonNullString(item.sectionListHeaderKey)) return null;
2894
2863
  args.isAccordion = this.isAccordion();
2895
2864
  args.columns = this.preparedColumns.visibleColumns;
@@ -2899,10 +2868,8 @@ export default class CommonDatagridComponent extends AppComponent {
2899
2868
  const style = typeof this.props.getSectionListHeaderStyle =='function' ? this.props.getSectionListHeaderStyle(args) : null;
2900
2869
  const cStyle = typeof this.props.getSectionListHeaderContentContainerStyle =="function" ?this.props.getSectionListHeaderContentContainerStyle(args) : undefined;
2901
2870
  const lStyle = typeof this.props.getSectionListHeaderLabelStyle =='function' ? this.props.getSectionListHeaderLabelStyle(args) : null;
2902
-
2903
- rowProps = defaultObj(rowProps);
2904
2871
  const rowKey = defaultVal(args.rowIndex,args.index,args.rowCounterIndex);
2905
- const testID = rowProps.testID = defaultStr(args.testID,"RN_DatagridSectionListHeader")+"_"+rowKey;
2872
+ const testID = defaultStr(args.testID,"RN_DatagridSectionListHeader")+"_"+rowKey;
2906
2873
  if(Array.isArray(rowStyle)){
2907
2874
  if(style){
2908
2875
  rowStyle.push(style);
@@ -2965,37 +2932,26 @@ export default class CommonDatagridComponent extends AppComponent {
2965
2932
  if(isObj(rowKey)){
2966
2933
  rowKey = this.getRowKey(rowKey,rowIndex);
2967
2934
  }
2968
- if(!this.isValidRowKey(rowKey) || !isObj(this.selectedRowsRefs[rowKey])) return false;
2969
- return !!(isObj(this.selectedRows[rowKey]) && this.selectedRowsRefs[rowKey].checked);
2935
+ if(!this.isValidRowKey(rowKey)){
2936
+ rowKey = this.getRowKeyByIndex(rowIndex);
2937
+ }
2938
+ if(!this.isValidRowKey(rowKey)) return false;
2939
+ return this.selectedRowsKeys.has(rowKey);
2970
2940
  }
2971
2941
  /*** permet de définir les lignes sélectionnées du datagrid */
2972
2942
  setSelectedRows (rows){
2973
- let obj = this.selectedRows;
2974
- this.selectedRowsCount = 0;
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
- });
2943
+ this.selectedRowsKeys.clear();
2944
+ const sRows = {};
2982
2945
  Object.map(rows,(row,i)=>{
2983
- if(this.canSelectRow(row)) {
2984
- const rowKey = this.getRowKey(row,i);
2985
- this.rowsByKeys[rowKey] = row;
2986
- this.selectedRowsCount++;
2987
- this.selectedRows[rowKey] = row;
2988
- const sRowRef = this.selectedRowsRefs[rowKey];
2989
- if(isObj(sRowRef) && sRowRef.check && sRowRef.uncheck){
2990
- sRowRef.check(false);
2991
- }
2946
+ const rowKey = this.getRowKey(row,i);
2947
+ if(this.canSelectRow(row) && this.isValidRowKey(rowKey)) {
2948
+ this.selectedRowsKeys.add(rowKey);
2949
+ sRows[rowKey] = row;
2992
2950
  }
2993
2951
  });
2994
- this.toggleSelectableColumnCheckbox();
2995
- return this.selectedRows;
2996
- }
2952
+ return sRows;
2953
+ }
2997
2954
 
2998
-
2999
2955
  getProgressBar(props){
3000
2956
  if(typeof props !=='object' || !props){
3001
2957
  props = {};
@@ -3576,8 +3532,9 @@ export default class CommonDatagridComponent extends AppComponent {
3576
3532
  cb();
3577
3533
  }, 200);
3578
3534
  }
3579
- isAllRowsSelected(update){
3580
- return this.selectedRowsCount && this.selectedRowsCount === this.getMaxSelectableRows()? true : false;
3535
+ isAllRowsSelected(){
3536
+ const count = this.getSelectedRowsCount() - this.getSectionListDataSize();
3537
+ return count >=0 && count >= this.getMaxSelectableRows()? true : false;
3581
3538
  }
3582
3539
  getDefaultPaginationRowsPerPageItems (){
3583
3540
  return [5,10,15,20,25,30,40,50,60,80,100];
@@ -3676,11 +3633,10 @@ export default class CommonDatagridComponent extends AppComponent {
3676
3633
  }
3677
3634
  return <Checkbox
3678
3635
  testID = "RN_SelectColumnHeaderCell"
3679
- checked ={this.isAllRowsSelected()?true:false}
3636
+ toggleAll
3680
3637
  key = {this.getSelectableColumName()}
3681
3638
  secondaryOnCheck
3682
- style = {style}
3683
- ref = {this.selectableColumnRef}
3639
+ style = {[style]}
3684
3640
  onPress = {({checked})=>{
3685
3641
  this.handleAllRowsToggle(!checked);
3686
3642
  return;
@@ -3696,7 +3652,7 @@ export default class CommonDatagridComponent extends AppComponent {
3696
3652
  this.sort(columnField);
3697
3653
  };
3698
3654
  return <TouchableRipple disabled={!sortable} style={styles.sortableColumn} onPress={sortMe}>
3699
- <>
3655
+ <View testID={"RN_DatagridHeaderCellContainer_"+columnField} style={[tableStyles.cell,theme.styles.row,theme.styles.flex1,theme.styles.justifyContentFlexStart,theme.styles.alignItemsCenter]}>
3700
3656
  {isColumnSorted ? <Icon
3701
3657
  {...sortedColumn}
3702
3658
  size = {24}
@@ -3705,8 +3661,8 @@ export default class CommonDatagridComponent extends AppComponent {
3705
3661
  onPress = {sortMe}
3706
3662
  primary
3707
3663
  />: null}
3708
- <Label textBold style={[{fontSize:13}]} primary={isColumnSorted}>{ret}</Label>
3709
- </>
3664
+ <Label testID={"RN_DatagridHeaderCellLabel_"+columnField} textBold style={[{fontSize:13}]} primary={isColumnSorted}>{ret}</Label>
3665
+ </View>
3710
3666
  </TouchableRipple>
3711
3667
  }
3712
3668
  canScrollTo(){
@@ -3751,6 +3707,21 @@ export default class CommonDatagridComponent extends AppComponent {
3751
3707
  getRowByKey(rowKey){
3752
3708
  return (this.isValidRowKey(rowKey)) && isObj(this.rowsByKeys[rowKey]) && this.rowsByKeys[rowKey] || null;
3753
3709
  }
3710
+ getRowsKeysIndexes(){
3711
+ return Array.isArray(this.rowsKeysIndexes) ? this.rowsKeysIndexes : [];
3712
+ }
3713
+ getRowKeyByIndex(rowIndex){
3714
+ if(typeof rowIndex !='number') return undefined;
3715
+ const idx = this.getRowsKeysIndexes();
3716
+ if(rowIndex < idx.length-1 && rowIndex>=0){
3717
+ return idx[rowIndex];
3718
+ }
3719
+ return undefined;
3720
+ }
3721
+ getRowByIndex(rowIndex){
3722
+ const rowKey = this.getRowKeyByIndex(rowIndex);
3723
+ return rowKey !== undefined ? this.getRowByKey(rowIndex) : null;
3724
+ }
3754
3725
  /*** retourne le rendu d'une cellule de la ligne du tableau
3755
3726
  @parm, rowData, object, la ligne à afficher le rendu du contenu
3756
3727
  @param , rowInidex, l'indice de la ligne dont on affiche le rendu en cours
@@ -3777,7 +3748,6 @@ export default class CommonDatagridComponent extends AppComponent {
3777
3748
  rowKey,
3778
3749
  rowData,
3779
3750
  checked : this.isRowSelected(rowKey,rowIndex),
3780
- rowsRefs : this.selectedRowsRefs,
3781
3751
  onPress : ({checked})=>{
3782
3752
  return this.handleRowToggle({rowIndex,rowKey,selected:!checked});
3783
3753
  }
@@ -3844,7 +3814,7 @@ CommonDatagridComponent.propTypes = {
3844
3814
  selectedRowsActions : PropTypes.oneOfType([PropTypes.object,PropTypes.array,PropTypes.func]),
3845
3815
  /** 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
3816
  * La fonction prend en paramètre :
3847
- * selectedRows : this.selectedRows : les lignes sélectionnées
3817
+ * selectedRows : : les lignes sélectionnées
3848
3818
  data : this.state.data : les données du datagrid
3849
3819
  rows : this.state.data : les données du datagrid
3850
3820
  allData : this.INITIAL_STATE.data : l'ensemble des données du datagrid
@@ -3959,7 +3929,6 @@ CommonDatagridComponent.propTypes = {
3959
3929
  * title : PropTypes.node , //le titre du header
3960
3930
  * avatar : PropTypes.string(dataUrl,src,other) || PropTypes.node, ///l'avatar,
3961
3931
  * rowClassName : la class à appliquer à la ligne
3962
- * rowProps : les props à appliquer à la ligne de la liste
3963
3932
  * headerClassName : la class à appliquer au header de la ligne
3964
3933
  * primaryText : //
3965
3934
  * 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
- visibleColumnsNames,
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 = {visibleColumnsNames}
53
+ visibleColumns = {columnsVisibilities}
54
54
  filteredColumns = {filteredColumns}
55
55
  orOperator = {filterOrOperator}
56
56
  andOperator = {filterAndOperator}