@fto-consult/expo-ui 2.32.0 → 2.33.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/appConfig.txt +1 -1
- package/package.json +2 -2
- package/src/components/Chart/index.js +5 -1
- package/src/components/Datagrid/Common/Common.js +83 -26
- package/src/components/Datagrid/Common/TableData.js +1 -0
- package/src/components/Form/Fields/CurrencyFormat.js +18 -0
- package/src/components/Form/Fields/SelectCurrency.js +2 -26
- package/src/components/Form/Fields/SelectTableData/Component.js +4 -2
- package/src/components/Form/Fields/index.js +3 -1
- package/src/components/Form/FormData/componentsTypes.js +2 -0
- package/src/components/SelectCurrency/Format.js +27 -0
- package/src/components/SelectCurrency/index.js +5 -69
- package/src/layouts/DatabaseStatistics/DatabaseStatistic.js +10 -7
- package/src/layouts/DatabaseStatistics/index.js +21 -21
package/appConfig.txt
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fto-consult/expo-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.0",
|
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@emotion/native": "^11.10.0",
|
|
62
62
|
"@expo/html-elements": "^0.2.0",
|
|
63
63
|
"@expo/vector-icons": "^13.0.0",
|
|
64
|
-
"@fto-consult/common": "^1.
|
|
64
|
+
"@fto-consult/common": "^1.26.0",
|
|
65
65
|
"@gorhom/portal": "^1.0.14",
|
|
66
66
|
"@react-native-async-storage/async-storage": "~1.17.3",
|
|
67
67
|
"@react-native-community/datetimepicker": "6.5.2",
|
|
@@ -41,7 +41,11 @@ const ChartComponent = React.forwardRef(({options,style,height,width,chartId:cus
|
|
|
41
41
|
destroyChart(chartContext.current);
|
|
42
42
|
}
|
|
43
43
|
},[])
|
|
44
|
-
|
|
44
|
+
if(theme.isDark()){
|
|
45
|
+
options.tooltip = defaultObj(options.tooltip);
|
|
46
|
+
options.tooltip.theme = 'dark';
|
|
47
|
+
}
|
|
48
|
+
return <Chart {...props} ref={ref} chartId={chartId} style={[options.chart.height && {minHeight:options.chart.height},options.chart.width && {minWidth:options.chart.width},theme.styles.p1,style]} options={options} chartContext={chartContext} testID={testID}/>
|
|
45
49
|
});
|
|
46
50
|
|
|
47
51
|
|
|
@@ -292,7 +292,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
292
292
|
if(this.canHandleColumnResize()){
|
|
293
293
|
this.state.columnsWidths = this.preparedColumns.widths;
|
|
294
294
|
}
|
|
295
|
-
this.state.chartConfig = extendObj({},this.getSessionData("chartConfig"),this.props.chartConfig);
|
|
295
|
+
this.state.chartConfig = extendObj(true,{},this.getSessionData("chartConfig"),this.props.chartConfig);
|
|
296
296
|
if(!("sparkline" in this.state.chartConfig) && this.isDashboard()){
|
|
297
297
|
this.state.chartConfig.sparkline = true;
|
|
298
298
|
}
|
|
@@ -1267,8 +1267,8 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1267
1267
|
isChartRendable(){
|
|
1268
1268
|
return !this.isPivotDatagrid() && this.hasFootersFields();
|
|
1269
1269
|
}
|
|
1270
|
-
isValidChartConfig(
|
|
1271
|
-
config =
|
|
1270
|
+
isValidChartConfig(){
|
|
1271
|
+
const config = this.state.chartConfig;
|
|
1272
1272
|
return isNonNullString(config.x) && isNonNullString(config.y);
|
|
1273
1273
|
}
|
|
1274
1274
|
canRenderChart(){
|
|
@@ -1404,10 +1404,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1404
1404
|
}
|
|
1405
1405
|
}
|
|
1406
1406
|
return new Promise((resolve,reject)=>{
|
|
1407
|
+
const data = this.getChartConfig();
|
|
1407
1408
|
DialogProvider.open({
|
|
1408
1409
|
title : 'Configuration des graphes',
|
|
1409
1410
|
subtitle : false,
|
|
1410
|
-
data
|
|
1411
|
+
data,
|
|
1411
1412
|
fields : {
|
|
1412
1413
|
x : {
|
|
1413
1414
|
text : 'Axe des x[horizontal]',
|
|
@@ -1445,6 +1446,42 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1445
1446
|
uncheckedValue : false,
|
|
1446
1447
|
defaultValue : this.isDashboard()? true : false,
|
|
1447
1448
|
},
|
|
1449
|
+
showXaxis : {
|
|
1450
|
+
type : "switch",
|
|
1451
|
+
text : "Afficher l'axe des X",
|
|
1452
|
+
type : "switch",
|
|
1453
|
+
checkedValue : true,
|
|
1454
|
+
uncheckedValue : false,
|
|
1455
|
+
defaultValue : !this.isDashboard(),
|
|
1456
|
+
},
|
|
1457
|
+
showYaxis : {
|
|
1458
|
+
type : "switch",
|
|
1459
|
+
text : "Afficher l'axe des Y",
|
|
1460
|
+
type : "switch",
|
|
1461
|
+
checkedValue : true,
|
|
1462
|
+
uncheckedValue : false,
|
|
1463
|
+
defaultValue : !this.isDashboard(),
|
|
1464
|
+
},
|
|
1465
|
+
showLegend : {
|
|
1466
|
+
type : "switch",
|
|
1467
|
+
text : "Afficher la legende",
|
|
1468
|
+
type : "switch",
|
|
1469
|
+
checkedValue : true,
|
|
1470
|
+
uncheckedValue : false,
|
|
1471
|
+
defaultValue : !this.isDashboard(),
|
|
1472
|
+
},
|
|
1473
|
+
width : {
|
|
1474
|
+
type : "number",
|
|
1475
|
+
text : "Largeur du graphe",
|
|
1476
|
+
tooltip : "Définissez la valeur 0 si vous voulez que le graphe occupe toute la largeur de con contenueur",
|
|
1477
|
+
defaultValue : this.getDefaultChartWidth(),
|
|
1478
|
+
},
|
|
1479
|
+
height : {
|
|
1480
|
+
type : "number",
|
|
1481
|
+
text : "Hauteur du graphe",
|
|
1482
|
+
validType : "numberGreaterThan[0]",
|
|
1483
|
+
defaultValue : this.getDefaultChartHeight(),
|
|
1484
|
+
},
|
|
1448
1485
|
stacked : stackSettings,
|
|
1449
1486
|
sparkline : {
|
|
1450
1487
|
type : 'switch',
|
|
@@ -1600,8 +1637,8 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1600
1637
|
}}
|
|
1601
1638
|
/>
|
|
1602
1639
|
}
|
|
1603
|
-
|
|
1604
|
-
return "N/A";
|
|
1640
|
+
getEmptySectionListHeaderValue(){
|
|
1641
|
+
return defaultStr(this.props.sectionListHeaderEmptyValue,"N/A");
|
|
1605
1642
|
}
|
|
1606
1643
|
/*** retourne les sectionHeaderSeries par défautt */
|
|
1607
1644
|
getDefaultSectionHeadersSeries(){
|
|
@@ -1614,6 +1651,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1614
1651
|
if(!isObj(footer)) continue;
|
|
1615
1652
|
if(counter >= max) break;
|
|
1616
1653
|
r.push(i);
|
|
1654
|
+
counter ++;
|
|
1617
1655
|
}
|
|
1618
1656
|
return r;
|
|
1619
1657
|
}
|
|
@@ -1646,7 +1684,6 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1646
1684
|
///on parcoure uniquement les entêtes des sectionLis
|
|
1647
1685
|
const dataIndexes={},dataInexesNames = {};
|
|
1648
1686
|
//la variable sectionListHeaderSeries, permet de récupérer les colonnes de type montant à utiliser pour le rendu du chart
|
|
1649
|
-
let serieName = "";
|
|
1650
1687
|
const tableFooters = this.getFootersFields();
|
|
1651
1688
|
const defaultSectionListHeadersSeries = this.getDefaultSectionHeadersSeries();
|
|
1652
1689
|
let seriesConfig = isDonut ? [] : Array.isArray(config.sectionListHeadersSeries) && config.sectionListHeadersSeries.length ? config.sectionListHeadersSeries : [];
|
|
@@ -1671,6 +1708,9 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1671
1708
|
const footer = footers[column.field];
|
|
1672
1709
|
if(typeof footer[code] !== 'number') return null;
|
|
1673
1710
|
if(typeof footer[code] !== 'number') return null;
|
|
1711
|
+
if(header === this.emptySectionListHeaderValue){
|
|
1712
|
+
header = this.getEmptySectionListHeaderValue();
|
|
1713
|
+
}
|
|
1674
1714
|
if(isDonut){
|
|
1675
1715
|
dataIndexes[header] = footer[code];
|
|
1676
1716
|
} else {
|
|
@@ -1713,6 +1753,12 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1713
1753
|
}
|
|
1714
1754
|
}
|
|
1715
1755
|
}
|
|
1756
|
+
getDefaultChartHeight(){
|
|
1757
|
+
return defaultNumber(this.props.chartProps?.height,this.isDashboard()?80:350);
|
|
1758
|
+
}
|
|
1759
|
+
getDefaultChartWidth(){
|
|
1760
|
+
return defaultNumber(this.props.chartProps?.width);
|
|
1761
|
+
}
|
|
1716
1762
|
/*** permet de formatter les valeurs de la courbe en fonction du type passé en paramètre */
|
|
1717
1763
|
chartValueFormattter(value,columnType){
|
|
1718
1764
|
|
|
@@ -1748,7 +1794,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1748
1794
|
xAxisColumn = this.state.columns[config.x];
|
|
1749
1795
|
}
|
|
1750
1796
|
const aggregatorFunction = this.getActiveAggregatorFunction().eval;
|
|
1751
|
-
const emptyValue = this.
|
|
1797
|
+
const emptyValue = this.getEmptySectionListHeaderValue();
|
|
1752
1798
|
const indexes = {};
|
|
1753
1799
|
let series = [],xaxis = {},customConfig = {},seriesNamesToColumns={};
|
|
1754
1800
|
let count = 0;
|
|
@@ -1854,8 +1900,12 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1854
1900
|
series,
|
|
1855
1901
|
chart : extendObj(true,{},
|
|
1856
1902
|
{toolbar : {show : false}},
|
|
1857
|
-
|
|
1858
|
-
{
|
|
1903
|
+
chartProps.chart,
|
|
1904
|
+
{
|
|
1905
|
+
height : defaultNumber(config.height,this.getDefaultChartHeight()),
|
|
1906
|
+
width : defaultNumber(config.width) || this.getDefaultChartWidth() || undefined,
|
|
1907
|
+
type : chartType.type
|
|
1908
|
+
},
|
|
1859
1909
|
)
|
|
1860
1910
|
}
|
|
1861
1911
|
const labelColor = theme.Colors.isValid(config.labelColor)? config.labelColor : theme.colors.text;
|
|
@@ -1868,7 +1918,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1868
1918
|
delete chartOptions.xaxis;
|
|
1869
1919
|
//delete chartOptions.yaxis;
|
|
1870
1920
|
}
|
|
1871
|
-
chartOptions.yaxis = extendObj(true,{},{type: 'category'},chartProps.yaxis);
|
|
1921
|
+
chartOptions.yaxis = extendObj(true,{},{type: 'category'},defaultObj(chartProps.yaxis));
|
|
1872
1922
|
const yLabels = chartOptions.yaxis.labels = defaultObj(chartOptions.yaxis.labels);
|
|
1873
1923
|
yLabels.style = defaultObj(yLabels.style)
|
|
1874
1924
|
yLabels.style.colors = (Array.isArray(yLabels.style.colors) && yLabels.style.colors.length || theme.Colors.isValid(yLabels.style.colors)) ? yLabels.style.colors : labelColor;
|
|
@@ -1879,7 +1929,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1879
1929
|
for(let i in series){
|
|
1880
1930
|
const v = series[i];
|
|
1881
1931
|
if(!isObj(v) || !isNonNullString(v.name) || !this.chartSeriesNamesColumnsMapping[v.name]) break;
|
|
1882
|
-
if(yLabelFormat &&
|
|
1932
|
+
if(yLabelFormat && this.chartSeriesNamesColumnsMapping[v.name]?.format !=yLabelFormat) {
|
|
1883
1933
|
yLabelFormat = null;
|
|
1884
1934
|
break;
|
|
1885
1935
|
}
|
|
@@ -1908,17 +1958,17 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1908
1958
|
if(chartOptions.chart.sparkline){
|
|
1909
1959
|
chartOptions.chart.sparkline = {enabled: true}
|
|
1910
1960
|
} else delete chartOptions.chart.sparkline;
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1961
|
+
//const spackLine = chartOptions.chart.sparkline;
|
|
1962
|
+
chartOptions.xaxis = defaultObj(chartOptions.xaxis);
|
|
1963
|
+
chartOptions.xaxis.labels = defaultObj(chartOptions.xaxis.labels);
|
|
1964
|
+
chartOptions.xaxis.labels.show = ("showXaxis" in config) ? !!config.showXaxis : !this.isDashboard();
|
|
1965
|
+
|
|
1966
|
+
chartOptions.yaxis.labels = defaultObj(chartOptions.yaxis.labels);
|
|
1967
|
+
chartOptions.yaxis.labels.show = ("showYaxis" in config) ? !!config.showYaxis : !this.isDashboard();
|
|
1968
|
+
|
|
1969
|
+
chartOptions.legend = defaultObj(chartOptions.legend);
|
|
1970
|
+
chartOptions.legend.show = ("showLegend" in config) ? !!config.showLegend : !this.isDashboard();
|
|
1915
1971
|
|
|
1916
|
-
chartOptions.yaxis = defaultObj(chartOptions.yaxis);
|
|
1917
|
-
chartOptions.yaxis.labels = defaultObj(chartOptions.yaxis.labels);
|
|
1918
|
-
chartOptions.yaxis.labels.show = false;
|
|
1919
|
-
chartOptions.legend = defaultObj(chartOptions.legend);
|
|
1920
|
-
chartOptions.legend.show = false;
|
|
1921
|
-
}
|
|
1922
1972
|
if("dataLabels" in config){
|
|
1923
1973
|
chartOptions.dataLabels.enabled = !!config.dataLabels;
|
|
1924
1974
|
}
|
|
@@ -2018,7 +2068,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2018
2068
|
const columns = args.columns || this.state.columns;
|
|
2019
2069
|
const currentSortedColumn = isObj(args.sortedColumn) && args.sortedColumn.column? args.sortedColumn : defaultObj(this.sortRef.current);
|
|
2020
2070
|
const visibleColumns = [],headerFilters = [],visibleColumnsNames={};
|
|
2021
|
-
const sectionListColumnsMenuItems = [];
|
|
2071
|
+
const sectionListColumnsMenuItems = [],filterableColumnsNames = [];
|
|
2022
2072
|
const sortable = defaultBool(this.props.sortable,true);
|
|
2023
2073
|
const sortedColumns = {};
|
|
2024
2074
|
let sortedColumnsLength = 0;
|
|
@@ -2121,6 +2171,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2121
2171
|
if(colFilter){
|
|
2122
2172
|
const fCol = defaultObj(this.filters[header.field]);
|
|
2123
2173
|
this.filters[header.field] = fCol;
|
|
2174
|
+
filterableColumnsNames.push(header.field);
|
|
2124
2175
|
delete restCol.sortable;
|
|
2125
2176
|
filterProps = {
|
|
2126
2177
|
...restCol,
|
|
@@ -2221,6 +2272,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2221
2272
|
this.preparedColumns.totalWidths = totalWidths;
|
|
2222
2273
|
this.preparedColumns.sectionListColumns = sectionListColumns;
|
|
2223
2274
|
this.preparedColumns.sectionListColumnsMenuItems = sectionListColumnsMenuItems;
|
|
2275
|
+
this.preparedColumns.filterableColumnsNames = filterableColumnsNames;
|
|
2224
2276
|
return this.preparedColumns;
|
|
2225
2277
|
}
|
|
2226
2278
|
getPaginatedSelectedRows(data){
|
|
@@ -2426,7 +2478,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2426
2478
|
args.columns = this.preparedColumns.visibleColumns;
|
|
2427
2479
|
args.columnsNames = this.preparedColumns.visibleColumnsNames;
|
|
2428
2480
|
const key = item.sectionListHeaderKey;
|
|
2429
|
-
const label = key === this.emptySectionListHeaderValue ?
|
|
2481
|
+
const label = key === this.emptySectionListHeaderValue ? this.getEmptySectionListHeaderValue() : key;
|
|
2430
2482
|
const style = typeof this.props.getSectionListHeaderStyle =='function' ? this.props.getSectionListHeaderStyle(args) : null;
|
|
2431
2483
|
const cStyle = typeof this.props.getSectionListHeaderContentContainerStyle =="function" ?this.props.getSectionListHeaderContentContainerStyle(args) : undefined;
|
|
2432
2484
|
const lStyle = typeof this.props.getSectionListHeaderLabelStyle =='function' ? this.props.getSectionListHeaderLabelStyle(args) : null;
|
|
@@ -2610,6 +2662,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2610
2662
|
willConvertFiltersToSQL(){
|
|
2611
2663
|
return !!defaultVal(this.props.convertFiltersToSQL,willConvertFiltersToSQL());;
|
|
2612
2664
|
}
|
|
2665
|
+
/*** retourne la liste des colonnes sur lesquelles on peut effectuer un filtre*/
|
|
2666
|
+
getFilterableColumnsNames(){
|
|
2667
|
+
const {filterableColumnsNames} = defaultObj(this.preparedColumns);
|
|
2668
|
+
return Array.isArray(filterableColumnsNames)? filterableColumnsNames : [];
|
|
2669
|
+
}
|
|
2613
2670
|
/*** récupère les filtres en cours du datagrid
|
|
2614
2671
|
* @param {boolean} prepare si les filtres seront apprêtés grace à la méthode prepareFilters de $cFilters
|
|
2615
2672
|
* @param {boolean} convertFiltersToSQL si les filtres seront convertis au formatSQL
|
|
@@ -3447,9 +3504,9 @@ CommonDatagridComponent.propTypes = {
|
|
|
3447
3504
|
//type : PropTypes.oneOfType(chartDisplayType).isRequired,//le type de graphe : l'une des valeurs parmis les éléments cités plus haut
|
|
3448
3505
|
x : PropTypes.string.isRequired, //l'axe horizontal
|
|
3449
3506
|
y : PropTypes.string.isRequired, //l'axe des y, les colonnes de type nombre
|
|
3450
|
-
series : PropTypes.arrayOf(
|
|
3507
|
+
series : PropTypes.arrayOf(PropTypes.string), //les séries, le nombre de courbe a afficher sur le graphe, en fonction du type
|
|
3451
3508
|
/**** les series à utiliser pour l'affichage des données lorsque les colonnes sont groupées, ie les montant de totalisation sont utilisés */
|
|
3452
|
-
sectionListHeadersSeries : PropTypes.arrayOf(
|
|
3509
|
+
sectionListHeadersSeries : PropTypes.arrayOf(PropTypes.string),
|
|
3453
3510
|
}),
|
|
3454
3511
|
displayType : chartDisplayType,
|
|
3455
3512
|
/*** les types d'afichates supportés par l'application */
|
|
@@ -98,6 +98,7 @@ export default class CommonTableDatagrid extends CommonDatagrid{
|
|
|
98
98
|
fetchOptions = extendObj(true,true,{},fetchOptions,{selector : fetchFilters});
|
|
99
99
|
fetchOptions.dataSources = this.currentDataSources;
|
|
100
100
|
fetchOptions.sort = this.getSort();
|
|
101
|
+
fetchOptions.fields = this.getFilterableColumnsNames();
|
|
101
102
|
let limit = this.getQueryLimit();
|
|
102
103
|
if(limit > 0 && !this.isPivotDatagrid()){
|
|
103
104
|
fetchOptions.limit = limit;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Format from "$ecomponents/SelectCurrency/Format";
|
|
2
|
+
import TextField from"./TextField";
|
|
3
|
+
export default class CurrencyFormatField extends TextField{
|
|
4
|
+
_render(props,setRef){
|
|
5
|
+
props.onChange = (args)=>{
|
|
6
|
+
this.validate(args);
|
|
7
|
+
}
|
|
8
|
+
return <Format
|
|
9
|
+
{...props}
|
|
10
|
+
setRef = {setRef}
|
|
11
|
+
/>
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
CurrencyFormatField.propTypes = {
|
|
17
|
+
...TextField.propTypes,
|
|
18
|
+
}
|
|
@@ -1,39 +1,15 @@
|
|
|
1
1
|
import SelectField from "./SelectField";
|
|
2
2
|
import {selectCurrencyFieldProps} from "$ecomponents/SelectCurrency";
|
|
3
|
-
import appConfig from "$app/config";
|
|
4
|
-
import {defaultStr} from "$utils";
|
|
5
3
|
|
|
6
4
|
export default class FormFieldSelectCurrency extends SelectField{
|
|
7
5
|
constructor(props){
|
|
8
6
|
super(props);
|
|
9
|
-
Object.defineProperties(this,{
|
|
10
|
-
currencyFormatRef : {value : {current:defaultStr(appConfig.currencyFormat)}}
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
onValidate(args){
|
|
14
|
-
const {context} = args;
|
|
15
|
-
if(context && context.getField){
|
|
16
|
-
const field = context.getField("currencyFormat");
|
|
17
|
-
if(field && field.setValue){
|
|
18
|
-
field.setValue(defaultStr(this.currencyFormatRef.current));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
super.onValidate(args);
|
|
22
7
|
}
|
|
23
8
|
getComponentProps(props){
|
|
24
|
-
|
|
25
|
-
return {...selectCurrencyFieldProps({...props,onChange:(args)=>{
|
|
26
|
-
this.currencyFormatRef.current = defaultStr(args.currencyFormat);
|
|
27
|
-
if(this.props.onChange){
|
|
28
|
-
this.props.onChange(args);
|
|
29
|
-
}
|
|
30
|
-
}})}
|
|
31
|
-
}
|
|
32
|
-
getValidValue(data){
|
|
33
|
-
data.currencyFormat = this.currencyFormatRef.current;
|
|
34
|
-
return super.getValidValue(data);
|
|
9
|
+
return {...selectCurrencyFieldProps(props)}
|
|
35
10
|
}
|
|
36
11
|
}
|
|
12
|
+
|
|
37
13
|
FormFieldSelectCurrency.propTypes = {
|
|
38
14
|
...SelectField.propTypes,
|
|
39
15
|
}
|
|
@@ -11,6 +11,7 @@ import {getFetchOptions,prepareFilters} from "$cutils/filters";
|
|
|
11
11
|
import fetch from "$capi"
|
|
12
12
|
import {willConvertFiltersToSQL} from "$ecomponents/Datagrid/utils";
|
|
13
13
|
import React from "$react";
|
|
14
|
+
import appConfig from "$appConfig";
|
|
14
15
|
|
|
15
16
|
/*** la tabledataSelectField permet de faire des requêtes distantes pour rechercher les données
|
|
16
17
|
* Elle doit prendre en paramètre et de manière requis : les props suivante :
|
|
@@ -24,7 +25,8 @@ const TableDataSelectField = React.forwardRef((_props,ref)=>{
|
|
|
24
25
|
props.data = defaultObj(props.data);
|
|
25
26
|
foreignKeyColumn = foreignKeyColumn.trim();
|
|
26
27
|
convertFiltersToSQL = defaultVal(convertFiltersToSQL,willConvertFiltersToSQL());
|
|
27
|
-
|
|
28
|
+
getForeignKeyTable = getForeignKeyTable || appConfig.get("getTableData");
|
|
29
|
+
const fKeyTable = typeof getForeignKeyTable =='function' ? getForeignKeyTable(foreignKeyTable,props) : undefined
|
|
28
30
|
if(!isObj(fKeyTable) || !(defaultStr(fKeyTable.tableName,fKeyTable.table))){
|
|
29
31
|
console.error("type de données invalide pour la fKeyTable ",fKeyTable," composant SelectTableData",_props);
|
|
30
32
|
return null;
|
|
@@ -224,7 +226,7 @@ TableDataSelectField.propTypes = {
|
|
|
224
226
|
PropTypes.string,
|
|
225
227
|
PropTypes.func, //s'il s'agit d'une fonciton qui sera appelée
|
|
226
228
|
]),
|
|
227
|
-
getForeignKeyTable : PropTypes.func
|
|
229
|
+
getForeignKeyTable : PropTypes.func, //la fonction permettant de récupérer la fKeyTable data dont fait référence le champ
|
|
228
230
|
foreignKeyTable : PropTypes.string, //le nom de la fKeyTable data à laquelle se reporte le champ
|
|
229
231
|
onFetchItems : PropTypes.func,
|
|
230
232
|
fetchDataOpts : PropTypes.shape({
|
|
@@ -20,7 +20,7 @@ import * as eFormFields from "$extendFormFields";
|
|
|
20
20
|
import "$utils";
|
|
21
21
|
import React from "$react";
|
|
22
22
|
import SelectDateFormat from "./SelectDateFormat";
|
|
23
|
-
|
|
23
|
+
import CurrencyFormat from "./CurrencyFormat";
|
|
24
24
|
export * from "$extendFormFields";
|
|
25
25
|
|
|
26
26
|
const defFormFields = {
|
|
@@ -30,6 +30,7 @@ const defFormFields = {
|
|
|
30
30
|
SelectTableData,
|
|
31
31
|
SelectCountry,
|
|
32
32
|
SelectCurrency
|
|
33
|
+
,CurrencyFormat
|
|
33
34
|
,Switch
|
|
34
35
|
,Checkbox
|
|
35
36
|
//,IdField
|
|
@@ -61,6 +62,7 @@ export {
|
|
|
61
62
|
SelectTableData,
|
|
62
63
|
SelectCountry
|
|
63
64
|
,SelectCurrency
|
|
65
|
+
,CurrencyFormat
|
|
64
66
|
,Switch
|
|
65
67
|
,Checkbox
|
|
66
68
|
//,IdField
|
|
@@ -16,6 +16,8 @@ const componentTypes = {
|
|
|
16
16
|
selectcountry : Fields.SelectCountry,
|
|
17
17
|
selectdateformat : Fields.SelectDateFormat,
|
|
18
18
|
selectcurrency : Fields.SelectCurrency,
|
|
19
|
+
currencyformat : Fields.CurrencyFormat,
|
|
20
|
+
currencyFormat : Fields.CurrencyFormat,
|
|
19
21
|
dateformat : Fields.SelectDateFormat,
|
|
20
22
|
date : Fields.Date,
|
|
21
23
|
time : Fields.Time,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright 2022 @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
|
+
import React from "$react";
|
|
5
|
+
import TextField from "$components/TextField";
|
|
6
|
+
import appConfig from "$capp/config";
|
|
7
|
+
import {isNonNullString,defaultStr} from "$cutils";
|
|
8
|
+
|
|
9
|
+
const CurrencyFormat = React.forwardRef((props,ref)=>{
|
|
10
|
+
const defaultValue = isNonNullString(props.defaultValue) && props.defaultValue.contains("v" && props.defaultValue || defaultStr(appConfig.currencyFormat,"%v %s"))
|
|
11
|
+
return <TextField
|
|
12
|
+
affix = {false}
|
|
13
|
+
enableCopy = {false}
|
|
14
|
+
{...props}
|
|
15
|
+
defaultValue = {defaultValue}
|
|
16
|
+
ref = {ref}
|
|
17
|
+
title="Format d'affichage des valeurs numériques : de la forme %v%s ou %v représente la valeur du montant et %s représente la devise : exemple %s%v => $10 et %s %v => 10 $"
|
|
18
|
+
/>
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
CurrencyFormat.displayName = "CurrencyFormatComponent";
|
|
22
|
+
|
|
23
|
+
export default CurrencyFormat;
|
|
24
|
+
|
|
25
|
+
CurrencyFormat.propTypes = {
|
|
26
|
+
...TextField.propTypes
|
|
27
|
+
}
|
|
@@ -2,32 +2,25 @@
|
|
|
2
2
|
// Use of this source code is governed by a BSD-style
|
|
3
3
|
// license that can be found in the LICENSE file.
|
|
4
4
|
import React from "$react";
|
|
5
|
-
import {
|
|
5
|
+
import {defaultStr} from "$utils";
|
|
6
6
|
import SimpleSelect from "$ecomponents/SimpleSelect";
|
|
7
|
-
import TextField from "$ecomponents/TextField";
|
|
8
|
-
import Icon from "$ecomponents/Icon";
|
|
9
7
|
import {currencies} from "$ccurrency";
|
|
10
|
-
import { Pressable } from "react-native";
|
|
11
|
-
import {styles} from "$theme";
|
|
12
8
|
import appConfig from "$app/config";
|
|
13
|
-
import
|
|
9
|
+
import Format from "./Format";
|
|
14
10
|
|
|
15
11
|
const CurrencySelector = React.forwardRef((props,ref)=>{
|
|
16
12
|
return <SimpleSelect ref={ref} {...selectCurrencyFieldProps(props)}/>
|
|
17
13
|
});
|
|
18
14
|
|
|
15
|
+
export {Format};
|
|
19
16
|
CurrencySelector.displayName = "CurrencySelector";
|
|
17
|
+
CurrencySelector.Format = Format;
|
|
20
18
|
|
|
21
19
|
export default CurrencySelector;
|
|
22
20
|
|
|
23
|
-
export const
|
|
24
|
-
|
|
25
|
-
/*** onAdd est appelé lorsqu'on ajoute un format personalisé */
|
|
26
|
-
export const selectCurrencyFieldProps = ({right,disabled,readOnly,onFormatChange,isFilter,onChange,onBlur,editable,...props})=>{
|
|
21
|
+
export const selectCurrencyFieldProps = ({disabled,readOnly,isFilter,editable,...props})=>{
|
|
27
22
|
const isEditable = disabled !== true && readOnly !== true && editable !== false;
|
|
28
23
|
const currency = appConfig.currency;
|
|
29
|
-
currencyFormatRef.current = defaultStr(currencyFormatRef.current,appConfig.currencyFormat,"%v %s");
|
|
30
|
-
const iconSize = 25;
|
|
31
24
|
return {
|
|
32
25
|
items : currencies,
|
|
33
26
|
getItemValue : ({item})=>item.code,
|
|
@@ -37,69 +30,12 @@ export const selectCurrencyFieldProps = ({right,disabled,readOnly,onFormatChange
|
|
|
37
30
|
enableCopy : false,
|
|
38
31
|
...props,
|
|
39
32
|
isFilter,
|
|
40
|
-
onChange : (args)=>{
|
|
41
|
-
args.currencyFormat = args.format = defaultStr(currencyFormatRef.current)
|
|
42
|
-
if(onChange){
|
|
43
|
-
onChange(args);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
onBlur : (args)=>{
|
|
47
|
-
args.currencyFormat = args.format = defaultStr(currencyFormatRef.current);
|
|
48
|
-
if(onBlur){
|
|
49
|
-
onBlur(args);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
33
|
disabled : !isEditable,
|
|
53
34
|
editable : isEditable,
|
|
54
|
-
right : !isEditable || isFilter ? right : (rP)=>{
|
|
55
|
-
const r = typeof right =='function'? right(rP) : right;
|
|
56
|
-
return <>
|
|
57
|
-
<Pressable style={{width:80}}
|
|
58
|
-
onPress = {(e)=>{
|
|
59
|
-
React.stopEventPropagation(e);
|
|
60
|
-
}}
|
|
61
|
-
>
|
|
62
|
-
<TextField
|
|
63
|
-
{...rP}
|
|
64
|
-
affix = {false}
|
|
65
|
-
editable = {isEditable}
|
|
66
|
-
disabled = {disabled}
|
|
67
|
-
readOnly = {readOnly}
|
|
68
|
-
enableCopy = {false}
|
|
69
|
-
contentContainerProps = {{
|
|
70
|
-
style:{height:37,paddingVertical:0,paddingHorizontal:0},
|
|
71
|
-
}}
|
|
72
|
-
mode = {'flat'}
|
|
73
|
-
left = {(p)=>{
|
|
74
|
-
return <Icon
|
|
75
|
-
{...rP}
|
|
76
|
-
{...p}
|
|
77
|
-
size = {iconSize}
|
|
78
|
-
style = {[styles.ml0,styles.mr0,{width:iconSize,height:iconSize}]}
|
|
79
|
-
icon = "alpha-f-box"
|
|
80
|
-
title="Format d'affichage des valeurs numériques : de la forme %v%s ou %v représente la valeur du montant et %s représente la devise : exemple %s%v => $10 et %s %v => 10 $"
|
|
81
|
-
/>
|
|
82
|
-
}}
|
|
83
|
-
defaultValue = {currencyFormatRef.current}
|
|
84
|
-
containerProps = {{
|
|
85
|
-
width:70,
|
|
86
|
-
}}
|
|
87
|
-
onChange = {(args)=>{
|
|
88
|
-
currencyFormatRef.current = args.value;
|
|
89
|
-
if(typeof onFormatChange =="function"){
|
|
90
|
-
onFormatChange(args)
|
|
91
|
-
}
|
|
92
|
-
}}
|
|
93
|
-
/>
|
|
94
|
-
</Pressable>
|
|
95
|
-
{React.isValidElement(r) && r || null}
|
|
96
|
-
</>
|
|
97
|
-
},
|
|
98
35
|
type : 'select',
|
|
99
36
|
}
|
|
100
37
|
}
|
|
101
38
|
|
|
102
39
|
CurrencySelector.propTypes = {
|
|
103
40
|
...SimpleSelect.propTypes,
|
|
104
|
-
onFormatChange : PropTypes.func,//lorsque le format de la currency change
|
|
105
41
|
}
|
|
@@ -16,7 +16,7 @@ import {Menu} from "$ecomponents/BottomSheet";
|
|
|
16
16
|
import Dashboard from "$ecomponents/Datagrid/Dashboard";
|
|
17
17
|
import fetch from "$capi/fetch";
|
|
18
18
|
import Auth from "$auth";
|
|
19
|
-
import
|
|
19
|
+
import Icon from "$ecomponents/Icon";
|
|
20
20
|
|
|
21
21
|
export default function DatabaseStatisticContainer ({dashboardProps,fetchDataProps,table,fetchCount,index,testID,title,icon,onPress:customOnPress,columns,fetchData,withDashboard,...props}){
|
|
22
22
|
dashboardProps = defaultObj(dashboardProps);
|
|
@@ -27,7 +27,7 @@ export default function DatabaseStatisticContainer ({dashboardProps,fetchDataPro
|
|
|
27
27
|
table = defaultObj(table);
|
|
28
28
|
const dbStatistics = defaultObj(table.databaseStatistics,table.databaseStatisticsProps);
|
|
29
29
|
const databaseStatisticsFields = defaultObj(table.databaseStatisticsFields);
|
|
30
|
-
const hasDFields = Object.size(databaseStatisticsFields,true);
|
|
30
|
+
const hasDFields = table.databaseStatistics !== false && Object.size(databaseStatisticsFields,true);
|
|
31
31
|
if(!withDashboard && hasDFields){
|
|
32
32
|
withDashboard = true;
|
|
33
33
|
}
|
|
@@ -39,7 +39,9 @@ export default function DatabaseStatisticContainer ({dashboardProps,fetchDataPro
|
|
|
39
39
|
columns = Object.size(columns,true)? columns : Object.size(dFields,true)? dFields : table.fields;
|
|
40
40
|
const tableName = defaultStr(table.tableName,table.table).toUpperCase();
|
|
41
41
|
fetchCount = typeof table.fetchCount =='function'? table.fetchCount : typeof fetchCount =='function'? fetchCount : undefined;
|
|
42
|
-
if((!fetchCount && !withDashboard) || !tableName)
|
|
42
|
+
if((!fetchCount && !withDashboard) || !tableName) {
|
|
43
|
+
return null
|
|
44
|
+
}
|
|
43
45
|
const refreshingRef = React.useRef(null);
|
|
44
46
|
const isMounted = React.useIsMounted();
|
|
45
47
|
|
|
@@ -76,7 +78,7 @@ export default function DatabaseStatisticContainer ({dashboardProps,fetchDataPro
|
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
},[]);
|
|
79
|
-
const progressBar = <View style={[theme.styles.justifyContentFlexStart,theme.styles.alignItemsFlexStart]}>
|
|
81
|
+
const progressBar = <View style={[theme.styles.justifyContentFlexStart,theme.styles.p1,theme.styles.alignItemsFlexStart]}>
|
|
80
82
|
<ActivityIndicator color={theme.colors.primary}/>
|
|
81
83
|
</View>;
|
|
82
84
|
const isDatagridLoading = datagridRef.current && datagridRef.current.isLoading && datagridRef.current.isLoading();
|
|
@@ -90,7 +92,7 @@ export default function DatabaseStatisticContainer ({dashboardProps,fetchDataPro
|
|
|
90
92
|
const fetchFields = React.useCallback(()=>{
|
|
91
93
|
const fetchFields = [];
|
|
92
94
|
Object.map(columns,(field,f)=>{
|
|
93
|
-
const ff = defaultStr(isObj(field)? field.field: undefined,f);
|
|
95
|
+
const ff = defaultStr(isObj(field) && field.filter !== false? field.field: undefined,f);
|
|
94
96
|
if(ff){
|
|
95
97
|
fetchFields.push(ff);
|
|
96
98
|
}
|
|
@@ -112,7 +114,7 @@ export default function DatabaseStatisticContainer ({dashboardProps,fetchDataPro
|
|
|
112
114
|
sessionName = {tableName+"-database-statistics"}
|
|
113
115
|
{...props}
|
|
114
116
|
{...dbStatistics}
|
|
115
|
-
style = {[theme.styles.
|
|
117
|
+
style = {[theme.styles.pr1,props.style]}
|
|
116
118
|
columns = {columns}
|
|
117
119
|
ref = {datagridRef}
|
|
118
120
|
progressBar = {isLoading?<View/>:<View style={[theme.styles.w100,theme.styles.alignItemsCenter,theme.styles.justifyContentCenter]}>{progressBar}</View>}
|
|
@@ -138,6 +140,7 @@ export default function DatabaseStatisticContainer ({dashboardProps,fetchDataPro
|
|
|
138
140
|
return <Pressable onPress={onPress} testID={testID+"_TitleContainer"} style={[theme.styles.w100]}>
|
|
139
141
|
<View testID={testID+"_TitleCountUp"} style={[theme.styles.w100]}>
|
|
140
142
|
<View style={[theme.styles.w100,theme.styles.row,theme.styles.alignItemsCenter]}>
|
|
143
|
+
<Icon style={[theme.styles.noPadding,theme.styles.noMargin]} suffix={index} icon= {icon} size={20} label={title}/>
|
|
141
144
|
{title}
|
|
142
145
|
{typeof dataSize =='number' && dataSize && <Label>
|
|
143
146
|
{dataSize.formatNumber()}
|
|
@@ -146,7 +149,7 @@ export default function DatabaseStatisticContainer ({dashboardProps,fetchDataPro
|
|
|
146
149
|
<Menu
|
|
147
150
|
testID={testID+"_Menu"}
|
|
148
151
|
items = {context.renderMenu()}
|
|
149
|
-
anchor = {(p)=><Pressable {...p} testID={testID+"_MenuAnchor"}>
|
|
152
|
+
anchor = {(p)=><Pressable {...p} style={[theme.styles.pl1]} testID={testID+"_MenuAnchor"}>
|
|
150
153
|
<Label
|
|
151
154
|
textCenter
|
|
152
155
|
style = {counUpStyle}
|
|
@@ -20,31 +20,31 @@ export default function DatabaseStatisticScreen ({withScreen,fetchDataProps,tabl
|
|
|
20
20
|
let content = [];
|
|
21
21
|
tableFilter = typeof tableFilter ==="function"? tableFilter : x=>true;
|
|
22
22
|
Object.map(tables,(table,index,suffix)=>{
|
|
23
|
-
|
|
23
|
+
if(!isObj(table)) return null;
|
|
24
|
+
let tableName = defaultStr(table.tableName,table.table);
|
|
25
|
+
if(!tableName || tableFilter({table,tableName}) === false) return null;
|
|
26
|
+
const t = typeof getTable =='function'?getTable(defaultStr(table?.tableName,table?.table,index),table) :null;
|
|
24
27
|
if(isObj(t) && defaultStr(t.table,t.tableName)){
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
if(isObj(table) && table.databaseStatistic !== false && table.databaseStatistics !== false && tableFilter(table) !== false){
|
|
28
|
-
content.push(
|
|
29
|
-
<Cell elevation = {5} withSurface mobileSize={12} desktopSize={3} tabletSize={4} {...contentProps} key = {index} >
|
|
30
|
-
<DatabaseStatistic
|
|
31
|
-
icon = {table.icon}
|
|
32
|
-
key = {index}
|
|
33
|
-
table = {table}
|
|
34
|
-
fetchData = {fetchData}
|
|
35
|
-
fetchDataProps = {fetchDataProps}
|
|
36
|
-
index = {suffix}
|
|
37
|
-
title = {defaultStr(table.text,table.label,table.title)}
|
|
38
|
-
fetchCount = {table.fetchCount|| typeof fetchCount =='function'? (a,b)=>{
|
|
39
|
-
return fetchCount({table,tableName:defaultStr(table.tableName,table.table)})
|
|
40
|
-
}:undefined}
|
|
41
|
-
></DatabaseStatistic>
|
|
42
|
-
</Cell>
|
|
43
|
-
)
|
|
28
|
+
table = t;
|
|
44
29
|
}
|
|
30
|
+
if(table.databaseStatistic === false || table.databaseStatistics === false) return null;
|
|
31
|
+
content.push(<Cell elevation = {5} withSurface mobileSize={12} desktopSize={3} tabletSize={4} {...contentProps} key = {index} >
|
|
32
|
+
<DatabaseStatistic
|
|
33
|
+
icon = {table.icon}
|
|
34
|
+
key = {index}
|
|
35
|
+
table = {table}
|
|
36
|
+
fetchData = {fetchData}
|
|
37
|
+
fetchDataProps = {fetchDataProps}
|
|
38
|
+
index = {suffix}
|
|
39
|
+
title = {defaultStr(table.text,table.label,table.title)}
|
|
40
|
+
fetchCount = {table.fetchCount|| typeof fetchCount =='function'? (a,b)=>{
|
|
41
|
+
return fetchCount({table,tableName})
|
|
42
|
+
}:undefined}
|
|
43
|
+
></DatabaseStatistic>
|
|
44
|
+
</Cell>
|
|
45
|
+
)
|
|
45
46
|
});
|
|
46
47
|
if(!content.length) {
|
|
47
|
-
Auth.showError();
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
50
|
content = <Component {...containerProps} style={[containerProps.style,theme.styles.mr1,theme.styles.ml1]}>
|