@fto-consult/expo-ui 1.1.36 → 1.1.38
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": "1.1.
|
|
3
|
+
"version": "1.1.38",
|
|
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
|
"@expo/html-elements": "^0.2.0",
|
|
62
62
|
"@expo/metro-config": "^0.4.0",
|
|
63
63
|
"@expo/webpack-config": "^0.17.2",
|
|
64
|
-
"@fto-consult/common": "^1.
|
|
64
|
+
"@fto-consult/common": "^1.2.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.2.0",
|
package/src/auth/Login.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "$react";
|
|
2
|
-
import {isNonNullString,defaultNumber,defaultStr,uniqid,extendObj,isFunction} from "$utils";
|
|
2
|
+
import {isNonNullString,isObj,defaultNumber,defaultStr,uniqid,extendObj,isFunction} from "$utils";
|
|
3
3
|
import {navigate} from "$cnavigation";
|
|
4
4
|
import FormData from "$ecomponents/Form/FormData/FormData";
|
|
5
5
|
import {getForm} from "$ecomponents/Form/utils";
|
|
@@ -37,7 +37,12 @@ export default function LoginComponent(props){
|
|
|
37
37
|
const _getForm = x=> getForm(formName);
|
|
38
38
|
|
|
39
39
|
const auth = useAuth();
|
|
40
|
-
const notifyUser = (message)=>
|
|
40
|
+
const notifyUser = (message,title)=> {
|
|
41
|
+
if(isObj(message)){
|
|
42
|
+
return notify.error({...message,position:'top'})
|
|
43
|
+
} else if(typeof message =='object') return false;
|
|
44
|
+
return notify.error({message,title,position:'top'});
|
|
45
|
+
}
|
|
41
46
|
const [state,setState] = React.useState({
|
|
42
47
|
step : defaultNumber(step,1),
|
|
43
48
|
data : defaultObj(props.data),
|
|
@@ -77,6 +82,9 @@ export default function LoginComponent(props){
|
|
|
77
82
|
const {header,children,data:loginData,canGoToNext,keyboardEvents,onSuccess:onLoginSuccess,canSubmit:canSubmitForm,onStepChange,...loginProps} = defaultObj(getProps({
|
|
78
83
|
...state,
|
|
79
84
|
state,
|
|
85
|
+
showError : notifyUser,
|
|
86
|
+
notifyUser,
|
|
87
|
+
notify,
|
|
80
88
|
getForm,
|
|
81
89
|
getData,
|
|
82
90
|
focusField,
|
|
@@ -118,18 +126,24 @@ export default function LoginComponent(props){
|
|
|
118
126
|
return
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
|
-
if(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
if(step > 1){
|
|
130
|
+
if(!form.isValid()){
|
|
131
|
+
notifyUser(form.getErrorText());
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if(canSubmit(args)){
|
|
135
|
+
Preloader.open("vérification ...");
|
|
136
|
+
return auth.signIn(data).then((a)=>{
|
|
137
|
+
if(typeof onLoginSuccess =='function' && onLoginSuccess(a)=== false) return;
|
|
138
|
+
if(isFunction(onSuccess)){
|
|
139
|
+
onSuccess(data);
|
|
140
|
+
} else {
|
|
141
|
+
navigate("Home");
|
|
142
|
+
}
|
|
143
|
+
}).finally(()=>{
|
|
144
|
+
Preloader.close();
|
|
145
|
+
})
|
|
146
|
+
}
|
|
133
147
|
} else {
|
|
134
148
|
setState({...state,step:step+1,data})
|
|
135
149
|
}
|
|
@@ -7,6 +7,7 @@ import theme from "$theme"
|
|
|
7
7
|
import Action from "$ecomponents/Form/Action";
|
|
8
8
|
import Menu from "$ecomponents/Menu";
|
|
9
9
|
import Icon,{ MORE_ICON } from "$ecomponents/Icon";
|
|
10
|
+
import {isAllowedFromStr} from "$cauth/perms";
|
|
10
11
|
|
|
11
12
|
export const ACTION_ICON_SIZE = 30;
|
|
12
13
|
|
|
@@ -91,7 +92,9 @@ export const splitActions = (args)=>{
|
|
|
91
92
|
let cEl = null;
|
|
92
93
|
if(!React.isValidElement(act)&& isPlainObj(act)){
|
|
93
94
|
let {label,perm,text,...action} = act;
|
|
94
|
-
if(
|
|
95
|
+
if(isNonNullString(perm) && !isAllowedFromStr(perm)){
|
|
96
|
+
continue;
|
|
97
|
+
} else if(typeof perm =='function' && perm(args) === false){
|
|
95
98
|
continue;
|
|
96
99
|
}
|
|
97
100
|
action = {...defaultObj(action)};
|
|
@@ -131,7 +134,7 @@ export const splitActions = (args)=>{
|
|
|
131
134
|
}
|
|
132
135
|
if(isPlainObj(cancelButton) && !React.isValidElement(cancelButton)){
|
|
133
136
|
let {label,perm,text,...action} = cancelButton;
|
|
134
|
-
let canAddCancelBtn = typeof perm =='function' ? perm(args) : true;
|
|
137
|
+
let canAddCancelBtn = isNonNullString(perm) ? isAllowedFromStr(perm) : typeof perm =='function' ? perm(args) : true;
|
|
135
138
|
if(canAddCancelBtn && (text||label)){
|
|
136
139
|
action = {...defaultObj(action)};
|
|
137
140
|
action.label = defaultVal(label,text)
|
|
@@ -777,7 +777,7 @@ export default class Field extends AppComponent {
|
|
|
777
777
|
const isFilter = this.isFilter();
|
|
778
778
|
rest = defaultObj(rest);
|
|
779
779
|
data = defaultObj(data);
|
|
780
|
-
label = defaultVal(label,text);
|
|
780
|
+
this.label = label = defaultVal(label,text);
|
|
781
781
|
rest.name = this.name;
|
|
782
782
|
rest.label = label;
|
|
783
783
|
rest.data = data;
|
|
@@ -29,7 +29,6 @@ export default class FormComponent extends React.AppComponent {
|
|
|
29
29
|
this.resetFields = this.resetFields.bind(this);
|
|
30
30
|
this.getData = this.getData.bind(this);
|
|
31
31
|
Forms.trigger("mount",props.name,this);
|
|
32
|
-
|
|
33
32
|
}
|
|
34
33
|
getErrorText(){
|
|
35
34
|
return defaultStr(this.___errorText);
|
|
@@ -105,6 +104,9 @@ export default class FormComponent extends React.AppComponent {
|
|
|
105
104
|
testID,
|
|
106
105
|
...rest
|
|
107
106
|
} = this.props;
|
|
107
|
+
if(isNonNullString(perm) && !Auth.isAllowedFromStr(perm)){
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
108
110
|
rest = defaultObj(rest);
|
|
109
111
|
const ComponentNode = defaultVal(Component,defaultComponentNode);
|
|
110
112
|
testID = defaultStr(testID,"RN_FormComponent");
|