@wavemaker/variables 12.0.0-next.141218 → 12.0.0-next.141221
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/dist/es2015/index.d.ts +14 -0
- package/dist/es2015/src/constants/variables.constants.d.ts +370 -0
- package/dist/es2015/src/factory/variable-manager.factory.d.ts +4 -0
- package/dist/es2015/src/model/variable/api-aware-variable.d.ts +1 -0
- package/dist/es2015/src/types/date-formatter.d.ts +1 -0
- package/dist/es2015/src/types/http-client.service.d.ts +1 -0
- package/dist/es2015/src/types/types.d.ts +6 -0
- package/dist/es2015/src/util/dataset-util.d.ts +29 -0
- package/dist/es2015/src/util/file-upload.util.d.ts +11 -0
- package/dist/es2015/src/util/notify-promise.d.ts +1 -0
- package/dist/es2015/src/util/oAuth.utils.d.ts +3 -0
- package/dist/es2015/src/util/variable/live-variable.http.utils.d.ts +21 -0
- package/dist/es2015/src/util/variable/live-variable.utils.d.ts +79 -0
- package/dist/es2015/src/util/variable/pagination.utils.d.ts +83 -0
- package/dist/es2015/src/util/variable/service-variable.utils.d.ts +18 -0
- package/dist/es2015/src/util/variable/variables.utils.d.ts +29 -0
- package/dist/es2015/webpack.config.d.ts +21 -0
- package/npm-shrinkwrap.json +2077 -0
- package/package-lock.json +2077 -0
- {variables → package}/package.json +4 -3
- package/scripts/build.d.ts +1 -0
- {variables → package}/scripts/build.js +52 -15
- package/scripts/build.js.map +1 -0
- package/src/manager/action/timer-action.manager.js.map +1 -0
- {variables → package}/src/manager/variable/base-variable.manager.js +2 -2
- package/src/manager/variable/base-variable.manager.js.map +1 -0
- {variables → package}/src/manager/variable/crud-variable.manager.js +16 -16
- package/src/manager/variable/crud-variable.manager.js.map +1 -0
- {variables → package}/src/manager/variable/live-variable.manager.js +50 -50
- package/src/manager/variable/live-variable.manager.js.map +1 -0
- {variables → package}/src/manager/variable/model-variable.manager.js +12 -12
- package/src/manager/variable/model-variable.manager.js.map +1 -0
- {variables → package}/src/manager/variable/service-variable.manager.js +40 -40
- package/src/manager/variable/service-variable.manager.js.map +1 -0
- package/src/model/action/timer-action.js.map +1 -0
- {variables → package}/src/model/base-action.d.ts +1 -1
- {variables → package}/src/model/base-action.js +3 -3
- package/src/model/base-action.js.map +1 -0
- {variables → package}/src/model/base-variable.d.ts +1 -1
- {variables → package}/src/model/base-variable.js +16 -16
- package/src/model/base-variable.js.map +1 -0
- {variables → package}/src/model/variable/crud-variable.js +2 -2
- package/src/model/variable/crud-variable.js.map +1 -0
- {variables → package}/src/model/variable/live-variable.js +7 -7
- package/src/model/variable/live-variable.js.map +1 -0
- package/src/model/variable/model-variable.js.map +1 -0
- {variables → package}/src/model/variable/service-variable.js +2 -2
- package/src/model/variable/service-variable.js.map +1 -0
- package/src/types/event-notifier.js.map +1 -0
- {variables → package}/src/util/dataset-util.js +16 -16
- package/src/util/dataset-util.js.map +1 -0
- {variables → package}/src/util/file-upload.util.js +12 -12
- package/src/util/file-upload.util.js.map +1 -0
- package/src/util/inflight-queue.js.map +1 -0
- package/src/util/notify-promise.js.map +1 -0
- {variables → package}/src/util/utils.js +19 -19
- package/src/util/utils.js.map +1 -0
- {variables → package}/src/util/variable/live-variable.http.utils.js +6 -6
- package/src/util/variable/live-variable.http.utils.js.map +1 -0
- {variables → package}/src/util/variable/live-variable.utils.js +84 -83
- package/src/util/variable/live-variable.utils.js.map +1 -0
- {variables → package}/src/util/variable/pagination.utils.js +18 -18
- package/src/util/variable/pagination.utils.js.map +1 -0
- {variables → package}/src/util/variable/service-variable.utils.js +28 -28
- package/src/util/variable/service-variable.utils.js.map +1 -0
- {variables → package}/src/util/variable/variables.utils.js +49 -49
- package/src/util/variable/variables.utils.js.map +1 -0
- package/webpack.config.d.ts +21 -0
- variables/scripts/build.js.map +0 -1
- variables/scripts/update-version.js +0 -27
- variables/scripts/update-version.js.map +0 -1
- variables/src/manager/action/timer-action.manager.js.map +0 -1
- variables/src/manager/variable/base-variable.manager.js.map +0 -1
- variables/src/manager/variable/crud-variable.manager.js.map +0 -1
- variables/src/manager/variable/live-variable.manager.js.map +0 -1
- variables/src/manager/variable/model-variable.manager.js.map +0 -1
- variables/src/manager/variable/service-variable.manager.js.map +0 -1
- variables/src/model/action/timer-action.js.map +0 -1
- variables/src/model/base-action.js.map +0 -1
- variables/src/model/base-variable.js.map +0 -1
- variables/src/model/variable/crud-variable.js.map +0 -1
- variables/src/model/variable/live-variable.js.map +0 -1
- variables/src/model/variable/model-variable.js.map +0 -1
- variables/src/model/variable/service-variable.js.map +0 -1
- variables/src/types/event-notifier.js.map +0 -1
- variables/src/util/dataset-util.js.map +0 -1
- variables/src/util/file-upload.util.js.map +0 -1
- variables/src/util/inflight-queue.js.map +0 -1
- variables/src/util/notify-promise.js.map +0 -1
- variables/src/util/utils.js.map +0 -1
- variables/src/util/variable/live-variable.http.utils.js.map +0 -1
- variables/src/util/variable/live-variable.utils.js.map +0 -1
- variables/src/util/variable/pagination.utils.js.map +0 -1
- variables/src/util/variable/service-variable.utils.js.map +0 -1
- variables/src/util/variable/variables.utils.js.map +0 -1
- variables/webpack.config.d.ts +0 -21
- {variables → package/dist/es2015}/scripts/build.d.ts +0 -0
- /variables/scripts/update-version.d.ts → /package/dist/es2015/src/advanced-options.d.ts +0 -0
- {variables → package}/index.d.ts +0 -0
- {variables → package}/index.js +0 -0
- {variables → package}/index.js.map +0 -0
- {variables → package}/src/advanced-options.d.ts +0 -0
- {variables → package}/src/advanced-options.js +0 -0
- {variables → package}/src/advanced-options.js.map +0 -0
- {variables → package}/src/constants/variables.constants.d.ts +0 -0
- {variables → package}/src/constants/variables.constants.js +0 -0
- {variables → package}/src/constants/variables.constants.js.map +0 -0
- {variables → package}/src/factory/variable-manager.factory.d.ts +0 -0
- {variables → package}/src/factory/variable-manager.factory.js +0 -0
- {variables → package}/src/factory/variable-manager.factory.js.map +0 -0
- {variables → package}/src/manager/action/timer-action.manager.d.ts +0 -0
- {variables → package}/src/manager/action/timer-action.manager.js +0 -0
- {variables → package}/src/manager/variable/base-variable.manager.d.ts +0 -0
- {variables → package}/src/manager/variable/crud-variable.manager.d.ts +0 -0
- {variables → package}/src/manager/variable/live-variable.manager.d.ts +0 -0
- {variables → package}/src/manager/variable/model-variable.manager.d.ts +0 -0
- {variables → package}/src/manager/variable/service-variable.manager.d.ts +0 -0
- {variables → package}/src/model/action/timer-action.d.ts +0 -0
- {variables → package}/src/model/action/timer-action.js +0 -0
- {variables → package}/src/model/crud-create.d.ts +0 -0
- {variables → package}/src/model/crud-create.js +0 -0
- {variables → package}/src/model/crud-create.js.map +0 -0
- {variables → package}/src/model/crud-delete.d.ts +0 -0
- {variables → package}/src/model/crud-delete.js +0 -0
- {variables → package}/src/model/crud-delete.js.map +0 -0
- {variables → package}/src/model/crud-list.d.ts +0 -0
- {variables → package}/src/model/crud-list.js +0 -0
- {variables → package}/src/model/crud-list.js.map +0 -0
- {variables → package}/src/model/crud-update.d.ts +0 -0
- {variables → package}/src/model/crud-update.js +0 -0
- {variables → package}/src/model/crud-update.js.map +0 -0
- {variables → package}/src/model/variable/api-aware-variable.d.ts +0 -0
- {variables → package}/src/model/variable/api-aware-variable.js +0 -0
- {variables → package}/src/model/variable/api-aware-variable.js.map +0 -0
- {variables → package}/src/model/variable/crud-variable.d.ts +0 -0
- {variables → package}/src/model/variable/live-variable.d.ts +0 -0
- {variables → package}/src/model/variable/model-variable.d.ts +0 -0
- {variables → package}/src/model/variable/model-variable.js +0 -0
- {variables → package}/src/model/variable/service-variable.d.ts +0 -0
- {variables → package}/src/types/date-formatter.d.ts +0 -0
- {variables → package}/src/types/date-formatter.js +0 -0
- {variables → package}/src/types/date-formatter.js.map +0 -0
- {variables → package}/src/types/event-notifier.d.ts +0 -0
- {variables → package}/src/types/event-notifier.js +0 -0
- {variables → package}/src/types/http-client.service.d.ts +0 -0
- {variables → package}/src/types/http-client.service.js +0 -0
- {variables → package}/src/types/http-client.service.js.map +0 -0
- {variables → package}/src/types/types.d.ts +0 -0
- {variables → package}/src/types/types.js +0 -0
- {variables → package}/src/types/types.js.map +0 -0
- {variables → package}/src/util/dataset-util.d.ts +0 -0
- {variables → package}/src/util/file-upload.util.d.ts +0 -0
- {variables → package}/src/util/inflight-queue.d.ts +0 -0
- {variables → package}/src/util/inflight-queue.js +0 -0
- {variables → package}/src/util/notify-promise.d.ts +0 -0
- {variables → package}/src/util/notify-promise.js +0 -0
- {variables → package}/src/util/oAuth.utils.d.ts +0 -0
- {variables → package}/src/util/oAuth.utils.js +0 -0
- {variables → package}/src/util/oAuth.utils.js.map +0 -0
- {variables → package}/src/util/utils.d.ts +0 -0
- {variables → package}/src/util/variable/live-variable.http.utils.d.ts +0 -0
- {variables → package}/src/util/variable/live-variable.utils.d.ts +0 -0
- {variables → package}/src/util/variable/pagination.utils.d.ts +0 -0
- {variables → package}/src/util/variable/service-variable.utils.d.ts +0 -0
- {variables → package}/src/util/variable/variables.utils.d.ts +0 -0
- {variables → package}/webpack.config.js +0 -0
- {variables → package}/webpack.config.js.map +0 -0
|
@@ -3,7 +3,7 @@ import { $rootScope, DB_CONSTANTS, SWAGGER_CONSTANTS } from '../../constants/var
|
|
|
3
3
|
import { getEvaluatedOrderBy, formatDate } from './variables.utils';
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
import moment from 'moment';
|
|
6
|
-
import
|
|
6
|
+
import { forEach, find, get, includes, map, filter, trim, isEmpty, endsWith, join, toLower, isObject, isArray, toUpper, reduce, isString, each, isNil, remove, isNull, some, indexOf, clone } from 'lodash-es';
|
|
7
7
|
var LiveVariableUtils = /** @class */ (function () {
|
|
8
8
|
function LiveVariableUtils() {
|
|
9
9
|
}
|
|
@@ -17,7 +17,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
17
17
|
LiveVariableUtils.getCompositeIDURL = function (primaryKeysData) {
|
|
18
18
|
var compositeId = '';
|
|
19
19
|
// Loop over the 'compositeKeysData' and construct the 'compositeId'.
|
|
20
|
-
|
|
20
|
+
forEach(primaryKeysData, function (paramValue, paramName) {
|
|
21
21
|
compositeId += paramName + '=' + encodeURIComponent(paramValue) + '&';
|
|
22
22
|
});
|
|
23
23
|
compositeId = compositeId.slice(0, -1);
|
|
@@ -25,7 +25,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
25
25
|
};
|
|
26
26
|
// Check if table has blob column
|
|
27
27
|
LiveVariableUtils.hasBlob = function (variable) {
|
|
28
|
-
return
|
|
28
|
+
return find(get(variable, ['propertiesMap', 'columns']), { 'type': 'blob' });
|
|
29
29
|
};
|
|
30
30
|
LiveVariableUtils.getPrimaryKey = function (variable) {
|
|
31
31
|
if (!variable.propertiesMap) {
|
|
@@ -37,12 +37,12 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
37
37
|
/*Old projects do not have primary fields. Get primary key from the columns*/
|
|
38
38
|
var primaryKey = [];
|
|
39
39
|
/*Loop through the propertiesMap and get the primary key column.*/
|
|
40
|
-
|
|
40
|
+
forEach(variable.propertiesMap.columns, function (index, column) {
|
|
41
41
|
if (column.isPrimaryKey) {
|
|
42
|
-
if (column.isRelated && (!
|
|
42
|
+
if (column.isRelated && (!includes(column.relatedFieldName, primaryKey))) {
|
|
43
43
|
primaryKey.push(column.relatedFieldName);
|
|
44
44
|
}
|
|
45
|
-
else if (!
|
|
45
|
+
else if (!includes(column.fieldName, primaryKey)) {
|
|
46
46
|
primaryKey.push(column.fieldName);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -54,21 +54,21 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
54
54
|
if (!responseData) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
var blobCols =
|
|
57
|
+
var blobCols = map(filter(variable.propertiesMap.columns, { 'type': 'blob' }), 'fieldName'), deployedUrl = trim($rootScope.project.deployedUrl);
|
|
58
58
|
var href = '', primaryKeys;
|
|
59
|
-
if (
|
|
59
|
+
if (isEmpty(blobCols)) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
if (hasCordova()) {
|
|
63
|
-
href +=
|
|
63
|
+
href += endsWith(deployedUrl, '/') ? deployedUrl : deployedUrl + '/';
|
|
64
64
|
}
|
|
65
65
|
href += ((variable._prefabName !== '' && variable._prefabName !== undefined) ? 'prefabs/' + variable._prefabName : 'services') + '/' + variable.liveSource + '/' + variable.type + '/';
|
|
66
66
|
primaryKeys = variable.propertiesMap.primaryFields || variable.propertiesMap.primaryKeys;
|
|
67
|
-
|
|
67
|
+
forEach(responseData, function (data) {
|
|
68
68
|
if (data) {
|
|
69
|
-
|
|
69
|
+
forEach(blobCols, function (col) {
|
|
70
70
|
var compositeKeysData = {};
|
|
71
|
-
if (data[col] === null || !
|
|
71
|
+
if (data[col] === null || !isEmpty(trim(data[col]))) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
if (LiveVariableUtils.isCompositeKey(primaryKeys)) {
|
|
@@ -78,7 +78,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
78
78
|
data[col] = href + 'composite-id/content/' + col + '?' + LiveVariableUtils.getCompositeIDURL(compositeKeysData);
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
data[col] = href + data[
|
|
81
|
+
data[col] = href + data[join(primaryKeys)] + '/content/' + col;
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
}
|
|
@@ -87,26 +87,26 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
87
87
|
LiveVariableUtils.getHibernateOrSqlType = function (variable, fieldName, type, entityName) {
|
|
88
88
|
var columns = variable.propertiesMap.columns;
|
|
89
89
|
var column, relatedCols, relatedCol, columnParts;
|
|
90
|
-
if (
|
|
90
|
+
if (includes(fieldName, '.')) {
|
|
91
91
|
columnParts = fieldName.split('.');
|
|
92
92
|
if (columnParts.length > 2) {
|
|
93
93
|
return undefined;
|
|
94
94
|
}
|
|
95
|
-
column =
|
|
95
|
+
column = find(columns, function (col) {
|
|
96
96
|
return col.fieldName === columnParts[0];
|
|
97
97
|
});
|
|
98
98
|
relatedCols = column && column.columns;
|
|
99
|
-
relatedCol =
|
|
99
|
+
relatedCol = find(relatedCols, function (col) {
|
|
100
100
|
return col.fieldName === columnParts[1];
|
|
101
101
|
});
|
|
102
102
|
return relatedCol && relatedCol[type];
|
|
103
103
|
}
|
|
104
|
-
column =
|
|
104
|
+
column = find(columns, function (col) {
|
|
105
105
|
return col.fieldName === fieldName || col.relatedColumnName === fieldName;
|
|
106
106
|
});
|
|
107
107
|
if (!column && entityName) {
|
|
108
|
-
var entity =
|
|
109
|
-
column =
|
|
108
|
+
var entity = find(columns, function (col) { return col.relatedEntityName === entityName; });
|
|
109
|
+
column = find(entity.columns, function (col) {
|
|
110
110
|
return col.fieldName === fieldName || col.relatedColumnName === fieldName;
|
|
111
111
|
});
|
|
112
112
|
}
|
|
@@ -132,10 +132,10 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
132
132
|
return true;
|
|
133
133
|
};
|
|
134
134
|
LiveVariableUtils.isStringType = function (type) {
|
|
135
|
-
return
|
|
135
|
+
return includes(['text', 'string'], toLower(type));
|
|
136
136
|
};
|
|
137
137
|
LiveVariableUtils.getSQLFieldType = function (variable, options) {
|
|
138
|
-
if (
|
|
138
|
+
if (includes(['timestamp', 'datetime', 'date'], options.type)) {
|
|
139
139
|
return options.type;
|
|
140
140
|
}
|
|
141
141
|
return LiveVariableUtils.getSqlType(variable, options.fieldName) || options.type;
|
|
@@ -150,7 +150,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
150
150
|
return attrName;
|
|
151
151
|
};
|
|
152
152
|
LiveVariableUtils.getFilterCondition = function (filterCondition) {
|
|
153
|
-
if (
|
|
153
|
+
if (includes(DB_CONSTANTS.DATABASE_RANGE_MATCH_MODES, filterCondition)) {
|
|
154
154
|
return filterCondition;
|
|
155
155
|
}
|
|
156
156
|
return DB_CONSTANTS.DATABASE_MATCH_MODES['exact'];
|
|
@@ -161,16 +161,16 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
161
161
|
filterCondition = matchModes[fieldOptions.matchMode] || matchModes[fieldOptions.filterCondition] || fieldOptions.filterCondition;
|
|
162
162
|
fieldOptions.type = fieldType;
|
|
163
163
|
/* if the field value is an object(complex type), loop over each field inside and push only first level fields */
|
|
164
|
-
if (
|
|
164
|
+
if (isObject(fieldValue) && !isArray(fieldValue)) {
|
|
165
165
|
var firstLevelValues_1 = [];
|
|
166
|
-
|
|
167
|
-
if (subFieldValue && !
|
|
166
|
+
forEach(fieldValue, function (subFieldValue, subFieldName) {
|
|
167
|
+
if (subFieldValue && !isObject(subFieldValue)) {
|
|
168
168
|
firstLevelValues_1.push(fieldName + '.' + subFieldName + '=' + subFieldValue);
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
return firstLevelValues_1;
|
|
172
172
|
}
|
|
173
|
-
if (
|
|
173
|
+
if (includes(DB_CONSTANTS.DATABASE_EMPTY_MATCH_MODES, filterCondition)) {
|
|
174
174
|
attributeName = LiveVariableUtils.getAttributeName(variable, fieldName);
|
|
175
175
|
// For non string types empty match modes are not supported, so convert them to null match modes.
|
|
176
176
|
if (fieldType && !LiveVariableUtils.isStringType(fieldType)) {
|
|
@@ -179,7 +179,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
179
179
|
filterOption = {
|
|
180
180
|
'attributeName': attributeName,
|
|
181
181
|
'attributeValue': '',
|
|
182
|
-
'attributeType':
|
|
182
|
+
'attributeType': toUpper(fieldType),
|
|
183
183
|
'filterCondition': filterCondition,
|
|
184
184
|
'required': fieldRequired
|
|
185
185
|
};
|
|
@@ -193,9 +193,9 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
193
193
|
if (fieldType) {
|
|
194
194
|
switch (fieldType) {
|
|
195
195
|
case 'integer':
|
|
196
|
-
fieldValue =
|
|
196
|
+
fieldValue = isArray(fieldValue) ? reduce(fieldValue, function (result, value) {
|
|
197
197
|
value = parseInt(value, 10);
|
|
198
|
-
if (!
|
|
198
|
+
if (!isNaN(value)) {
|
|
199
199
|
result.push(value);
|
|
200
200
|
}
|
|
201
201
|
return result;
|
|
@@ -210,8 +210,8 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
210
210
|
break;
|
|
211
211
|
case 'text':
|
|
212
212
|
case 'string':
|
|
213
|
-
if (
|
|
214
|
-
filterCondition =
|
|
213
|
+
if (isArray(fieldValue)) {
|
|
214
|
+
filterCondition = includes([matchModes['in'], matchModes['notin']], filterCondition) ? filterCondition : matchModes['exact'];
|
|
215
215
|
}
|
|
216
216
|
else {
|
|
217
217
|
filterCondition = filterCondition || matchModes['anywhereignorecase'];
|
|
@@ -223,13 +223,13 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
else {
|
|
226
|
-
filterCondition =
|
|
226
|
+
filterCondition = isString(fieldValue) ? matchModes['anywhereignorecase'] : matchModes['exact'];
|
|
227
227
|
}
|
|
228
228
|
attributeName = LiveVariableUtils.getAttributeName(variable, fieldName);
|
|
229
229
|
filterOption = {
|
|
230
230
|
'attributeName': attributeName,
|
|
231
231
|
'attributeValue': fieldValue,
|
|
232
|
-
'attributeType':
|
|
232
|
+
'attributeType': toUpper(fieldType),
|
|
233
233
|
'filterCondition': filterCondition,
|
|
234
234
|
'required': fieldRequired
|
|
235
235
|
};
|
|
@@ -241,10 +241,10 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
241
241
|
};
|
|
242
242
|
LiveVariableUtils.getFilterOptions = function (variable, filterFields, options) {
|
|
243
243
|
var filterOptions = [];
|
|
244
|
-
|
|
244
|
+
each(filterFields, function (fieldOptions) {
|
|
245
245
|
var filterOption = LiveVariableUtils.getFilterOption(variable, fieldOptions, options);
|
|
246
|
-
if (!
|
|
247
|
-
if (
|
|
246
|
+
if (!isNil(filterOption)) {
|
|
247
|
+
if (isArray(filterOption)) {
|
|
248
248
|
filterOptions = filterOptions.concat(filterOption);
|
|
249
249
|
}
|
|
250
250
|
else {
|
|
@@ -257,17 +257,18 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
257
257
|
// Wrap the field name and value in lower() in ignore case scenario
|
|
258
258
|
// TODO: Change the function name to represent the added functionality of identifiers for datetime, timestamp and float types. Previously only lower was warapped.
|
|
259
259
|
LiveVariableUtils.wrapInLowerCase = function (value, options, ignoreCase, isField) {
|
|
260
|
-
var type =
|
|
260
|
+
var type = toLower(options.attributeType);
|
|
261
261
|
// If ignore case is true and type is string/ text and match mode is string type, wrap in lower()
|
|
262
|
-
if (ignoreCase && (!type || LiveVariableUtils.isStringType(type)) &&
|
|
262
|
+
if (ignoreCase && (!type || LiveVariableUtils.isStringType(type)) && includes(DB_CONSTANTS.DATABASE_STRING_MODES, options.filterCondition)) {
|
|
263
263
|
return 'lower(' + value + ')';
|
|
264
264
|
}
|
|
265
265
|
return value;
|
|
266
266
|
};
|
|
267
267
|
LiveVariableUtils.encodeAndAddQuotes = function (value, type, skipEncode) {
|
|
268
268
|
var encodedValue = skipEncode ? value : encodeURIComponent(value);
|
|
269
|
-
type =
|
|
270
|
-
|
|
269
|
+
type = toLower(type);
|
|
270
|
+
//@ts-ignore
|
|
271
|
+
encodedValue = replace(encodedValue, /'/g, '\'\'');
|
|
271
272
|
// For number types, don't wrap the value in quotes
|
|
272
273
|
if ((isNumberType(type) && type !== 'float')) {
|
|
273
274
|
return encodedValue;
|
|
@@ -277,7 +278,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
277
278
|
LiveVariableUtils.getParamValue = function (value, options, ignoreCase, skipEncode) {
|
|
278
279
|
var param;
|
|
279
280
|
var filterCondition = options.filterCondition, dbModes = DB_CONSTANTS.DATABASE_MATCH_MODES, type = options.attributeType;
|
|
280
|
-
if (
|
|
281
|
+
if (includes(DB_CONSTANTS.DATABASE_EMPTY_MATCH_MODES, filterCondition)) {
|
|
281
282
|
// For empty matchmodes, no value is required
|
|
282
283
|
return '';
|
|
283
284
|
}
|
|
@@ -300,13 +301,13 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
300
301
|
param = LiveVariableUtils.wrapInLowerCase(param, options, ignoreCase);
|
|
301
302
|
break;
|
|
302
303
|
case dbModes.between:
|
|
303
|
-
param =
|
|
304
|
+
param = join(map(value, function (val) {
|
|
304
305
|
return LiveVariableUtils.wrapInLowerCase(LiveVariableUtils.encodeAndAddQuotes(val, type, skipEncode), options, ignoreCase);
|
|
305
306
|
}), ' and ');
|
|
306
307
|
break;
|
|
307
308
|
case dbModes.in:
|
|
308
309
|
case dbModes.notin:
|
|
309
|
-
param =
|
|
310
|
+
param = join(map(value, function (val) {
|
|
310
311
|
return LiveVariableUtils.wrapInLowerCase(LiveVariableUtils.encodeAndAddQuotes(val, type, skipEncode), options, ignoreCase);
|
|
311
312
|
}), ', ');
|
|
312
313
|
param = '(' + param + ')';
|
|
@@ -325,12 +326,12 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
325
326
|
LiveVariableUtils.getSearchQuery = function (filterOptions, operator, ignoreCase, skipEncode) {
|
|
326
327
|
var query;
|
|
327
328
|
var params = [];
|
|
328
|
-
|
|
329
|
-
var value = fieldValue.attributeValue, dbModes = DB_CONSTANTS.DATABASE_MATCH_MODES, isValArray =
|
|
329
|
+
forEach(filterOptions, function (fieldValue) {
|
|
330
|
+
var value = fieldValue.attributeValue, dbModes = DB_CONSTANTS.DATABASE_MATCH_MODES, isValArray = isArray(value);
|
|
330
331
|
var fieldName = fieldValue.attributeName, filterCondition = fieldValue.filterCondition, matchModeExpr, paramValue;
|
|
331
332
|
// If value is an empty array, do not generate the query
|
|
332
333
|
// If values is NaN and number type, do not generate query for this field
|
|
333
|
-
if ((isValArray &&
|
|
334
|
+
if ((isValArray && isEmpty(value)) || (!isValArray && isNaN(value) && (isNumberType(fieldValue.attributeType))) || (!isValArray && (isNaN(value) && !moment(value).isValid() && isDateTimeType(toLower(fieldValue.attributeType))))) {
|
|
334
335
|
return;
|
|
335
336
|
}
|
|
336
337
|
if (isValArray) {
|
|
@@ -343,7 +344,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
343
344
|
fieldName = LiveVariableUtils.wrapInLowerCase(fieldName, fieldValue, ignoreCase);
|
|
344
345
|
params.push(replace(matchModeExpr, [fieldName, paramValue]));
|
|
345
346
|
});
|
|
346
|
-
query =
|
|
347
|
+
query = join(params, operator); // empty space added intentionally around OR
|
|
347
348
|
return query;
|
|
348
349
|
};
|
|
349
350
|
/**
|
|
@@ -353,20 +354,20 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
353
354
|
* @param options options
|
|
354
355
|
*/
|
|
355
356
|
LiveVariableUtils.processFilterFields = function (rules, variable, options) {
|
|
356
|
-
|
|
357
|
-
return rule && (
|
|
357
|
+
remove(rules, function (rule) {
|
|
358
|
+
return rule && (isString(rule.value) && rule.value.indexOf('bind:') === 0 || (rule.matchMode === 'between' ? (isString(rule.secondvalue) && rule.secondvalue.indexOf('bind:') === 0) : false));
|
|
358
359
|
});
|
|
359
|
-
|
|
360
|
+
forEach(rules, function (rule, index) {
|
|
360
361
|
if (rule) {
|
|
361
362
|
if (rule.rules) {
|
|
362
363
|
LiveVariableUtils.processFilterFields(rule.rules, variable, options);
|
|
363
364
|
}
|
|
364
365
|
else {
|
|
365
|
-
if (!
|
|
366
|
+
if (!isNull(rule.target)) {
|
|
366
367
|
var value = rule.matchMode.toLowerCase() === DB_CONSTANTS.DATABASE_MATCH_MODES.between.toLowerCase()
|
|
367
|
-
? (
|
|
368
|
+
? (isArray(rule.value) ? rule.value : [rule.value, rule.secondvalue])
|
|
368
369
|
: (rule.matchMode.toLowerCase() === DB_CONSTANTS.DATABASE_MATCH_MODES.in.toLowerCase() || rule.matchMode.toLowerCase() === DB_CONSTANTS.DATABASE_MATCH_MODES.notin.toLowerCase()
|
|
369
|
-
? (
|
|
370
|
+
? (isArray(rule.value) ? rule.value : (rule.value ? rule.value.split(',').map(function (val) { return val.trim(); }) : ''))
|
|
370
371
|
: rule.value);
|
|
371
372
|
rules[index] = LiveVariableUtils.getFilterOption(variable, {
|
|
372
373
|
'fieldName': rule.target,
|
|
@@ -386,14 +387,14 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
386
387
|
var paramValue;
|
|
387
388
|
var filterCondition = fieldValue.filterCondition;
|
|
388
389
|
var value = fieldValue.attributeValue;
|
|
389
|
-
var isValArray =
|
|
390
|
+
var isValArray = isArray(value);
|
|
390
391
|
var dbModes = DB_CONSTANTS.DATABASE_MATCH_MODES;
|
|
391
392
|
// If value is an empty array, do not generate the query
|
|
392
393
|
// If values is NaN and number type, do not generate query for this field
|
|
393
|
-
if ((isValArray &&
|
|
394
|
-
(isValArray &&
|
|
394
|
+
if ((isValArray && isEmpty(value)) ||
|
|
395
|
+
(isValArray && some(value, function (val) { return (isNull(val) || isNaN(val) || val === ''); })) ||
|
|
395
396
|
(!isValArray && (isNaN(value) && (isNumberType(fieldValue.attributeType)))) ||
|
|
396
|
-
(!isValArray && (isNaN(value) && !moment(value).isValid() && isDateTimeType(
|
|
397
|
+
(!isValArray && (isNaN(value) && !moment(value).isValid() && isDateTimeType(toLower(fieldValue.attributeType))))) {
|
|
397
398
|
return;
|
|
398
399
|
}
|
|
399
400
|
if (isValArray) {
|
|
@@ -418,17 +419,17 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
418
419
|
*/
|
|
419
420
|
LiveVariableUtils.getIgnoreCase = function (matchMode, ignoreCase) {
|
|
420
421
|
var matchModes = DB_CONSTANTS.DATABASE_MATCH_MODES;
|
|
421
|
-
if (
|
|
422
|
+
if (indexOf([matchModes['anywhere'], matchModes['nowhere'], matchModes['start'], matchModes['end'], matchModes['exact']], matchMode) !== -1) {
|
|
422
423
|
return false;
|
|
423
424
|
}
|
|
424
|
-
if (
|
|
425
|
+
if (indexOf([matchModes['anywhereignorecase'], matchModes['nowhereignorecase'], matchModes['startignorecase'], matchModes['endignorecase'], matchModes['exactignorecase']], matchMode) !== -1) {
|
|
425
426
|
return true;
|
|
426
427
|
}
|
|
427
428
|
return ignoreCase;
|
|
428
429
|
};
|
|
429
430
|
LiveVariableUtils.generateSearchQuery = function (rules, condition, ignoreCase, skipEncode) {
|
|
430
431
|
var params = [];
|
|
431
|
-
|
|
432
|
+
forEach(rules, function (rule) {
|
|
432
433
|
if (rule) {
|
|
433
434
|
if (rule.rules) {
|
|
434
435
|
var query = LiveVariableUtils.generateSearchQuery(rule.rules, rule.condition, ignoreCase, skipEncode);
|
|
@@ -438,13 +439,13 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
438
439
|
}
|
|
439
440
|
else {
|
|
440
441
|
var searchField = LiveVariableUtils.getSearchField(rule, LiveVariableUtils.getIgnoreCase(rule.filterCondition, ignoreCase), skipEncode);
|
|
441
|
-
if (!
|
|
442
|
+
if (!isNil(searchField)) {
|
|
442
443
|
params.push(searchField);
|
|
443
444
|
}
|
|
444
445
|
}
|
|
445
446
|
}
|
|
446
447
|
});
|
|
447
|
-
return
|
|
448
|
+
return join(params, ' ' + condition + ' ');
|
|
448
449
|
};
|
|
449
450
|
LiveVariableUtils.prepareTableOptionsForFilterExps = function (variable, options, clonedFields) {
|
|
450
451
|
if (!isDefined(options.searchWithQuery)) {
|
|
@@ -455,25 +456,25 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
455
456
|
var orderByFields, orderByOptions, query;
|
|
456
457
|
var clonedObj = clonedFields || getClonedObject(variable.filterExpressions);
|
|
457
458
|
// if filterexpression from live filter is present use it to query
|
|
458
|
-
if (options.filterExpr && !
|
|
459
|
+
if (options.filterExpr && !isEmpty(options.filterExpr)) {
|
|
459
460
|
clonedObj = options.filterExpr;
|
|
460
461
|
}
|
|
461
462
|
// merge live filter runtime values
|
|
462
463
|
var filterRules = {};
|
|
463
|
-
if (!
|
|
464
|
+
if (!isEmpty(options.filterFields)) {
|
|
464
465
|
var operator = '';
|
|
465
466
|
for (var field in options.filterFields) {
|
|
466
467
|
operator = options.filterFields[field] && options.filterFields[field]['logicalOp'] || '';
|
|
467
468
|
break;
|
|
468
469
|
}
|
|
469
470
|
filterRules = { 'condition': options.logicalOp || operator || 'AND', 'rules': [] };
|
|
470
|
-
|
|
471
|
+
forEach(options.filterFields, function (filterObj, filterName) {
|
|
471
472
|
if (!filterObj) {
|
|
472
473
|
return;
|
|
473
474
|
}
|
|
474
475
|
var filterCondition = matchModes[filterObj.matchMode] || matchModes[filterObj.filterCondition] || filterObj.filterCondition;
|
|
475
|
-
if (
|
|
476
|
-
(!
|
|
476
|
+
if (includes(DB_CONSTANTS.DATABASE_EMPTY_MATCH_MODES, filterCondition) ||
|
|
477
|
+
(!isNil(filterObj.value) && filterObj.value !== '')) {
|
|
477
478
|
var type = filterObj.type || LiveVariableUtils.getSqlType(variable, filterName, options.entityName);
|
|
478
479
|
var ruleObj = {
|
|
479
480
|
'target': filterName,
|
|
@@ -486,8 +487,8 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
486
487
|
}
|
|
487
488
|
});
|
|
488
489
|
}
|
|
489
|
-
if (!
|
|
490
|
-
if (!
|
|
490
|
+
if (!isEmpty(clonedObj)) {
|
|
491
|
+
if (!isNil(filterRules.rules) && filterRules.rules.length) {
|
|
491
492
|
// combine both the rules using 'AND'
|
|
492
493
|
var tempRules = { 'condition': 'AND', 'rules': [] };
|
|
493
494
|
tempRules.rules.push(getClonedObject(clonedObj));
|
|
@@ -519,8 +520,8 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
519
520
|
var filterOptions = [], orderByFields, orderByOptions, query, optionsQuery;
|
|
520
521
|
clonedFields = clonedFields || variable.filterFields;
|
|
521
522
|
// get the filter fields from the variable
|
|
522
|
-
|
|
523
|
-
if (
|
|
523
|
+
forEach(clonedFields, function (value, key) {
|
|
524
|
+
if (isObject(value) && (!options.filterFields || !options.filterFields[key] || options.filterFields[key].logicalOp === 'AND')) {
|
|
524
525
|
value.fieldName = key;
|
|
525
526
|
if (LiveVariableUtils.isStringType(LiveVariableUtils.getSQLFieldType(variable, value))) {
|
|
526
527
|
value.filterCondition = DB_CONSTANTS.DATABASE_MATCH_MODES[value.matchMode || variable.matchMode];
|
|
@@ -530,7 +531,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
530
531
|
}
|
|
531
532
|
});
|
|
532
533
|
// get the filter fields from the options
|
|
533
|
-
|
|
534
|
+
forEach(options.filterFields, function (value, key) {
|
|
534
535
|
value.fieldName = key;
|
|
535
536
|
value.filterCondition = DB_CONSTANTS.DATABASE_MATCH_MODES[value.matchMode || options.matchMode || variable.matchMode];
|
|
536
537
|
filterFields.push(value);
|
|
@@ -543,9 +544,9 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
543
544
|
*/
|
|
544
545
|
if (options.searchWithQuery && filterOptions.length) {
|
|
545
546
|
// Generate query for variable filter fields. This has AND logical operator
|
|
546
|
-
query = LiveVariableUtils.getSearchQuery(
|
|
547
|
+
query = LiveVariableUtils.getSearchQuery(filter(filterOptions, { 'isVariableFilter': true }), ' AND ', variable.ignoreCase, options.skipEncode);
|
|
547
548
|
// Generate query for option filter fields. This has default logical operator as OR
|
|
548
|
-
optionsQuery = LiveVariableUtils.getSearchQuery(
|
|
549
|
+
optionsQuery = LiveVariableUtils.getSearchQuery(filter(filterOptions, { 'isVariableFilter': undefined }), ' ' + (options.logicalOp || 'AND') + ' ', variable.ignoreCase, options.skipEncode);
|
|
549
550
|
if (optionsQuery) {
|
|
550
551
|
// If both variable and option query are present, merge them with AND
|
|
551
552
|
query = query ? (query + ' AND ( ' + optionsQuery + ' )') : optionsQuery;
|
|
@@ -564,12 +565,12 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
564
565
|
var fieldType, columns, result;
|
|
565
566
|
if (variable.propertiesMap) {
|
|
566
567
|
columns = variable.propertiesMap.columns || [];
|
|
567
|
-
result =
|
|
568
|
+
result = find(columns, function (obj) {
|
|
568
569
|
return obj.fieldName === fieldName;
|
|
569
570
|
});
|
|
570
571
|
// if related field name passed, get its type from columns inside the current field
|
|
571
572
|
if (relatedField && result) {
|
|
572
|
-
result =
|
|
573
|
+
result = find(result.columns, function (obj) {
|
|
573
574
|
return obj.fieldName === relatedField;
|
|
574
575
|
});
|
|
575
576
|
}
|
|
@@ -580,12 +581,12 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
580
581
|
// Prepare formData for blob columns
|
|
581
582
|
LiveVariableUtils.prepareFormData = function (variableDetails, rowObject) {
|
|
582
583
|
var formData = new FormData();
|
|
583
|
-
formData.rowData =
|
|
584
|
-
|
|
584
|
+
formData.rowData = clone(rowObject);
|
|
585
|
+
forEach(rowObject, function (colValue, colName) {
|
|
585
586
|
if (LiveVariableUtils.getFieldType(colName, variableDetails) === 'blob') {
|
|
586
|
-
if (
|
|
587
|
-
if (
|
|
588
|
-
|
|
587
|
+
if (isObject(colValue)) {
|
|
588
|
+
if (isArray(colValue)) {
|
|
589
|
+
forEach(colValue, function (fileObject) {
|
|
589
590
|
formData.append(colName, fileObject, fileObject.name);
|
|
590
591
|
});
|
|
591
592
|
}
|
|
@@ -603,7 +604,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
603
604
|
};
|
|
604
605
|
LiveVariableUtils.traverseFilterExpressions = function (filterExpressions, traverseCallbackFn) {
|
|
605
606
|
if (filterExpressions && filterExpressions.rules) {
|
|
606
|
-
|
|
607
|
+
forEach(filterExpressions.rules, function (filExpObj, i) {
|
|
607
608
|
if (filExpObj.rules) {
|
|
608
609
|
LiveVariableUtils.traverseFilterExpressions(filExpObj, traverseCallbackFn);
|
|
609
610
|
}
|
|
@@ -626,7 +627,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
626
627
|
var traverseCallbackFn = function (parentFilExpObj, filExpObj) {
|
|
627
628
|
if (filExpObj
|
|
628
629
|
&& filExpObj.required
|
|
629
|
-
&& ((
|
|
630
|
+
&& ((indexOf(['null', 'isnotnull', 'empty', 'isnotempty', 'nullorempty'], filExpObj.matchMode) === -1) && filExpObj.value === '')) {
|
|
630
631
|
isRequiredFieldAbsent = true;
|
|
631
632
|
return false;
|
|
632
633
|
}
|