@fto-consult/expo-ui 2.36.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "2.36.0",
3
+ "version": "2.36.1",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -89,10 +89,6 @@ const DatagridFactory = (Factory)=>{
89
89
  const formatValue = this.formatValue.bind(this);
90
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};
91
91
  }
92
- toggleAbreviateValues(){
93
- this.renderingItemsProps = {};
94
- return super.toggleAbreviateValues(true);
95
- }
96
92
  getRenderingItemProps ({item,rowKey,numColumns,index}){
97
93
  const rKey = rowKey;
98
94
  this.renderingItemsProps = isObj(this.renderingItemsProps)? this.renderingItemsProps : {};
@@ -1357,15 +1357,16 @@ export default class CommonDatagridComponent extends AppComponent {
1357
1357
  }
1358
1358
  return this.aggregatorFunctions[Object.keys(this.aggregatorFunctions)[0]];
1359
1359
  }
1360
- toggleAbreviateValues(resetData){
1360
+ toggleAbreviateValues(){
1361
1361
  setTimeout(()=>{
1362
1362
  this.setIsLoading(true,()=>{
1363
- const abreviateValues = !this.state.abreviateValues;
1364
- const state = resetData ===true ? {data : [...this.state.data]} : {};
1365
- this.setState({abreviateValues,...state},()=>{
1366
- this.setIsLoading(false,false);
1367
- this.setSessionData("abreviateValues",abreviateValues);
1368
- })
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
+ });
1369
1370
  },true);
1370
1371
  },TIMEOUT);
1371
1372
  }
@@ -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
- items.push(renderExpandableOrSection({items:itx,key:i,item}))
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
- const tt = type.replaceAll("_","").toLowerCase();
115
- if(React.isComponent(componentTypes[tt])){
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 "$components/TextField";
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 defaultValue = isNonNullString(props.defaultValue) && props.defaultValue.contains("v" && props.defaultValue || defaultStr(appConfig.currencyFormat,"%v %s"))
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="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 $"
37
+ title={title}
18
38
  />
19
39
  });
20
40