@qrvey/utils 1.1.2-0 → 1.1.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/README.md +458 -378
- package/dist/cjs/constants/COLUMN_PROPERTY.d.ts +6 -6
- package/dist/cjs/constants/COLUMN_PROPERTY_VALUE.d.ts +1 -2
- package/dist/cjs/constants/COLUMN_PROPERTY_VALUE.js +3 -8
- package/dist/cjs/date/constants/DATE_PROPERTY_VALUE.d.ts +6 -6
- package/dist/cjs/date/constants/DATE_PROPERTY_VALUE.js +6 -6
- package/dist/cjs/date/constants/DATE_P_PROPERTIES.js +6 -6
- package/dist/cjs/date/constants/DATE_P_VALUES.js +3 -3
- package/dist/cjs/date/constants/DATE_TIME_P_VALUES.js +3 -3
- package/dist/cjs/date/constants/DATE_TIME_VALUES.js +3 -3
- package/dist/cjs/date/constants/DATE_VALUES.d.ts +6 -0
- package/dist/cjs/date/constants/DATE_VALUES.js +10 -0
- package/dist/cjs/filters/adapters/FDToFlatUI.js +3 -1
- package/dist/cjs/filters/adapters/FDToUI.js +3 -1
- package/dist/cjs/filters/adapters/UIToFlatUI.js +3 -1
- package/dist/cjs/filters/adapters/UIToOldLogic.js +3 -1
- package/dist/cjs/filters/adapters/adaptDateGroupingProperty.d.ts +8 -0
- package/dist/cjs/filters/adapters/adaptDateGroupingProperty.js +19 -0
- package/dist/cjs/filters/adapters/adaptFilterData.js +1 -1
- package/dist/cjs/filters/adapters/flatUIToFD.js +3 -1
- package/dist/cjs/filters/adapters/flatUIToOldLogic.js +1 -5
- package/dist/cjs/filters/adapters/flatUIToUI.js +3 -1
- package/dist/cjs/filters/adapters/index.d.ts +1 -0
- package/dist/cjs/filters/adapters/index.js +1 -0
- package/dist/cjs/filters/adapters/logicToFlatUI.js +77 -63
- package/dist/cjs/filters/helpers/backend/getBackendGroupValue.js +4 -3
- package/dist/cjs/filters/helpers/backend/getBackendProperty.js +1 -5
- package/dist/cjs/filters/helpers/ui/getFilterPropertyLabel.d.ts +7 -0
- package/dist/cjs/filters/helpers/ui/getFilterPropertyLabel.js +13 -0
- package/dist/cjs/filters/helpers/ui/index.d.ts +1 -0
- package/dist/cjs/filters/helpers/ui/index.js +1 -0
- package/dist/cjs/general/array/filterNestedTree.d.ts +5 -2
- package/dist/cjs/general/array/filterNestedTree.js +13 -5
- package/dist/cjs/general/mix/getTag.d.ts +7 -0
- package/dist/cjs/general/mix/getTag.js +16 -0
- package/dist/cjs/general/mix/index.d.ts +1 -0
- package/dist/cjs/general/mix/index.js +1 -0
- package/dist/cjs/general/mix/isEmpty.js +8 -4
- package/dist/cjs/general/mix/isNull.js +1 -1
- package/dist/cjs/general/mix/randomId.d.ts +6 -3
- package/dist/cjs/general/mix/randomId.js +24 -7
- package/dist/cjs/general/mix/size.d.ts +5 -5
- package/dist/cjs/general/mix/size.js +9 -6
- package/dist/cjs/general/object/get.d.ts +1 -1
- package/dist/cjs/general/object/getAttribute.d.ts +9 -2
- package/dist/cjs/general/object/getAttribute.js +39 -8
- package/dist/cjs/general/object/hasProperty.d.ts +1 -1
- package/dist/cjs/general/object/hasProperty.js +10 -2
- package/dist/cjs/general/object/index.d.ts +1 -0
- package/dist/cjs/general/object/index.js +1 -0
- package/dist/cjs/general/object/isObject.js +2 -1
- package/dist/cjs/general/object/objectCopy.d.ts +7 -0
- package/dist/cjs/general/object/objectCopy.js +32 -0
- package/dist/cjs/general/string/capitalize.d.ts +3 -3
- package/dist/cjs/general/string/capitalize.js +6 -3
- package/dist/cjs/qrvey/getPropertyLabel.d.ts +2 -0
- package/dist/cjs/qrvey/getPropertyLabel.js +14 -0
- package/dist/cjs/qrvey/index.d.ts +1 -0
- package/dist/cjs/qrvey/index.js +1 -0
- package/dist/constants/COLUMN_PROPERTY.d.ts +6 -6
- package/dist/constants/COLUMN_PROPERTY_VALUE.d.ts +1 -2
- package/dist/constants/COLUMN_PROPERTY_VALUE.js +4 -9
- package/dist/date/constants/DATE_PROPERTY_VALUE.d.ts +6 -6
- package/dist/date/constants/DATE_PROPERTY_VALUE.js +6 -6
- package/dist/date/constants/DATE_P_PROPERTIES.js +6 -6
- package/dist/date/constants/DATE_P_VALUES.js +3 -3
- package/dist/date/constants/DATE_TIME_P_VALUES.js +3 -3
- package/dist/date/constants/DATE_TIME_VALUES.js +3 -3
- package/dist/date/constants/DATE_VALUES.d.ts +6 -0
- package/dist/date/constants/DATE_VALUES.js +7 -0
- package/dist/filters/adapters/FDToFlatUI.js +3 -1
- package/dist/filters/adapters/FDToUI.js +3 -1
- package/dist/filters/adapters/UIToFlatUI.js +3 -1
- package/dist/filters/adapters/UIToOldLogic.js +3 -1
- package/dist/filters/adapters/adaptDateGroupingProperty.d.ts +8 -0
- package/dist/filters/adapters/adaptDateGroupingProperty.js +15 -0
- package/dist/filters/adapters/adaptFilterData.js +1 -1
- package/dist/filters/adapters/flatUIToFD.js +3 -1
- package/dist/filters/adapters/flatUIToOldLogic.js +1 -5
- package/dist/filters/adapters/flatUIToUI.js +3 -1
- package/dist/filters/adapters/index.d.ts +1 -0
- package/dist/filters/adapters/index.js +1 -0
- package/dist/filters/adapters/logicToFlatUI.js +79 -65
- package/dist/filters/helpers/backend/getBackendGroupValue.js +4 -3
- package/dist/filters/helpers/backend/getBackendProperty.js +2 -6
- package/dist/filters/helpers/ui/getFilterPropertyLabel.d.ts +7 -0
- package/dist/filters/helpers/ui/getFilterPropertyLabel.js +9 -0
- package/dist/filters/helpers/ui/index.d.ts +1 -0
- package/dist/filters/helpers/ui/index.js +1 -0
- package/dist/general/array/filterNestedTree.d.ts +5 -2
- package/dist/general/array/filterNestedTree.js +13 -5
- package/dist/general/mix/getTag.d.ts +7 -0
- package/dist/general/mix/getTag.js +12 -0
- package/dist/general/mix/index.d.ts +1 -0
- package/dist/general/mix/index.js +1 -0
- package/dist/general/mix/isEmpty.js +8 -4
- package/dist/general/mix/isNull.js +1 -1
- package/dist/general/mix/randomId.d.ts +6 -3
- package/dist/general/mix/randomId.js +24 -7
- package/dist/general/mix/size.d.ts +5 -5
- package/dist/general/mix/size.js +9 -6
- package/dist/general/object/get.d.ts +1 -1
- package/dist/general/object/getAttribute.d.ts +9 -2
- package/dist/general/object/getAttribute.js +39 -8
- package/dist/general/object/hasProperty.d.ts +1 -1
- package/dist/general/object/hasProperty.js +8 -0
- package/dist/general/object/index.d.ts +1 -0
- package/dist/general/object/index.js +1 -0
- package/dist/general/object/isObject.js +2 -1
- package/dist/general/object/objectCopy.d.ts +7 -0
- package/dist/general/object/objectCopy.js +28 -0
- package/dist/general/string/capitalize.d.ts +3 -3
- package/dist/general/string/capitalize.js +6 -3
- package/dist/qrvey/getPropertyLabel.d.ts +2 -0
- package/dist/qrvey/getPropertyLabel.js +10 -0
- package/dist/qrvey/index.d.ts +1 -0
- package/dist/qrvey/index.js +1 -0
- package/package.json +1 -1
- package/src/constants/COLUMN_PROPERTY.ts +7 -7
- package/src/constants/COLUMN_PROPERTY_VALUE.ts +4 -10
- package/src/date/constants/DATE_P_VALUES.ts +3 -3
- package/src/date/constants/DATE_TIME_P_VALUES.ts +3 -3
- package/src/date/constants/DATE_TIME_VALUES.ts +3 -3
- package/src/date/constants/DATE_VALUES.ts +9 -0
- package/src/filters/adapters/FDToFlatUI.ts +3 -1
- package/src/filters/adapters/FDToUI.ts +4 -0
- package/src/filters/adapters/UIToFlatUI.ts +3 -1
- package/src/filters/adapters/UIToOldLogic.ts +4 -1
- package/src/filters/adapters/adaptDateGroupingProperty.ts +18 -0
- package/src/filters/adapters/adaptFilterData.ts +1 -1
- package/src/filters/adapters/flatUIToFD.ts +4 -1
- package/src/filters/adapters/flatUIToOldLogic.ts +1 -3
- package/src/filters/adapters/flatUIToUI.ts +4 -1
- package/src/filters/adapters/index.ts +1 -0
- package/src/filters/adapters/logicToFlatUI.ts +87 -70
- package/src/filters/helpers/backend/getAggFiltersBySummaryIndex.ts +1 -1
- package/src/filters/helpers/backend/getBackendGroupValue.ts +4 -3
- package/src/filters/helpers/backend/getBackendProperty.ts +2 -4
- package/src/filters/helpers/ui/getFilterPropertyLabel.ts +11 -0
- package/src/filters/helpers/ui/index.ts +1 -0
- package/src/general/array/filterNestedTree.ts +13 -4
- package/src/general/mix/getTag.ts +12 -0
- package/src/general/mix/index.ts +1 -0
- package/src/general/mix/isEmpty.ts +9 -4
- package/src/general/mix/isNull.ts +1 -1
- package/src/general/mix/randomId.ts +24 -7
- package/src/general/mix/size.ts +10 -6
- package/src/general/object/get.ts +1 -1
- package/src/general/object/getAttribute.ts +47 -9
- package/src/general/object/hasProperty.ts +10 -1
- package/src/general/object/index.ts +1 -0
- package/src/general/object/isObject.ts +3 -1
- package/src/general/object/objectCopy.ts +35 -0
- package/src/general/string/capitalize.ts +7 -3
- package/src/qrvey/getPropertyLabel.ts +9 -0
- package/src/qrvey/index.ts +1 -0
- package/test/general/array/filterNestedTree.test.js +115 -0
- package/test/general/mix/getTag.test.js +101 -0
- package/test/general/mix/isEmpty.test.js +30 -24
- package/test/general/mix/isNull.test.js +72 -0
- package/test/general/mix/randomId.test.js +134 -0
- package/test/general/mix/size.test.js +87 -0
- package/test/general/object/cloneDeep.test.js +8 -16
- package/test/general/object/getAttribute.test.js +316 -0
- package/test/general/object/hasProperty.test.js +103 -0
- package/test/general/object/objectCopy.test.js +105 -0
- package/test/general/string/capitalize.test.js +87 -0
|
@@ -1,14 +1,31 @@
|
|
|
1
|
+
import { isEmpty, isNull } from ".";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Creates a random string
|
|
4
|
+
* - If the first given argument is different than a length number, the variable is replaced by a default number
|
|
5
|
+
* - If the optional second given argument is passed the random string is permutated.
|
|
3
6
|
* @param {Number} length size of the generated string. Default 8
|
|
4
|
-
* @
|
|
7
|
+
* @param {Array} exclude collection of strings that is going to be excluded of the random string.
|
|
8
|
+
* @return {String} Random string
|
|
5
9
|
*/
|
|
6
|
-
export function randomId(
|
|
10
|
+
export function randomId(length = 8, exclude = []) {
|
|
11
|
+
if (typeof length !== 'number')
|
|
12
|
+
length = 8;
|
|
13
|
+
if (isNull(exclude) || !Array.isArray(exclude))
|
|
14
|
+
exclude = [];
|
|
15
|
+
exclude = exclude.filter(e => typeof e === 'string');
|
|
7
16
|
const charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_';
|
|
17
|
+
const blackList = [];
|
|
8
18
|
let id = '';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
do {
|
|
20
|
+
if (!isEmpty(id) && !blackList.includes(id))
|
|
21
|
+
blackList.push(id);
|
|
22
|
+
id = '';
|
|
23
|
+
for (let i = 0; i < length; i++) {
|
|
24
|
+
const randPos = Math.floor(Math.random() * charSet.length);
|
|
25
|
+
id += charSet[randPos];
|
|
26
|
+
}
|
|
27
|
+
} while (exclude.length > 0 && exclude.includes(id) && blackList.length < exclude.length);
|
|
28
|
+
if (exclude.length > 0 && blackList.length >= exclude.length)
|
|
29
|
+
id = '';
|
|
13
30
|
return id;
|
|
14
31
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* For `null` or `undefined` argument the returned value will be 0.
|
|
5
|
-
* @param {Any} obj
|
|
6
|
-
* @returns {Number}
|
|
2
|
+
* Gets the length of the given array.
|
|
3
|
+
* - Useful for Object, Array and string type.
|
|
4
|
+
* - For `null` or `undefined` or else argument the returned value will be 0.
|
|
5
|
+
* @param {Any} obj Any object-type variable
|
|
6
|
+
* @returns {Number} the size of the given variable
|
|
7
7
|
*/
|
|
8
8
|
export declare function size(obj: any): number;
|
package/dist/general/mix/size.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { isEmpty } from ".";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* For `null` or `undefined` argument the returned value will be 0.
|
|
5
|
-
* @param {Any} obj
|
|
6
|
-
* @returns {Number}
|
|
3
|
+
* Gets the length of the given array.
|
|
4
|
+
* - Useful for Object, Array and string type.
|
|
5
|
+
* - For `null` or `undefined` or else argument the returned value will be 0.
|
|
6
|
+
* @param {Any} obj Any object-type variable
|
|
7
|
+
* @returns {Number} the size of the given variable
|
|
7
8
|
*/
|
|
8
9
|
export function size(obj) {
|
|
9
|
-
|
|
10
|
+
if (isEmpty(obj))
|
|
11
|
+
return 0;
|
|
12
|
+
return Object.keys(obj).length;
|
|
10
13
|
}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* _get({ item1: { item11: 'Hello Again' }, item2: {} }, ['item1', 'item11'])
|
|
27
27
|
* @returns the resolved value.
|
|
28
28
|
*/
|
|
29
|
-
export declare function _get(baseObject:
|
|
29
|
+
export declare function _get<T = any>(baseObject: T, path: string | string[], defaultValue?: any): any;
|
|
30
30
|
/**
|
|
31
31
|
*
|
|
32
32
|
* /**
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Searchs for properties in different case styles such as: lower, upper, camel and pascal
|
|
3
|
+
* - To optimize the searching, it is required a key in a snake_case style
|
|
4
|
+
* - List of cases that do not match
|
|
5
|
+
* -- From lower to snake case
|
|
6
|
+
* -- From upper to snake case
|
|
7
|
+
* -- From lower to camel case
|
|
8
|
+
* -- From upper to camel case
|
|
9
|
+
* -- From lower to pascal case
|
|
10
|
+
* -- From upper to pascal case
|
|
4
11
|
* @param {object} obj object to look for
|
|
5
12
|
* @param {string} key String attribute in snake_case style
|
|
6
13
|
*
|
|
@@ -1,17 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Searchs for properties in different case styles such as: lower, upper, camel and pascal
|
|
3
|
+
* - To optimize the searching, it is required a key in a snake_case style
|
|
4
|
+
* - List of cases that do not match
|
|
5
|
+
* -- From lower to snake case
|
|
6
|
+
* -- From upper to snake case
|
|
7
|
+
* -- From lower to camel case
|
|
8
|
+
* -- From upper to camel case
|
|
9
|
+
* -- From lower to pascal case
|
|
10
|
+
* -- From upper to pascal case
|
|
4
11
|
* @param {object} obj object to look for
|
|
5
12
|
* @param {string} key String attribute in snake_case style
|
|
6
13
|
*
|
|
7
14
|
* @example
|
|
8
15
|
* getAttribute(obj, 'snake_case') //it search for: obj.snake_case || obj.snakeCase || obj.SnakeCase || obj.snakecase || obj.SNAKECASE
|
|
9
16
|
*/
|
|
17
|
+
import { isObject } from ".";
|
|
18
|
+
import { isEmpty } from "..";
|
|
10
19
|
export function getAttribute(obj, key) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
20
|
+
var _a, _b, _c, _d, _e;
|
|
21
|
+
if (!isValid(obj, key))
|
|
22
|
+
return;
|
|
23
|
+
const snake = getSnakeCase(key);
|
|
24
|
+
const camel = getCamelCase(snake);
|
|
25
|
+
const pascal = getPascalCase(camel);
|
|
26
|
+
const lower = getLowerCase(pascal);
|
|
27
|
+
const upper = getUpperCase(lower);
|
|
28
|
+
return (_e = (_d = (_c = (_b = (_a = obj[key]) !== null && _a !== void 0 ? _a : obj[snake]) !== null && _b !== void 0 ? _b : obj[camel]) !== null && _c !== void 0 ? _c : obj[pascal]) !== null && _d !== void 0 ? _d : obj[lower]) !== null && _e !== void 0 ? _e : obj[upper];
|
|
29
|
+
}
|
|
30
|
+
function getSnakeCase(key) {
|
|
31
|
+
return key.replace(/[A-Z]/g, (a, i) => i == 0 ? a.toLowerCase() : '_' + a.toLowerCase());
|
|
32
|
+
}
|
|
33
|
+
function getCamelCase(key) {
|
|
34
|
+
return key.replace(/(.)/, (_, a) => a.toLowerCase()).replace(/_(.)/g, (_, a) => a.toUpperCase());
|
|
35
|
+
}
|
|
36
|
+
function getPascalCase(key) {
|
|
37
|
+
return key.replace(/(.)/, (_, a) => a.toUpperCase());
|
|
38
|
+
}
|
|
39
|
+
function getLowerCase(key) {
|
|
40
|
+
return key.replace(/_/g, '').toLowerCase();
|
|
41
|
+
}
|
|
42
|
+
function getUpperCase(key) {
|
|
43
|
+
return key.toUpperCase();
|
|
44
|
+
}
|
|
45
|
+
function isValid(obj, key) {
|
|
46
|
+
return (!isEmpty(obj) && isObject(obj))
|
|
47
|
+
&& (!isEmpty(key) && typeof key === 'string');
|
|
17
48
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isObject } from ".";
|
|
2
|
+
import { isEmpty } from "..";
|
|
1
3
|
/**
|
|
2
4
|
* Use the hasOwnProperty in order to verify if the given property exists in the object.
|
|
3
5
|
*
|
|
@@ -15,5 +17,11 @@
|
|
|
15
17
|
* _hasProperty(ob1, prop2) // false
|
|
16
18
|
*/
|
|
17
19
|
export function _hasProperty(obj = {}, property = '') {
|
|
20
|
+
if (!isValid(obj, property))
|
|
21
|
+
return false;
|
|
18
22
|
return Object.prototype.hasOwnProperty.call(obj, property);
|
|
19
23
|
}
|
|
24
|
+
function isValid(obj, property) {
|
|
25
|
+
return !isEmpty(obj) && (isObject(obj) || Array.isArray(obj))
|
|
26
|
+
&& !isEmpty(property) && (typeof property === 'string' || typeof property === 'number');
|
|
27
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { getTag } from "..";
|
|
1
2
|
/**
|
|
2
3
|
* Checks if the given argument is an object type
|
|
3
4
|
* @param obj the variable to check
|
|
4
5
|
* @returns True: It is an object; False: It is not.
|
|
5
6
|
*/
|
|
6
7
|
export function isObject(obj) {
|
|
7
|
-
return Object
|
|
8
|
+
return obj === Object(obj) || getTag(obj) === '[object Object]';
|
|
8
9
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created a new reference of the given argument
|
|
3
|
+
* @param entity The variable to be copied
|
|
4
|
+
* @param cache
|
|
5
|
+
* @returns A new reference of the given argument
|
|
6
|
+
*/
|
|
7
|
+
export function objectCopy(entity, cache = new WeakMap()) {
|
|
8
|
+
if (!isClonable(entity))
|
|
9
|
+
return entity;
|
|
10
|
+
if (cache.has(entity))
|
|
11
|
+
return cache.get(entity);
|
|
12
|
+
const c = new entity.constructor;
|
|
13
|
+
if (c.name === 'Date')
|
|
14
|
+
return new Date(entity);
|
|
15
|
+
if (entity instanceof Map) {
|
|
16
|
+
entity.forEach((value, key) => c.set(objectCopy(key), objectCopy(value)));
|
|
17
|
+
}
|
|
18
|
+
if (entity instanceof Set) {
|
|
19
|
+
entity.forEach((value) => c.add(objectCopy(value)));
|
|
20
|
+
}
|
|
21
|
+
cache.set(entity, c);
|
|
22
|
+
return Object.assign(c, ...Object.keys(entity).map((prop) => ({ [prop]: objectCopy(entity[prop], cache) })));
|
|
23
|
+
}
|
|
24
|
+
function isClonable(entity) {
|
|
25
|
+
const referenceTypes = ['Array', 'Object', 'Map', 'Set', 'Date'];
|
|
26
|
+
const entityName = entity && entity.constructor.name;
|
|
27
|
+
return referenceTypes.includes(entityName);
|
|
28
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Upper case
|
|
2
|
+
* Upper case the first letter of a given text
|
|
3
3
|
* @param {String} text
|
|
4
|
-
* @returns {String}
|
|
4
|
+
* @returns {String} a capitalized text
|
|
5
5
|
*/
|
|
6
|
-
export declare function capitalize(text
|
|
6
|
+
export declare function capitalize(text?: string): string;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { isEmpty } from "..";
|
|
1
2
|
/**
|
|
2
|
-
* Upper case
|
|
3
|
+
* Upper case the first letter of a given text
|
|
3
4
|
* @param {String} text
|
|
4
|
-
* @returns {String}
|
|
5
|
+
* @returns {String} a capitalized text
|
|
5
6
|
*/
|
|
6
|
-
export function capitalize(text) {
|
|
7
|
+
export function capitalize(text = '') {
|
|
8
|
+
if (isEmpty(text) || typeof text !== 'string')
|
|
9
|
+
return text;
|
|
7
10
|
return text.toLowerCase().replace(/^\w/, c => c.toUpperCase());
|
|
8
11
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isDateColumn } from ".";
|
|
2
|
+
import { COLUMN_PROPERTY_VALUE, isEmpty } from "..";
|
|
3
|
+
export function getPropertyLabel(column, property) {
|
|
4
|
+
var _a;
|
|
5
|
+
let propertyLabel;
|
|
6
|
+
const propertyValues = COLUMN_PROPERTY_VALUE[isDateColumn(column) ? column.type + '-complete' : column.type];
|
|
7
|
+
if (!isEmpty(propertyValues))
|
|
8
|
+
propertyLabel = (_a = propertyValues.find(pValue => pValue.value === property)) === null || _a === void 0 ? void 0 : _a.label;
|
|
9
|
+
return propertyLabel;
|
|
10
|
+
}
|
package/dist/qrvey/index.d.ts
CHANGED
package/dist/qrvey/index.js
CHANGED
package/package.json
CHANGED
|
@@ -11,15 +11,15 @@ export const enum COLUMN_PROPERTY {
|
|
|
11
11
|
DATE_SECOND = 'second',
|
|
12
12
|
|
|
13
13
|
// PROPERTY DATE TYPES
|
|
14
|
-
DATE_YEAR_QUARTER = '
|
|
15
|
-
DATE_YEAR_MONTH = '
|
|
14
|
+
DATE_YEAR_QUARTER = 'quarter_only',
|
|
15
|
+
DATE_YEAR_MONTH = 'month_only',
|
|
16
16
|
// DATE_YEAR_DAY = 'p-y-day',
|
|
17
|
-
DATE_MONTH_DAY = '
|
|
17
|
+
DATE_MONTH_DAY = 'day_only',
|
|
18
18
|
//DATE_WEEK_DAY = 'p-w-day'
|
|
19
|
-
DATE_DAY_HOUR = '
|
|
20
|
-
DATE_HOUR_MINUTE = '
|
|
21
|
-
DATE_MINUTE_SECOND = '
|
|
22
|
-
|
|
19
|
+
DATE_DAY_HOUR = 'hour_only',
|
|
20
|
+
DATE_HOUR_MINUTE = 'minute_only',
|
|
21
|
+
DATE_MINUTE_SECOND = 'second_only',
|
|
22
|
+
|
|
23
23
|
// COMPLEX PROPERTY TYPES
|
|
24
24
|
NAME_FIRST = 'first_name',
|
|
25
25
|
NAME_LAST = 'last_name',
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import { DATE_P_VALUES, DATE_TIME_P_VALUES } from "../date";
|
|
1
|
+
import { DATE_P_VALUES, DATE_TIME_VALUES, DATE_TIME_P_VALUES } from "../date";
|
|
2
|
+
import { DATE_VALUES } from "../date/constants/DATE_VALUES";
|
|
2
3
|
import { COLUMN } from "./COLUMN";
|
|
3
4
|
import { COLUMN_COMPLEX_VALUE } from "./COLUMN_COMPLEX_VALUE";
|
|
4
|
-
import { COLUMN_PROPERTY } from "./COLUMN_PROPERTY";
|
|
5
5
|
|
|
6
6
|
const setTabStructure = compound => ({ value: compound.property, label: compound.shortLabel });
|
|
7
7
|
const C = {
|
|
8
|
-
[COLUMN.DATE]:
|
|
9
|
-
{ value: COLUMN_PROPERTY.DATE_DAY, label: 'Complete Date', display: true },
|
|
10
|
-
{ value: COLUMN_PROPERTY.DATE_YEAR, label: 'Year', display: true },
|
|
11
|
-
{ value: COLUMN_PROPERTY.DATE_QUARTER, label: 'Quarter', display: true },
|
|
12
|
-
{ value: COLUMN_PROPERTY.DATE_MONTH, label: 'Month', display: true },
|
|
13
|
-
{ value: COLUMN_PROPERTY.DATE_WEEK, label: 'Weeks', display: true }
|
|
14
|
-
],
|
|
8
|
+
[COLUMN.DATE]: DATE_VALUES,
|
|
15
9
|
[COLUMN.LOOKUP]: [
|
|
16
10
|
{ value: 'display', label: 'Display', display: true },
|
|
17
11
|
{ value: 'value', label: 'Value', display: true }
|
|
@@ -26,6 +20,6 @@ const C = {
|
|
|
26
20
|
[COLUMN.IMAGEUPLOAD]: COLUMN_COMPLEX_VALUE.IMAGEUPLOAD.map(setTabStructure),
|
|
27
21
|
};
|
|
28
22
|
|
|
29
|
-
C[COLUMN.DATE + '-complete'] = C[COLUMN.DATE].concat(DATE_P_VALUES).concat(DATE_TIME_P_VALUES);
|
|
23
|
+
C[COLUMN.DATE + '-complete'] = C[COLUMN.DATE].concat(DATE_TIME_VALUES).concat(DATE_P_VALUES).concat(DATE_TIME_P_VALUES);
|
|
30
24
|
|
|
31
25
|
export const COLUMN_PROPERTY_VALUE = C;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { COLUMN_PROPERTY } from "../../constants";
|
|
2
2
|
|
|
3
3
|
export const DATE_P_VALUES = [
|
|
4
|
-
{ value: COLUMN_PROPERTY.DATE_YEAR_QUARTER, label: 'Quarter
|
|
5
|
-
{ value: COLUMN_PROPERTY.DATE_YEAR_MONTH, label: 'Month
|
|
6
|
-
{ value: COLUMN_PROPERTY.DATE_MONTH_DAY, label: 'Day
|
|
4
|
+
{ value: COLUMN_PROPERTY.DATE_YEAR_QUARTER, label: 'Quarter', display: true },
|
|
5
|
+
{ value: COLUMN_PROPERTY.DATE_YEAR_MONTH, label: 'Month', display: true },
|
|
6
|
+
{ value: COLUMN_PROPERTY.DATE_MONTH_DAY, label: 'Day (Month)', display: true },
|
|
7
7
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { COLUMN_PROPERTY } from "../../constants";
|
|
2
2
|
|
|
3
3
|
export const DATE_TIME_P_VALUES = [
|
|
4
|
-
{ value: COLUMN_PROPERTY.DATE_DAY_HOUR, label: 'Hour
|
|
5
|
-
{ value: COLUMN_PROPERTY.DATE_HOUR_MINUTE, label: 'Minute
|
|
6
|
-
{ value: COLUMN_PROPERTY.DATE_MINUTE_SECOND, label: 'Second
|
|
4
|
+
{ value: COLUMN_PROPERTY.DATE_DAY_HOUR, label: 'Hour', display: true },
|
|
5
|
+
{ value: COLUMN_PROPERTY.DATE_HOUR_MINUTE, label: 'Minute', display: true },
|
|
6
|
+
{ value: COLUMN_PROPERTY.DATE_MINUTE_SECOND, label: 'Second', display: true },
|
|
7
7
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { COLUMN_PROPERTY } from "../../constants";
|
|
2
2
|
|
|
3
3
|
export const DATE_TIME_VALUES = [
|
|
4
|
-
{ label: '
|
|
5
|
-
{ label: '
|
|
6
|
-
{ label: '
|
|
4
|
+
{ label: 'Date, Hour', value: COLUMN_PROPERTY.DATE_HOUR, display: true },
|
|
5
|
+
{ label: 'Date, Minute', value: COLUMN_PROPERTY.DATE_MINUTE, display: true },
|
|
6
|
+
{ label: 'Date, Second', value: COLUMN_PROPERTY.DATE_SECOND, display: true },
|
|
7
7
|
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { COLUMN_PROPERTY } from "../../constants";
|
|
2
|
+
|
|
3
|
+
export const DATE_VALUES = [
|
|
4
|
+
{ value: COLUMN_PROPERTY.DATE_DAY, label: 'Full Date', display: true },
|
|
5
|
+
{ value: COLUMN_PROPERTY.DATE_YEAR, label: 'Year', display: true },
|
|
6
|
+
{ value: COLUMN_PROPERTY.DATE_QUARTER, label: 'Quarter, Year', display: true },
|
|
7
|
+
{ value: COLUMN_PROPERTY.DATE_MONTH, label: 'Month, Year', display: true },
|
|
8
|
+
{ value: COLUMN_PROPERTY.DATE_WEEK, label: 'Week, Year', display: true }
|
|
9
|
+
];
|
|
@@ -2,6 +2,7 @@ import { cloneDeep, isEmpty, _get } from "../../general";
|
|
|
2
2
|
import { IQrveyColumn, IQrveyDataset } from "../../interfaces/Qrvey.Interface";
|
|
3
3
|
import { getUIValues } from "../helpers";
|
|
4
4
|
import { IFSData, IFSScope, IFUFlattenedFilter } from "../interfaces";
|
|
5
|
+
import { adaptDateGroupingProperty } from "./adaptDateGroupingProperty";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Generates a Flattened UI filter structure from Filter Data structure.
|
|
@@ -41,6 +42,7 @@ function FD21ToFlatUI(scopes: IFSScope[] = [], datasetsInfo: IQrveyDataset[] = [
|
|
|
41
42
|
let columnInfo: IQrveyColumn;
|
|
42
43
|
if (!isEmpty(datasetInfo)) columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
43
44
|
const info = !isEmpty(filter.extras.info) ? { icon: filter.extras.info.icon, label: filter.extras.info.label } : undefined;
|
|
45
|
+
const property = adaptDateGroupingProperty(filter.property);
|
|
44
46
|
|
|
45
47
|
const uFilter: IFUFlattenedFilter = {
|
|
46
48
|
collapsed: filter.collapsed,
|
|
@@ -88,7 +90,7 @@ function FD21ToFlatUI(scopes: IFSScope[] = [], datasetsInfo: IQrveyDataset[] = [
|
|
|
88
90
|
lookupDisplayIndex: filter.lookupDisplayIndex,
|
|
89
91
|
nullValues: filter.nullValues,
|
|
90
92
|
operator: filter.operator,
|
|
91
|
-
property:
|
|
93
|
+
property: property,
|
|
92
94
|
uiValues: getUIValues(filter),
|
|
93
95
|
validator: filter.validator,
|
|
94
96
|
values: filter.values,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { adaptDateGroupingProperty } from ".";
|
|
1
2
|
import { cloneDeep, isEmpty, _get } from "../../general";
|
|
2
3
|
import { IQrveyColumn, IQrveyDataset } from "../../interfaces";
|
|
3
4
|
import { FILTER_SECTION, FILTER_STRUCTURE_VERSION } from "../constants";
|
|
@@ -51,6 +52,8 @@ import { IFSData, IFSection, IFSScope, IFUData, IFUScope } from "../interfaces";
|
|
|
51
52
|
filters: dataset.filters.map(filter => {
|
|
52
53
|
let columnInfo: IQrveyColumn;
|
|
53
54
|
if (!isEmpty(datasetInfo)) columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
55
|
+
const property = adaptDateGroupingProperty(filter.property);
|
|
56
|
+
|
|
54
57
|
return {
|
|
55
58
|
...filter,
|
|
56
59
|
column: {
|
|
@@ -65,6 +68,7 @@ import { IFSData, IFSection, IFSScope, IFUData, IFUScope } from "../interfaces";
|
|
|
65
68
|
qrveyid: filter.column.qrveyid,
|
|
66
69
|
type: columnInfo?.type || filter.column.type,
|
|
67
70
|
},
|
|
71
|
+
property,
|
|
68
72
|
uiValues: getUIValues(filter),
|
|
69
73
|
};
|
|
70
74
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { adaptDateGroupingProperty } from ".";
|
|
1
2
|
import { cloneDeep, isEmpty } from "../../general";
|
|
2
3
|
import { IQrveyColumn, IQrveyDataset } from "../../interfaces/Qrvey.Interface";
|
|
3
4
|
import { getUIValues } from "../helpers";
|
|
@@ -40,6 +41,7 @@ function UI21ToFlatUI(scopes: IFUScope[] = [], datasetsInfo: IQrveyDataset[] = [
|
|
|
40
41
|
let columnInfo: IQrveyColumn;
|
|
41
42
|
if (!isEmpty(datasetInfo)) columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
42
43
|
const info = !isEmpty(filter.extras.info) ? { icon: filter.extras.info.icon, label: filter.extras.info.label } : undefined;
|
|
44
|
+
const property = adaptDateGroupingProperty(filter.property);
|
|
43
45
|
|
|
44
46
|
const uFilter: IFUFlattenedFilter = {
|
|
45
47
|
collapsed: filter.collapsed,
|
|
@@ -87,7 +89,7 @@ function UI21ToFlatUI(scopes: IFUScope[] = [], datasetsInfo: IQrveyDataset[] = [
|
|
|
87
89
|
lookupDisplayIndex: filter.lookupDisplayIndex,
|
|
88
90
|
nullValues: filter.nullValues,
|
|
89
91
|
operator: filter.operator,
|
|
90
|
-
property
|
|
92
|
+
property,
|
|
91
93
|
uiValues: getUIValues(filter),
|
|
92
94
|
validator: filter.validator,
|
|
93
95
|
values: filter.values,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { adaptDateGroupingProperty } from ".";
|
|
1
2
|
import { cloneDeep, isEmpty } from "../../general";
|
|
2
3
|
import { FILTER_OPERATOR } from "../constants";
|
|
3
4
|
import { getBackendGroupValue, getBackendProperty, getBackendValidator, getBackendValues, getUIValues } from "../helpers";
|
|
@@ -107,6 +108,8 @@ const getFilterDetail = (filter: IFUFilter, scope: IFUScope, dataset: IFUDataset
|
|
|
107
108
|
label: filter.extras.info.label,
|
|
108
109
|
};
|
|
109
110
|
}
|
|
111
|
+
const property = adaptDateGroupingProperty(filter.property);
|
|
112
|
+
|
|
110
113
|
return {
|
|
111
114
|
collapsed: filter.collapsed,
|
|
112
115
|
column: {
|
|
@@ -134,7 +137,7 @@ const getFilterDetail = (filter: IFUFilter, scope: IFUScope, dataset: IFUDataset
|
|
|
134
137
|
lookupDisplayIndex: filter.lookupDisplayIndex,
|
|
135
138
|
nullValues: filter.nullValues,
|
|
136
139
|
operator: filter.operator,
|
|
137
|
-
property
|
|
140
|
+
property,
|
|
138
141
|
scope: scope.scope,
|
|
139
142
|
scopeid: filter.extras.scopeid,
|
|
140
143
|
scopeEnabled: scope.enabled,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IFProperty } from "..";
|
|
2
|
+
import { COLUMN_PROPERTY } from "../..";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* [TODO: For 2022, eliminate this adapter]
|
|
6
|
+
* Get the new property base on the old date grouping properties
|
|
7
|
+
* @param property
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export function adaptDateGroupingProperty(property: IFProperty | any): IFProperty {
|
|
11
|
+
return property === 'p&quarter' ? COLUMN_PROPERTY.DATE_YEAR_QUARTER :
|
|
12
|
+
property === 'p&month' ? COLUMN_PROPERTY.DATE_YEAR_MONTH :
|
|
13
|
+
property === 'p&day' ? COLUMN_PROPERTY.DATE_MONTH_DAY :
|
|
14
|
+
property === 'p&hour' ? COLUMN_PROPERTY.DATE_DAY_HOUR :
|
|
15
|
+
property === 'p&minute' ? COLUMN_PROPERTY.DATE_HOUR_MINUTE :
|
|
16
|
+
property === 'p&second' ? COLUMN_PROPERTY.DATE_MINUTE_SECOND :
|
|
17
|
+
property;
|
|
18
|
+
}
|
|
@@ -13,7 +13,7 @@ import { UIToFD } from "./UIToFD";
|
|
|
13
13
|
* @param datasetsInfo Collection of datasets information. If getUIFilterData is true, the datasetsInfo should be mandatory
|
|
14
14
|
* @returns A new filter data structure v2.1
|
|
15
15
|
*/
|
|
16
|
-
export function adaptFilterData(filterData: IFSData | IFUData | OLD_IFilterData, getUIFilterData =
|
|
16
|
+
export function adaptFilterData(filterData: IFSData | IFUData | OLD_IFilterData, getUIFilterData = true, datasetsInfo: IQrveyDataset[] = []): IFSData | IFUData {
|
|
17
17
|
if (isEmpty(filterData)) return;
|
|
18
18
|
filterData = cloneDeep(filterData);
|
|
19
19
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { adaptDateGroupingProperty } from ".";
|
|
1
2
|
import { isEmpty } from "../../general";
|
|
2
3
|
import { FILTER_SECTION, FILTER_STRUCTURE_VERSION } from "../constants";
|
|
3
4
|
import { IFSData, IFSDataset, IFSection, IFSFilter, IFSScope, IFUFlattenedFilter } from "../interfaces";
|
|
@@ -83,6 +84,8 @@ function buildDataset(uFilter: IFUFlattenedFilter): IFSDataset {
|
|
|
83
84
|
*/
|
|
84
85
|
function buildFilter(uFilter: IFUFlattenedFilter): IFSFilter {
|
|
85
86
|
const info = !isEmpty(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
|
|
87
|
+
const property = adaptDateGroupingProperty(uFilter.property);
|
|
88
|
+
|
|
86
89
|
return {
|
|
87
90
|
collapsed: uFilter.collapsed,
|
|
88
91
|
column: {
|
|
@@ -109,7 +112,7 @@ function buildFilter(uFilter: IFUFlattenedFilter): IFSFilter {
|
|
|
109
112
|
lookupDisplayIndex: uFilter.lookupDisplayIndex,
|
|
110
113
|
nullValues: uFilter.nullValues,
|
|
111
114
|
operator: uFilter.operator,
|
|
112
|
-
property
|
|
115
|
+
property,
|
|
113
116
|
validator: uFilter.validator,
|
|
114
117
|
values: uFilter.values,
|
|
115
118
|
};
|
|
@@ -185,10 +185,8 @@ function getGroupValue(props: OLD_IFilterDetail): IFProperty {
|
|
|
185
185
|
|
|
186
186
|
function getProperty(props: OLD_IFilterDetail) {
|
|
187
187
|
if (isEmpty(props.column.aggregate)) {
|
|
188
|
-
if (isNullValidator(props.validator)) {
|
|
188
|
+
if (isNullValidator(props.validator) || isDateColumn(props.column as any)) {
|
|
189
189
|
return undefined;
|
|
190
|
-
} else if (isDateColumn(props.column as any)) {
|
|
191
|
-
return arePropertiesDateP(props.column as any, props.property) ? props.property?.split('p&')[1] as IFProperty : undefined;
|
|
192
190
|
} else if (props.column.type === COLUMN.EXPRESSION && props.property != null) {
|
|
193
191
|
return undefined;
|
|
194
192
|
} else if (props.column.type === COLUMN.LOOKUP && props.property === COLUMN_PROPERTY.LOOKUP_DISPLAY && props.lookupDisplayIndex != null) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { adaptDateGroupingProperty } from ".";
|
|
1
2
|
import { isEmpty, getLastIndexFromArray } from "../../general";
|
|
2
3
|
import { FILTER_SECTION, FILTER_STRUCTURE_VERSION } from "../constants";
|
|
3
4
|
import { getUIValues } from "../helpers";
|
|
@@ -89,6 +90,8 @@ function buildDataset(uFilter: IFUFlattenedFilter): IFUDataset {
|
|
|
89
90
|
*/
|
|
90
91
|
function buildFilter(uFilter: IFUFlattenedFilter): IFUFilter {
|
|
91
92
|
const info = !isEmpty(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
|
|
93
|
+
const property = adaptDateGroupingProperty(uFilter.property);
|
|
94
|
+
|
|
92
95
|
return {
|
|
93
96
|
collapsed: uFilter.collapsed,
|
|
94
97
|
column: {
|
|
@@ -122,7 +125,7 @@ function buildFilter(uFilter: IFUFlattenedFilter): IFUFilter {
|
|
|
122
125
|
lookupDisplayIndex: uFilter.lookupDisplayIndex,
|
|
123
126
|
nullValues: uFilter.nullValues,
|
|
124
127
|
operator: uFilter.operator,
|
|
125
|
-
property
|
|
128
|
+
property,
|
|
126
129
|
uiValues: getUIValues(uFilter),
|
|
127
130
|
validator: uFilter.validator,
|
|
128
131
|
values: uFilter.values,
|