@wavemaker/variables 12.0.0-next.45752 → 12.0.0-next.47809
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/npm-shrinkwrap.json +1993 -0
- package/package-lock.json +1993 -0
- {variables → package}/package.json +4 -3
- {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 +61 -44
- 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.d.ts +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.d.ts +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 -84
- package/src/util/variable/live-variable.utils.js.map +1 -0
- {variables → package}/src/util/variable/pagination.utils.js +38 -20
- package/src/util/variable/pagination.utils.js.map +1 -0
- {variables → package}/src/util/variable/service-variable.utils.d.ts +1 -0
- {variables → package}/src/util/variable/service-variable.utils.js +31 -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.d.ts +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}/index.d.ts +0 -0
- {variables → package}/index.js +0 -0
- {variables → package}/index.js.map +0 -0
- {variables → package}/scripts/build.d.ts +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/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/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/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, replace as _replace, isNaN as _isNaN } 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,17 @@ 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
|
-
encodedValue =
|
|
269
|
+
type = toLower(type);
|
|
270
|
+
encodedValue = _replace(encodedValue, /'/g, '\'\'');
|
|
271
271
|
// For number types, don't wrap the value in quotes
|
|
272
272
|
if ((isNumberType(type) && type !== 'float')) {
|
|
273
273
|
return encodedValue;
|
|
@@ -277,7 +277,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
277
277
|
LiveVariableUtils.getParamValue = function (value, options, ignoreCase, skipEncode) {
|
|
278
278
|
var param;
|
|
279
279
|
var filterCondition = options.filterCondition, dbModes = DB_CONSTANTS.DATABASE_MATCH_MODES, type = options.attributeType;
|
|
280
|
-
if (
|
|
280
|
+
if (includes(DB_CONSTANTS.DATABASE_EMPTY_MATCH_MODES, filterCondition)) {
|
|
281
281
|
// For empty matchmodes, no value is required
|
|
282
282
|
return '';
|
|
283
283
|
}
|
|
@@ -300,13 +300,13 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
300
300
|
param = LiveVariableUtils.wrapInLowerCase(param, options, ignoreCase);
|
|
301
301
|
break;
|
|
302
302
|
case dbModes.between:
|
|
303
|
-
param =
|
|
303
|
+
param = join(map(value, function (val) {
|
|
304
304
|
return LiveVariableUtils.wrapInLowerCase(LiveVariableUtils.encodeAndAddQuotes(val, type, skipEncode), options, ignoreCase);
|
|
305
305
|
}), ' and ');
|
|
306
306
|
break;
|
|
307
307
|
case dbModes.in:
|
|
308
308
|
case dbModes.notin:
|
|
309
|
-
param =
|
|
309
|
+
param = join(map(value, function (val) {
|
|
310
310
|
return LiveVariableUtils.wrapInLowerCase(LiveVariableUtils.encodeAndAddQuotes(val, type, skipEncode), options, ignoreCase);
|
|
311
311
|
}), ', ');
|
|
312
312
|
param = '(' + param + ')';
|
|
@@ -325,12 +325,12 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
325
325
|
LiveVariableUtils.getSearchQuery = function (filterOptions, operator, ignoreCase, skipEncode) {
|
|
326
326
|
var query;
|
|
327
327
|
var params = [];
|
|
328
|
-
|
|
329
|
-
var value = fieldValue.attributeValue, dbModes = DB_CONSTANTS.DATABASE_MATCH_MODES, isValArray =
|
|
328
|
+
forEach(filterOptions, function (fieldValue) {
|
|
329
|
+
var value = fieldValue.attributeValue, dbModes = DB_CONSTANTS.DATABASE_MATCH_MODES, isValArray = isArray(value);
|
|
330
330
|
var fieldName = fieldValue.attributeName, filterCondition = fieldValue.filterCondition, matchModeExpr, paramValue;
|
|
331
331
|
// If value is an empty array, do not generate the query
|
|
332
332
|
// If values is NaN and number type, do not generate query for this field
|
|
333
|
-
if ((isValArray &&
|
|
333
|
+
if ((isValArray && isEmpty(value)) || (!isValArray && _isNaN(value) && (isNumberType(fieldValue.attributeType))) || (!isValArray && (_isNaN(value) && !moment(value).isValid() && isDateTimeType(toLower(fieldValue.attributeType))))) {
|
|
334
334
|
return;
|
|
335
335
|
}
|
|
336
336
|
if (isValArray) {
|
|
@@ -343,7 +343,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
343
343
|
fieldName = LiveVariableUtils.wrapInLowerCase(fieldName, fieldValue, ignoreCase);
|
|
344
344
|
params.push(replace(matchModeExpr, [fieldName, paramValue]));
|
|
345
345
|
});
|
|
346
|
-
query =
|
|
346
|
+
query = join(params, operator); // empty space added intentionally around OR
|
|
347
347
|
return query;
|
|
348
348
|
};
|
|
349
349
|
/**
|
|
@@ -353,20 +353,20 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
353
353
|
* @param options options
|
|
354
354
|
*/
|
|
355
355
|
LiveVariableUtils.processFilterFields = function (rules, variable, options) {
|
|
356
|
-
|
|
357
|
-
return rule && (
|
|
356
|
+
remove(rules, function (rule) {
|
|
357
|
+
return rule && (isString(rule.value) && rule.value.indexOf('bind:') === 0 || (rule.matchMode === 'between' ? (isString(rule.secondvalue) && rule.secondvalue.indexOf('bind:') === 0) : false));
|
|
358
358
|
});
|
|
359
|
-
|
|
359
|
+
forEach(rules, function (rule, index) {
|
|
360
360
|
if (rule) {
|
|
361
361
|
if (rule.rules) {
|
|
362
362
|
LiveVariableUtils.processFilterFields(rule.rules, variable, options);
|
|
363
363
|
}
|
|
364
364
|
else {
|
|
365
|
-
if (!
|
|
365
|
+
if (!isNull(rule.target)) {
|
|
366
366
|
var value = rule.matchMode.toLowerCase() === DB_CONSTANTS.DATABASE_MATCH_MODES.between.toLowerCase()
|
|
367
|
-
? (
|
|
367
|
+
? (isArray(rule.value) ? rule.value : [rule.value, rule.secondvalue])
|
|
368
368
|
: (rule.matchMode.toLowerCase() === DB_CONSTANTS.DATABASE_MATCH_MODES.in.toLowerCase() || rule.matchMode.toLowerCase() === DB_CONSTANTS.DATABASE_MATCH_MODES.notin.toLowerCase()
|
|
369
|
-
? (
|
|
369
|
+
? (isArray(rule.value) ? rule.value : (rule.value ? rule.value.split(',').map(function (val) { return val.trim(); }) : ''))
|
|
370
370
|
: rule.value);
|
|
371
371
|
rules[index] = LiveVariableUtils.getFilterOption(variable, {
|
|
372
372
|
'fieldName': rule.target,
|
|
@@ -386,14 +386,14 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
386
386
|
var paramValue;
|
|
387
387
|
var filterCondition = fieldValue.filterCondition;
|
|
388
388
|
var value = fieldValue.attributeValue;
|
|
389
|
-
var isValArray =
|
|
389
|
+
var isValArray = isArray(value);
|
|
390
390
|
var dbModes = DB_CONSTANTS.DATABASE_MATCH_MODES;
|
|
391
391
|
// If value is an empty array, do not generate the query
|
|
392
392
|
// If values is NaN and number type, do not generate query for this field
|
|
393
|
-
if ((isValArray &&
|
|
394
|
-
(isValArray &&
|
|
395
|
-
(!isValArray && (
|
|
396
|
-
(!isValArray && (
|
|
393
|
+
if ((isValArray && isEmpty(value)) ||
|
|
394
|
+
(isValArray && some(value, function (val) { return (isNull(val) || _isNaN(val) || val === ''); })) ||
|
|
395
|
+
(!isValArray && (_isNaN(value) && (isNumberType(fieldValue.attributeType)))) ||
|
|
396
|
+
(!isValArray && (_isNaN(value) && !moment(value).isValid() && isDateTimeType(toLower(fieldValue.attributeType))))) {
|
|
397
397
|
return;
|
|
398
398
|
}
|
|
399
399
|
if (isValArray) {
|
|
@@ -418,17 +418,17 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
418
418
|
*/
|
|
419
419
|
LiveVariableUtils.getIgnoreCase = function (matchMode, ignoreCase) {
|
|
420
420
|
var matchModes = DB_CONSTANTS.DATABASE_MATCH_MODES;
|
|
421
|
-
if (
|
|
421
|
+
if (indexOf([matchModes['anywhere'], matchModes['nowhere'], matchModes['start'], matchModes['end'], matchModes['exact']], matchMode) !== -1) {
|
|
422
422
|
return false;
|
|
423
423
|
}
|
|
424
|
-
if (
|
|
424
|
+
if (indexOf([matchModes['anywhereignorecase'], matchModes['nowhereignorecase'], matchModes['startignorecase'], matchModes['endignorecase'], matchModes['exactignorecase']], matchMode) !== -1) {
|
|
425
425
|
return true;
|
|
426
426
|
}
|
|
427
427
|
return ignoreCase;
|
|
428
428
|
};
|
|
429
429
|
LiveVariableUtils.generateSearchQuery = function (rules, condition, ignoreCase, skipEncode) {
|
|
430
430
|
var params = [];
|
|
431
|
-
|
|
431
|
+
forEach(rules, function (rule) {
|
|
432
432
|
if (rule) {
|
|
433
433
|
if (rule.rules) {
|
|
434
434
|
var query = LiveVariableUtils.generateSearchQuery(rule.rules, rule.condition, ignoreCase, skipEncode);
|
|
@@ -438,13 +438,13 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
438
438
|
}
|
|
439
439
|
else {
|
|
440
440
|
var searchField = LiveVariableUtils.getSearchField(rule, LiveVariableUtils.getIgnoreCase(rule.filterCondition, ignoreCase), skipEncode);
|
|
441
|
-
if (!
|
|
441
|
+
if (!isNil(searchField)) {
|
|
442
442
|
params.push(searchField);
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
});
|
|
447
|
-
return
|
|
447
|
+
return join(params, ' ' + condition + ' ');
|
|
448
448
|
};
|
|
449
449
|
LiveVariableUtils.prepareTableOptionsForFilterExps = function (variable, options, clonedFields) {
|
|
450
450
|
if (!isDefined(options.searchWithQuery)) {
|
|
@@ -455,25 +455,25 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
455
455
|
var orderByFields, orderByOptions, query;
|
|
456
456
|
var clonedObj = clonedFields || getClonedObject(variable.filterExpressions);
|
|
457
457
|
// if filterexpression from live filter is present use it to query
|
|
458
|
-
if (options.filterExpr && !
|
|
458
|
+
if (options.filterExpr && !isEmpty(options.filterExpr)) {
|
|
459
459
|
clonedObj = options.filterExpr;
|
|
460
460
|
}
|
|
461
461
|
// merge live filter runtime values
|
|
462
462
|
var filterRules = {};
|
|
463
|
-
if (!
|
|
463
|
+
if (!isEmpty(options.filterFields)) {
|
|
464
464
|
var operator = '';
|
|
465
465
|
for (var field in options.filterFields) {
|
|
466
466
|
operator = options.filterFields[field] && options.filterFields[field]['logicalOp'] || '';
|
|
467
467
|
break;
|
|
468
468
|
}
|
|
469
469
|
filterRules = { 'condition': options.logicalOp || operator || 'AND', 'rules': [] };
|
|
470
|
-
|
|
470
|
+
forEach(options.filterFields, function (filterObj, filterName) {
|
|
471
471
|
if (!filterObj) {
|
|
472
472
|
return;
|
|
473
473
|
}
|
|
474
474
|
var filterCondition = matchModes[filterObj.matchMode] || matchModes[filterObj.filterCondition] || filterObj.filterCondition;
|
|
475
|
-
if (
|
|
476
|
-
(!
|
|
475
|
+
if (includes(DB_CONSTANTS.DATABASE_EMPTY_MATCH_MODES, filterCondition) ||
|
|
476
|
+
(!isNil(filterObj.value) && filterObj.value !== '')) {
|
|
477
477
|
var type = filterObj.type || LiveVariableUtils.getSqlType(variable, filterName, options.entityName);
|
|
478
478
|
var ruleObj = {
|
|
479
479
|
'target': filterName,
|
|
@@ -486,8 +486,8 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
486
486
|
}
|
|
487
487
|
});
|
|
488
488
|
}
|
|
489
|
-
if (!
|
|
490
|
-
if (!
|
|
489
|
+
if (!isEmpty(clonedObj)) {
|
|
490
|
+
if (!isNil(filterRules.rules) && filterRules.rules.length) {
|
|
491
491
|
// combine both the rules using 'AND'
|
|
492
492
|
var tempRules = { 'condition': 'AND', 'rules': [] };
|
|
493
493
|
tempRules.rules.push(getClonedObject(clonedObj));
|
|
@@ -519,8 +519,8 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
519
519
|
var filterOptions = [], orderByFields, orderByOptions, query, optionsQuery;
|
|
520
520
|
clonedFields = clonedFields || variable.filterFields;
|
|
521
521
|
// get the filter fields from the variable
|
|
522
|
-
|
|
523
|
-
if (
|
|
522
|
+
forEach(clonedFields, function (value, key) {
|
|
523
|
+
if (isObject(value) && (!options.filterFields || !options.filterFields[key] || options.filterFields[key].logicalOp === 'AND')) {
|
|
524
524
|
value.fieldName = key;
|
|
525
525
|
if (LiveVariableUtils.isStringType(LiveVariableUtils.getSQLFieldType(variable, value))) {
|
|
526
526
|
value.filterCondition = DB_CONSTANTS.DATABASE_MATCH_MODES[value.matchMode || variable.matchMode];
|
|
@@ -530,7 +530,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
530
530
|
}
|
|
531
531
|
});
|
|
532
532
|
// get the filter fields from the options
|
|
533
|
-
|
|
533
|
+
forEach(options.filterFields, function (value, key) {
|
|
534
534
|
value.fieldName = key;
|
|
535
535
|
value.filterCondition = DB_CONSTANTS.DATABASE_MATCH_MODES[value.matchMode || options.matchMode || variable.matchMode];
|
|
536
536
|
filterFields.push(value);
|
|
@@ -543,9 +543,9 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
543
543
|
*/
|
|
544
544
|
if (options.searchWithQuery && filterOptions.length) {
|
|
545
545
|
// Generate query for variable filter fields. This has AND logical operator
|
|
546
|
-
query = LiveVariableUtils.getSearchQuery(
|
|
546
|
+
query = LiveVariableUtils.getSearchQuery(filter(filterOptions, { 'isVariableFilter': true }), ' AND ', variable.ignoreCase, options.skipEncode);
|
|
547
547
|
// Generate query for option filter fields. This has default logical operator as OR
|
|
548
|
-
optionsQuery = LiveVariableUtils.getSearchQuery(
|
|
548
|
+
optionsQuery = LiveVariableUtils.getSearchQuery(filter(filterOptions, { 'isVariableFilter': undefined }), ' ' + (options.logicalOp || 'AND') + ' ', variable.ignoreCase, options.skipEncode);
|
|
549
549
|
if (optionsQuery) {
|
|
550
550
|
// If both variable and option query are present, merge them with AND
|
|
551
551
|
query = query ? (query + ' AND ( ' + optionsQuery + ' )') : optionsQuery;
|
|
@@ -564,12 +564,12 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
564
564
|
var fieldType, columns, result;
|
|
565
565
|
if (variable.propertiesMap) {
|
|
566
566
|
columns = variable.propertiesMap.columns || [];
|
|
567
|
-
result =
|
|
567
|
+
result = find(columns, function (obj) {
|
|
568
568
|
return obj.fieldName === fieldName;
|
|
569
569
|
});
|
|
570
570
|
// if related field name passed, get its type from columns inside the current field
|
|
571
571
|
if (relatedField && result) {
|
|
572
|
-
result =
|
|
572
|
+
result = find(result.columns, function (obj) {
|
|
573
573
|
return obj.fieldName === relatedField;
|
|
574
574
|
});
|
|
575
575
|
}
|
|
@@ -580,12 +580,12 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
580
580
|
// Prepare formData for blob columns
|
|
581
581
|
LiveVariableUtils.prepareFormData = function (variableDetails, rowObject) {
|
|
582
582
|
var formData = new FormData();
|
|
583
|
-
formData.rowData =
|
|
584
|
-
|
|
583
|
+
formData.rowData = clone(rowObject);
|
|
584
|
+
forEach(rowObject, function (colValue, colName) {
|
|
585
585
|
if (LiveVariableUtils.getFieldType(colName, variableDetails) === 'blob') {
|
|
586
|
-
if (
|
|
587
|
-
if (
|
|
588
|
-
|
|
586
|
+
if (isObject(colValue)) {
|
|
587
|
+
if (isArray(colValue)) {
|
|
588
|
+
forEach(colValue, function (fileObject) {
|
|
589
589
|
formData.append(colName, fileObject, fileObject.name);
|
|
590
590
|
});
|
|
591
591
|
}
|
|
@@ -603,7 +603,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
603
603
|
};
|
|
604
604
|
LiveVariableUtils.traverseFilterExpressions = function (filterExpressions, traverseCallbackFn) {
|
|
605
605
|
if (filterExpressions && filterExpressions.rules) {
|
|
606
|
-
|
|
606
|
+
forEach(filterExpressions.rules, function (filExpObj, i) {
|
|
607
607
|
if (filExpObj.rules) {
|
|
608
608
|
LiveVariableUtils.traverseFilterExpressions(filExpObj, traverseCallbackFn);
|
|
609
609
|
}
|
|
@@ -626,7 +626,7 @@ var LiveVariableUtils = /** @class */ (function () {
|
|
|
626
626
|
var traverseCallbackFn = function (parentFilExpObj, filExpObj) {
|
|
627
627
|
if (filExpObj
|
|
628
628
|
&& filExpObj.required
|
|
629
|
-
&& ((
|
|
629
|
+
&& ((indexOf(['null', 'isnotnull', 'empty', 'isnotempty', 'nullorempty'], filExpObj.matchMode) === -1) && filExpObj.value === '')) {
|
|
630
630
|
isRequiredFieldAbsent = true;
|
|
631
631
|
return false;
|
|
632
632
|
}
|