@fto-consult/expo-ui 2.38.2 → 2.39.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "2.38.2",
3
+ "version": "2.39.1",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/readChart.txt ADDED
@@ -0,0 +1,6 @@
1
+ // Copyright 2023 @fto-consult/Boris Fouomene. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ Les valeurs pouvant appartenir au séries groupées des charts peuvent être uniquement les valeurs calculées du footer,
6
+ lorsque les colonnes sont grouépes
@@ -1419,12 +1419,53 @@ export default class CommonDatagridComponent extends AppComponent {
1419
1419
  }}
1420
1420
  />
1421
1421
  }
1422
+ configureSectionLists(){
1423
+ const config = this.getChartConfig();
1424
+ return new Promise((resolve)=>{
1425
+ DialogProvider.open({
1426
+ title : "Paramètres de groupe",
1427
+ data : config,
1428
+ fields : {
1429
+ displayGroupLabels : {
1430
+ type : "switch",
1431
+ text : "Afficher les libelés de groupées",
1432
+ tooltip : "Afficher/Masquer les noms de colonnes sur les entêtes des valeurs groupées",
1433
+ defaultValue : 1,
1434
+ },
1435
+ displayGroupLabelsSeparator : {
1436
+ type : "text",
1437
+ label : "Séparateur de valeurs d'entêtes",
1438
+ title : "Définisser un séparateur pour les valeurs d'entêtes de groupe, lorsque le tableau est groupé par plusieurs colonnes",
1439
+ defaultValue : ", "
1440
+ },
1441
+ },
1442
+ actions : [
1443
+ {
1444
+ text : "Configurer",
1445
+ icon : "check",
1446
+ onPress : ({data})=>{
1447
+ const chartConfig = {...config,...data};
1448
+ this.setSessionData("chartConfig",chartConfig);
1449
+ DialogProvider.close();
1450
+ this.setIsLoading(true,true);
1451
+ this.prepareData({data:this.INITIAL_STATE.data,config:chartConfig},(state)=>{
1452
+ this.setState({...state,chartConfig},()=>{
1453
+ resolve(chartConfig)
1454
+ })
1455
+ })
1456
+ }
1457
+ }
1458
+ ]
1459
+ })
1460
+ })
1461
+ }
1422
1462
  configureChart(refreshChart){
1423
1463
  if(!this.isChartRendable()){
1424
1464
  return Promise.reject({message:'Impossible de configurer le graphe car le type de données ne permet pas de rendu de type graphe'});
1425
1465
  }
1426
1466
  const xItems = {},yItems = {},config = defaultObj(this.state.chartConfig);
1427
- const series = {};
1467
+ const series = {},seriesGroups = {};
1468
+ const footers = this.getFootersFields();
1428
1469
  const isValidConfig = this.isValidChartConfig();
1429
1470
  Object.map(this.state.columns,(field,f)=>{
1430
1471
  if(isObj(field) && !this.isSelectableColumn(field) && !this.isIndexColumn(field)){
@@ -1432,6 +1473,9 @@ export default class CommonDatagridComponent extends AppComponent {
1432
1473
  if(type === 'number' || type=='decimal'){
1433
1474
  yItems[f] = field;
1434
1475
  series[f] = field;
1476
+ if(isObj(footers[f])){
1477
+ seriesGroups[f] = field;
1478
+ }
1435
1479
  } else {
1436
1480
  xItems[f] = field;
1437
1481
  }
@@ -1482,7 +1526,7 @@ export default class CommonDatagridComponent extends AppComponent {
1482
1526
  sectionListHeadersSeries : {
1483
1527
  text : "Series des données groupées",
1484
1528
  type : "select",
1485
- items : yItems,
1529
+ items : seriesGroups,
1486
1530
  multiple : true,
1487
1531
  },
1488
1532
  dataLabels : {
@@ -1635,6 +1679,7 @@ export default class CommonDatagridComponent extends AppComponent {
1635
1679
  text : "Format des dates",
1636
1680
  type : "dateFormat",
1637
1681
  required : true,
1682
+ defaultValue : DateLib.defaultDateFormat,
1638
1683
  },
1639
1684
  }
1640
1685
  }
@@ -1934,14 +1979,13 @@ export default class CommonDatagridComponent extends AppComponent {
1934
1979
  if(!isValidAggregator(aggregatorFunction)){
1935
1980
  aggregatorFunction = this.getActiveAggregatorFunction();
1936
1981
  }
1937
-
1938
1982
  const code = aggregatorFunction.code;
1939
1983
  const isDonut = chartType.isDonut || chartType.isRadial;
1940
1984
  const config = this.getChartConfig();
1941
1985
  //@see : https://apexcharts.com/docs/series/
1942
1986
  ///lorsqu'on affiche uniquement les totaux des sections, alors la visualition se fait sur uniquement sur la base des valeurs
1943
1987
  ///on parcoure uniquement les entêtes des sectionLis
1944
- const dataIndexes={},dataInexesNames = {};
1988
+ const dataIndexes={};
1945
1989
  //la variable sectionListHeaderSeries, permet de récupérer les colonnes de type montant à utiliser pour le rendu du chart
1946
1990
  const tableFooters = this.getFootersFields();
1947
1991
  const defaultSectionListHeadersSeries = this.getDefaultSectionHeadersSeries();
@@ -1959,7 +2003,6 @@ export default class CommonDatagridComponent extends AppComponent {
1959
2003
  seriesConfig = defaultSectionListHeadersSeries;
1960
2004
  }
1961
2005
  }
1962
- const seriesNamesMapping = {};
1963
2006
  /**** boucle sur chaque éléments trouvée dans le tableau des données sectionListData */
1964
2007
  const loopForFooter = ({column,serieName,footers,header})=>{
1965
2008
  if(!isObj(column) || !isObj(footers)) return null;
@@ -2055,13 +2098,20 @@ export default class CommonDatagridComponent extends AppComponent {
2055
2098
  const aggregatorFunction = this.getActiveAggregatorFunction().eval;
2056
2099
  const emptyValue = this.getEmptySectionListHeaderValue();
2057
2100
  const indexes = {};
2058
- let series = [],xaxis = {},customConfig = {},seriesNamesToColumns={};
2101
+ let series = [],xaxis = {},customConfig = {};
2059
2102
  let count = 0;
2060
2103
  //on réinitialise le mappage entre les index
2061
2104
  Object.map(this.chartSeriesNamesColumnsMapping,(_,k)=>{
2062
2105
  delete this.chartSeriesNamesColumnsMapping[k];
2063
2106
  });
2064
2107
  if(!this.isSectionList()){
2108
+ const sColumns = {};
2109
+ Object.map(seriesConfig,(s,v)=>{
2110
+ if(!isNonNullString(s) || !this.state.columns[s]) return null;
2111
+ const columnDef = this.state.columns[s];
2112
+ if(!isObj(columnDef)) return null;
2113
+ sColumns[s] = columnDef;
2114
+ })
2065
2115
  this.state.data.map((data,index)=>{
2066
2116
  if(!isObj(data))return null;
2067
2117
  const txt = this.renderRowCell({
@@ -2074,10 +2124,7 @@ export default class CommonDatagridComponent extends AppComponent {
2074
2124
  columnField : xAxisColumn.field,
2075
2125
  });
2076
2126
  const text = isNonNullString(txt)? txt : emptyValue;
2077
- Object.map(seriesConfig,(s,v)=>{
2078
- if(!isNonNullString(s) || !this.state.columns[s]) return null;
2079
- const columnDef = this.state.columns[s];
2080
- if(!isObj(columnDef)) return null;
2127
+ Object.map(sColumns,(columnDef,s)=>{
2081
2128
  indexes[s] = defaultObj(indexes[s]);
2082
2129
  const current = indexes[s];
2083
2130
  current[text] = typeof current[text] =="number"? current[text] : 0;
@@ -2294,6 +2341,7 @@ export default class CommonDatagridComponent extends AppComponent {
2294
2341
  closeOnPress : false,
2295
2342
  divider : true,
2296
2343
  style : theme.styles.bold,
2344
+ onPress : this.configureSectionLists.bind(this),
2297
2345
  },
2298
2346
  this.canDisplayOnlySectionListHeaders() && this.state.displayType =='table' && {
2299
2347
  text : "Afficher uniquement totaux",
@@ -2578,8 +2626,9 @@ export default class CommonDatagridComponent extends AppComponent {
2578
2626
  return defaultNumber(this.sectionListDataSize.current)
2579
2627
  }
2580
2628
  prepareData(args,cb){
2581
- let {pagination,aggregatorFunction:customAggregatorFunction,displayOnlySectionListHeaders:cdisplayOnlySectionListHeaders,data,force,sectionListColumns,updateFooters} = defaultObj(args);
2629
+ let {pagination,config,aggregatorFunction:customAggregatorFunction,displayOnlySectionListHeaders:cdisplayOnlySectionListHeaders,data,force,sectionListColumns,updateFooters} = defaultObj(args);
2582
2630
  cb = typeof cb ==='function'? cb : typeof args.cb == 'function'? args.cb : undefined;
2631
+ config = isObj(config) && Object.size(config,true)? config : this.getChartConfig();
2583
2632
  const aggregatorFunction = isNonNullString(customAggregatorFunction) && customAggregatorFunction in this.aggregatorFunctions ? this.aggregatorFunctions[customAggregatorFunction] : this.getActiveAggregatorFunction();
2584
2633
  sectionListColumns = isObj(sectionListColumns) ? sectionListColumns : this.state.sectionListColumns;
2585
2634
  const displayOnlySectionListHeaders = typeof cdisplayOnlySectionListHeaders == 'boolean'?cdisplayOnlySectionListHeaders : this.state.displayOnlySectionListHeaders;
@@ -2631,7 +2680,7 @@ export default class CommonDatagridComponent extends AppComponent {
2631
2680
  return;
2632
2681
  }
2633
2682
  if(hasSectionColumns){
2634
- 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});
2683
+ 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});
2635
2684
  if(sHeader === false) return;//on omet la donnée si la fonction de récupération de son header retourne false
2636
2685
  if(!isNonNullString(sHeader) || sHeader.toLowerCase().trim() =="undefined"){
2637
2686
  if(this.props.ignoreEmptySectionListHeader !== false){
@@ -2709,7 +2758,10 @@ export default class CommonDatagridComponent extends AppComponent {
2709
2758
  if(this.getSectionListHeaderProp){
2710
2759
  return this.getSectionListHeaderProp(args);
2711
2760
  }
2712
- const {fields,sectionListColumnsSize,data} = args;
2761
+ const chartConfig = isObj(args.config) && Object.size(args.config,true)? args.config : this.getChartConfig();
2762
+ const displayGroupLabels = "displayGroupLabels" in chartConfig? chartConfig.displayGroupLabels : true;
2763
+ const displayGroupLabelsSeparator = typeof chartConfig.displayGroupLabelsSeparator =='string'? chartConfig.displayGroupLabelsSeparator : arrayValueSeparator;
2764
+ const {fields,sectionListColumnsSize} = args;
2713
2765
  const d = [];
2714
2766
  Object.map(fields,(field,i)=>{
2715
2767
  const txt = this.renderRowCell({
@@ -2720,13 +2772,13 @@ export default class CommonDatagridComponent extends AppComponent {
2720
2772
  columnField : defaultStr(field.field,i),
2721
2773
  });
2722
2774
  if(!isNonNullString(txt) && typeof txt !=='number') return;
2723
- if(sectionListColumnsSize == 1){
2775
+ if(sectionListColumnsSize == 1 || !displayGroupLabels){
2724
2776
  d.push(txt);
2725
2777
  } else {
2726
2778
  d.push("{0} : {1}".sprintf(defaultStr(field.label,field.txt),txt))
2727
2779
  }
2728
2780
  });
2729
- return d.length ? d.join(arrayValueSeparator) : undefined;
2781
+ return d.length ? d.join(displayGroupLabelsSeparator) : undefined;
2730
2782
  }
2731
2783
  /*** retourne le type d'item à rendre à la fonction flashlist
2732
2784
  * @see : https://shopify.github.io/flash-list/docs/guides/section-list
@@ -175,6 +175,7 @@ export default class CommonTableDatagrid extends CommonDatagrid{
175
175
  cb(data)
176
176
  }
177
177
  resolve(data);
178
+ this.isRenderingRef.current = false;
178
179
  this.isFetchingData = undefined;
179
180
  this.setIsLoading(false,false);
180
181
  })
@@ -196,6 +196,10 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
196
196
  const fetchCB = ({data,total})=>{
197
197
  totalRef.current = total;
198
198
  dataRef.current = data;
199
+ const dd = Object.size(data);
200
+ if(dd>total){
201
+ total = dd;
202
+ }
199
203
  hasResultRef.current = true;
200
204
  if(onFetchData && typeof onFetchData =='function'){
201
205
  onFetchData({allData:data,total,data,context:innerRef.current})