@fto-consult/expo-ui 2.3.3 → 2.3.5
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();
|
|
@@ -495,4 +495,58 @@ const operatorsMap = {
|
|
|
495
495
|
$nin : 'NOT IN',
|
|
496
496
|
$eq: '=',
|
|
497
497
|
$regex : "LIKE"
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
*
|
|
502
|
+
* @param {*} operand
|
|
503
|
+
* @param {*} operator
|
|
504
|
+
* @param {*} field
|
|
505
|
+
*
|
|
506
|
+
* Return the operand in right format
|
|
507
|
+
*/
|
|
508
|
+
export const getTyppedOperand = (operand, operator, field) => {
|
|
509
|
+
if (typeof operand === 'string') { // wrap strings in double quots
|
|
510
|
+
return "'" +(operand) + "'"
|
|
511
|
+
} else if (operator === 'IN' || operator =='NOT IN') { // wrap IN arguments in brackers
|
|
512
|
+
operand = Array.isArray(operand)? operand.map(op => getTyppedOperand(op, null, null))
|
|
513
|
+
.join(', '): operand;
|
|
514
|
+
return '(' + operand + ')'
|
|
515
|
+
} else if (!isNonNullString(field) && Array.isArray(operand)) { // AND or OR elements
|
|
516
|
+
// recursively call 'buildWhereElement' for nested elements
|
|
517
|
+
// join each element with operator AND or OR
|
|
518
|
+
return operand.reduce((prev, curr) => {
|
|
519
|
+
return [...prev, buildWhereElement(curr)]
|
|
520
|
+
}, []).join(' ' + operator + ' ')
|
|
521
|
+
} else {
|
|
522
|
+
return operand
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
*
|
|
528
|
+
* @param {*} elem
|
|
529
|
+
*
|
|
530
|
+
* Return element of WHERE clause
|
|
531
|
+
*/
|
|
532
|
+
export const buildWhereElement = (elem) => {
|
|
533
|
+
const { field, operator, operand } = elem
|
|
534
|
+
if (!isNonNullString(field)) { // nested WHERE element
|
|
535
|
+
return '(' + getTyppedOperand(operand, operator, field) + ')'
|
|
536
|
+
} else { // simple WHERE element
|
|
537
|
+
return field + ' ' + operator + ' ' + getTyppedOperand(operand, operator, field)
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**** construit une requête Where à partir des filtres préparé dans le tableau whereClausePrepared
|
|
542
|
+
* @see : https://github.com/gordonBusyman/mongo-to-sql-converter
|
|
543
|
+
* @parm {array} whereClausePrepared, les filtres préparés avec la méthode prepareFilters puis convertis avec la fonction convertToSQL
|
|
544
|
+
@return {string}, la requête Where correspondante
|
|
545
|
+
*/
|
|
546
|
+
export const buildWhere = (whereClausePrepared)=>{
|
|
547
|
+
if(!Array.isArray(whereClausePrepared)) return null;
|
|
548
|
+
// build WHERE string clause by adding each element of array to it, separated with AND
|
|
549
|
+
return whereClausePrepared.reduce((prev, curr) => [
|
|
550
|
+
...prev, buildWhereElement(curr)
|
|
551
|
+
], []).join(' AND ');
|
|
498
552
|
}
|