@fto-consult/expo-ui 2.0.4 → 2.0.6

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.
@@ -12,6 +12,8 @@ module.exports = (opts)=>{
12
12
  const expo = require("./lookup-expo-ui-path")()?path.resolve(r.$src,"..","expo-ui","src") : path.resolve(dir,"src");
13
13
  r["$eauth"] = path.resolve(expo,"auth");
14
14
  r["$ecomponents"] = r["$expo-components"] = path.resolve(expo,"components");
15
+ r["$etableLink"] = r["$eTableLink"] = path.resolve(r["$ecomponents"],"TableLink");
16
+ r.$tableLink = r.$TableLink = r.$tableLink || r.$TableLink || path.resolve(r.$etableLink,"default");
15
17
  r["$components"] = r["$components"] || r["$ecomponents"];
16
18
  r["$elayouts"] = path.resolve(expo,"layouts");
17
19
  r["$emedia"] = path.resolve(expo,"media");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,6 +29,7 @@ import i18n from "$i18n";
29
29
  import { makePhoneCall,canMakePhoneCall as canMakeCall} from "$makePhoneCall";
30
30
  import copyToClipboard from "$capp/clipboard";
31
31
  import { Pressable } from "react-native";
32
+ import TableLink from "$TableLink";
32
33
  import appConfig from "$capp/config";
33
34
 
34
35
  export const arrayValueSeparator = ", ";
@@ -1497,7 +1498,7 @@ export default class CommonDatagridComponent extends AppComponent {
1497
1498
  _render = <Hashtag>{_render}</Hashtag>
1498
1499
  } else if(typeof columnDef.render === "function"){
1499
1500
  _render = columnDef.render.call(this,renderArgs);
1500
- } else if(arrayValueExists( _type,["date","date2time","time"]) && isNonNullString(rowData[columnField])){
1501
+ } else if(arrayValueExists( _type,["date","datetime","time"]) && isNonNullString(rowData[columnField])){
1501
1502
  let _dd =DateLib.parse(rowData[columnField],_type === 'time'?DateLib.isoTimeFormat:DateLib.SQLDateFormat);
1502
1503
  if(DateLib.isDateObj(_dd)){
1503
1504
  _render = DateLib.format(_dd,(_type === 'time'?DateLib.defaultTimeFormat:DateLib.masks.defaultDate));
@@ -1512,6 +1513,22 @@ export default class CommonDatagridComponent extends AppComponent {
1512
1513
  if(val === checkedValue){
1513
1514
  _render = checkedLabel;
1514
1515
  } else _render = uncheckedLabel;
1516
+ }
1517
+ ///le lien vers le table data se fait via une colonne de type selecttabledata ou select_tabledata ou potant l'une des propriétés foreignKeyTable ou linkToTable de type chaine de caractère non nulle
1518
+ else if(arrayValueExists(['piece','selecttabledata','id'],_type) || isNonNullString(columnDef.linkToTable) || isNonNullString(columnDef.foreignKeyTable)){
1519
+ let tableName = defaultStr(columnDef.linkToTable && columnDef.linkToTable,columnDef.foreignKeyTable && columnDef.foreignKeyTable,columnDef.tableName,columnDef.table).toUpperCase();
1520
+ const id = rowData[columnField]?.toString();
1521
+ if(isNonNullString(id)){
1522
+ _render = <TableLink
1523
+ tableName = {tableName}
1524
+ id = {id}
1525
+ data = {rowData}
1526
+ columnDef = {columnDef}
1527
+ columnField = {columnField}
1528
+ >
1529
+ {rowData[columnField]}
1530
+ </TableLink>
1531
+ }
1515
1532
  } else if((_type.contains('select'))){
1516
1533
  let v1 = rowData[columnField];
1517
1534
  _render = v1;
@@ -0,0 +1,5 @@
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
+
5
+ export {default} from "./index";
@@ -13,19 +13,22 @@ import {styles as _styles} from "$theme";
13
13
  import Tooltip from "$ecomponents/Tooltip";
14
14
 
15
15
  const TableLinKComponent = React.forwardRef((props,ref)=>{
16
- let {disabled,labelProps,server,containerProps,testID,Component,routeName,routeParams,component,_id,primary,triggerProps,onPress,children, ...rest} = props;
16
+ let {disabled,labelProps,server,containerProps,id,columnDef,tableName,data,testID,Component,routeName,routeParams,component,primary,triggerProps,onPress,children, ...rest} = props;
17
17
  testID = defaultStr(testID,"RN_TableDataLinkContainer")
18
+ tableName = defaultStr(tableName).trim();
18
19
  rest = defaultObj(rest);
19
20
  containerProps = defaultObj(containerProps)
20
21
  labelProps = defaultObj(labelProps);
21
- _id = defaultStr(_id);
22
- if(!_id){
22
+ columnDef = defaultObj(columnDef);
23
+ data = defaultObj(data);
24
+ id = defaultStr(id);
25
+ if(!id){
23
26
  disabled = true;
24
27
  }
25
- const pointerEvents = disabled || !_id? 'none' : 'auto';
28
+ const pointerEvents = disabled || !id? 'none' : 'auto';
26
29
  const onPressLink = (event)=>{
27
30
  React.stopEventPropagation(event);
28
- const r = typeof onPress =='function'? onPress(event) : undefined;
31
+ const r = typeof onPress =='function'? onPress({...React.getOnPressArgs(event),...columnDef,tableName,table:tableName,data,id,value:id,}) : undefined;
29
32
  if(isPromise(r)){
30
33
  openPreloader("traitement de la requête...");
31
34
  r.finally(closePreloader);
@@ -49,7 +52,7 @@ TableLinKComponent.propTypes = {
49
52
  ///les props à utiliser pour afficher la table de données en cas de click sur le lien
50
53
  triggerProps : PropTypes.object,
51
54
  /*** l'id de la données à récupérer en cas de clic sur le lien */
52
- _id : PropTypes.string.isRequired,
55
+ id : PropTypes.string,
53
56
  routeName : PropTypes.string,///la route via laquelle on devra naviguer
54
57
  routeParam : PropTypes.object,///les props à passer à la route en question
55
58
  children : PropTypes.node
@@ -69,7 +69,7 @@ export default function MainScreenScreenWithOrWithoutAuthContainer(props) {
69
69
  ];
70
70
  options = defaultObj(options);
71
71
  appBarProps = defaultObj(appBarProps)
72
- title = defaultVal(appBarProps.title,options.title,title);
72
+ title = defaultVal(title,appBarProps.title,options.title);
73
73
  subtitle = defaultVal(appBarProps.subtitle,options.subtitle,subtitle);
74
74
  const appBarRef = createAppBarRef();
75
75
  const navigation = useNavigation();