@fto-consult/expo-ui 2.24.5 → 2.25.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/package.json
CHANGED
|
@@ -20,6 +20,7 @@ export const getCountryFieldProps = (props)=>{
|
|
|
20
20
|
items : countries,
|
|
21
21
|
upper : true,
|
|
22
22
|
dialogProps : {title:'Sélectionner un pays'},
|
|
23
|
+
appConfigDefaultValueKey : "countryCode",
|
|
23
24
|
getItemValue : ({item})=>item.code.toUpperCase(),
|
|
24
25
|
renderText : ({item})=>"[{0}] {1}".sprintf(item?.code?.toUpperCase(),item?.label),
|
|
25
26
|
compare : (a,b)=>{
|
|
@@ -1079,6 +1079,8 @@ Field.propTypes = {
|
|
|
1079
1079
|
* lorsque allowWhiteSpace === false alors on vérifiera si le champ n'admet pas des caractères accentuées
|
|
1080
1080
|
*/
|
|
1081
1081
|
allowWhiteSpaces : PropTypes.bool,
|
|
1082
|
+
autoSetDefaultValue : PropTypes.bool,//si la valeur par défaut sera définie automatiquement
|
|
1083
|
+
appConfigDefaultValueKey : PropTypes.string,//le nom de la clé des paramètres de configuration vers laquelle chercher la valeur par défaut
|
|
1082
1084
|
}
|
|
1083
1085
|
|
|
1084
1086
|
const styles = StyleSheet.create({
|
|
@@ -13,6 +13,7 @@ import {handleBeforeSaveCallback} from "./utils";
|
|
|
13
13
|
import componentsTypes from "./componentsTypes";
|
|
14
14
|
import { keyboardShortcuts } from "../utils";
|
|
15
15
|
import {getScreenProps} from "$cnavigation";
|
|
16
|
+
import appConfig from "$capp/config";
|
|
16
17
|
|
|
17
18
|
export default class FormDataComponent extends AppComponent{
|
|
18
19
|
constructor(props){
|
|
@@ -192,6 +193,7 @@ export default class FormDataComponent extends AppComponent{
|
|
|
192
193
|
} else if(isObj(field) && field.form !== false) {
|
|
193
194
|
const name = defaultStr(field.name,field.field,index);
|
|
194
195
|
const type = defaultStr(field.jsType,field.type,"text").trim().toLowerCase().replaceAll("_","");
|
|
196
|
+
const isDate = (type.contains('date') || type.contains('time'));
|
|
195
197
|
const Component = componentsTypes[type] || componentsTypes.default;
|
|
196
198
|
let {defaultValue,useDefaultValueFromData,hidden,renderFormDataField,getMediaQueryStyle,printLabels,queryLimit,selected,value,visible,dataFilesInterest,perm,ignore,form,responsiveProps:customResponsiveProps,...rest} = field;
|
|
197
199
|
rest = Object.assign({},rest);
|
|
@@ -218,6 +220,14 @@ export default class FormDataComponent extends AppComponent{
|
|
|
218
220
|
if(rest.defaultValue === null){
|
|
219
221
|
rest.defaultValue = undefined;
|
|
220
222
|
}
|
|
223
|
+
// les champs de type date par défaut qui sont requis, auront comme valeur par défaut la date actuelle s'il ne sont pas définies
|
|
224
|
+
if(rest.autoSetDefaultValue !== false && (!rest.defaultValue && typeof rest.defaultValue !=='boolean' && typeof rest.defaultValue !=='number')){
|
|
225
|
+
if(isDate && rest.required === true ){
|
|
226
|
+
rest.defaultValue = new Date();
|
|
227
|
+
} else if(!isDate && isNonNullString(rest.appConfigDefaultValueKey)){
|
|
228
|
+
rest.defaultValue = appConfigDefaultValueKey.get(rest.appConfigDefaultValueKey);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
221
231
|
customResponsiveProps = defaultObj(customResponsiveProps);
|
|
222
232
|
content.push(<Component
|
|
223
233
|
data = {data}
|
|
@@ -237,7 +237,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
237
237
|
containerProps : customContainerProps,
|
|
238
238
|
formProps : customFormProps,
|
|
239
239
|
newElementLabel,
|
|
240
|
-
|
|
240
|
+
prepareField,
|
|
241
241
|
...rest
|
|
242
242
|
} = getScreenProps(props);
|
|
243
243
|
const table = this.table;
|
|
@@ -259,10 +259,6 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
259
259
|
if(currentField.visibleOnlyOnEditing === true && !isUpdated){
|
|
260
260
|
currentField.form = false;
|
|
261
261
|
}
|
|
262
|
-
// les champs de type date par défaut qui sont requis, auront comme valeur par défaut la date actuelle s'il ne sont pas définies
|
|
263
|
-
if(currentField.autoSetDefaultValue !== false && (type.contains('date') || type.contains('time')) && currentField.required === true && !currentField.defaultValue){
|
|
264
|
-
currentField.defaultValue = new Date();
|
|
265
|
-
}
|
|
266
262
|
generatedColumnsProperties.map((f)=>{
|
|
267
263
|
//on affiche les champs générés uniquement en cas de mise à jour
|
|
268
264
|
if(currentField[f] === true){
|
|
@@ -287,12 +283,12 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
287
283
|
extendObj(true,fields,customFields);
|
|
288
284
|
}
|
|
289
285
|
///on effectue une mutator sur le champ en cours de modification
|
|
290
|
-
if(typeof
|
|
286
|
+
if(typeof prepareField =='function'){
|
|
291
287
|
Object.map(fields,(field,i,counterIndex)=>{
|
|
292
288
|
if(!isObj(field)) return;
|
|
293
289
|
const name = defaultStr(field.field,i) || "";
|
|
294
290
|
const isPrimary = this.primaryKeyFields[name] && true || false;
|
|
295
|
-
const f =
|
|
291
|
+
const f = prepareField({field,isUpdate:isUpdated,name,index:i,counterIndex,isPrimary,fields,contex:this,data,datas,currentIndex,isUpdated,tableName,table});
|
|
296
292
|
if(f === false) {
|
|
297
293
|
delete fields[i];
|
|
298
294
|
}
|
|
@@ -339,10 +335,6 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
339
335
|
archivedPermsFilter : this.archivedPermsFilter.bind(this),
|
|
340
336
|
onPressCopyToClipboard : this.copyToClipboard.bind(this)
|
|
341
337
|
}
|
|
342
|
-
///modifie le container par défaut de fasson à définir la bonne date pour les champs de type date
|
|
343
|
-
if(isObj(fields.date)){
|
|
344
|
-
fields.date.defaultValue = new Date();
|
|
345
|
-
}
|
|
346
338
|
if(isUpdated){
|
|
347
339
|
fields.approved = this.isApprovable()? {
|
|
348
340
|
text : 'Approuvé',
|
|
@@ -836,7 +828,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
836
828
|
|
|
837
829
|
TableDataScreenComponent.propTypes = {
|
|
838
830
|
...defaultObj(FormData.propTypes),
|
|
839
|
-
|
|
831
|
+
prepareField : PropTypes.func,//La fonction permettant de faire des mutations sur le champ field à passer au formulaire form. si elle retourne false alors la field ne sera pas pris een compte
|
|
840
832
|
table : PropTypes.shape({
|
|
841
833
|
tableName : PropTypes.string,
|
|
842
834
|
table : PropTypes.string,
|
|
@@ -874,7 +866,6 @@ TableDataScreenComponent.propTypes = {
|
|
|
874
866
|
PropTypes.element,
|
|
875
867
|
]),
|
|
876
868
|
showPreloaderOnUpsert : PropTypes.bool,//Si le preloader sera afficher en cas d'insertion/modification
|
|
877
|
-
autoSetDefaultValue : PropTypes.bool,//si la valeur par défaut sera définie pour les champs de types date et time
|
|
878
869
|
}
|
|
879
870
|
|
|
880
871
|
const styles = StyleSheet.create({
|