@fto-consult/expo-ui 7.15.0 → 7.16.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "7.15.0",
3
+ "version": "7.16.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",
@@ -186,11 +186,14 @@ export default class CommonDatagridComponent extends AppComponent {
186
186
  SET_DATAGRID_QUERY_LIMIT : this.onSetQueryLimit.bind(this),
187
187
  });
188
188
  }
189
+ if(this.props.resetSessionData === true){
190
+ this.resetSessionData();
191
+ }
189
192
  rest = defaultObj(rest);
190
193
  this._pagination = defaultObj(rest.pagination);
191
194
  this.hasLocalFilters = false;
192
195
  data = (data && typeof data == 'object')? Object.toArray(data):[];
193
- let sData = this.getSessionData()
196
+ const sData = this.getSessionData()
194
197
  sData.showFooters = defaultVal(sData.showFooters,this.isTableData());
195
198
  sData.fixedTable = defaultBool(sData.fixedTable,false);
196
199
  this.rowsByKeys = {};
@@ -274,14 +277,15 @@ export default class CommonDatagridComponent extends AppComponent {
274
277
  chartSeriesNamesColumnsMapping : {value : {}},//le mappage entre les index des series et les colonnes coorespondantes
275
278
  });
276
279
  this.setSelectedRows(selectedRows);
277
- const config = extendObj(true,{},this.getSessionData("config"),this.props.chartConfig);
280
+ const config = extendObj(true,{},this.props.chartConfig,this.getSessionData("config"));
278
281
  Object.map(config,(v,k)=>{
279
282
  if(typeof v =='function'){
280
283
  delete config[k];
281
284
  }
282
285
  });
283
286
  this.state.fetchOnlyVisibleColumns = !!defaultVal(this.props.fetchOnlyVisibleColumns,config.fetchOnlyVisibleColumns,this.getSessionData("fetchOnlyVisibleColumns"));
284
- this.state.abreviateValues = "abreviateValues" in this.props? !!this.props.abreviateValues : !!this.getSessionData("abreviateValues");
287
+ const abreviateVals = this.getSessionData("abreviateValues");
288
+ this.state.abreviateValues = abreviateVals !== undefined ? !!abreviateVals : "abreviateValues" in this.props? !!this.props.abreviateValues : true;
285
289
  const sessionAggregator = this.getSessionData("aggregatorFunction");
286
290
  this.state.aggregatorFunction= this.isValidAggregator(config.aggregatorFunction) && config.aggregatorFunction || this.isValidAggregator(this.props.aggregatorFunction) && this.props.aggregatorFunction || this.isValidAggregator(sessionAggregator) && sessionAggregator || Object.keys(this.aggregatorFunctions)[0];;
287
291
  this.isLoading = this.isLoading.bind(this);
@@ -433,10 +437,14 @@ export default class CommonDatagridComponent extends AppComponent {
433
437
  }
434
438
  },
435
439
  setSessionData : {
436
- value : (sessionKey,sessionValue)=>{
440
+ value : (sessionKey,sessionValue,reset)=>{
437
441
  if(this.props.session === false) return;
438
442
  let key = this.getSessionKey();
439
443
  if(!isNonNullString(key)) return false;
444
+ if(reset === true){
445
+ $session.set(key,{});
446
+ return {};
447
+ }
440
448
  let dat = defaultObj(this.getSessionData());
441
449
  if(isNonNullString(sessionKey)){
442
450
  dat[sessionKey] = sessionValue;
@@ -451,6 +459,9 @@ export default class CommonDatagridComponent extends AppComponent {
451
459
  }
452
460
  })
453
461
  }
462
+ resetSessionData(){
463
+ return this.setSessionData(null,null,true);
464
+ }
454
465
  /*** lorsque les filtres locaux changes */
455
466
  onLocalFiltersChange(localFilters){
456
467
  return;
@@ -1609,12 +1620,18 @@ export default class CommonDatagridComponent extends AppComponent {
1609
1620
  text : "Largeur du graphe",
1610
1621
  tooltip : "Définissez la valeur 0 si vous voulez que le graphe occupe toute la largeur de con contenueur",
1611
1622
  defaultValue : this.getDefaultChartWidth(),
1623
+ formatValue : ({value})=>{
1624
+ return value.formatNumber()+" px";
1625
+ },
1612
1626
  },
1613
1627
  height : {
1614
1628
  type : "number",
1615
1629
  text : "Hauteur du graphe",
1616
1630
  validType : "numberGreaterThan[0]",
1617
1631
  defaultValue : this.getDefaultChartHeight(),
1632
+ formatValue : ({value})=>{
1633
+ return value.formatNumber()+" px";
1634
+ },
1618
1635
  },
1619
1636
  stacked : stackSettings,
1620
1637
  sparkline : {
@@ -2431,7 +2448,9 @@ export default class CommonDatagridComponent extends AppComponent {
2431
2448
 
2432
2449
  chartOptions.legend = defaultObj(chartOptions.legend);
2433
2450
  chartOptions.legend.show = ("showLegend" in config) ? !!config.showLegend : !this.isDashboard();
2434
-
2451
+ chartOptions.legend.labels = Object.assign({},chartOptions.legend.labels);
2452
+ const legendLabels = chartOptions.legend.labels;
2453
+ chartOptions.legend.labels.colors = (Array.isArray(legendLabels.colors) && legendLabels.colors.length || theme.Colors.isValid(legendLabels.colors)) ? legendLabels.colors : labelColor;
2435
2454
  if("dataLabels" in config){
2436
2455
  chartOptions.dataLabels.enabled = !!config.dataLabels;
2437
2456
  }
@@ -4162,6 +4181,7 @@ CommonDatagridComponent.propTypes = {
4162
4181
  aggregatorFunction : PropTypes.string,
4163
4182
  /*** permet de faire une mutation sur les options de la recherche, immédiatement avant le lancement de la recherche */
4164
4183
  fetchOptionsMutator : PropTypes.func,
4184
+ resetSessionData : PropTypes.bool, //pour forcer la réinitialisation des données de sessions liés à la table data
4165
4185
  /*** si les données à récupérer à distance seront */
4166
4186
  fetchOnlyVisibleColumns : PropTypes.bool,
4167
4187
  canFetchOnlyVisibleColumns : PropTypes.bool,//si l'on peut modifier le type d'affichage lié à la possibilité de récupérer uniquement les données reletives aux colonnes visibles
@@ -1,5 +1,5 @@
1
1
  import {TableData} from "../Common";
2
- import {defaultObj,defaultArray,defaultStr,defaultDecimal,isNonNullString} from "$cutils";
2
+ import {defaultObj,defaultArray,defaultStr,defaultNumber} from "$cutils";
3
3
  import View from "$ecomponents/View";
4
4
  import { StyleSheet,Dimensions,Pressable } from "react-native";
5
5
  import Icon,{MENU_ICON} from "$ecomponents/Icon";
@@ -96,7 +96,9 @@ export default class DatagridDashboard extends TableData {
96
96
  testID = this.getTestID();
97
97
  rest = defaultObj(rest);
98
98
  const pointerEvents = this.getPointerEvents();
99
- const maxHeight = 300;
99
+ const chartData = this.renderChart();
100
+ const max = defaultNumber(chartData?.props?.options?.chart?.height);
101
+ const maxHeight = Math.max(300,max+80);
100
102
  return <View {...rest} testID={testID} style={[styles.container,{maxHeight},rest.style]} pointerEvents={pointerEvents}>
101
103
  {this.renderTitle()}
102
104
  {showPagination ? <View style={[styles.paginationContainer]}>
@@ -110,7 +112,7 @@ export default class DatagridDashboard extends TableData {
110
112
  </View> : null}
111
113
  {<View testID={testID+"_ChartContainer"} {...chartContainerProps} style={[theme.styles.w100,styles.chartContainer,chartContainerProps.style]}>
112
114
  {this.renderProgressBar()}
113
- {this.renderChart()}
115
+ {chartData}
114
116
  </View>}
115
117
  </View>
116
118
  }