terminusdb 12.0.2

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 (86) hide show
  1. package/Contributing.md +36 -0
  2. package/LICENSE +201 -0
  3. package/README.md +175 -0
  4. package/RELEASE_NOTES.md +462 -0
  5. package/dist/index.html +22 -0
  6. package/dist/terminusdb-client.min.js +3 -0
  7. package/dist/terminusdb-client.min.js.LICENSE.txt +188 -0
  8. package/dist/terminusdb-client.min.js.map +1 -0
  9. package/dist/typescript/index.d.ts +14 -0
  10. package/dist/typescript/lib/accessControl.d.ts +554 -0
  11. package/dist/typescript/lib/axiosInstance.d.ts +2 -0
  12. package/dist/typescript/lib/connectionConfig.d.ts +381 -0
  13. package/dist/typescript/lib/const.d.ts +54 -0
  14. package/dist/typescript/lib/dispatchRequest.d.ts +17 -0
  15. package/dist/typescript/lib/errorMessage.d.ts +25 -0
  16. package/dist/typescript/lib/query/woqlBuilder.d.ts +75 -0
  17. package/dist/typescript/lib/query/woqlCore.d.ts +341 -0
  18. package/dist/typescript/lib/query/woqlDoc.d.ts +63 -0
  19. package/dist/typescript/lib/query/woqlLibrary.d.ts +718 -0
  20. package/dist/typescript/lib/query/woqlPrinter.d.ts +71 -0
  21. package/dist/typescript/lib/query/woqlQuery.d.ts +833 -0
  22. package/dist/typescript/lib/typedef.d.ts +624 -0
  23. package/dist/typescript/lib/utils.d.ts +199 -0
  24. package/dist/typescript/lib/valueHash.d.ts +146 -0
  25. package/dist/typescript/lib/viewer/chartConfig.d.ts +62 -0
  26. package/dist/typescript/lib/viewer/chooserConfig.d.ts +38 -0
  27. package/dist/typescript/lib/viewer/documentFrame.d.ts +44 -0
  28. package/dist/typescript/lib/viewer/frameConfig.d.ts +74 -0
  29. package/dist/typescript/lib/viewer/frameRule.d.ts +145 -0
  30. package/dist/typescript/lib/viewer/graphConfig.d.ts +73 -0
  31. package/dist/typescript/lib/viewer/objectFrame.d.ts +212 -0
  32. package/dist/typescript/lib/viewer/streamConfig.d.ts +23 -0
  33. package/dist/typescript/lib/viewer/tableConfig.d.ts +66 -0
  34. package/dist/typescript/lib/viewer/terminusRule.d.ts +75 -0
  35. package/dist/typescript/lib/viewer/viewConfig.d.ts +47 -0
  36. package/dist/typescript/lib/viewer/woqlChart.d.ts +1 -0
  37. package/dist/typescript/lib/viewer/woqlChooser.d.ts +56 -0
  38. package/dist/typescript/lib/viewer/woqlGraph.d.ts +26 -0
  39. package/dist/typescript/lib/viewer/woqlPaging.d.ts +1 -0
  40. package/dist/typescript/lib/viewer/woqlResult.d.ts +128 -0
  41. package/dist/typescript/lib/viewer/woqlRule.d.ts +96 -0
  42. package/dist/typescript/lib/viewer/woqlStream.d.ts +31 -0
  43. package/dist/typescript/lib/viewer/woqlTable.d.ts +102 -0
  44. package/dist/typescript/lib/viewer/woqlView.d.ts +49 -0
  45. package/dist/typescript/lib/woql.d.ts +1267 -0
  46. package/dist/typescript/lib/woqlClient.d.ts +1216 -0
  47. package/index.js +28 -0
  48. package/lib/.eslintrc +1 -0
  49. package/lib/accessControl.js +988 -0
  50. package/lib/axiosInstance.js +5 -0
  51. package/lib/connectionConfig.js +765 -0
  52. package/lib/const.js +59 -0
  53. package/lib/dispatchRequest.js +236 -0
  54. package/lib/errorMessage.js +110 -0
  55. package/lib/query/woqlBuilder.js +234 -0
  56. package/lib/query/woqlCore.js +934 -0
  57. package/lib/query/woqlDoc.js +177 -0
  58. package/lib/query/woqlLibrary.js +1015 -0
  59. package/lib/query/woqlPrinter.js +476 -0
  60. package/lib/query/woqlQuery.js +1865 -0
  61. package/lib/typedef.js +248 -0
  62. package/lib/utils.js +817 -0
  63. package/lib/valueHash.js_old +581 -0
  64. package/lib/viewer/chartConfig.js +411 -0
  65. package/lib/viewer/chooserConfig.js +234 -0
  66. package/lib/viewer/documentFrame.js +206 -0
  67. package/lib/viewer/frameConfig.js +469 -0
  68. package/lib/viewer/frameRule.js +519 -0
  69. package/lib/viewer/graphConfig.js +345 -0
  70. package/lib/viewer/objectFrame.js +1550 -0
  71. package/lib/viewer/streamConfig.js +82 -0
  72. package/lib/viewer/tableConfig.js +310 -0
  73. package/lib/viewer/terminusRule.js +196 -0
  74. package/lib/viewer/viewConfig.js +219 -0
  75. package/lib/viewer/woqlChart.js +17 -0
  76. package/lib/viewer/woqlChooser.js +171 -0
  77. package/lib/viewer/woqlGraph.js +295 -0
  78. package/lib/viewer/woqlPaging.js +148 -0
  79. package/lib/viewer/woqlResult.js +258 -0
  80. package/lib/viewer/woqlRule.js +312 -0
  81. package/lib/viewer/woqlStream.js +27 -0
  82. package/lib/viewer/woqlTable.js +332 -0
  83. package/lib/viewer/woqlView.js +107 -0
  84. package/lib/woql.js +1693 -0
  85. package/lib/woqlClient.js +2091 -0
  86. package/package.json +110 -0
@@ -0,0 +1,411 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ /* eslint-disable no-use-before-define */
3
+ /// /@ts-check
4
+ const Config = require('./viewConfig');
5
+ // eslint-disable-next-line no-unused-vars
6
+ const WOQLChart = require('./woqlChart');
7
+
8
+ function WOQLChartConfig() {
9
+ Config.ViewConfig.call(this);
10
+ this.type = 'chart';
11
+ }
12
+
13
+ Object.setPrototypeOf(WOQLChartConfig.prototype, Config.ViewConfig.prototype);
14
+
15
+ WOQLChartConfig.prototype.prettyPrint = function () {
16
+ let str = 'view = View.chart();\n';
17
+ // eslint-disable-next-line no-plusplus
18
+ for (let i = 0; i < this.rules.length; i++) {
19
+ str += `view.${this.rules[i].prettyPrint()}\n`;
20
+ }
21
+ if (typeof this.margin() !== 'undefined') {
22
+ str += `view.margin(${this.margin()})\n`;
23
+ }
24
+ if (typeof this.title() !== 'undefined') {
25
+ str += `view.title('${this.title()}')\n`;
26
+ }
27
+ if (typeof this.description() !== 'undefined') {
28
+ str += `view.description('${this.description()}')\n`;
29
+ }
30
+ if (typeof this.layout() !== 'undefined') {
31
+ str += `view.layout('${this.layout()}')\n`;
32
+ }
33
+ if (typeof this.align() !== 'undefined') {
34
+ str += `view.align('${this.align()}')\n`;
35
+ }
36
+
37
+ str += this.getBasicPrettyPrint();
38
+ return str;
39
+ };
40
+
41
+ WOQLChartConfig.prototype.json = function () {
42
+ /*
43
+ *general properties
44
+ */
45
+ const conf = {};
46
+ if (typeof this.margin() !== 'undefined') {
47
+ conf.margin = this.margin();
48
+ }
49
+ if (typeof this.title() !== 'undefined') {
50
+ conf.title = this.title();
51
+ }
52
+ if (typeof this.description() !== 'undefined') {
53
+ conf.description = this.description();
54
+ }
55
+ if (typeof this.layout() !== 'undefined') {
56
+ conf.layout = this.layout();
57
+ }
58
+ if (typeof this.align() !== 'undefined') {
59
+ conf.align = this.align();
60
+ }
61
+
62
+ const mj = { chart: conf, rules: this.getRulesJSON() };
63
+ return mj;
64
+ };
65
+
66
+ WOQLChartConfig.prototype.loadJSON = function (config, rules) {
67
+ this.loadBasicJSON(config);
68
+ const jr = [];
69
+ // eslint-disable-next-line no-plusplus
70
+ for (let i = 0; i < rules.length; i++) {
71
+ const nr = new WOQLChartRule();
72
+ nr.json(rules[i]);
73
+ jr.push(nr);
74
+ }
75
+ this.rules = jr;
76
+ if (typeof config.margin !== 'undefined') {
77
+ this.margin(config.margin);
78
+ }
79
+ if (typeof config.title !== 'undefined') {
80
+ this.title(config.title);
81
+ }
82
+ if (typeof config.description !== 'undefined') {
83
+ this.description(config.description);
84
+ }
85
+ if (typeof config.layout !== 'undefined') {
86
+ this.layout(config.layout);
87
+ }
88
+ if (typeof config.align !== 'undefined') {
89
+ this.align(config.align);
90
+ }
91
+ };
92
+
93
+ WOQLChartConfig.prototype.title = function (title) {
94
+ if (typeof title === 'undefined') {
95
+ return this._title;
96
+ }
97
+ this._title = title;
98
+ return this;
99
+ };
100
+
101
+ WOQLChartConfig.prototype.description = function (description) {
102
+ if (description) {
103
+ this._description = description;
104
+ return this;
105
+ }
106
+ return this._description;
107
+ };
108
+
109
+ // legend layout "vertical" | "horizontal"
110
+ WOQLChartConfig.prototype.layout = function (layout) {
111
+ if (layout) {
112
+ this._layout = layout;
113
+ return this;
114
+ }
115
+ return this._layout;
116
+ };
117
+ // legend align'left', 'center', 'right'
118
+ WOQLChartConfig.prototype.align = function (align) {
119
+ if (align) {
120
+ this._align = align;
121
+ return this;
122
+ }
123
+ return this._align;
124
+ };
125
+ // default is { top: 10, right: 30, left: 0, bottom: 80 }
126
+ WOQLChartConfig.prototype.margin = function (marginObj) {
127
+ if (marginObj) {
128
+ this._margin = marginObj;
129
+ return this;
130
+ }
131
+
132
+ return this._margin;
133
+ };
134
+
135
+ WOQLChartConfig.prototype.create = function (client) {
136
+ const wqt = new WOQLChartConfig(client, this);
137
+ return wqt;
138
+ };
139
+
140
+ /*
141
+ {"XAxis":{dataKey:"date_i",type:'number'}
142
+ ,"chartObj":
143
+ [{'label':'Confident','dataKey':'conf',"chartType":"Area",
144
+ "style":{"stroke":"#82ca9d", "fillOpacity":1, "fill":"#82ca9d"}},
145
+ {'label':'Predictions','dataKey':'predictions',"chartType":"Line",
146
+ "style":{"strokeWidth":2, "stroke":"#ff8000"}},
147
+ {'label':'Picks','dataKey':'picks',"chartType":"Point","style":
148
+ {"stroke": '#8884d8', "fill": '#8884d8'}},
149
+ {'label':'Stock','dataKey':'stock',"chartType":"Line","style":
150
+ {"stroke": '#0000ff', "fill": '#0000ff'}}]}
151
+
152
+ {"XAxis":{dataKey:"v:Date","label":{rotate:"-50"}},"chartObj":
153
+ [{'dot':true, 'label':'Quantity','dataKey':'v:Quantity',"chartType":"Line",
154
+ "style": {"stroke": '#FF9800', "fill": '#FF9800'}}]
155
+ }
156
+ */
157
+
158
+ WOQLChartConfig.prototype.xAxis = function (...vars) {
159
+ const woqlRule = new WOQLChartRule().scope('XAxis');
160
+ woqlRule.setVariables(vars);
161
+ this.rules.push(woqlRule);
162
+ return woqlRule;
163
+ };
164
+
165
+ WOQLChartConfig.prototype.legend = function (...vars) {
166
+ const woqlRule = new WOQLChartRule().scope('Legend');
167
+ woqlRule.setVariables(vars);
168
+ this.rules.push(woqlRule);
169
+ return woqlRule;
170
+ };
171
+
172
+ WOQLChartConfig.prototype.yAxis = function (...vars) {
173
+ const woqlRule = new WOQLChartRule().scope('YAxis');
174
+ woqlRule.setVariables(vars);
175
+ this.rules.push(woqlRule);
176
+ return woqlRule;
177
+ };
178
+
179
+ WOQLChartConfig.prototype.bar = function (...vars) {
180
+ const woqlRule = new WOQLChartRule().scope('Bar');
181
+ woqlRule.setVariables(vars);
182
+ this.rules.push(woqlRule);
183
+ return woqlRule;
184
+ };
185
+
186
+ WOQLChartConfig.prototype.line = function (...vars) {
187
+ const woqlRule = new WOQLChartRule().scope('Line');
188
+ woqlRule.setVariables(vars);
189
+ this.rules.push(woqlRule);
190
+ return woqlRule;
191
+ };
192
+
193
+ WOQLChartConfig.prototype.point = function (...vars) {
194
+ const woqlRule = new WOQLChartRule().scope('Point');
195
+ woqlRule.setVariables(vars);
196
+ this.rules.push(woqlRule);
197
+ return woqlRule;
198
+ };
199
+
200
+ WOQLChartConfig.prototype.area = function (...vars) {
201
+ const woqlRule = new WOQLChartRule().scope('Area');
202
+ woqlRule.setVariables(vars);
203
+ this.rules.push(woqlRule);
204
+ return woqlRule;
205
+ };
206
+
207
+ // fillOpacity
208
+ /**
209
+ *
210
+ * @param {Chart} scope
211
+ */
212
+ function WOQLChartRule() {
213
+ Config.WOQLViewRule.call(this);
214
+ }
215
+
216
+ Object.setPrototypeOf(WOQLChartRule.prototype, Config.WOQLViewRule.prototype);
217
+
218
+ WOQLChartRule.prototype.style = function (key, value) {
219
+ if (value) {
220
+ this.rule[key] = value;
221
+ return this;
222
+ }
223
+ return this.rule[key];
224
+ };
225
+
226
+ WOQLChartRule.prototype.label = function (label) {
227
+ if (label) {
228
+ this.rule.label = label;
229
+ return this;
230
+ }
231
+ return this.rule.label;
232
+ };
233
+
234
+ /*
235
+ *line is the default value
236
+ * 'line' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'square' | 'star' |
237
+ * 'triangle' | 'wye' | 'none'
238
+ */
239
+
240
+ WOQLChartRule.prototype.legendType = function (legendType) {
241
+ if (legendType) {
242
+ this.rule.legendType = legendType;
243
+ return this;
244
+ }
245
+ return this.rule.legendType;
246
+ };
247
+
248
+ WOQLChartRule.prototype.fillOpacity = function (fillOpacity) {
249
+ if (fillOpacity || fillOpacity === 0) {
250
+ this.rule.fillOpacity = fillOpacity;
251
+ return this;
252
+ }
253
+ return this.rule.fillOpacity;
254
+ };
255
+
256
+ WOQLChartRule.prototype.fill = function (color) {
257
+ if (color) {
258
+ this.rule.fill = color;
259
+ return this;
260
+ }
261
+ return this.rule.fill;
262
+ };
263
+
264
+ WOQLChartRule.prototype.stroke = function (color) {
265
+ if (color) {
266
+ this.rule.stroke = color;
267
+ return this;
268
+ }
269
+ return this.rule.stroke;
270
+ };
271
+
272
+ WOQLChartRule.prototype.strokeWidth = function (size) {
273
+ if (typeof size !== 'undefined') {
274
+ this.rule.strokeWidth = size;
275
+ return this;
276
+ }
277
+ return this.rule.strokeWidth;
278
+ };
279
+
280
+ WOQLChartRule.prototype.dot = function (isVisible) {
281
+ if (typeof isVisible !== 'undefined') {
282
+ this.rule.dot = isVisible;
283
+ return this;
284
+ }
285
+ return this.rule.dot;
286
+ };
287
+
288
+ WOQLChartRule.prototype.labelRotate = function (angle) {
289
+ if (angle !== undefined) {
290
+ this.rule.labelRotate = angle;
291
+ return this;
292
+ }
293
+ return this.rule.labelRotate;
294
+ };
295
+
296
+ // Specify the padding of x-axis. DEFAULT: { left: 0, right: 0 }
297
+ WOQLChartRule.prototype.padding = function (paddingObj) {
298
+ if (paddingObj) {
299
+ this.rule.padding = paddingObj;
300
+ return this;
301
+ }
302
+
303
+ return this.rule.padding;
304
+ };
305
+
306
+ /*
307
+ *
308
+ */
309
+
310
+ WOQLChartRule.prototype.labelDateInput = function (labelDateInput) {
311
+ if (labelDateInput) {
312
+ this.rule.labelDateInput = labelDateInput;
313
+ return this;
314
+ }
315
+ return this.rule.labelDateInput;
316
+ };
317
+
318
+ /*
319
+ * output date example 'YYYY-MM-DD' : 2020:03:11 or ''YYYY [text] YYYY', 2020 mytext 2020'
320
+ */
321
+
322
+ WOQLChartRule.prototype.labelDateOutput = function (labelDateOutput) {
323
+ if (labelDateOutput) {
324
+ this.rule.labelDateOutput = labelDateOutput;
325
+ return this;
326
+ }
327
+ return this.rule.labelDateOutput;
328
+ };
329
+
330
+ WOQLChartRule.prototype.stackId = function (stackId) {
331
+ if (stackId) {
332
+ this.rule.stackId = stackId;
333
+ return this;
334
+ }
335
+ return this.rule.stackId;
336
+ };
337
+
338
+ /*
339
+ * The type of xAxis 'number' | 'category' default is 'category'
340
+ * The type of yAxis 'number' | 'category' default is 'number'
341
+ * The type of line chart 'basis'|'basisClosed'|'basisOpen'|'linear'|'linearClosed'|'natural'|
342
+ * 'monotoneX'|'monotoneY'|'monotone' | 'step' | 'stepBefore' | 'stepAfter' |
343
+ */
344
+
345
+ WOQLChartRule.prototype.type = function (type) {
346
+ if (type) {
347
+ this.rule.type = type;
348
+ return this;
349
+ }
350
+ return this.rule.type;
351
+ };
352
+ /*
353
+ * works only if type is number
354
+ * domainArr =[min,max];
355
+ */
356
+ WOQLChartRule.prototype.axisDomain = function (domainArr) {
357
+ if (domainArr) {
358
+ this.rule.domain = domainArr;
359
+ return this;
360
+ }
361
+ return this.rule.domain;
362
+ };
363
+
364
+ /*
365
+ *
366
+ * @param {string} name of the variable for the custom color
367
+ */
368
+
369
+ WOQLChartRule.prototype.colorEntry = function (propValue) {
370
+ if (propValue) {
371
+ this.rule.colorEntry = propValue;
372
+ return this;
373
+ }
374
+ return this.rule.colorEntry;
375
+ };
376
+
377
+ /*
378
+ *
379
+ * @param {object} an object of possible value and color {"value1":"#ff0000"...}
380
+ */
381
+
382
+ WOQLChartRule.prototype.customColors = function (colorsObj) {
383
+ if (colorsObj) {
384
+ this.rule.customColors = colorsObj;
385
+ return this;
386
+ }
387
+ return this.rule.customColors;
388
+ };
389
+
390
+ /*
391
+ * @param {array} payload array of the object for descrive the legend
392
+ [{value:"legend label",color:"#ff0000",type:"rect","id":'element id'}]
393
+ */
394
+
395
+ WOQLChartRule.prototype.payload = function (payloadArr) {
396
+ if (payloadArr) {
397
+ this.rule.payload = payloadArr;
398
+ return this;
399
+ }
400
+ return this.rule.payload;
401
+ };
402
+
403
+ WOQLChartRule.prototype.barSize = function (barSize) {
404
+ if (barSize) {
405
+ this.rule.barSize = barSize;
406
+ return this;
407
+ }
408
+ return this.rule.barSize;
409
+ };
410
+
411
+ module.exports = WOQLChartConfig;
@@ -0,0 +1,234 @@
1
+ /* eslint-disable no-param-reassign */
2
+ /* eslint-disable no-use-before-define */
3
+ const Config = require('./viewConfig');
4
+ const WOQLChooser = require('./woqlChooser');
5
+ const UTILS = require('../utils');
6
+
7
+ function WOQLChooserConfig() {
8
+ Config.ViewConfig.call(this);
9
+ this.type = 'chooser';
10
+ }
11
+
12
+ Object.setPrototypeOf(WOQLChooserConfig.prototype, Config.ViewConfig.prototype);
13
+
14
+ WOQLChooserConfig.prototype.create = function (client) {
15
+ const wqt = new WOQLChooser(client, this);
16
+ return wqt;
17
+ };
18
+
19
+ WOQLChooserConfig.prototype.prettyPrint = function () {
20
+ let str = 'view = View.chooser();\n';
21
+ str += this.getBasicPrettyPrint();
22
+ if (typeof this.change() !== 'undefined') {
23
+ str += `view.change(${this.change()})\n`;
24
+ }
25
+ if (typeof this.show_empty() !== 'undefined') {
26
+ str += `view.show_empty('${this.show_empty()}')\n`;
27
+ }
28
+ if (typeof this.values() !== 'undefined') {
29
+ str += `view.values('${UTILS.removeNamespaceFromVariable(this.values())}')\n`;
30
+ }
31
+ if (typeof this.labels() !== 'undefined') {
32
+ str += `view.labels('${UTILS.removeNamespaceFromVariable(this.labels())}')\n`;
33
+ }
34
+ if (typeof this.titles() !== 'undefined') {
35
+ str += `view.titles('${UTILS.removeNamespaceFromVariable(this.titles())}')\n`;
36
+ }
37
+ if (typeof this.sort() !== 'undefined') {
38
+ str += `view.sort(${this.sort()})\n`;
39
+ }
40
+ if (typeof this.direction() !== 'undefined') {
41
+ str += `view.direction('${this.direction()}')\n`;
42
+ }
43
+ // eslint-disable-next-line no-plusplus
44
+ for (let i = 0; i < this.rules.length; i++) {
45
+ str += `view.${this.rules[i].prettyPrint('chooser')}\n`;
46
+ }
47
+ return str;
48
+ };
49
+
50
+ WOQLChooserConfig.prototype.json = function () {
51
+ const conf = this.getBasicJSON();
52
+ if (typeof this.change() !== 'undefined') {
53
+ conf.change = this.change();
54
+ }
55
+ if (typeof this.show_empty() !== 'undefined') {
56
+ conf.show_empty = this.show_empty();
57
+ }
58
+ if (typeof this.values() !== 'undefined') {
59
+ conf.values = this.values();
60
+ }
61
+ if (typeof this.labels() !== 'undefined') {
62
+ conf.labels = this.labels();
63
+ }
64
+ if (typeof this.titles() !== 'undefined') {
65
+ conf.titles = this.titles();
66
+ }
67
+ if (typeof this.sort() !== 'undefined') {
68
+ conf.sort = this.sort();
69
+ }
70
+ if (typeof this.direction() !== 'undefined') {
71
+ conf.direction = this.direction();
72
+ }
73
+ const mj = { chooser: conf, rules: this.getRulesJSON() };
74
+ return mj;
75
+ };
76
+
77
+ WOQLChooserConfig.prototype.loadJSON = function (config, rules) {
78
+ const jr = [];
79
+ // eslint-disable-next-line no-plusplus
80
+ for (let i = 0; i < rules.length; i++) {
81
+ const nr = new WOQLChooserRule();
82
+ nr.json(rules[i]);
83
+ jr.push(nr);
84
+ }
85
+ this.rules = jr;
86
+ this.loadBasicJSON(config);
87
+ if (typeof config.change !== 'undefined') {
88
+ this.change(config.change);
89
+ }
90
+ if (typeof config.show_empty !== 'undefined') {
91
+ this.show_empty(config.show_empty);
92
+ }
93
+ if (typeof config.values !== 'undefined') {
94
+ this.values(config.values);
95
+ }
96
+ if (typeof config.labels !== 'undefined') {
97
+ this.labels(config.labels);
98
+ }
99
+ if (typeof config.titles !== 'undefined') {
100
+ this.titles(config.titles);
101
+ }
102
+ if (typeof config.sort !== 'undefined') {
103
+ this.sort(config.sort);
104
+ }
105
+ if (typeof config.direction !== 'undefined') {
106
+ this.direction(config.direction);
107
+ }
108
+ };
109
+
110
+ WOQLChooserConfig.prototype.change = function (v) {
111
+ if (typeof v !== 'undefined') {
112
+ this.onChange = v;
113
+ return this;
114
+ }
115
+ return this.onChange;
116
+ };
117
+
118
+ WOQLChooserConfig.prototype.show_empty = function (p) {
119
+ if (typeof p !== 'undefined') {
120
+ this.placeholder = p;
121
+ return this;
122
+ }
123
+ return this.placeholder;
124
+ };
125
+
126
+ WOQLChooserConfig.prototype.rule = function (v) {
127
+ const nr = new WOQLChooserRule().scope('row');
128
+ this.rules.push(nr);
129
+ if (v) nr.vars(v);
130
+ // if(v) nr.v(v);
131
+ return nr;
132
+ };
133
+
134
+ WOQLChooserConfig.prototype.values = function (v) {
135
+ if (typeof v !== 'undefined') {
136
+ if (v.substring(0, 2) === 'v:') v = v.substring(2);
137
+ this.value_variable = v;
138
+ return this;
139
+ }
140
+ return this.value_variable;
141
+ };
142
+
143
+ WOQLChooserConfig.prototype.labels = function (v) {
144
+ if (v) {
145
+ if (v.substring(0, 2) === 'v:') v = v.substring(2);
146
+ this.label_variable = v;
147
+ return this;
148
+ }
149
+ return this.label_variable;
150
+ };
151
+
152
+ WOQLChooserConfig.prototype.titles = function (v) {
153
+ if (v) {
154
+ if (v.substring(0, 2) === 'v:') v = v.substring(2);
155
+ this.title_variable = v;
156
+ return this;
157
+ }
158
+ return this.title_variable;
159
+ };
160
+
161
+ WOQLChooserConfig.prototype.sort = function (v) {
162
+ if (v) {
163
+ if (v.substring(0, 2) === 'v:') v = v.substring(2);
164
+ this.sort_variable = v;
165
+ return this;
166
+ }
167
+ return this.sort_variable;
168
+ };
169
+
170
+ WOQLChooserConfig.prototype.direction = function (v) {
171
+ if (v) {
172
+ this.sort_direction = v;
173
+ return this;
174
+ }
175
+ return this.sort_direction;
176
+ };
177
+
178
+ function WOQLChooserRule(scope) {
179
+ Config.WOQLViewRule.call(this, scope);
180
+ }
181
+
182
+ Object.setPrototypeOf(WOQLChooserRule.prototype, Config.WOQLViewRule.prototype);
183
+
184
+ WOQLChooserRule.prototype.label = function (l) {
185
+ if (l) {
186
+ this.rule.label = l;
187
+ return this;
188
+ }
189
+ return this.rule.label;
190
+ };
191
+
192
+ WOQLChooserRule.prototype.title = function (l) {
193
+ if (l) {
194
+ this.rule.title = l;
195
+ return this;
196
+ }
197
+ return this.rule.title;
198
+ };
199
+
200
+ WOQLChooserRule.prototype.values = function (l) {
201
+ if (l) {
202
+ this.rule.values = l;
203
+ return this;
204
+ }
205
+ return this.rule.values;
206
+ };
207
+
208
+ WOQLChooserRule.prototype.selected = function (s) {
209
+ if (typeof s !== 'undefined') {
210
+ this.rule.selected = s;
211
+ return this;
212
+ }
213
+ return this.rule.selected;
214
+ };
215
+
216
+ WOQLChooserRule.prototype.prettyPrint = function () {
217
+ // eslint-disable-next-line no-undef
218
+ let str = WOQLViewRule.prototype.prettyPrint.apply(this);
219
+ if (typeof this.selected() !== 'undefined') {
220
+ str += `.selected(${this.selected()})`;
221
+ }
222
+ if (typeof this.label() !== 'undefined') {
223
+ str += `.label("${this.label()}")`;
224
+ }
225
+ if (typeof this.title() !== 'undefined') {
226
+ str += `.title("${this.title()}")`;
227
+ }
228
+ if (typeof this.values() !== 'undefined') {
229
+ str += `.values("${this.values()}")`;
230
+ }
231
+ return str;
232
+ };
233
+
234
+ module.exports = WOQLChooserConfig;