@fto-consult/expo-ui 2.35.2 → 2.36.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 +2 -2
- package/src/components/Datagrid/Accordion/index.js +3 -1
- package/src/components/Datagrid/Common/Common.js +94 -67
- package/src/components/Datagrid/Footer/Footer.js +11 -5
- package/src/components/Datagrid/Table/index.js +1 -0
- package/src/components/Drawer/DrawerItems/index.js +11 -5
- package/src/components/Form/FormData/componentsTypes.js +3 -11
- package/src/components/SelectCurrency/Format.js +24 -4
- package/src/layouts/DatabaseStatistics/DatabaseStatistic.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fto-consult/expo-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.36.1",
|
|
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": "^2.1.
|
|
64
|
+
"@fto-consult/common": "^2.1.3",
|
|
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",
|
|
@@ -86,7 +86,8 @@ const DatagridFactory = (Factory)=>{
|
|
|
86
86
|
}
|
|
87
87
|
getItemCallArgs({item,index}){
|
|
88
88
|
const rowIndexCount = index+1;
|
|
89
|
-
|
|
89
|
+
const formatValue = this.formatValue.bind(this);
|
|
90
|
+
return {...this.getActionsArgs(),valueFormatter:formatValue,formatValue,abreviateValues:this.state.abreviateValues,row:item,items:this.state.data,item,rowData:item,index,rowIndex:index,rowCounterIndex:rowIndexCount,rowIndexCount};
|
|
90
91
|
}
|
|
91
92
|
getRenderingItemProps ({item,rowKey,numColumns,index}){
|
|
92
93
|
const rKey = rowKey;
|
|
@@ -575,6 +576,7 @@ const DatagridFactory = (Factory)=>{
|
|
|
575
576
|
key = {field}
|
|
576
577
|
testID={testID+"_FooterItem_"+field}
|
|
577
578
|
{...footer}
|
|
579
|
+
abreviate = {this.state.abreviateValues}
|
|
578
580
|
aggregatorFunction = {this.getActiveAggregatorFunction().code}
|
|
579
581
|
aggregatorFunctions = {this.aggregatorFunctions}
|
|
580
582
|
anchorProps = {{style:[theme.styles.ph1,theme.styles.mh05]}}
|
|
@@ -43,6 +43,8 @@ import notify from "$cnotify";
|
|
|
43
43
|
import FileSystem from "$file-system";
|
|
44
44
|
import sprintf from "$cutils/sprintf";
|
|
45
45
|
|
|
46
|
+
export const TIMEOUT = 200;
|
|
47
|
+
|
|
46
48
|
export const donutChart = {
|
|
47
49
|
isChart : true,
|
|
48
50
|
code : 'donutChart',
|
|
@@ -266,6 +268,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
266
268
|
chartRef : {value : {current:null}},
|
|
267
269
|
chartSeriesNamesColumnsMapping : {value : {}},//le mappage entre les index des series et les colonnes coorespondantes
|
|
268
270
|
})
|
|
271
|
+
this.state.abreviateValues = "abreviateValues" in this.props? !!this.props.abreviateValues : !!this.getSessionData("abreviateValues");
|
|
269
272
|
const sessionAggregator = defaultStr(this.getSessionData("aggregatorFunction")).trim();
|
|
270
273
|
const aggregatorProps = defaultStr(this.props.aggregatorFunction).trim();
|
|
271
274
|
let aggregatorFunction = null;
|
|
@@ -1087,7 +1090,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1087
1090
|
this.isUpdating = false;
|
|
1088
1091
|
this.setSessionData({showFilters});
|
|
1089
1092
|
})
|
|
1090
|
-
},
|
|
1093
|
+
},TIMEOUT);
|
|
1091
1094
|
}
|
|
1092
1095
|
showFilters(){
|
|
1093
1096
|
return this.toggleFilters(true);
|
|
@@ -1120,7 +1123,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1120
1123
|
this.isUpdating = false;
|
|
1121
1124
|
this.setSessionData({showFooters:showOrHide})
|
|
1122
1125
|
})
|
|
1123
|
-
},
|
|
1126
|
+
},TIMEOUT)
|
|
1124
1127
|
}
|
|
1125
1128
|
showFooters(){
|
|
1126
1129
|
return this.toggleFooters(true);
|
|
@@ -1134,11 +1137,16 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1134
1137
|
|
|
1135
1138
|
|
|
1136
1139
|
toggleFixedTableState(){
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1140
|
+
setTimeout(()=>{
|
|
1141
|
+
this.setIsLoading(true,()=>{
|
|
1142
|
+
const fixedTable = !this.state.fixedTable;
|
|
1143
|
+
this.setState({fixedTable},()=>{
|
|
1144
|
+
this.updateLayout();
|
|
1145
|
+
this.setSessionData("fixedTable",fixedTable);
|
|
1146
|
+
this.setIsLoading(false,false);
|
|
1147
|
+
})
|
|
1148
|
+
},true)
|
|
1149
|
+
},TIMEOUT)
|
|
1142
1150
|
}
|
|
1143
1151
|
getSessionNameKey (){
|
|
1144
1152
|
return defaultStr(this.props.table,this.props.tableName,this.props.sessionName);
|
|
@@ -1146,32 +1154,39 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1146
1154
|
/*** affiche ou masque une colonne filtrée */
|
|
1147
1155
|
toggleFilterColumnVisibility(field){
|
|
1148
1156
|
if(!isNonNullString(field)) return;
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1157
|
+
setTimeout(()=>{
|
|
1158
|
+
this.setIsLoading(true,()=>{
|
|
1159
|
+
let filteredColumns = {...this.state.filteredColumns};
|
|
1160
|
+
filteredColumns[field] = defaultBool(filteredColumns[field],false) == false ? true : false;
|
|
1161
|
+
this.prepareColumns({filteredColumns});
|
|
1162
|
+
this.setState({filteredColumns},()=>{
|
|
1163
|
+
this.setSessionData("filteredColumns"+this.getSessionNameKey(),filteredColumns);
|
|
1164
|
+
if(!filteredColumns[field]){
|
|
1165
|
+
this.filters[field] = defaultObj(this.filters[field]);
|
|
1166
|
+
this.filters[field].value = this.filters[field].defaultValue = undefined;
|
|
1167
|
+
this.doFilter({value:undefined,field})
|
|
1168
|
+
}
|
|
1169
|
+
this.setIsLoading(false,false);
|
|
1170
|
+
});
|
|
1171
|
+
},true)
|
|
1172
|
+
},TIMEOUT)
|
|
1160
1173
|
}
|
|
1161
1174
|
/*** affiche ou masque une colonne */
|
|
1162
1175
|
toggleColumnVisibility(field,removeFocus){
|
|
1163
1176
|
if(!isNonNullString(field)) return;
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
footers[field]
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
this.
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1177
|
+
setTimeout(()=>{
|
|
1178
|
+
let columns = {...this.state.columns};
|
|
1179
|
+
columns[field].visible = !columns[field].visible;
|
|
1180
|
+
const footers = this.getFootersFields();
|
|
1181
|
+
if(isObj(footers[field])){
|
|
1182
|
+
footers[field].visible = columns[field].visible;
|
|
1183
|
+
}
|
|
1184
|
+
this.setIsLoading(true,()=>{
|
|
1185
|
+
this.prepareColumns({columns});
|
|
1186
|
+
this.setState({columns});
|
|
1187
|
+
this.setIsLoading(false,false);
|
|
1188
|
+
})
|
|
1189
|
+
},TIMEOUT)
|
|
1175
1190
|
}
|
|
1176
1191
|
/****le nombre maximum de courbes supportées */
|
|
1177
1192
|
getMaxSeriesSize(){
|
|
@@ -1263,15 +1278,17 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1263
1278
|
} else {
|
|
1264
1279
|
sectionListColumns[columnName] = {field:columnName};
|
|
1265
1280
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
this.
|
|
1269
|
-
this.
|
|
1270
|
-
this.
|
|
1271
|
-
|
|
1281
|
+
setTimeout(()=>{
|
|
1282
|
+
const {sectionListColumns:pSListColumns} = this.prepareColumns({sectionListColumns});
|
|
1283
|
+
this.setIsLoading(true,()=>{
|
|
1284
|
+
this.prepareData({data:this.INITIAL_STATE.data,sectionListColumns:pSListColumns},(state)=>{
|
|
1285
|
+
this.setState({...state,sectionListColumns:pSListColumns},()=>{
|
|
1286
|
+
this.setIsLoading(false,false);
|
|
1287
|
+
this.setSessionData("sectionListColumns",Object.keys(pSListColumns));
|
|
1288
|
+
});
|
|
1272
1289
|
});
|
|
1273
|
-
});
|
|
1274
|
-
},
|
|
1290
|
+
},true);
|
|
1291
|
+
},TIMEOUT);
|
|
1275
1292
|
}
|
|
1276
1293
|
removeAllColumnsInSectionList(){
|
|
1277
1294
|
const {sectionListColumns} = this.prepareColumns({sectionListColumns:{}});
|
|
@@ -1340,6 +1357,19 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1340
1357
|
}
|
|
1341
1358
|
return this.aggregatorFunctions[Object.keys(this.aggregatorFunctions)[0]];
|
|
1342
1359
|
}
|
|
1360
|
+
toggleAbreviateValues(){
|
|
1361
|
+
setTimeout(()=>{
|
|
1362
|
+
this.setIsLoading(true,()=>{
|
|
1363
|
+
this.prepareData({data:this.INITIAL_STATE.data},(state)=>{
|
|
1364
|
+
const abreviateValues = !this.state.abreviateValues;
|
|
1365
|
+
this.setState({abreviateValues,...state},()=>{
|
|
1366
|
+
this.setIsLoading(false,false);
|
|
1367
|
+
this.setSessionData("abreviateValues",abreviateValues);
|
|
1368
|
+
})
|
|
1369
|
+
});
|
|
1370
|
+
},true);
|
|
1371
|
+
},TIMEOUT);
|
|
1372
|
+
}
|
|
1343
1373
|
/**** récupère l'item de menu permettant lié à la sélection de la fonction d'aggggrégation */
|
|
1344
1374
|
getAggregatorFunctionsMenuItems(withDivider){
|
|
1345
1375
|
if(!this.hasFootersFields()) return [];
|
|
@@ -1355,6 +1385,8 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1355
1385
|
}
|
|
1356
1386
|
})
|
|
1357
1387
|
});
|
|
1388
|
+
m.push({divider:true});
|
|
1389
|
+
m.push({text:"Abréger les valeurs numériques",textBold:!!this.state.abreviateValues,icon:this.state.abreviateValues?'check':null,onPress:this.toggleAbreviateValues.bind(this)})
|
|
1358
1390
|
if(m.length){
|
|
1359
1391
|
m.unshift({
|
|
1360
1392
|
text : "Fonctions d'aggrégation",
|
|
@@ -1373,15 +1405,24 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1373
1405
|
}
|
|
1374
1406
|
toggleActiveAggregatorFunction(ag){
|
|
1375
1407
|
if(!isValidAggregator(ag) || ag.code == this.state.aggregatorFunction) return null;
|
|
1376
|
-
|
|
1377
|
-
this.
|
|
1378
|
-
this.
|
|
1379
|
-
this.
|
|
1380
|
-
|
|
1408
|
+
setTimeout(()=>{
|
|
1409
|
+
this.setIsLoading(true,()=>{
|
|
1410
|
+
this.prepareData({data:this.INITIAL_STATE.data,aggregatorFunction:ag.code},(state)=>{
|
|
1411
|
+
this.setState(state,()=>{
|
|
1412
|
+
this.setSessionData("aggregatorFunction",ag.code);
|
|
1413
|
+
this.setIsLoading(false,false);
|
|
1414
|
+
})
|
|
1381
1415
|
})
|
|
1382
|
-
})
|
|
1383
|
-
},
|
|
1416
|
+
},true);
|
|
1417
|
+
},TIMEOUT);
|
|
1384
1418
|
}
|
|
1419
|
+
formatValue(value,format){
|
|
1420
|
+
if(typeof value !='number') return value;
|
|
1421
|
+
if(format && typeof format =='string' && format.toLowerCase() =='money'){
|
|
1422
|
+
return this.state.abreviateValues? value.abreviate2FormatMoney() : value.formatMoney();
|
|
1423
|
+
}
|
|
1424
|
+
return this.state.abreviateValues ? value.abreviate() : value.formatNumber();
|
|
1425
|
+
}
|
|
1385
1426
|
renderAggregatorFunctionsMenu(){
|
|
1386
1427
|
const m = this.getAggregatorFunctionsMenuItems(false,false);
|
|
1387
1428
|
if(!m.length) return null;
|
|
@@ -1894,7 +1935,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1894
1935
|
chartProps[settingKey][key] = config[key];
|
|
1895
1936
|
});
|
|
1896
1937
|
const mappedColumns = {};
|
|
1897
|
-
const abreviateValues = defaultVal(config.abreviateValues,true);
|
|
1938
|
+
const abreviateValues = defaultVal(config.abreviateValues,true) || this.state.abreviateValues;
|
|
1898
1939
|
const dataLabelFormatter = typeof chartProps.dataLabels?.formatter =="function"? chartProps.dataLabels.formatter : undefined;
|
|
1899
1940
|
const chartOptions = {
|
|
1900
1941
|
...chartProps,
|
|
@@ -1906,18 +1947,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1906
1947
|
if((column) && column.field){
|
|
1907
1948
|
mappedColumns[seriesIndex] = column;
|
|
1908
1949
|
}
|
|
1909
|
-
/*if(value>=660 && value < 661){
|
|
1910
|
-
console.log(value," will format ",column,seriesIndex,serieName)
|
|
1911
|
-
}*/
|
|
1912
1950
|
const columnField = defaultStr(column.field, isDonut? config.y : undefined);
|
|
1913
1951
|
if(dataLabelFormatter){
|
|
1914
1952
|
return dataLabelFormatter({value,column,columnDef:column,columnField,serie,serieName,seriesIndex})
|
|
1915
1953
|
}
|
|
1916
|
-
|
|
1917
|
-
if(defaultStr(column.format).toLowerCase() ==='money'){
|
|
1918
|
-
return abreviateValues ? value.abreviate2FormatMoney() : value.formatMoney();
|
|
1919
|
-
}
|
|
1920
|
-
return abreviateValues ? value.abreviate() : value.formatNumber();
|
|
1954
|
+
return this.formatValue(value,column.format);
|
|
1921
1955
|
}
|
|
1922
1956
|
}),
|
|
1923
1957
|
title :extendObj(true,{}, {
|
|
@@ -1976,11 +2010,8 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1976
2010
|
}
|
|
1977
2011
|
}
|
|
1978
2012
|
yLabels.formatter = (value)=>{
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
return abreviateValues ? value.abreviate2FormatMoney() : value.formatMoney();
|
|
1982
|
-
}
|
|
1983
|
-
return abreviateValues? value.abreviate() : value.formatNumber();
|
|
2013
|
+
const format = (yLabelFormat =='money' || (isDonut && yAxisColumn.format =="money")) || (yLabelsColumn && yLabelsColumn.format =='money') ? 'money' : '';
|
|
2014
|
+
return this.formatValue(value,format);
|
|
1984
2015
|
}
|
|
1985
2016
|
chartOptions.chart.id = this.chartIdPrefix+"-"+defaultStr(chartType.key,"no-key");
|
|
1986
2017
|
if(!chartType.isDonut){
|
|
@@ -2563,6 +2594,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2563
2594
|
key = {key2}
|
|
2564
2595
|
testID={testID+"_FooterItem_"+key2}
|
|
2565
2596
|
{...footer}
|
|
2597
|
+
abreviate = {this.state.abreviateValues}
|
|
2566
2598
|
aggregatorFunction = {this.getActiveAggregatorFunction().code}
|
|
2567
2599
|
aggregatorFunctions = {this.aggregatorFunctions}
|
|
2568
2600
|
displayLabel = {false}
|
|
@@ -2573,7 +2605,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2573
2605
|
});
|
|
2574
2606
|
}
|
|
2575
2607
|
}
|
|
2576
|
-
return <View testID={testID+"_ContentContainer"} style={[theme.styles.w100,isA && this.state.displayOnlySectionListHeaders && {borderTopColor:theme.colors.divider,borderTopWidth:1},isA ? [theme.styles.ph2,theme.styles.pt1] : theme.styles.pt1,theme.styles.justifyContentCenter,theme.styles.alignItemsCenter,theme.styles.pb1,!cells && theme.styles.ml1,theme.styles.mr1,cStyle]}>
|
|
2608
|
+
return <View testID={testID+"_ContentContainer"} style={[theme.styles.w100,isA && this.state.displayOnlySectionListHeaders && {borderTopColor:theme.colors.divider,borderTopWidth:1},isA ? [theme.styles.ph2,theme.styles.pt1] : [theme.styles.pt1,theme.styles.ph1],theme.styles.justifyContentCenter,theme.styles.alignItemsCenter,theme.styles.pb1,!cells && theme.styles.ml1,theme.styles.mr1,cStyle]}>
|
|
2577
2609
|
<Label testID={testID+"_Label"} splitText numberOfLines={3} textBold style={[theme.styles.w100,{color:theme.colors.primaryOnSurface,fontSize:isA?15 :16},lStyle]}>{label}</Label>
|
|
2578
2610
|
{cells ? <View testID={testID+"_TableRow"} style = {[theme.styles.w100,theme.styles.row,isA && theme.styles.pt1,theme.styles.alignItemsFlexStart]}
|
|
2579
2611
|
>{cells}</View> : null}
|
|
@@ -3189,6 +3221,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
3189
3221
|
const renderText = isSectionListHeader === true || customRenderRowCell === false ? true : false;
|
|
3190
3222
|
rowIndex = isDecimal(rowIndex)? rowIndex : isDecimal(index)? index : undefined;
|
|
3191
3223
|
rowCounterIndex = isDecimal(rowCounterIndex) ? rowCounterIndex : isDecimal(rowIndex)? rowIndex+1 : defaultDecimal(rowCounterIndex);
|
|
3224
|
+
const abreviate = this.state.abreviateValues;
|
|
3192
3225
|
if(!isObj(rowData)) return renderText ? null : {render:null,extra:{}};
|
|
3193
3226
|
let _render = null;
|
|
3194
3227
|
columnDef = defaultObj(columnDef);
|
|
@@ -3317,14 +3350,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
3317
3350
|
if(isFunction(renderProps)){
|
|
3318
3351
|
renderProps = renderProps.call(this,renderArgs);
|
|
3319
3352
|
}
|
|
3320
|
-
|
|
3321
|
-
let fmat = defaultStr(columnDef.format).toLowerCase();
|
|
3322
|
-
if(fmat == "money"){
|
|
3323
|
-
_render = _render.formatMoney();
|
|
3324
|
-
} else //if(fmat =="number") {
|
|
3325
|
-
_render = _render.formatNumber();
|
|
3326
|
-
//}
|
|
3327
|
-
}
|
|
3353
|
+
_render = this.formatValue(_render,columnDef.format);
|
|
3328
3354
|
if(!renderText && _render && isObj(renderProps)){
|
|
3329
3355
|
let Component = defaultVal(renderProps.Component,Label);
|
|
3330
3356
|
delete renderProps.Component;
|
|
@@ -3572,6 +3598,7 @@ CommonDatagridComponent.propTypes = {
|
|
|
3572
3598
|
/*** permet de faire une mutation sur les options de la recherche, immédiatement avant le lancement de la recherche */
|
|
3573
3599
|
fetchOptionsMutator : PropTypes.func,
|
|
3574
3600
|
useLinesProgressBar : PropTypes.bool,//si le progress bar lignes horizontale seront utilisés
|
|
3601
|
+
abreviateValues : PropTypes.bool, //si les valeurs numériques seront abregées
|
|
3575
3602
|
}
|
|
3576
3603
|
|
|
3577
3604
|
const styles = StyleSheet.create({
|
|
@@ -79,11 +79,17 @@ const loopForAggregator = (aggregatorFunctions,result)=>{
|
|
|
79
79
|
result[aggregatorObj.code] = aggregatorObj;
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
const formatValue = ({value,format,aggregatorFunction})=>{
|
|
83
|
-
|
|
82
|
+
const formatValue = ({value,format,abreviate,aggregatorFunction})=>{
|
|
83
|
+
if((format === 'money' && aggregatorFunction != 'count')){
|
|
84
|
+
if(abreviate){
|
|
85
|
+
return value.abreviate2FormatMoney();
|
|
86
|
+
}
|
|
87
|
+
return value.formatMoney();
|
|
88
|
+
}
|
|
89
|
+
return abreviate? value.abreviate():value.formatNumber();
|
|
84
90
|
}
|
|
85
91
|
export default function DGGridFooterValue (props){
|
|
86
|
-
let {label,text,displayLabel,withLabel,style,aggregatorFunctions,aggregatorFunction,format,testID,anchorProps} = props;
|
|
92
|
+
let {label,text,displayLabel,withLabel,abreviate,style,aggregatorFunctions,aggregatorFunction,format,testID,anchorProps} = props;
|
|
87
93
|
aggregatorFunctions = defaultObj(aggregatorFunctions);
|
|
88
94
|
anchorProps = defaultObj(anchorProps);
|
|
89
95
|
testID = defaultStr(testID,"RN_DatagridFooterComponent");
|
|
@@ -104,7 +110,7 @@ export default function DGGridFooterValue (props){
|
|
|
104
110
|
for(let aggregatorFunction in aggregatorFunctions){
|
|
105
111
|
let val = defaultDecimal(props[aggregatorFunction]);
|
|
106
112
|
if(isDecimal(val)){
|
|
107
|
-
let fText = formatValue({value:val,format,aggregatorFunction});
|
|
113
|
+
let fText = formatValue({value:val,format,abreviate,aggregatorFunction});
|
|
108
114
|
const mText = defaultStr(aggregatorFunctions[aggregatorFunction].label,aggregatorFunctions[aggregatorFunction].code,aggregatorFunction);
|
|
109
115
|
title +=(title? ", ":"")+mText +" : "+fText
|
|
110
116
|
menuItems.push({
|
|
@@ -132,7 +138,7 @@ export default function DGGridFooterValue (props){
|
|
|
132
138
|
</>
|
|
133
139
|
: null}
|
|
134
140
|
<Label testID={testID+"_LabelContent"} primary style={[styles.value]}>
|
|
135
|
-
{formatValue({value:defaultDecimal(props[active]),aggregatorFunction:active,format})}
|
|
141
|
+
{formatValue({value:defaultDecimal(props[active]),abreviate,aggregatorFunction:active,format})}
|
|
136
142
|
</Label>
|
|
137
143
|
</Pressable>
|
|
138
144
|
}}
|
|
@@ -57,6 +57,7 @@ const DatagridFactory = (Factory)=>{
|
|
|
57
57
|
if(isObj(footerFields[columnField])){
|
|
58
58
|
return <Footer
|
|
59
59
|
{...defaultObj(footersValues[columnField])}
|
|
60
|
+
abreviate = {this.state.abreviateValues}
|
|
60
61
|
displayLabel = {false}
|
|
61
62
|
style = {[style]}
|
|
62
63
|
aggregatorFunction = {this.getActiveAggregatorFunction().code}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from '$react';
|
|
2
|
-
import {isObj} from "$utils";
|
|
2
|
+
import {isObj,isNonNullString} from "$utils";
|
|
3
3
|
import ExpandableItem from './ExpandableItem';
|
|
4
4
|
import DrawerItem from './DrawerItem';
|
|
5
5
|
import DrawerSection from "./DrawerSection"
|
|
@@ -11,6 +11,7 @@ export * from "./utils";
|
|
|
11
11
|
|
|
12
12
|
const DrawerItemsComponent = React.forwardRef((props,ref)=> {
|
|
13
13
|
let {items:_items,minimized} = props;
|
|
14
|
+
const hasAuth = typeof window.Auth !=='undefined' && Auth && Auth.isAllowedFromStr ? true : false;
|
|
14
15
|
_items = typeof _items ==='function'? _items(props) : _items;
|
|
15
16
|
if(React.isValidElement(_items)){
|
|
16
17
|
return _items;
|
|
@@ -18,6 +19,7 @@ const DrawerItemsComponent = React.forwardRef((props,ref)=> {
|
|
|
18
19
|
const r = React.useMemo(()=>{
|
|
19
20
|
let items = []
|
|
20
21
|
const renderExpandableOrSection = ({item,key,items})=>{
|
|
22
|
+
if(hasAuth && isNonNullString(item.perm) && !Auth.isAllowedFromStr(item.perm)) return null;
|
|
21
23
|
const {section,items:itx2,...rest} = item;
|
|
22
24
|
if(section){
|
|
23
25
|
return <DrawerSection
|
|
@@ -50,16 +52,19 @@ const DrawerItemsComponent = React.forwardRef((props,ref)=> {
|
|
|
50
52
|
Object.map(item.items,(it,j)=>{
|
|
51
53
|
if(!isObj(it)) return ;
|
|
52
54
|
getDefaultProps(it);
|
|
53
|
-
const r = renderItem({minimized,renderExpandableOrSection,items:item.items,item:it,key:i+j,props});
|
|
55
|
+
const r = renderItem({minimized,hasAuth,renderExpandableOrSection,items:item.items,item:it,key:i+j,props});
|
|
54
56
|
if(r){
|
|
55
57
|
itx.push(r);
|
|
56
58
|
}
|
|
57
59
|
});
|
|
58
60
|
if(itx.length){
|
|
59
|
-
|
|
61
|
+
const rr = renderExpandableOrSection({items:itx,key:i,item});
|
|
62
|
+
if(rr){
|
|
63
|
+
items.push(rr);
|
|
64
|
+
}
|
|
60
65
|
}
|
|
61
66
|
} else {
|
|
62
|
-
const r = renderItem({minimized,renderExpandableOrSection,items:_items,item,key:i+"",props});
|
|
67
|
+
const r = renderItem({minimized,hasAuth,renderExpandableOrSection,items:_items,item,key:i+"",props});
|
|
63
68
|
if(r){
|
|
64
69
|
items.push(r);
|
|
65
70
|
}
|
|
@@ -114,13 +119,14 @@ const getDefaultProps = function(item){
|
|
|
114
119
|
return item;
|
|
115
120
|
}
|
|
116
121
|
|
|
117
|
-
const renderItem = ({item,minimized,renderExpandableOrSection,index,key})=>{
|
|
122
|
+
const renderItem = ({item,minimized,hasAuth,renderExpandableOrSection,index,key})=>{
|
|
118
123
|
key = key||index;
|
|
119
124
|
if(React.isValidElement(item)){
|
|
120
125
|
return <React.Fragment key={key}>
|
|
121
126
|
{item}
|
|
122
127
|
</React.Fragment>
|
|
123
128
|
} else {
|
|
129
|
+
if(hasAuth && isNonNullString(item.perm) && !Auth.isAllowedFromStr(item.perm)) return null;
|
|
124
130
|
if(!item.label && !item.text && !item.icon) {
|
|
125
131
|
if(item.divider === true){
|
|
126
132
|
const {divider,...rest} = item;
|
|
@@ -17,7 +17,6 @@ const componentTypes = {
|
|
|
17
17
|
selectdateformat : Fields.SelectDateFormat,
|
|
18
18
|
selectcurrency : Fields.SelectCurrency,
|
|
19
19
|
currencyformat : Fields.CurrencyFormat,
|
|
20
|
-
currencyFormat : Fields.CurrencyFormat,
|
|
21
20
|
dateformat : Fields.SelectDateFormat,
|
|
22
21
|
date : Fields.Date,
|
|
23
22
|
time : Fields.Time,
|
|
@@ -70,12 +69,8 @@ export const getFilterComponentProps = (_props)=>{
|
|
|
70
69
|
props = defaultObj(props);
|
|
71
70
|
let component = Fields.TextField;
|
|
72
71
|
type = defaultStr(jsType,type,'text').toLowerCase().replaceAll("_","").replaceAll("-","").trim();
|
|
72
|
+
const sanitizedType = type.replaceAll("_","").toLowerCase().trim();
|
|
73
73
|
props = defaultObj(props);
|
|
74
|
-
/*if(type =='datafile'){
|
|
75
|
-
type = 'select';
|
|
76
|
-
props = {...selectFieldProps,items : dataFileManager.getAll(),...props};
|
|
77
|
-
label = defaultStr(label,dataFileManager.dataFileText);
|
|
78
|
-
}*/
|
|
79
74
|
if(type.startsWith("select")){
|
|
80
75
|
props.inputProps = Object.assign({},props.inputProps);
|
|
81
76
|
props.inputProps.placeholder = defaultStr(props.inputProps.placeholder,i18n.lang("search.."))
|
|
@@ -104,16 +99,13 @@ export const getFilterComponentProps = (_props)=>{
|
|
|
104
99
|
component = Fields.SelectDateFormat;
|
|
105
100
|
} else if(React.isComponent(componentTypes[type])) {
|
|
106
101
|
component = componentTypes[type];
|
|
107
|
-
} else if(React.isComponent(componentTypes[type.replaceAll("_","")])){
|
|
108
|
-
component = componentTypes[type.replaceAll("_","")];
|
|
109
102
|
} else if(isNonNullString(props.foreignKeyColumn) && isNonNullString(props.foreignKeyTable)) {
|
|
110
103
|
component = Fields.SelectTableData;
|
|
111
104
|
props.multiple = true;
|
|
112
105
|
type = "select";
|
|
113
106
|
}else {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
component = componentTypes[tt];
|
|
107
|
+
if(React.isComponent(componentTypes[sanitizedType])){
|
|
108
|
+
component = componentTypes[sanitizedType];
|
|
117
109
|
}
|
|
118
110
|
delete props.dbName;
|
|
119
111
|
delete props.tableName;
|
|
@@ -2,19 +2,39 @@
|
|
|
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 TextField from "$
|
|
5
|
+
import TextField from "$ecomponents/TextField";
|
|
6
6
|
import appConfig from "$capp/config";
|
|
7
7
|
import {isNonNullString,defaultStr} from "$cutils";
|
|
8
|
+
import Icon from "$ecomponents/Icon";
|
|
9
|
+
import {styles} from "$theme";
|
|
8
10
|
|
|
9
|
-
const CurrencyFormat = React.forwardRef((props,ref)=>{
|
|
10
|
-
const
|
|
11
|
+
const CurrencyFormat = React.forwardRef(({disabled,readOnly,right,isFilter,editable,...props},ref)=>{
|
|
12
|
+
const isEditable = disabled !== true && readOnly !== true && editable !== false;
|
|
13
|
+
const defaultValue = isNonNullString(props.defaultValue) && props.defaultValue.contains("v" && props.defaultValue) && props.defaultValue || defaultStr(appConfig.currencyFormat,"%v %s");
|
|
14
|
+
const title = "Format d'affichage des valeurs numériques : une chaine de caractère constitué des lettre %v et %s où %v représente la valeur du montant et %s représente la devise : exemple %s%v => $10 et %s %v => 10 $";
|
|
11
15
|
return <TextField
|
|
12
16
|
affix = {false}
|
|
13
17
|
enableCopy = {false}
|
|
14
18
|
{...props}
|
|
19
|
+
disabled = {disabled}
|
|
20
|
+
readOnly = {readOnly}
|
|
21
|
+
editable = {isEditable}
|
|
15
22
|
defaultValue = {defaultValue}
|
|
23
|
+
right = {!isEditable || isFilter ? right : (rP)=>{
|
|
24
|
+
const r = typeof right =='function'? right(rP) : right;
|
|
25
|
+
return <>
|
|
26
|
+
<Icon
|
|
27
|
+
{...rP}
|
|
28
|
+
size = {25}
|
|
29
|
+
style = {[styles.ml0,styles.mr0]}
|
|
30
|
+
name = "alpha-f-box"
|
|
31
|
+
title={title}
|
|
32
|
+
/>
|
|
33
|
+
{React.isValidElement(r) && r || null}
|
|
34
|
+
</>
|
|
35
|
+
}}
|
|
16
36
|
ref = {ref}
|
|
17
|
-
title=
|
|
37
|
+
title={title}
|
|
18
38
|
/>
|
|
19
39
|
});
|
|
20
40
|
|
|
@@ -142,6 +142,7 @@ export default function DatabaseStatisticContainer ({dashboardProps,onRefreshAll
|
|
|
142
142
|
if(typeof value !=='number'){
|
|
143
143
|
value = isObj(footerValue) && typeof footerValue.sum =='number'? footerValue.sum : 0;
|
|
144
144
|
}
|
|
145
|
+
const formattedValue = typeof context.formatValue =="function"? context.formatValue(value,format) : (format =='money'?value.formatMoney():value.formatNumber());
|
|
145
146
|
return <Pressable onPress={onPress} testID={testID+"_TitleContainer"} style={[theme.styles.w100]}>
|
|
146
147
|
<View testID={testID+"_TitleCountUp"} style={[theme.styles.w100]}>
|
|
147
148
|
<View style={[theme.styles.w100,theme.styles.row,theme.styles.alignItemsCenter]}>
|
|
@@ -158,7 +159,7 @@ export default function DatabaseStatisticContainer ({dashboardProps,onRefreshAll
|
|
|
158
159
|
<Label
|
|
159
160
|
textCenter
|
|
160
161
|
style = {counUpStyle}
|
|
161
|
-
>{
|
|
162
|
+
>{formattedValue}</Label>
|
|
162
163
|
</Pressable>}
|
|
163
164
|
/>
|
|
164
165
|
</View>
|