@fto-consult/expo-ui 2.3.3 → 2.3.4
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
|
@@ -41,16 +41,16 @@ export default function DateTimePickerComponent({left,isPeriodAction,withSeconds
|
|
|
41
41
|
timeFormat = format[1].trim();
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
const changeDateArgsRef =
|
|
44
|
+
const changeDateArgsRef = {current:{
|
|
45
45
|
date : dateObj,
|
|
46
|
-
}
|
|
46
|
+
}}
|
|
47
47
|
const getTimeValue = (date)=>{
|
|
48
48
|
date = DateLib.isValid(date)? date : new Date();
|
|
49
49
|
const sqlTime = date.toSQLTimeFormat();
|
|
50
50
|
return sqlTime.substring(0,withSeconds ?sqlTime.length :5);
|
|
51
51
|
}
|
|
52
52
|
const timeDefaultValue = getTimeValue(dateObj);
|
|
53
|
-
const changedTimeArgsRef =
|
|
53
|
+
const changedTimeArgsRef = {current:{...defaultObj(parseTime(timeDefaultValue,withSeconds))}};
|
|
54
54
|
withSeconds = defaultBool(timeProps.withSeconds,withSeconds,true);
|
|
55
55
|
|
|
56
56
|
const maxWidth = 120;//withSeconds ? 120 : 120;
|
|
@@ -506,7 +506,10 @@ export default class Filter extends AppComponent {
|
|
|
506
506
|
style : [styles.bold,styles.noVerticalPadding],
|
|
507
507
|
}:null],
|
|
508
508
|
...Object.mapToArray(actions,(x,j)=>{
|
|
509
|
-
|
|
509
|
+
if(ignoreDefaultValue && !periodActions[j]){
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
let checked = j === action?true : false;
|
|
510
513
|
if(checked && (isNumber(defaultValue) || isNonNullString(defaultValue))) {
|
|
511
514
|
let hasS = false;
|
|
512
515
|
let act = defaultStr(action).toLowerCase();
|
|
@@ -402,6 +402,7 @@ export const prepareFilters = (filtersToPrepare,opts)=>{
|
|
|
402
402
|
filters[f.operator].push(ob)
|
|
403
403
|
}
|
|
404
404
|
});
|
|
405
|
+
const f = convertToSQL(filters);
|
|
405
406
|
return convToSQL ? convertToSQL(filters) : filters;
|
|
406
407
|
}
|
|
407
408
|
|
|
@@ -495,4 +496,58 @@ const operatorsMap = {
|
|
|
495
496
|
$nin : 'NOT IN',
|
|
496
497
|
$eq: '=',
|
|
497
498
|
$regex : "LIKE"
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
*
|
|
503
|
+
* @param {*} operand
|
|
504
|
+
* @param {*} operator
|
|
505
|
+
* @param {*} field
|
|
506
|
+
*
|
|
507
|
+
* Return the operand in right format
|
|
508
|
+
*/
|
|
509
|
+
export const getTyppedOperand = (operand, operator, field) => {
|
|
510
|
+
if (typeof operand === 'string') { // wrap strings in double quots
|
|
511
|
+
return "'" +(operand) + "'"
|
|
512
|
+
} else if (operator === 'IN' || operator =='NOT IN') { // wrap IN arguments in brackers
|
|
513
|
+
operand = Array.isArray(operand)? operand.map(op => getTyppedOperand(op, null, null))
|
|
514
|
+
.join(', '): operand;
|
|
515
|
+
return '(' + operand + ')'
|
|
516
|
+
} else if (!isNonNullString(field) && Array.isArray(operand)) { // AND or OR elements
|
|
517
|
+
// recursively call 'buildWhereElement' for nested elements
|
|
518
|
+
// join each element with operator AND or OR
|
|
519
|
+
return operand.reduce((prev, curr) => {
|
|
520
|
+
return [...prev, buildWhereElement(curr)]
|
|
521
|
+
}, []).join(' ' + operator + ' ')
|
|
522
|
+
} else {
|
|
523
|
+
return operand
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
*
|
|
529
|
+
* @param {*} elem
|
|
530
|
+
*
|
|
531
|
+
* Return element of WHERE clause
|
|
532
|
+
*/
|
|
533
|
+
export const buildWhereElement = (elem) => {
|
|
534
|
+
const { field, operator, operand } = elem
|
|
535
|
+
if (!isNonNullString(field)) { // nested WHERE element
|
|
536
|
+
return '(' + getTyppedOperand(operand, operator, field) + ')'
|
|
537
|
+
} else { // simple WHERE element
|
|
538
|
+
return field + ' ' + operator + ' ' + getTyppedOperand(operand, operator, field)
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**** construit une requête Where à partir des filtres préparé dans le tableau whereClausePrepared
|
|
543
|
+
* @see : https://github.com/gordonBusyman/mongo-to-sql-converter
|
|
544
|
+
* @parm {array} whereClausePrepared, les filtres préparés avec la méthode prepareFilters puis convertis avec la fonction convertToSQL
|
|
545
|
+
@return {string}, la requête Where correspondante
|
|
546
|
+
*/
|
|
547
|
+
export const buildWhere = (whereClausePrepared)=>{
|
|
548
|
+
if(!Array.isArray(whereClausePrepared)) return null;
|
|
549
|
+
// build WHERE string clause by adding each element of array to it, separated with AND
|
|
550
|
+
return whereClausePrepared.reduce((prev, curr) => [
|
|
551
|
+
...prev, buildWhereElement(curr)
|
|
552
|
+
], []).join(' AND ');
|
|
498
553
|
}
|