@qikdev/sdk 0.1.168 → 0.1.169

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.
Files changed (73) hide show
  1. package/dist/sdk.js +2 -0
  2. package/dist/sdk.js.LICENSE.txt +8 -0
  3. package/package.json +12 -2
  4. package/.gitlab-ci.yml +0 -24
  5. package/.husky/pre-commit +0 -5
  6. package/eslint.config.js +0 -6
  7. package/jsdoc.conf +0 -10
  8. package/public/docs/access.html +0 -3826
  9. package/public/docs/api.html +0 -1356
  10. package/public/docs/auth.html +0 -2180
  11. package/public/docs/cache.html +0 -351
  12. package/public/docs/content.html +0 -2560
  13. package/public/docs/files.html +0 -779
  14. package/public/docs/filter.html +0 -1355
  15. package/public/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  16. package/public/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  17. package/public/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  18. package/public/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  19. package/public/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  20. package/public/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  21. package/public/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  22. package/public/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  23. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  24. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -978
  25. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  26. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  27. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  28. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  29. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -1049
  30. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  31. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  32. package/public/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  33. package/public/docs/index.html +0 -96
  34. package/public/docs/qik.access.js.html +0 -790
  35. package/public/docs/qik.api.js.html +0 -511
  36. package/public/docs/qik.auth.js.html +0 -1006
  37. package/public/docs/qik.cache.js.html +0 -131
  38. package/public/docs/qik.content.js.html +0 -918
  39. package/public/docs/qik.core.js.html +0 -301
  40. package/public/docs/qik.files.js.html +0 -219
  41. package/public/docs/qik.filter.js.html +0 -611
  42. package/public/docs/qik.socket.js.html +0 -416
  43. package/public/docs/qik.system.js.html +0 -117
  44. package/public/docs/qik.utils.js.html +0 -1467
  45. package/public/docs/scripts/collapse.js +0 -20
  46. package/public/docs/scripts/linenumber.js +0 -25
  47. package/public/docs/scripts/nav.js +0 -12
  48. package/public/docs/scripts/polyfill.js +0 -4
  49. package/public/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  50. package/public/docs/scripts/prettify/lang-css.js +0 -2
  51. package/public/docs/scripts/prettify/prettify.js +0 -28
  52. package/public/docs/scripts/search.js +0 -83
  53. package/public/docs/socket.html +0 -810
  54. package/public/docs/styles/jsdoc.css +0 -765
  55. package/public/docs/styles/prettify.css +0 -79
  56. package/public/docs/system.html +0 -197
  57. package/src/api/qik.access.js +0 -825
  58. package/src/api/qik.api.js +0 -431
  59. package/src/api/qik.auth.js +0 -881
  60. package/src/api/qik.cache.js +0 -63
  61. package/src/api/qik.content.js +0 -839
  62. package/src/api/qik.core.js +0 -245
  63. package/src/api/qik.files.js +0 -186
  64. package/src/api/qik.filter.js +0 -543
  65. package/src/api/qik.geo.js +0 -895
  66. package/src/api/qik.socket.js +0 -358
  67. package/src/api/qik.system.js +0 -49
  68. package/src/api/qik.utils.js +0 -1412
  69. package/src/index.js +0 -20
  70. package/src/version.js +0 -1
  71. package/test/index.spec.js +0 -41
  72. package/test/mocha.opts +0 -0
  73. package/yarn-error.log +0 -3598
@@ -1,611 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
-
5
- <meta charset="utf-8">
6
- <title>qik.filter.js - Documentation</title>
7
-
8
-
9
- <script src="scripts/prettify/prettify.js"></script>
10
- <script src="scripts/prettify/lang-css.js"></script>
11
- <!--[if lt IE 9]>
12
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
13
- <![endif]-->
14
- <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
- <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
- <script src="scripts/nav.js" defer></script>
17
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
- </head>
19
- <body>
20
-
21
- <input type="checkbox" id="nav-trigger" class="nav-trigger" />
22
- <label for="nav-trigger" class="navicon-button x">
23
- <div class="navicon"></div>
24
- </label>
25
-
26
- <label for="nav-trigger" class="overlay"></label>
27
-
28
- <nav >
29
-
30
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="access.html">access</a><ul class='methods'><li data-type='method'><a href="access.html#.actionableScopes">actionableScopes</a></li><li data-type='method'><a href="access.html#.allPermissions">allPermissions</a></li><li data-type='method'><a href="access.html#.allPermissionTypes">allPermissionTypes</a></li><li data-type='method'><a href="access.html#.allUserScopes">allUserScopes</a></li><li data-type='method'><a href="access.html#.canCreate">canCreate</a></li><li data-type='method'><a href="access.html#.canDeleteItem">canDeleteItem</a></li><li data-type='method'><a href="access.html#.canEditItem">canEditItem</a></li><li data-type='method'><a href="access.html#.canEraseItem">canEraseItem</a></li><li data-type='method'><a href="access.html#.canKnowOf">canKnowOf</a></li><li data-type='method'><a href="access.html#.canListItem">canListItem</a></li><li data-type='method'><a href="access.html#.canRestoreItem">canRestoreItem</a></li><li data-type='method'><a href="access.html#.canViewItem">canViewItem</a></li><li data-type='method'><a href="access.html#.checkActionAccess">checkActionAccess</a></li><li data-type='method'><a href="access.html#.getAllDescendants">getAllDescendants</a></li><li data-type='method'><a href="access.html#.has">has</a></li><li data-type='method'><a href="access.html#.hashPermissions">hashPermissions</a></li><li data-type='method'><a href="access.html#.isAdministrator">isAdministrator</a></li><li data-type='method'><a href="access.html#.isOwner">isOwner</a></li></ul></li><li><a href="api.html">api</a><ul class='methods'><li data-type='method'><a href="api.html#.delete">delete</a></li><li data-type='method'><a href="api.html#.generateEndpointURL">generateEndpointURL</a></li><li data-type='method'><a href="api.html#.get">get</a></li><li data-type='method'><a href="api.html#.patch">patch</a></li><li data-type='method'><a href="api.html#.post">post</a></li><li data-type='method'><a href="api.html#.put">put</a></li></ul></li><li><a href="auth.html">auth</a><ul class='methods'><li data-type='method'><a href="auth.html#.changeOrganisation">changeOrganisation</a></li><li data-type='method'><a href="auth.html#.ensureValidToken">ensureValidToken</a></li><li data-type='method'><a href="auth.html#.getCurrentToken">getCurrentToken</a></li><li data-type='method'><a href="auth.html#.getCurrentUser">getCurrentUser</a></li><li data-type='method'><a href="auth.html#.impersonate">impersonate</a></li><li data-type='method'><a href="auth.html#.login">login</a></li><li data-type='method'><a href="auth.html#.logout">logout</a></li><li data-type='method'><a href="auth.html#.retrieveUserFromResetToken">retrieveUserFromResetToken</a></li><li data-type='method'><a href="auth.html#.sendResetPasswordRequest">sendResetPasswordRequest</a></li><li data-type='method'><a href="auth.html#.set">set</a></li><li data-type='method'><a href="auth.html#.sync">sync</a></li><li data-type='method'><a href="auth.html#.updateUserWithToken">updateUserWithToken</a></li></ul></li><li><a href="cache.html">cache</a><ul class='methods'><li data-type='method'><a href="cache.html#.get">get</a></li><li data-type='method'><a href="cache.html#.reset">reset</a></li></ul></li><li><a href="content.html">content</a><ul class='methods'><li data-type='method'><a href="content.html#.create">create</a></li><li data-type='method'><a href="content.html#.delete">delete</a></li><li data-type='method'><a href="content.html#.get">get</a></li><li data-type='method'><a href="content.html#.getFromSlug">getFromSlug</a></li><li data-type='method'><a href="content.html#.glossary">glossary</a></li><li data-type='method'><a href="content.html#.list">list</a></li><li data-type='method'><a href="content.html#.patch">patch</a></li><li data-type='method'><a href="content.html#.restore">restore</a></li><li data-type='method'><a href="content.html#.scopeGlossary">scopeGlossary</a></li><li data-type='method'><a href="content.html#.update">update</a></li><li data-type='method'><a href="content.html#.validateField">validateField</a></li><li data-type='method'><a href="content.html#.variables">variables</a></li></ul></li><li><a href="files.html">files</a><ul class='methods'><li data-type='method'><a href="files.html#.downloadUrl">downloadUrl</a></li><li data-type='method'><a href="files.html#.filesize">filesize</a></li><li data-type='method'><a href="files.html#.getBinaryTypeFromMime">getBinaryTypeFromMime</a></li><li data-type='method'><a href="files.html#.mediaUrl">mediaUrl</a></li></ul></li><li><a href="filter.html">filter</a><ul class='methods'><li data-type='method'><a href="filter.html#.activeFilterKeys">activeFilterKeys</a></li><li data-type='method'><a href="filter.html#.activeFilterKeys">activeFilterKeys</a></li><li data-type='method'><a href="filter.html#.activeFilterOperators">activeFilterOperators</a></li><li data-type='method'><a href="filter.html#.activeFilters">activeFilters</a></li><li data-type='method'><a href="filter.html#.activeFilterValues">activeFilterValues</a></li><li data-type='method'><a href="filter.html#.filterChangeString">filterChangeString</a></li><li data-type='method'><a href="filter.html#.isValidFilter">isValidFilter</a></li></ul></li><li><a href="socket.html">socket</a><ul class='methods'><li data-type='method'><a href="socket.html#.channel">channel</a></li><li data-type='method'><a href="socket.html#.close">close</a></li><li data-type='method'><a href="socket.html#.connect">connect</a></li><li data-type='method'><a href="socket.html#.reconnect">reconnect</a></li><li data-type='method'><a href="socket.html#.subscribe">subscribe</a></li><li data-type='method'><a href="socket.html#.unsubscribe">unsubscribe</a></li></ul></li><li><a href="system.html">system</a><ul class='methods'><li data-type='method'><a href="system.html#.countries">countries</a></li></ul></li></ul>
31
- </nav>
32
-
33
- <div id="main">
34
-
35
- <h1 class="page-title">qik.filter.js</h1>
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
- <section>
44
- <article>
45
- <pre class="prettyprint source linenums"><code>/**
46
- * @name filter
47
- * @classdesc Provides functions helpful for interacting with the filtering system
48
- * @class
49
- */
50
-
51
-
52
-
53
- ///////////////////////
54
-
55
- var service = {};
56
-
57
-
58
- ///////////////////////
59
-
60
-
61
- function isEmpty(value) {
62
- if (value === 0) {
63
- return false;
64
- }
65
-
66
- var empty = typeof value === 'undefined' || value === null || String(value).trim() === '';
67
-
68
- if (empty) {
69
- return true;
70
- }
71
-
72
- //If it's a string of undefined or null then treat it as empty also
73
- if (value === 'undefined' || value === 'null') {
74
- return true;
75
- }
76
-
77
- return false;
78
- }
79
-
80
- function compactFunction(val) {
81
- return !isEmpty(val)
82
- }
83
-
84
-
85
- ///////////////////////
86
-
87
- service.cleanKey = function(key) {
88
- key = String(key).split('|')[0];
89
-
90
- if (key[0] == '.') {
91
- key = key.slice(1);
92
- }
93
-
94
- return key;
95
- }
96
-
97
- ///////////////////////
98
-
99
- /**
100
- * @description Check if an object is a valid filter
101
- * @alias filter.isValidFilter
102
- * @param {Object} filter The filter block to check
103
- * @example
104
- * // Missing a 'key'
105
- * const invalidFilter = sdk.filter.isValidFilter({comparator:'in', values:['Red', 'Green', 'Blue']})
106
- * // returns false
107
- *
108
- * const validFilter = sdk.filter.isValidFilter({key:'favoriteColor', comparator:'in', values:['Red', 'Green', 'Blue']})
109
- * // returns true
110
- */
111
- service.isValidFilter = function(filter) {
112
- if (!filter) {
113
- return false;
114
- }
115
-
116
- ///////////////////////////
117
-
118
- //If the filter has nested filters consider it valid
119
- //if it has valid child filters
120
- if (filter.operator) {
121
- if (!filter.filters || !filter.filters.length) {
122
- return false;
123
- }
124
-
125
- return filter.filters.some(service.isValidFilter);
126
- }
127
-
128
- // ///////////////////////////
129
-
130
- // //Get the comparator for the filter
131
- // var comparator = hash[filter.comparator];
132
- // if (!comparator) {
133
- // //No comparator was specified for the filter
134
- // return false;
135
- // }
136
-
137
- ///////////////////////////
138
-
139
- var key = service.cleanKey(filter.key);
140
- if (!key) {
141
- //No key has been specified for the filter
142
- return false;
143
- }
144
-
145
- // if(filter.comparator.inputType === 'none') {
146
- // console.log('COMPARATOR IS EMPTY')
147
- // return true;
148
- // }
149
-
150
-
151
- switch (filter.comparator) {
152
- case 'empty':
153
- case 'notempty':
154
- case 'datetoday':
155
- case 'datenottoday':
156
- case 'datebeforetoday':
157
- case 'dateaftertoday':
158
- case 'dateweektoday':
159
- case 'datemonthtoday':
160
- case 'datebeforenow':
161
- case 'dateafternow':
162
- case 'datethisweek':
163
- case 'datethismonth':
164
- return true;
165
- break;
166
- }
167
-
168
-
169
-
170
- var multiValues = (filter.values || []).filter(compactFunction);
171
-
172
-
173
-
174
- return !isEmpty(filter.value) || !isEmpty(filter.value2) || multiValues.length;
175
- // ///////////////////////////
176
-
177
- // switch (filter.inputType) {
178
- // case 'none':
179
- // //If we are checking empty/notempty
180
- // //the filter is always valid without any extra parameters
181
- // return true;
182
- // break;
183
- // case 'range':
184
- // //If we are filtering a number range
185
- // //we need the start and end of the range
186
- // if (!filter.value || isNaN(filter.value)) {
187
- // return false;
188
- // }
189
-
190
- // if (!filter.value2 || isNaN(filter.value2)) {
191
- // return false;
192
- // }
193
- // break;
194
- // case 'daterange':
195
- // if (!filter.value || !parseDate(filter.value)) {
196
- // return false;
197
- // }
198
-
199
- // if (!filter.value2 || !parseDate(filter.value2)) {
200
- // return false;
201
- // }
202
- // break;
203
- // case 'array':
204
- // if (!filter.values || !filter.values.length) {
205
- // return false;
206
- // }
207
- // break;
208
- // default:
209
- // // if (filter.dataType == 'boolean') {
210
- // // //Check if they provided a valid boolean value to the filter
211
- // // return validBooleans[String(filter.value).toLowerCase()];
212
- // // } else {
213
- // // //The filter has not been provided with a value
214
- // if (isEmpty(filter.value)) {
215
- // return false;
216
- // }
217
- // // }
218
- // break;
219
- // }
220
-
221
- ///////////////////////////
222
-
223
- //If we got this far then the information
224
- //provided to the filter is enough to run it
225
- return true;
226
-
227
- }
228
-
229
- ////////////////////////////////////////////////
230
-
231
- /**
232
- *
233
- * @description Returns an array of all active filters
234
- * @alias filter.activeFilters
235
- * @param {Object} filterConfiguration A filter configuration object
236
- * @example
237
- *
238
- * const filterConfiguration = {
239
- * "operator": "and",
240
- * "filters": [
241
- * {
242
- * "operator": "and",
243
- * "filters": [
244
- * {
245
- * "key": "formData.person.firstName",
246
- * "comparator": "startswith",
247
- * "value": "c"
248
- * },
249
- * {
250
- * "key": "invalid no comparator",
251
- * "value": "e"
252
- * }
253
- * {
254
- * "key": "formData.person.lastName",
255
- * "comparator": "endswith",
256
- * "value": "e"
257
- * }
258
- * ]
259
- * }
260
- * ]
261
- * }
262
- *
263
- * const activeFilters = sdk.filter.activeFilters(filterConfiguration);
264
- *
265
- * const returns = [
266
- * {
267
- * "key": "formData.person.firstName",
268
- * "comparator": "startswith",
269
- * "value": "c"
270
- * },
271
- * {
272
- * "key": "formData.person.lastName",
273
- * "comparator": "endswith",
274
- * "value": "e"
275
- * }]
276
- *
277
- */
278
- service.activeFilters = function(filterConfiguration) {
279
- var memo = [];
280
-
281
- retrieveActiveFilter(filterConfiguration, memo);
282
-
283
- return memo;
284
-
285
- ////////////////////////////
286
-
287
- function retrieveActiveFilter(filterBlock, memo) {
288
- if (!filterBlock) {
289
- return;
290
- }
291
-
292
- var isValid = service.isValidFilter(filterBlock);
293
-
294
- if (isValid) {
295
- memo.push(filterBlock);
296
- }
297
-
298
- if (filterBlock.filters &amp;&amp; filterBlock.filters.length) {
299
- filterBlock.filters.forEach(function(b) {
300
- retrieveActiveFilter(b, memo);
301
- })
302
- }
303
- }
304
- }
305
-
306
- ////////////////////////////////////////////////
307
-
308
-
309
- /**
310
- *
311
- * @description Returns an array of all keys that are being actively filtered on
312
- * @alias filter.activeFilterKeys
313
- * @param {Object} filterConfiguration A filter configuration object
314
- * @example
315
- *
316
- * const filterConfiguration = {
317
- * "operator": "and",
318
- * "filters": [
319
- * {
320
- * "operator": "and",
321
- * "filters": [
322
- * {
323
- * "key": "formData.person.firstName",
324
- * "comparator": "startswith",
325
- * "value": "c"
326
- * },
327
- * {
328
- * "key": "invalid no comparator",
329
- * "value": "e"
330
- * }
331
- * {
332
- * "key": "formData.person.lastName",
333
- * "comparator": "endswith",
334
- * "value": "e"
335
- * }
336
- * ]
337
- * }
338
- * ]
339
- * }
340
- *
341
- * const activeFilters = sdk.filter.activeFilterKeys(filterConfiguration);
342
- * // Returns ['formData.person.firstName', 'formData.person.lastName']
343
- *
344
- */
345
- service.activeFilterKeys = function(filterConfiguration, options) {
346
- options = options || {}
347
-
348
- var activeFilters = service.activeFilters(filterConfiguration);
349
- var value = activeFilters
350
- .filter(function(entry) {
351
- //Ignore all the wrapping entries
352
- return !entry.operator;
353
- })
354
- .reduce(function(set, filter) {
355
- var rootKey = service.cleanKey(filter.key);
356
- if (options.trimArrayDelimeters !== false) {
357
- rootKey = rootKey.split('[]').join('');
358
- }
359
- set[rootKey] = true;
360
- return set;
361
- }, {});
362
-
363
- var keys = Object.keys(value);
364
-
365
- return keys;
366
- };
367
-
368
-
369
- /**
370
- *
371
- * @description Returns an array of all comparators that are being actively filtered
372
- * @alias filter.activeFilterKeys
373
- * @param {Object} filterConfiguration A filter configuration object
374
- * @example
375
- *
376
- * const filterConfiguration = {
377
- * "operator": "and",
378
- * "filters": [
379
- * {
380
- * "operator": "and",
381
- * "filters": [
382
- * {
383
- * "key": "formData.person.firstName",
384
- * "comparator": "startswith",
385
- * "value": "c"
386
- * },
387
- * {
388
- * "key": "invalid no comparator",
389
- * "value": "e"
390
- * }
391
- * {
392
- * "key": "formData.person.lastName",
393
- * "comparator": "endswith",
394
- * "value": "e"
395
- * }
396
- * ]
397
- * }
398
- * ]
399
- * }
400
- *
401
- * const activeFilters = sdk.filter.activeFilterKeys(filterConfiguration);
402
- * // Returns ['startswith', 'endswith']
403
- *
404
- */
405
- service.activeFilterComparators = function(filterConfiguration) {
406
- var comparators = service.activeFilters(filterConfiguration)
407
- .filter(function(entry) {
408
- //Ignore all the wrapping entries
409
- return !entry.operator;
410
- })
411
- .reduce(function(set, filter) {
412
- set[filter.comparator] = true;
413
- return set;
414
- }, {})
415
-
416
- return Object.keys(comparators);
417
- }
418
-
419
- /**
420
- *
421
- * @description Returns an array of all comparators that are being actively filtered
422
- * @alias filter.activeFilterOperators
423
- * @param {Object} filterConfiguration A filter configuration object
424
- * @example
425
- *
426
- * const filterConfiguration = {
427
- * "operator": "and",
428
- * "filters": [
429
- * {
430
- * "operator": "nor",
431
- * "filters": [
432
- * {
433
- * "key": "formData.person.firstName",
434
- * "comparator": "startswith",
435
- * "value": "c"
436
- * },
437
- * {
438
- * "key": "invalid no comparator",
439
- * "value": "e"
440
- * }
441
- * {
442
- * "key": "formData.person.lastName",
443
- * "comparator": "endswith",
444
- * "value": "e"
445
- * }
446
- * ]
447
- * }
448
- * ]
449
- * }
450
- *
451
- * const activeFilterOperators = sdk.filter.activeFilterOperators(filterConfiguration);
452
- * // Returns ['and', 'nor']
453
- *
454
- */
455
- service.activeFilterOperators = function(filterConfiguration) {
456
- var operators = service.activeFilters(filterConfiguration)
457
- .filter(function(entry) {
458
- return entry.operator;
459
- })
460
- .reduce(function(set, filter) {
461
- set[filter.operator] = true;
462
- return set;
463
- }, {})
464
-
465
- return Object.keys(operators);
466
- }
467
-
468
-
469
- /**
470
- *
471
- * @description Returns an array of all values that are being actively used by a filter
472
- * @alias filter.activeFilterValues
473
- * @param {Object} filterConfiguration A filter configuration object
474
- * @example
475
- *
476
- * const filterConfiguration = {
477
- * "operator": "and",
478
- * "filters": [
479
- * {
480
- * "operator": "nor",
481
- * "filters": [
482
- * {
483
- * "key": "formData.person.firstName",
484
- * "comparator": "startswith",
485
- * "value": "c"
486
- * },
487
- * {
488
- * "key": "invalid no comparator",
489
- * "value": "e"
490
- * }
491
- * {
492
- * "key": "formData.person.lastName",
493
- * "comparator": "endswith",
494
- * "value": "a"
495
- * }
496
- * ]
497
- * }
498
- * ]
499
- * }
500
- *
501
- * const activeFilterValues = sdk.filter.activeFilterValues(filterConfiguration);
502
- * // Returns ['c', 'a']
503
- *
504
- */
505
- service.activeFilterValues = function(filterConfiguration, options) {
506
-
507
- options = options || {};
508
-
509
- var activeFilters = service.activeFilters(filterConfiguration);
510
-
511
- function mapValue(v) {
512
- if (!v) {
513
- return;
514
- }
515
-
516
- return v._id || v.id || v.title || v.name || v;
517
- }
518
-
519
- var values = activeFilters
520
- .filter(function(entry) {
521
- //Ignore all the wrapping entries
522
- return !entry.operator;
523
- })
524
- .reduce(function(set, filter) {
525
- set = [...set, ...(filter.values || []).map(mapValue), mapValue(filter.value), mapValue(filter.value2)];
526
- return set;
527
- }, [])
528
- .filter(compactFunction);
529
-
530
-
531
-
532
- return values;
533
- }
534
-
535
-
536
- /**
537
- *
538
- * @description Returns an string representation of a filter configuration.
539
- * Often used to check if a user has changed the filter in any way, the string only takes into consideration active valid filters
540
- * @alias filter.filterChangeString
541
- * @param {Object} filterConfiguration A filter configuration object
542
- * @example
543
- *
544
- * const filterConfiguration = {
545
- * "operator": "and",
546
- * "filters": [
547
- * {
548
- * "operator": "nor",
549
- * "filters": [
550
- * {
551
- * "key": "formData.person.firstName",
552
- * "comparator": "startswith",
553
- * "value": "c"
554
- * },
555
- * {
556
- * "key": "invalid no comparator",
557
- * "value": "e"
558
- * }
559
- * {
560
- * "key": "formData.person.lastName",
561
- * "comparator": "endswith",
562
- * "value": "a"
563
- * }
564
- * ]
565
- * }
566
- * ]
567
- * }
568
- *
569
- * // Watch this string for changes
570
- * const changeString = sdk.filter.filterChangeString(filterConfiguration);
571
- */
572
- service.filterChangeString = function(config) {
573
-
574
- var activeFilters = service.activeFilters(config);
575
- return JSON.stringify(activeFilters);
576
- // const string = [
577
- // service.activeFilterKeys(config).join(', '),
578
- // service.activeFilterValues(config).join(', '),
579
- // service.activeFilterComparators(config).join(', '),
580
- // service.activeFilterOperators(config).join(', '),
581
- // ]
582
- // return string.filter(compactFunction).join(', ');
583
- };
584
-
585
- ///////////////////////
586
-
587
- export default service;</code></pre>
588
- </article>
589
- </section>
590
-
591
-
592
-
593
-
594
-
595
-
596
- </div>
597
-
598
- <br class="clear">
599
-
600
- <footer>
601
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Thu Sep 28 2023 07:24:39 GMT+1000 (Australian Eastern Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
602
- </footer>
603
-
604
- <script>prettyPrint();</script>
605
- <script src="scripts/polyfill.js"></script>
606
- <script src="scripts/linenumber.js"></script>
607
-
608
-
609
-
610
- </body>
611
- </html>