@wavemaker-ai/variables 1.0.0-rc.647469
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/index.d.ts +14 -0
- package/index.js +15 -0
- package/index.js.map +1 -0
- package/npm-shrinkwrap.json +1967 -0
- package/package-lock.json +1967 -0
- package/package.json +48 -0
- package/scripts/build.d.ts +1 -0
- package/scripts/build.js +183 -0
- package/scripts/build.js.map +1 -0
- package/src/advanced-options.d.ts +4 -0
- package/src/advanced-options.js +2 -0
- package/src/advanced-options.js.map +1 -0
- package/src/constants/variables.constants.d.ts +307 -0
- package/src/constants/variables.constants.js +334 -0
- package/src/constants/variables.constants.js.map +1 -0
- package/src/factory/variable-manager.factory.d.ts +3 -0
- package/src/factory/variable-manager.factory.js +26 -0
- package/src/factory/variable-manager.factory.js.map +1 -0
- package/src/manager/action/timer-action.manager.d.ts +4 -0
- package/src/manager/action/timer-action.manager.js +38 -0
- package/src/manager/action/timer-action.manager.js.map +1 -0
- package/src/manager/variable/base-variable.manager.d.ts +24 -0
- package/src/manager/variable/base-variable.manager.js +79 -0
- package/src/manager/variable/base-variable.manager.js.map +1 -0
- package/src/manager/variable/crud-variable.manager.d.ts +85 -0
- package/src/manager/variable/crud-variable.manager.js +415 -0
- package/src/manager/variable/crud-variable.manager.js.map +1 -0
- package/src/manager/variable/live-variable.manager.d.ts +154 -0
- package/src/manager/variable/live-variable.manager.js +1078 -0
- package/src/manager/variable/live-variable.manager.js.map +1 -0
- package/src/manager/variable/model-variable.manager.d.ts +4 -0
- package/src/manager/variable/model-variable.manager.js +56 -0
- package/src/manager/variable/model-variable.manager.js.map +1 -0
- package/src/manager/variable/service-variable.manager.d.ts +113 -0
- package/src/manager/variable/service-variable.manager.js +713 -0
- package/src/manager/variable/service-variable.manager.js.map +1 -0
- package/src/model/action/timer-action.d.ts +12 -0
- package/src/model/action/timer-action.js +60 -0
- package/src/model/action/timer-action.js.map +1 -0
- package/src/model/base-action.d.ts +32 -0
- package/src/model/base-action.js +89 -0
- package/src/model/base-action.js.map +1 -0
- package/src/model/base-variable.d.ts +58 -0
- package/src/model/base-variable.js +180 -0
- package/src/model/base-variable.js.map +1 -0
- package/src/model/crud-create.d.ts +8 -0
- package/src/model/crud-create.js +17 -0
- package/src/model/crud-create.js.map +1 -0
- package/src/model/crud-delete.d.ts +8 -0
- package/src/model/crud-delete.js +17 -0
- package/src/model/crud-delete.js.map +1 -0
- package/src/model/crud-list.d.ts +8 -0
- package/src/model/crud-list.js +17 -0
- package/src/model/crud-list.js.map +1 -0
- package/src/model/crud-update.d.ts +8 -0
- package/src/model/crud-update.js +17 -0
- package/src/model/crud-update.js.map +1 -0
- package/src/model/variable/api-aware-variable.d.ts +23 -0
- package/src/model/variable/api-aware-variable.js +25 -0
- package/src/model/variable/api-aware-variable.js.map +1 -0
- package/src/model/variable/crud-variable.d.ts +30 -0
- package/src/model/variable/crud-variable.js +181 -0
- package/src/model/variable/crud-variable.js.map +1 -0
- package/src/model/variable/live-variable.d.ts +40 -0
- package/src/model/variable/live-variable.js +262 -0
- package/src/model/variable/live-variable.js.map +1 -0
- package/src/model/variable/model-variable.d.ts +11 -0
- package/src/model/variable/model-variable.js +83 -0
- package/src/model/variable/model-variable.js.map +1 -0
- package/src/model/variable/service-variable.d.ts +35 -0
- package/src/model/variable/service-variable.js +147 -0
- package/src/model/variable/service-variable.js.map +1 -0
- package/src/types/date-formatter.d.ts +3 -0
- package/src/types/date-formatter.js +2 -0
- package/src/types/date-formatter.js.map +1 -0
- package/src/types/event-notifier.d.ts +9 -0
- package/src/types/event-notifier.js +25 -0
- package/src/types/event-notifier.js.map +1 -0
- package/src/types/http-client.service.d.ts +8 -0
- package/src/types/http-client.service.js +2 -0
- package/src/types/http-client.service.js.map +1 -0
- package/src/types/types.d.ts +50 -0
- package/src/types/types.js +54 -0
- package/src/types/types.js.map +1 -0
- package/src/util/dataset-util.d.ts +27 -0
- package/src/util/dataset-util.js +147 -0
- package/src/util/dataset-util.js.map +1 -0
- package/src/util/file-upload.util.d.ts +11 -0
- package/src/util/file-upload.util.js +183 -0
- package/src/util/file-upload.util.js.map +1 -0
- package/src/util/inflight-queue.d.ts +35 -0
- package/src/util/inflight-queue.js +102 -0
- package/src/util/inflight-queue.js.map +1 -0
- package/src/util/notify-promise.d.ts +3 -0
- package/src/util/notify-promise.js +37 -0
- package/src/util/notify-promise.js.map +1 -0
- package/src/util/oAuth.utils.d.ts +3 -0
- package/src/util/oAuth.utils.js +11 -0
- package/src/util/oAuth.utils.js.map +1 -0
- package/src/util/utils.d.ts +69 -0
- package/src/util/utils.js +364 -0
- package/src/util/utils.js.map +1 -0
- package/src/util/variable/live-variable.http.utils.d.ts +21 -0
- package/src/util/variable/live-variable.http.utils.js +212 -0
- package/src/util/variable/live-variable.http.utils.js.map +1 -0
- package/src/util/variable/live-variable.utils.d.ts +72 -0
- package/src/util/variable/live-variable.utils.js +667 -0
- package/src/util/variable/live-variable.utils.js.map +1 -0
- package/src/util/variable/pagination.utils.d.ts +91 -0
- package/src/util/variable/pagination.utils.js +493 -0
- package/src/util/variable/pagination.utils.js.map +1 -0
- package/src/util/variable/service-variable.utils.d.ts +17 -0
- package/src/util/variable/service-variable.utils.js +394 -0
- package/src/util/variable/service-variable.utils.js.map +1 -0
- package/src/util/variable/variables.utils.d.ts +120 -0
- package/src/util/variable/variables.utils.js +544 -0
- package/src/util/variable/variables.utils.js.map +1 -0
- package/src/wm-namespace.d.ts +11 -0
- package/src/wm-namespace.js +13 -0
- package/src/wm-namespace.js.map +1 -0
- package/webpack.config.d.ts +21 -0
- package/webpack.config.js +28 -0
- package/webpack.config.js.map +1 -0
|
@@ -0,0 +1,667 @@
|
|
|
1
|
+
import { hasCordova, getClonedObject, isDateTimeType, isDefined, replace, triggerFn, isNumberType } from "../../util/utils";
|
|
2
|
+
import { $rootScope, DB_CONSTANTS, SWAGGER_CONSTANTS } from '../../constants/variables.constants';
|
|
3
|
+
import { getEvaluatedOrderBy, formatDate } from './variables.utils';
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import moment from 'moment';
|
|
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
|
+
var LiveVariableUtils = /** @class */ (function () {
|
|
8
|
+
function LiveVariableUtils() {
|
|
9
|
+
}
|
|
10
|
+
LiveVariableUtils.isCompositeKey = function (primaryKey) {
|
|
11
|
+
return !primaryKey || (primaryKey && (!primaryKey.length || primaryKey.length > 1));
|
|
12
|
+
};
|
|
13
|
+
LiveVariableUtils.isNoPrimaryKey = function (primaryKey) {
|
|
14
|
+
return (!primaryKey || (primaryKey && !primaryKey.length));
|
|
15
|
+
};
|
|
16
|
+
// Generate the URL based on the primary keys and their values
|
|
17
|
+
LiveVariableUtils.getCompositeIDURL = function (primaryKeysData) {
|
|
18
|
+
var compositeId = '';
|
|
19
|
+
// Loop over the 'compositeKeysData' and construct the 'compositeId'.
|
|
20
|
+
forEach(primaryKeysData, function (paramValue, paramName) {
|
|
21
|
+
compositeId += paramName + '=' + encodeURIComponent(paramValue) + '&';
|
|
22
|
+
});
|
|
23
|
+
compositeId = compositeId.slice(0, -1);
|
|
24
|
+
return compositeId;
|
|
25
|
+
};
|
|
26
|
+
// Check if table has blob column
|
|
27
|
+
LiveVariableUtils.hasBlob = function (variable) {
|
|
28
|
+
return find(get(variable, ['propertiesMap', 'columns']), { 'type': 'blob' });
|
|
29
|
+
};
|
|
30
|
+
LiveVariableUtils.getPrimaryKey = function (variable) {
|
|
31
|
+
if (!variable.propertiesMap) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
if (variable.propertiesMap.primaryFields) {
|
|
35
|
+
return variable.propertiesMap.primaryFields;
|
|
36
|
+
}
|
|
37
|
+
/*Old projects do not have primary fields. Get primary key from the columns*/
|
|
38
|
+
var primaryKey = [];
|
|
39
|
+
/*Loop through the propertiesMap and get the primary key column.*/
|
|
40
|
+
forEach(variable.propertiesMap.columns, function (index, column) {
|
|
41
|
+
if (column.isPrimaryKey) {
|
|
42
|
+
if (column.isRelated && (!includes(column.relatedFieldName, primaryKey))) {
|
|
43
|
+
primaryKey.push(column.relatedFieldName);
|
|
44
|
+
}
|
|
45
|
+
else if (!includes(column.fieldName, primaryKey)) {
|
|
46
|
+
primaryKey.push(column.fieldName);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return primaryKey;
|
|
51
|
+
};
|
|
52
|
+
// Construct the URL for blob columns and set it in the data, so that widgets can use this
|
|
53
|
+
LiveVariableUtils.processBlobColumns = function (responseData, variable) {
|
|
54
|
+
if (!responseData) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
var blobCols = map(filter(variable.propertiesMap.columns, { 'type': 'blob' }), 'fieldName'), deployedUrl = trim($rootScope.project.deployedUrl);
|
|
58
|
+
var href = '', primaryKeys;
|
|
59
|
+
if (isEmpty(blobCols)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (hasCordova()) {
|
|
63
|
+
href += endsWith(deployedUrl, '/') ? deployedUrl : deployedUrl + '/';
|
|
64
|
+
}
|
|
65
|
+
href += ((variable._prefabName !== '' && variable._prefabName !== undefined) ? 'prefabs/' + variable._prefabName : 'services') + '/' + variable.liveSource + '/' + variable.type + '/';
|
|
66
|
+
primaryKeys = variable.propertiesMap.primaryFields || variable.propertiesMap.primaryKeys;
|
|
67
|
+
forEach(responseData, function (data) {
|
|
68
|
+
if (data) {
|
|
69
|
+
forEach(blobCols, function (col) {
|
|
70
|
+
var compositeKeysData = {};
|
|
71
|
+
if (data[col] === null || !isEmpty(trim(data[col]))) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (LiveVariableUtils.isCompositeKey(primaryKeys)) {
|
|
75
|
+
primaryKeys.forEach(function (key) {
|
|
76
|
+
compositeKeysData[key] = data[key];
|
|
77
|
+
});
|
|
78
|
+
data[col] = href + 'composite-id/content/' + col + '?' + LiveVariableUtils.getCompositeIDURL(compositeKeysData);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
data[col] = href + data[join(primaryKeys)] + '/content/' + col;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
LiveVariableUtils.getHibernateOrSqlType = function (variable, fieldName, type, entityName) {
|
|
88
|
+
var columns = variable.propertiesMap.columns;
|
|
89
|
+
var column, relatedCols, relatedCol, columnParts;
|
|
90
|
+
if (includes(fieldName, '.')) {
|
|
91
|
+
columnParts = fieldName.split('.');
|
|
92
|
+
if (columnParts.length > 2) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
column = find(columns, function (col) {
|
|
96
|
+
return col.fieldName === columnParts[0];
|
|
97
|
+
});
|
|
98
|
+
relatedCols = column && column.columns;
|
|
99
|
+
relatedCol = find(relatedCols, function (col) {
|
|
100
|
+
return col.fieldName === columnParts[1];
|
|
101
|
+
});
|
|
102
|
+
return relatedCol && relatedCol[type];
|
|
103
|
+
}
|
|
104
|
+
column = find(columns, function (col) {
|
|
105
|
+
return col.fieldName === fieldName || col.relatedColumnName === fieldName;
|
|
106
|
+
});
|
|
107
|
+
if (!column && entityName) {
|
|
108
|
+
var entity = find(columns, function (col) { return col.relatedEntityName === entityName; });
|
|
109
|
+
column = find(entity.columns, function (col) {
|
|
110
|
+
return col.fieldName === fieldName || col.relatedColumnName === fieldName;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return column && column[type];
|
|
114
|
+
};
|
|
115
|
+
/*Function to get the sqlType of the specified field.*/
|
|
116
|
+
LiveVariableUtils.getSqlType = function (variable, fieldName, entityName) {
|
|
117
|
+
return LiveVariableUtils.getHibernateOrSqlType(variable, fieldName, 'type', entityName);
|
|
118
|
+
};
|
|
119
|
+
/*Function to check if the specified field has a one-to-many relation or not.*/
|
|
120
|
+
LiveVariableUtils.isRelatedFieldMany = function (variable, fieldName) {
|
|
121
|
+
var columns = variable.propertiesMap.columns, columnsCount = columns.length;
|
|
122
|
+
var index, column;
|
|
123
|
+
/*Loop through the columns of the liveVariable*/
|
|
124
|
+
for (index = 0; index < columnsCount; index += 1) {
|
|
125
|
+
column = columns[index];
|
|
126
|
+
/*If the specified field is found in the columns of the variable,
|
|
127
|
+
* then it has a many-to-one relation.*/
|
|
128
|
+
if (column.fieldName === fieldName) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
};
|
|
134
|
+
LiveVariableUtils.isStringType = function (type) {
|
|
135
|
+
return includes(['text', 'string'], toLower(type));
|
|
136
|
+
};
|
|
137
|
+
LiveVariableUtils.getSQLFieldType = function (variable, options) {
|
|
138
|
+
if (includes(['timestamp', 'datetime', 'date'], options.type)) {
|
|
139
|
+
return options.type;
|
|
140
|
+
}
|
|
141
|
+
return LiveVariableUtils.getSqlType(variable, options.fieldName) || options.type;
|
|
142
|
+
};
|
|
143
|
+
LiveVariableUtils.getAttributeName = function (variable, fieldName) {
|
|
144
|
+
var attrName = fieldName;
|
|
145
|
+
variable.propertiesMap.columns.forEach(function (column) {
|
|
146
|
+
if (column.fieldName === fieldName && column.isRelated) {
|
|
147
|
+
attrName = column.relatedFieldName;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return attrName;
|
|
151
|
+
};
|
|
152
|
+
LiveVariableUtils.getFilterCondition = function (filterCondition) {
|
|
153
|
+
if (includes(DB_CONSTANTS.DATABASE_RANGE_MATCH_MODES, filterCondition)) {
|
|
154
|
+
return filterCondition;
|
|
155
|
+
}
|
|
156
|
+
return DB_CONSTANTS.DATABASE_MATCH_MODES['exact'];
|
|
157
|
+
};
|
|
158
|
+
LiveVariableUtils.getFilterOption = function (variable, fieldOptions, options) {
|
|
159
|
+
var attributeName, fieldValue = fieldOptions.value, filterOption, filterCondition;
|
|
160
|
+
var matchModes = DB_CONSTANTS.DATABASE_MATCH_MODES, fieldName = fieldOptions.fieldName, fieldRequired = fieldOptions.required || false, fieldType = LiveVariableUtils.getSQLFieldType(variable, fieldOptions);
|
|
161
|
+
filterCondition = matchModes[fieldOptions.matchMode] || matchModes[fieldOptions.filterCondition] || fieldOptions.filterCondition;
|
|
162
|
+
fieldOptions.type = fieldType;
|
|
163
|
+
/* if the field value is an object(complex type), loop over each field inside and push only first level fields */
|
|
164
|
+
if (isObject(fieldValue) && !isArray(fieldValue)) {
|
|
165
|
+
var firstLevelValues_1 = [];
|
|
166
|
+
forEach(fieldValue, function (subFieldValue, subFieldName) {
|
|
167
|
+
if (subFieldValue && !isObject(subFieldValue)) {
|
|
168
|
+
firstLevelValues_1.push(fieldName + '.' + subFieldName + '=' + subFieldValue);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return firstLevelValues_1;
|
|
172
|
+
}
|
|
173
|
+
if (includes(DB_CONSTANTS.DATABASE_EMPTY_MATCH_MODES, filterCondition)) {
|
|
174
|
+
attributeName = LiveVariableUtils.getAttributeName(variable, fieldName);
|
|
175
|
+
// For non string types empty match modes are not supported, so convert them to null match modes.
|
|
176
|
+
if (fieldType && !LiveVariableUtils.isStringType(fieldType)) {
|
|
177
|
+
filterCondition = DB_CONSTANTS.DATABASE_NULL_EMPTY_MATCH[filterCondition];
|
|
178
|
+
}
|
|
179
|
+
filterOption = {
|
|
180
|
+
'attributeName': attributeName,
|
|
181
|
+
'attributeValue': '',
|
|
182
|
+
'attributeType': toUpper(fieldType),
|
|
183
|
+
'filterCondition': filterCondition,
|
|
184
|
+
'required': fieldRequired
|
|
185
|
+
};
|
|
186
|
+
if (options.searchWithQuery) {
|
|
187
|
+
filterOption.isVariableFilter = fieldOptions.isVariableFilter;
|
|
188
|
+
}
|
|
189
|
+
return filterOption;
|
|
190
|
+
}
|
|
191
|
+
if (isDefined(fieldValue) && fieldValue !== null && fieldValue !== '') {
|
|
192
|
+
/*Based on the sqlType of the field, format the value & set the filter condition.*/
|
|
193
|
+
if (fieldType) {
|
|
194
|
+
switch (fieldType) {
|
|
195
|
+
case 'integer':
|
|
196
|
+
fieldValue = isArray(fieldValue) ? reduce(fieldValue, function (result, value) {
|
|
197
|
+
value = parseInt(value, 10);
|
|
198
|
+
if (!_isNaN(value)) {
|
|
199
|
+
result.push(value);
|
|
200
|
+
}
|
|
201
|
+
return result;
|
|
202
|
+
}, []) : parseInt(fieldValue, 10);
|
|
203
|
+
filterCondition = filterCondition ? LiveVariableUtils.getFilterCondition(filterCondition) : matchModes['exact'];
|
|
204
|
+
break;
|
|
205
|
+
case 'date':
|
|
206
|
+
case 'datetime':
|
|
207
|
+
case 'timestamp':
|
|
208
|
+
fieldValue = formatDate(fieldValue, fieldType, variable.dateFormatter);
|
|
209
|
+
filterCondition = filterCondition ? LiveVariableUtils.getFilterCondition(filterCondition) : matchModes['exact'];
|
|
210
|
+
break;
|
|
211
|
+
case 'text':
|
|
212
|
+
case 'string':
|
|
213
|
+
if (isArray(fieldValue)) {
|
|
214
|
+
filterCondition = includes([matchModes['in'], matchModes['notin']], filterCondition) ? filterCondition : matchModes['exact'];
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
filterCondition = filterCondition || matchModes['anywhereignorecase'];
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
default:
|
|
221
|
+
filterCondition = filterCondition ? LiveVariableUtils.getFilterCondition(filterCondition) : matchModes['exact'];
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
filterCondition = isString(fieldValue) ? matchModes['anywhereignorecase'] : matchModes['exact'];
|
|
227
|
+
}
|
|
228
|
+
attributeName = LiveVariableUtils.getAttributeName(variable, fieldName);
|
|
229
|
+
filterOption = {
|
|
230
|
+
'attributeName': attributeName,
|
|
231
|
+
'attributeValue': fieldValue,
|
|
232
|
+
'attributeType': toUpper(fieldType),
|
|
233
|
+
'filterCondition': filterCondition,
|
|
234
|
+
'required': fieldRequired
|
|
235
|
+
};
|
|
236
|
+
if (options.searchWithQuery) {
|
|
237
|
+
filterOption.isVariableFilter = fieldOptions.isVariableFilter;
|
|
238
|
+
}
|
|
239
|
+
return filterOption;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
LiveVariableUtils.getFilterOptions = function (variable, filterFields, options) {
|
|
243
|
+
var filterOptions = [];
|
|
244
|
+
each(filterFields, function (fieldOptions) {
|
|
245
|
+
var filterOption = LiveVariableUtils.getFilterOption(variable, fieldOptions, options);
|
|
246
|
+
if (!isNil(filterOption)) {
|
|
247
|
+
if (isArray(filterOption)) {
|
|
248
|
+
filterOptions = filterOptions.concat(filterOption);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
filterOptions.push(filterOption);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
return filterOptions;
|
|
256
|
+
};
|
|
257
|
+
// Wrap the field name and value in lower() in ignore case scenario
|
|
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
|
+
LiveVariableUtils.wrapInLowerCase = function (value, options, ignoreCase, isField) {
|
|
260
|
+
var type = toLower(options.attributeType);
|
|
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)) && includes(DB_CONSTANTS.DATABASE_STRING_MODES, options.filterCondition)) {
|
|
263
|
+
return 'lower(' + value + ')';
|
|
264
|
+
}
|
|
265
|
+
return value;
|
|
266
|
+
};
|
|
267
|
+
LiveVariableUtils.encodeAndAddQuotes = function (value, type, skipEncode) {
|
|
268
|
+
var encodedValue = skipEncode ? value : encodeURIComponent(value);
|
|
269
|
+
type = toLower(type);
|
|
270
|
+
encodedValue = _replace(encodedValue, /'/g, '\'\'');
|
|
271
|
+
// For number types, don't wrap the value in quotes
|
|
272
|
+
if ((isNumberType(type) && type !== 'float')) {
|
|
273
|
+
return encodedValue;
|
|
274
|
+
}
|
|
275
|
+
return '\'' + encodedValue + '\'';
|
|
276
|
+
};
|
|
277
|
+
LiveVariableUtils.getParamValue = function (value, options, ignoreCase, skipEncode) {
|
|
278
|
+
var param;
|
|
279
|
+
var filterCondition = options.filterCondition, dbModes = DB_CONSTANTS.DATABASE_MATCH_MODES, type = options.attributeType;
|
|
280
|
+
if (includes(DB_CONSTANTS.DATABASE_EMPTY_MATCH_MODES, filterCondition)) {
|
|
281
|
+
// For empty matchmodes, no value is required
|
|
282
|
+
return '';
|
|
283
|
+
}
|
|
284
|
+
switch (filterCondition) {
|
|
285
|
+
case dbModes.startignorecase:
|
|
286
|
+
case dbModes.start:
|
|
287
|
+
param = LiveVariableUtils.encodeAndAddQuotes(value + '%', type, skipEncode);
|
|
288
|
+
param = LiveVariableUtils.wrapInLowerCase(param, options, ignoreCase);
|
|
289
|
+
break;
|
|
290
|
+
case dbModes.endignorecase:
|
|
291
|
+
case dbModes.end:
|
|
292
|
+
param = LiveVariableUtils.encodeAndAddQuotes('%' + value, type, skipEncode);
|
|
293
|
+
param = LiveVariableUtils.wrapInLowerCase(param, options, ignoreCase);
|
|
294
|
+
break;
|
|
295
|
+
case dbModes.nowhereignorecase:
|
|
296
|
+
case dbModes.nowhere:
|
|
297
|
+
case dbModes.anywhereignorecase:
|
|
298
|
+
case dbModes.anywhere:
|
|
299
|
+
param = LiveVariableUtils.encodeAndAddQuotes('%' + value + '%', type, skipEncode);
|
|
300
|
+
param = LiveVariableUtils.wrapInLowerCase(param, options, ignoreCase);
|
|
301
|
+
break;
|
|
302
|
+
case dbModes.between:
|
|
303
|
+
param = join(map(value, function (val) {
|
|
304
|
+
return LiveVariableUtils.wrapInLowerCase(LiveVariableUtils.encodeAndAddQuotes(val, type, skipEncode), options, ignoreCase);
|
|
305
|
+
}), ' and ');
|
|
306
|
+
break;
|
|
307
|
+
case dbModes.in:
|
|
308
|
+
case dbModes.notin:
|
|
309
|
+
param = join(map(value, function (val) {
|
|
310
|
+
return LiveVariableUtils.wrapInLowerCase(LiveVariableUtils.encodeAndAddQuotes(val, type, skipEncode), options, ignoreCase);
|
|
311
|
+
}), ', ');
|
|
312
|
+
param = '(' + param + ')';
|
|
313
|
+
break;
|
|
314
|
+
/*case dbModes.exactignorecase:
|
|
315
|
+
case dbModes.exact:
|
|
316
|
+
case dbModes.notequals:
|
|
317
|
+
The above three cases will be handled by default*/
|
|
318
|
+
default:
|
|
319
|
+
param = LiveVariableUtils.encodeAndAddQuotes(value, type, skipEncode);
|
|
320
|
+
param = LiveVariableUtils.wrapInLowerCase(param, options, ignoreCase);
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
return isDefined(param) ? param : '';
|
|
324
|
+
};
|
|
325
|
+
LiveVariableUtils.getSearchQuery = function (filterOptions, operator, ignoreCase, skipEncode) {
|
|
326
|
+
var query;
|
|
327
|
+
var params = [];
|
|
328
|
+
forEach(filterOptions, function (fieldValue) {
|
|
329
|
+
var value = fieldValue.attributeValue, dbModes = DB_CONSTANTS.DATABASE_MATCH_MODES, isValArray = isArray(value);
|
|
330
|
+
var fieldName = fieldValue.attributeName, filterCondition = fieldValue.filterCondition, matchModeExpr, paramValue;
|
|
331
|
+
// If value is an empty array, do not generate the query
|
|
332
|
+
// If values is NaN and number type, do not generate query for this field
|
|
333
|
+
if ((isValArray && isEmpty(value)) || (!isValArray && _isNaN(value) && (isNumberType(fieldValue.attributeType))) || (!isValArray && (_isNaN(value) && !moment(value).isValid() && isDateTimeType(toLower(fieldValue.attributeType))))) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (isValArray) {
|
|
337
|
+
// If array is value and mode is between, pass between. Else pass as in query
|
|
338
|
+
filterCondition = filterCondition === dbModes.between || filterCondition === dbModes.notin ? filterCondition : dbModes.in;
|
|
339
|
+
fieldValue.filterCondition = filterCondition;
|
|
340
|
+
}
|
|
341
|
+
matchModeExpr = DB_CONSTANTS.DATABASE_MATCH_MODES_WITH_QUERY[filterCondition];
|
|
342
|
+
paramValue = LiveVariableUtils.getParamValue(value, fieldValue, ignoreCase, skipEncode);
|
|
343
|
+
fieldName = LiveVariableUtils.wrapInLowerCase(fieldName, fieldValue, ignoreCase);
|
|
344
|
+
params.push(replace(matchModeExpr, [fieldName, paramValue]));
|
|
345
|
+
});
|
|
346
|
+
query = join(params, operator); // empty space added intentionally around OR
|
|
347
|
+
return query;
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* creating the proper values from the actual object like for between,in matchModes value has to be an array like [1,2]
|
|
351
|
+
* @param rules recursive filterexpressions object
|
|
352
|
+
* @param variable variable object
|
|
353
|
+
* @param options options
|
|
354
|
+
*/
|
|
355
|
+
LiveVariableUtils.processFilterFields = function (rules, variable, options) {
|
|
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
|
+
});
|
|
359
|
+
forEach(rules, function (rule, index) {
|
|
360
|
+
if (rule) {
|
|
361
|
+
if (rule.rules) {
|
|
362
|
+
LiveVariableUtils.processFilterFields(rule.rules, variable, options);
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
if (!isNull(rule.target)) {
|
|
366
|
+
var value = rule.matchMode.toLowerCase() === DB_CONSTANTS.DATABASE_MATCH_MODES.between.toLowerCase()
|
|
367
|
+
? (isArray(rule.value) ? rule.value : [rule.value, rule.secondvalue])
|
|
368
|
+
: (rule.matchMode.toLowerCase() === DB_CONSTANTS.DATABASE_MATCH_MODES.in.toLowerCase() || rule.matchMode.toLowerCase() === DB_CONSTANTS.DATABASE_MATCH_MODES.notin.toLowerCase()
|
|
369
|
+
? (isArray(rule.value) ? rule.value : (rule.value ? rule.value.split(',').map(function (val) { return val.trim(); }) : ''))
|
|
370
|
+
: rule.value);
|
|
371
|
+
rules[index] = LiveVariableUtils.getFilterOption(variable, {
|
|
372
|
+
'fieldName': rule.target,
|
|
373
|
+
'type': rule.type,
|
|
374
|
+
'value': value,
|
|
375
|
+
'required': rule.required,
|
|
376
|
+
'filterCondition': rule.matchMode || options.matchMode || variable.matchMode
|
|
377
|
+
}, options);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
};
|
|
383
|
+
LiveVariableUtils.getSearchField = function (fieldValue, ignoreCase, skipEncode) {
|
|
384
|
+
var fieldName = fieldValue.attributeName;
|
|
385
|
+
var matchModeExpr;
|
|
386
|
+
var paramValue;
|
|
387
|
+
var filterCondition = fieldValue.filterCondition;
|
|
388
|
+
var value = fieldValue.attributeValue;
|
|
389
|
+
var isValArray = isArray(value);
|
|
390
|
+
var dbModes = DB_CONSTANTS.DATABASE_MATCH_MODES;
|
|
391
|
+
// If value is an empty array, do not generate the query
|
|
392
|
+
// If values is NaN and number type, do not generate query for this field
|
|
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
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
if (isValArray) {
|
|
400
|
+
// If array is value and mode is between, pass between. Else pass as in query
|
|
401
|
+
filterCondition = filterCondition === dbModes.between || filterCondition === dbModes.notin ? filterCondition : dbModes.in;
|
|
402
|
+
fieldValue.filterCondition = filterCondition;
|
|
403
|
+
}
|
|
404
|
+
matchModeExpr = DB_CONSTANTS.DATABASE_MATCH_MODES_WITH_QUERY[filterCondition];
|
|
405
|
+
paramValue = LiveVariableUtils.getParamValue(value, fieldValue, ignoreCase, skipEncode);
|
|
406
|
+
fieldName = LiveVariableUtils.wrapInLowerCase(fieldName, fieldValue, ignoreCase);
|
|
407
|
+
return replace(matchModeExpr, [fieldName, paramValue]);
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* this is used to identify whether to use ignorecase at each criteria level and not use the variable
|
|
411
|
+
* level isIgnoreCase flag and apply it to all the rules.
|
|
412
|
+
* Instead of adding an extra param to the criteria object, we have added few other matchmodes for string types like
|
|
413
|
+
* anywhere with anywhereignorecase, start with startignorecase, end with endignorecase, exact with exactignorecase,
|
|
414
|
+
* So while creating the criteria itseld user can choose whether to use ignore case or not for a particular column while querying
|
|
415
|
+
* @param matchMode
|
|
416
|
+
* @param ignoreCase
|
|
417
|
+
* @returns {*} boolean
|
|
418
|
+
*/
|
|
419
|
+
LiveVariableUtils.getIgnoreCase = function (matchMode, ignoreCase) {
|
|
420
|
+
var matchModes = DB_CONSTANTS.DATABASE_MATCH_MODES;
|
|
421
|
+
if (indexOf([matchModes['anywhere'], matchModes['nowhere'], matchModes['start'], matchModes['end'], matchModes['exact']], matchMode) !== -1) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
if (indexOf([matchModes['anywhereignorecase'], matchModes['nowhereignorecase'], matchModes['startignorecase'], matchModes['endignorecase'], matchModes['exactignorecase']], matchMode) !== -1) {
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
return ignoreCase;
|
|
428
|
+
};
|
|
429
|
+
LiveVariableUtils.generateSearchQuery = function (rules, condition, ignoreCase, skipEncode) {
|
|
430
|
+
var params = [];
|
|
431
|
+
forEach(rules, function (rule) {
|
|
432
|
+
if (rule) {
|
|
433
|
+
if (rule.rules) {
|
|
434
|
+
var query = LiveVariableUtils.generateSearchQuery(rule.rules, rule.condition, ignoreCase, skipEncode);
|
|
435
|
+
if (query !== '') {
|
|
436
|
+
params.push('(' + query + ')');
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
var searchField = LiveVariableUtils.getSearchField(rule, LiveVariableUtils.getIgnoreCase(rule.filterCondition, ignoreCase), skipEncode);
|
|
441
|
+
if (!isNil(searchField)) {
|
|
442
|
+
params.push(searchField);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
return join(params, ' ' + condition + ' ');
|
|
448
|
+
};
|
|
449
|
+
LiveVariableUtils.prepareTableOptionsForFilterExps = function (variable, options, clonedFields) {
|
|
450
|
+
if (!isDefined(options.searchWithQuery)) {
|
|
451
|
+
options.searchWithQuery = true; // Using query api instead of search api
|
|
452
|
+
}
|
|
453
|
+
var filterOptions = [];
|
|
454
|
+
var matchModes = DB_CONSTANTS.DATABASE_MATCH_MODES;
|
|
455
|
+
var orderByFields, orderByOptions, query;
|
|
456
|
+
var clonedObj = clonedFields || getClonedObject(variable.filterExpressions);
|
|
457
|
+
// if filterexpression from live filter is present use it to query
|
|
458
|
+
if (options.filterExpr && !isEmpty(options.filterExpr)) {
|
|
459
|
+
clonedObj = options.filterExpr;
|
|
460
|
+
}
|
|
461
|
+
// merge live filter runtime values
|
|
462
|
+
var filterRules = {};
|
|
463
|
+
if (!isEmpty(options.filterFields)) {
|
|
464
|
+
var operator = '';
|
|
465
|
+
for (var field in options.filterFields) {
|
|
466
|
+
operator = options.filterFields[field] && options.filterFields[field]['logicalOp'] || '';
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
filterRules = { 'condition': options.logicalOp || operator || 'AND', 'rules': [] };
|
|
470
|
+
forEach(options.filterFields, function (filterObj, filterName) {
|
|
471
|
+
if (!filterObj) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
var filterCondition = matchModes[filterObj.matchMode] || matchModes[filterObj.filterCondition] || filterObj.filterCondition;
|
|
475
|
+
if (includes(DB_CONSTANTS.DATABASE_EMPTY_MATCH_MODES, filterCondition) ||
|
|
476
|
+
(!isNil(filterObj.value) && filterObj.value !== '')) {
|
|
477
|
+
var type = filterObj.type || LiveVariableUtils.getSqlType(variable, filterName, options.entityName);
|
|
478
|
+
var ruleObj = {
|
|
479
|
+
'target': filterName,
|
|
480
|
+
'type': type,
|
|
481
|
+
'matchMode': filterObj.matchMode || (LiveVariableUtils.isStringType(type) ? 'startignorecase' : 'exact'),
|
|
482
|
+
'value': filterObj.value,
|
|
483
|
+
'required': filterObj.required || false
|
|
484
|
+
};
|
|
485
|
+
filterRules.rules.push(ruleObj);
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
if (!isEmpty(clonedObj)) {
|
|
490
|
+
if (!isNil(filterRules.rules) && filterRules.rules.length) {
|
|
491
|
+
// combine both the rules using 'AND'
|
|
492
|
+
var tempRules = { 'condition': 'AND', 'rules': [] };
|
|
493
|
+
tempRules.rules.push(getClonedObject(clonedObj));
|
|
494
|
+
tempRules.rules.push(filterRules);
|
|
495
|
+
clonedObj = tempRules;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
clonedObj = filterRules;
|
|
500
|
+
}
|
|
501
|
+
LiveVariableUtils.processFilterFields(clonedObj.rules, variable, options);
|
|
502
|
+
query = LiveVariableUtils.generateSearchQuery(clonedObj.rules, clonedObj.condition, variable.ignoreCase, options.skipEncode);
|
|
503
|
+
orderByFields = getEvaluatedOrderBy(variable.orderBy, options.orderBy);
|
|
504
|
+
orderByOptions = orderByFields ? 'sort=' + orderByFields : '';
|
|
505
|
+
return {
|
|
506
|
+
'filter': filterOptions,
|
|
507
|
+
'sort': orderByOptions,
|
|
508
|
+
'query': query
|
|
509
|
+
};
|
|
510
|
+
};
|
|
511
|
+
LiveVariableUtils.prepareTableOptions = function (variable, options, clonedFields) {
|
|
512
|
+
if (variable.operation === 'read') {
|
|
513
|
+
return LiveVariableUtils.prepareTableOptionsForFilterExps(variable, options, clonedFields);
|
|
514
|
+
}
|
|
515
|
+
if (!isDefined(options.searchWithQuery)) {
|
|
516
|
+
options.searchWithQuery = true; // Using query api instead of search api
|
|
517
|
+
}
|
|
518
|
+
var filterFields = [];
|
|
519
|
+
var filterOptions = [], orderByFields, orderByOptions, query, optionsQuery;
|
|
520
|
+
clonedFields = clonedFields || variable.filterFields;
|
|
521
|
+
// get the filter fields from the variable
|
|
522
|
+
forEach(clonedFields, function (value, key) {
|
|
523
|
+
if (isObject(value) && (!options.filterFields || !options.filterFields[key] || options.filterFields[key].logicalOp === 'AND')) {
|
|
524
|
+
value.fieldName = key;
|
|
525
|
+
if (LiveVariableUtils.isStringType(LiveVariableUtils.getSQLFieldType(variable, value))) {
|
|
526
|
+
value.filterCondition = DB_CONSTANTS.DATABASE_MATCH_MODES[value.matchMode || variable.matchMode];
|
|
527
|
+
}
|
|
528
|
+
value.isVariableFilter = true;
|
|
529
|
+
filterFields.push(value);
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
// get the filter fields from the options
|
|
533
|
+
forEach(options.filterFields, function (value, key) {
|
|
534
|
+
value.fieldName = key;
|
|
535
|
+
value.filterCondition = DB_CONSTANTS.DATABASE_MATCH_MODES[value.matchMode || options.matchMode || variable.matchMode];
|
|
536
|
+
filterFields.push(value);
|
|
537
|
+
});
|
|
538
|
+
if (variable.operation === 'read' || options.operation === 'read') {
|
|
539
|
+
filterOptions = LiveVariableUtils.getFilterOptions(variable, filterFields, options);
|
|
540
|
+
}
|
|
541
|
+
/*if searchWithQuery is true, then convert the input params into query string. For example if firstName and lastName
|
|
542
|
+
should be sent as params then query string will be q='firstName containing 'someValue' OR lastName containing 'someValue''
|
|
543
|
+
*/
|
|
544
|
+
if (options.searchWithQuery && filterOptions.length) {
|
|
545
|
+
// Generate query for variable filter fields. This has AND logical operator
|
|
546
|
+
query = LiveVariableUtils.getSearchQuery(filter(filterOptions, { 'isVariableFilter': true }), ' AND ', variable.ignoreCase, options.skipEncode);
|
|
547
|
+
// Generate query for option filter fields. This has default logical operator as OR
|
|
548
|
+
optionsQuery = LiveVariableUtils.getSearchQuery(filter(filterOptions, { 'isVariableFilter': undefined }), ' ' + (options.logicalOp || 'AND') + ' ', variable.ignoreCase, options.skipEncode);
|
|
549
|
+
if (optionsQuery) {
|
|
550
|
+
// If both variable and option query are present, merge them with AND
|
|
551
|
+
query = query ? (query + ' AND ( ' + optionsQuery + ' )') : optionsQuery;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
orderByFields = getEvaluatedOrderBy(variable.orderBy, options.orderBy);
|
|
555
|
+
orderByOptions = orderByFields ? 'sort=' + orderByFields : '';
|
|
556
|
+
return {
|
|
557
|
+
'filter': filterOptions,
|
|
558
|
+
'sort': orderByOptions,
|
|
559
|
+
'query': query
|
|
560
|
+
};
|
|
561
|
+
};
|
|
562
|
+
/* Function to check if specified field is of type date*/
|
|
563
|
+
LiveVariableUtils.getFieldType = function (fieldName, variable, relatedField) {
|
|
564
|
+
var fieldType, columns, result;
|
|
565
|
+
if (variable.propertiesMap) {
|
|
566
|
+
columns = variable.propertiesMap.columns || [];
|
|
567
|
+
result = find(columns, function (obj) {
|
|
568
|
+
return obj.fieldName === fieldName;
|
|
569
|
+
});
|
|
570
|
+
// if related field name passed, get its type from columns inside the current field
|
|
571
|
+
if (relatedField && result) {
|
|
572
|
+
result = find(result.columns, function (obj) {
|
|
573
|
+
return obj.fieldName === relatedField;
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
fieldType = result && result.type;
|
|
577
|
+
}
|
|
578
|
+
return fieldType;
|
|
579
|
+
};
|
|
580
|
+
// Prepare formData for blob columns
|
|
581
|
+
LiveVariableUtils.prepareFormData = function (variableDetails, rowObject) {
|
|
582
|
+
var formData = new FormData();
|
|
583
|
+
formData.rowData = clone(rowObject);
|
|
584
|
+
forEach(rowObject, function (colValue, colName) {
|
|
585
|
+
if (LiveVariableUtils.getFieldType(colName, variableDetails) === 'blob') {
|
|
586
|
+
if (isObject(colValue)) {
|
|
587
|
+
if (isArray(colValue)) {
|
|
588
|
+
forEach(colValue, function (fileObject) {
|
|
589
|
+
formData.append(colName, fileObject, fileObject.name);
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
formData.append(colName, colValue, colValue.name);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
rowObject[colName] = colValue !== null ? '' : null;
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
formData.append(SWAGGER_CONSTANTS.WM_DATA_JSON, new Blob([JSON.stringify(rowObject)], {
|
|
600
|
+
type: 'application/json'
|
|
601
|
+
}));
|
|
602
|
+
return formData;
|
|
603
|
+
};
|
|
604
|
+
LiveVariableUtils.traverseFilterExpressions = function (filterExpressions, traverseCallbackFn) {
|
|
605
|
+
if (filterExpressions && filterExpressions.rules) {
|
|
606
|
+
forEach(filterExpressions.rules, function (filExpObj, i) {
|
|
607
|
+
if (filExpObj.rules) {
|
|
608
|
+
LiveVariableUtils.traverseFilterExpressions(filExpObj, traverseCallbackFn);
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
return triggerFn(traverseCallbackFn, filterExpressions, filExpObj);
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
/**
|
|
617
|
+
* Traverses recursively the filterExpressions object and if there is any required field present with no value,
|
|
618
|
+
* then we will return without proceeding further. Its upto the developer to provide the mandatory value,
|
|
619
|
+
* if he wants to assign it in teh onbefore<delete/insert/update>function then make that field in
|
|
620
|
+
* the filter query section as optional
|
|
621
|
+
* @param filterExpressions - recursive rule Object
|
|
622
|
+
* @returns {Object} object or boolean. Object if everything gets validated or else just boolean indicating failure in the validations
|
|
623
|
+
*/
|
|
624
|
+
LiveVariableUtils.getFilterExprFields = function (filterExpressions) {
|
|
625
|
+
var isRequiredFieldAbsent = false;
|
|
626
|
+
var traverseCallbackFn = function (parentFilExpObj, filExpObj) {
|
|
627
|
+
if (filExpObj
|
|
628
|
+
&& filExpObj.required
|
|
629
|
+
&& ((indexOf(['null', 'isnotnull', 'empty', 'isnotempty', 'nullorempty'], filExpObj.matchMode) === -1) && filExpObj.value === '')) {
|
|
630
|
+
isRequiredFieldAbsent = true;
|
|
631
|
+
return false;
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
LiveVariableUtils.traverseFilterExpressions(filterExpressions, traverseCallbackFn);
|
|
635
|
+
return isRequiredFieldAbsent ? !isRequiredFieldAbsent : filterExpressions;
|
|
636
|
+
};
|
|
637
|
+
/**
|
|
638
|
+
*
|
|
639
|
+
* @param variable
|
|
640
|
+
* @param options
|
|
641
|
+
* @returns {function(*=): *} returns a function which should be called for the where clause.
|
|
642
|
+
* This return function can take a function as argument. This argument function can modify the filter fields
|
|
643
|
+
* before generating where clause.
|
|
644
|
+
*/
|
|
645
|
+
LiveVariableUtils.getWhereClauseGenerator = function (variable, options, updatedFilterFields) {
|
|
646
|
+
return function (modifier, skipEncode) {
|
|
647
|
+
var clonedFields = LiveVariableUtils.getFilterExprFields(getClonedObject(updatedFilterFields || variable.filterExpressions));
|
|
648
|
+
// this flag skips the encoding of the query
|
|
649
|
+
if (isDefined(skipEncode)) {
|
|
650
|
+
options.skipEncode = skipEncode;
|
|
651
|
+
}
|
|
652
|
+
if (modifier) {
|
|
653
|
+
// handling the scenario where variable can also have filterFields
|
|
654
|
+
if (options.filterFields) {
|
|
655
|
+
modifier(clonedFields, options);
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
modifier(clonedFields);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
return LiveVariableUtils.prepareTableOptions(variable, options, clonedFields).query;
|
|
662
|
+
};
|
|
663
|
+
};
|
|
664
|
+
return LiveVariableUtils;
|
|
665
|
+
}());
|
|
666
|
+
export { LiveVariableUtils };
|
|
667
|
+
//# sourceMappingURL=live-variable.utils.js.map
|