@fibery/views 1.1.14 → 1.1.15
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/lib/views.js +91 -187
- package/package.json +9 -5
package/lib/views.js
CHANGED
|
@@ -9,20 +9,17 @@ var immutableUpdate__default = /*#__PURE__*/_interopDefaultLegacy(immutableUpdat
|
|
|
9
9
|
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
10
10
|
|
|
11
11
|
function _extends() {
|
|
12
|
-
_extends = Object.assign
|
|
12
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
13
13
|
for (var i = 1; i < arguments.length; i++) {
|
|
14
14
|
var source = arguments[i];
|
|
15
|
-
|
|
16
15
|
for (var key in source) {
|
|
17
16
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
18
17
|
target[key] = source[key];
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
return target;
|
|
24
22
|
};
|
|
25
|
-
|
|
26
23
|
return _extends.apply(this, arguments);
|
|
27
24
|
}
|
|
28
25
|
|
|
@@ -30,86 +27,69 @@ const getFieldType = (schema, fromType, field) => {
|
|
|
30
27
|
if (!schema.typeObjectsByName.hasOwnProperty(fromType) || !schema.typeObjectsByName[fromType].fieldObjectsByName.hasOwnProperty(field)) {
|
|
31
28
|
return null;
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
return schema.typeObjectsByName[fromType].fieldObjectsByName[field].type;
|
|
35
31
|
};
|
|
36
|
-
|
|
37
32
|
const getFieldMeta = (schema, fromType, field) => {
|
|
38
33
|
if (!schema.typeObjectsByName.hasOwnProperty(fromType) || !schema.typeObjectsByName[fromType].fieldObjectsByName.hasOwnProperty(field)) {
|
|
39
34
|
return null;
|
|
40
35
|
}
|
|
41
|
-
|
|
42
36
|
return schema.typeObjectsByName[fromType].fieldObjectsByName[field].rawMeta;
|
|
43
37
|
};
|
|
44
|
-
|
|
45
38
|
const getUnitTypeForTextField = fieldMeta => {
|
|
46
39
|
switch (fieldMeta["ui/type"]) {
|
|
47
40
|
case "email":
|
|
48
41
|
return "email";
|
|
49
|
-
|
|
50
42
|
case "url":
|
|
51
43
|
return "url";
|
|
52
|
-
|
|
53
44
|
case "phone":
|
|
54
45
|
return "phone";
|
|
55
|
-
|
|
56
46
|
default:
|
|
57
47
|
return "text";
|
|
58
48
|
}
|
|
59
49
|
};
|
|
60
|
-
|
|
61
50
|
const fixViewUnit = (schema, fromType, unit) => {
|
|
62
51
|
const {
|
|
63
52
|
type,
|
|
64
53
|
expression
|
|
65
54
|
} = unit;
|
|
66
|
-
|
|
67
55
|
if (type === "date") {
|
|
68
56
|
const [field] = expression;
|
|
69
|
-
|
|
70
57
|
if (getFieldType(schema, fromType, field) === "fibery/date-time") {
|
|
71
58
|
return _extends({}, unit, {
|
|
72
59
|
type: "date-time"
|
|
73
60
|
});
|
|
74
61
|
}
|
|
75
62
|
}
|
|
76
|
-
|
|
77
63
|
if (type === "date-range") {
|
|
78
64
|
const [field] = expression;
|
|
79
|
-
|
|
80
65
|
if (getFieldType(schema, fromType, field) === "fibery/date-time-range") {
|
|
81
66
|
return _extends({}, unit, {
|
|
82
67
|
type: "date-time-range"
|
|
83
68
|
});
|
|
84
69
|
}
|
|
85
70
|
}
|
|
86
|
-
|
|
87
71
|
if (type === "text") {
|
|
88
72
|
const [field] = expression;
|
|
89
73
|
const fieldType = getFieldType(schema, fromType, field);
|
|
90
|
-
|
|
91
74
|
if (fieldType === "fibery/email") {
|
|
92
75
|
return _extends({}, unit, {
|
|
93
76
|
type: "email"
|
|
94
77
|
});
|
|
95
78
|
}
|
|
96
79
|
}
|
|
97
|
-
|
|
98
80
|
if (["text", "email", "phone", "url"].includes(type)) {
|
|
99
81
|
const [field] = expression;
|
|
100
|
-
|
|
101
82
|
if (getFieldType(schema, fromType, field) === "fibery/text") {
|
|
102
83
|
return _extends({}, unit, {
|
|
103
84
|
type: getUnitTypeForTextField(getFieldMeta(schema, fromType, field))
|
|
104
85
|
});
|
|
105
86
|
}
|
|
106
87
|
}
|
|
107
|
-
|
|
108
88
|
return unit;
|
|
109
89
|
};
|
|
110
90
|
|
|
91
|
+
// Return this symbol from a visitor callback to remove the node from the
|
|
111
92
|
// output. Not supported in all places, add support as needed.
|
|
112
|
-
|
|
113
93
|
const REMOVE = Symbol("remove");
|
|
114
94
|
const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, queryExpression) => {
|
|
115
95
|
const {
|
|
@@ -117,7 +97,6 @@ const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, quer
|
|
|
117
97
|
"q/where": whereExpression,
|
|
118
98
|
"q/order-by": orderByExpression
|
|
119
99
|
} = queryExpression;
|
|
120
|
-
|
|
121
100
|
if (schema.typeObjectsByName.hasOwnProperty(fromExpression)) {
|
|
122
101
|
const typeObject = schema.typeObjectsByName[fromExpression];
|
|
123
102
|
return ___default["default"].pickBy(_extends({}, queryExpression, whereExpression ? {
|
|
@@ -126,7 +105,6 @@ const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, quer
|
|
|
126
105
|
"q/order-by": visitors.deleteExpressionsWithNotFoundFieldsVisitor(typeObject).visitOrderByExpression(orderByExpression)
|
|
127
106
|
} : null));
|
|
128
107
|
}
|
|
129
|
-
|
|
130
108
|
return null;
|
|
131
109
|
};
|
|
132
110
|
const replaceNamesWithIdsInExpression = (schema, fromType, expression) => {
|
|
@@ -134,7 +112,6 @@ const replaceNamesWithIdsInExpression = (schema, fromType, expression) => {
|
|
|
134
112
|
const typeObject = schema.typeObjectsByName[fromType];
|
|
135
113
|
return visitors.replaceNamesWithIdsVisitor(typeObject).visitExpression(expression);
|
|
136
114
|
}
|
|
137
|
-
|
|
138
115
|
return expression;
|
|
139
116
|
};
|
|
140
117
|
const replaceIdsWithNamesInExpression = (schema, fromTypeId, expression) => {
|
|
@@ -142,20 +119,17 @@ const replaceIdsWithNamesInExpression = (schema, fromTypeId, expression) => {
|
|
|
142
119
|
const typeObject = schema.typeObjectsById[fromTypeId];
|
|
143
120
|
return visitors.replaceIdsWithNamesVisitor(typeObject).visitExpression(expression);
|
|
144
121
|
}
|
|
145
|
-
|
|
146
122
|
return expression;
|
|
147
123
|
};
|
|
148
124
|
const visitViewUnit = (fromType, unit, visitor) => {
|
|
149
125
|
const {
|
|
150
126
|
expression
|
|
151
127
|
} = unit;
|
|
152
|
-
|
|
153
128
|
if (expression) {
|
|
154
129
|
return _extends({}, unit, {
|
|
155
130
|
expression: visitor.visitExpression(fromType, expression)
|
|
156
131
|
});
|
|
157
132
|
}
|
|
158
|
-
|
|
159
133
|
return unit;
|
|
160
134
|
};
|
|
161
135
|
const visitContextExpression = (fromType, contextExpression, visitor) => {
|
|
@@ -168,7 +142,6 @@ const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
|
|
|
168
142
|
"q/where": whereExpression,
|
|
169
143
|
"q/order-by": orderByExpression
|
|
170
144
|
} = queryExpression;
|
|
171
|
-
|
|
172
145
|
if (schema.typeObjectsById.hasOwnProperty(fromExpression)) {
|
|
173
146
|
const typeObject = schema.typeObjectsById[fromExpression];
|
|
174
147
|
return _extends({}, queryExpression, {
|
|
@@ -179,7 +152,6 @@ const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
|
|
|
179
152
|
"q/order-by": visitors.replaceIdsWithNamesVisitor(typeObject).visitOrderByExpression(orderByExpression)
|
|
180
153
|
} : null);
|
|
181
154
|
}
|
|
182
|
-
|
|
183
155
|
return queryExpression;
|
|
184
156
|
};
|
|
185
157
|
const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
|
|
@@ -188,7 +160,6 @@ const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
|
|
|
188
160
|
"q/where": whereExpression,
|
|
189
161
|
"q/order-by": orderByExpression
|
|
190
162
|
} = queryExpression;
|
|
191
|
-
|
|
192
163
|
if (schema.typeObjectsByName.hasOwnProperty(fromExpression)) {
|
|
193
164
|
const typeObject = schema.typeObjectsByName[fromExpression];
|
|
194
165
|
return _extends({}, queryExpression, {
|
|
@@ -199,7 +170,6 @@ const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
|
|
|
199
170
|
"q/order-by": visitors.replaceNamesWithIdsVisitor(typeObject).visitOrderByExpression(orderByExpression)
|
|
200
171
|
} : null);
|
|
201
172
|
}
|
|
202
|
-
|
|
203
173
|
return queryExpression;
|
|
204
174
|
};
|
|
205
175
|
const deleteExpressionWithNotFoundFieldsOrTypesInExpression = (schema, fromType, expression) => {
|
|
@@ -207,7 +177,6 @@ const deleteExpressionWithNotFoundFieldsOrTypesInExpression = (schema, fromType,
|
|
|
207
177
|
const typeObject = schema.typeObjectsByName[fromType];
|
|
208
178
|
return visitors.deleteExpressionsWithNotFoundFieldsVisitor(typeObject).visitExpression(expression);
|
|
209
179
|
}
|
|
210
|
-
|
|
211
180
|
return null;
|
|
212
181
|
};
|
|
213
182
|
const resetContextExpressionIfBroken = (schema, fromType, expression, defaultExpression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression) || defaultExpression;
|
|
@@ -218,7 +187,6 @@ const isUnitExpressionValid = unit => {
|
|
|
218
187
|
} = unit;
|
|
219
188
|
return expression !== null;
|
|
220
189
|
}
|
|
221
|
-
|
|
222
190
|
return true;
|
|
223
191
|
};
|
|
224
192
|
|
|
@@ -227,20 +195,16 @@ const visitQueryExpressionHolder = (queryHolder, visitor) => {
|
|
|
227
195
|
const {
|
|
228
196
|
query
|
|
229
197
|
} = queryHolder;
|
|
230
|
-
|
|
231
198
|
if (query) {
|
|
232
199
|
const queryNew = visitor.visitQueryExpression(query);
|
|
233
200
|
return queryNew ? _extends({}, queryHolder, {
|
|
234
201
|
query: queryNew
|
|
235
202
|
}) : null;
|
|
236
203
|
}
|
|
237
|
-
|
|
238
204
|
return queryHolder;
|
|
239
205
|
}
|
|
240
|
-
|
|
241
206
|
return queryHolder;
|
|
242
207
|
};
|
|
243
|
-
|
|
244
208
|
const visitAxisUnits = (axis, fromType, visitor) => {
|
|
245
209
|
return fromType ? immutableUpdate__default["default"](axis, {
|
|
246
210
|
contextExpression: {
|
|
@@ -251,20 +215,15 @@ const visitAxisUnits = (axis, fromType, visitor) => {
|
|
|
251
215
|
}
|
|
252
216
|
}) : axis;
|
|
253
217
|
};
|
|
254
|
-
|
|
255
218
|
const visitAxis$1 = (axis, visitor) => {
|
|
256
219
|
if (axis && axis.hasOwnProperty("query")) {
|
|
257
220
|
const fromType = ___default["default"].get(axis, ["query", "q/from"]);
|
|
258
|
-
|
|
259
221
|
const axisWithVisitedQuery = visitQueryExpressionHolder(axis, visitor);
|
|
260
|
-
|
|
261
222
|
if (axisWithVisitedQuery) {
|
|
262
223
|
return visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
|
|
263
224
|
}
|
|
264
|
-
|
|
265
225
|
return axisWithVisitedQuery;
|
|
266
226
|
}
|
|
267
|
-
|
|
268
227
|
if (axis && axis.hasOwnProperty("enums")) {
|
|
269
228
|
const axisNew = immutableUpdate__default["default"](axis, {
|
|
270
229
|
enums: {
|
|
@@ -276,24 +235,18 @@ const visitAxis$1 = (axis, visitor) => {
|
|
|
276
235
|
} = axisNew;
|
|
277
236
|
return enums ? axisNew : null;
|
|
278
237
|
}
|
|
279
|
-
|
|
280
238
|
return axis;
|
|
281
239
|
};
|
|
282
|
-
|
|
240
|
+
const isAxisFieldExpression = expression => utils.isFieldExpression(expression) && expression.length === 1;
|
|
283
241
|
const ensureAxisAndItemExpressionInvariant$1 = view => {
|
|
284
242
|
const actions = [];
|
|
285
|
-
|
|
286
243
|
const x = ___default["default"].get(view, ["fibery/meta", "x"]);
|
|
287
|
-
|
|
288
244
|
const y = ___default["default"].get(view, ["fibery/meta", "y"]);
|
|
289
|
-
|
|
290
245
|
const items = ___default["default"].get(view, ["fibery/meta", "items"]);
|
|
291
|
-
|
|
292
246
|
if (x === null) {
|
|
293
247
|
const resetActions = items.map(item => () => item.xExpression = null);
|
|
294
248
|
actions.push(...resetActions);
|
|
295
249
|
}
|
|
296
|
-
|
|
297
250
|
if (x !== null && ___default["default"].some(items, ({
|
|
298
251
|
xExpression
|
|
299
252
|
}) => xExpression === null)) {
|
|
@@ -301,12 +254,10 @@ const ensureAxisAndItemExpressionInvariant$1 = view => {
|
|
|
301
254
|
actions.push(...resetActions);
|
|
302
255
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "x"], null));
|
|
303
256
|
}
|
|
304
|
-
|
|
305
257
|
if (y === null) {
|
|
306
258
|
const resetActions = items.map(item => () => item.yExpression = null);
|
|
307
259
|
actions.push(...resetActions);
|
|
308
260
|
}
|
|
309
|
-
|
|
310
261
|
if (y !== null && ___default["default"].some(items, ({
|
|
311
262
|
yExpression
|
|
312
263
|
}) => yExpression === null)) {
|
|
@@ -314,36 +265,30 @@ const ensureAxisAndItemExpressionInvariant$1 = view => {
|
|
|
314
265
|
actions.push(...resetActions);
|
|
315
266
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
|
|
316
267
|
}
|
|
317
|
-
|
|
318
268
|
if (x !== null && ___default["default"].isEmpty(items)) {
|
|
319
269
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "x"], null));
|
|
320
270
|
}
|
|
321
|
-
|
|
322
271
|
if (y !== null && ___default["default"].isEmpty(items)) {
|
|
323
272
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
|
|
324
273
|
}
|
|
325
|
-
|
|
326
274
|
if (x !== null && ___default["default"].some(items, ({
|
|
327
275
|
xExpression
|
|
328
|
-
}) => !
|
|
276
|
+
}) => !isAxisFieldExpression(xExpression))) {
|
|
329
277
|
const resetActions = items.map(item => () => item.xExpression = null);
|
|
330
278
|
actions.push(...resetActions);
|
|
331
279
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "x"], null));
|
|
332
280
|
}
|
|
333
|
-
|
|
334
281
|
if (y !== null && ___default["default"].some(items, ({
|
|
335
282
|
yExpression
|
|
336
|
-
}) => !
|
|
283
|
+
}) => !isAxisFieldExpression(yExpression))) {
|
|
337
284
|
const resetActions = items.map(item => () => item.yExpression = null);
|
|
338
285
|
actions.push(...resetActions);
|
|
339
286
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
|
|
340
287
|
}
|
|
341
|
-
|
|
342
288
|
actions.forEach(action => action());
|
|
343
289
|
return view;
|
|
344
290
|
};
|
|
345
|
-
|
|
346
|
-
const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
291
|
+
const visitView$5 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
347
292
|
"fibery/meta": {
|
|
348
293
|
x: {
|
|
349
294
|
$apply: x => visitAxis$1(x, visitor)
|
|
@@ -354,7 +299,6 @@ const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
354
299
|
items: {
|
|
355
300
|
$apply: items => items.map(item => {
|
|
356
301
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
357
|
-
|
|
358
302
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
359
303
|
xExpression: {
|
|
360
304
|
$apply: xExpression => xExpression ? visitor.visitExpression(fromType, xExpression) : xExpression
|
|
@@ -388,7 +332,6 @@ const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
388
332
|
}
|
|
389
333
|
}
|
|
390
334
|
});
|
|
391
|
-
|
|
392
335
|
const replaceNamesWithIdsViewVisitor = schema => {
|
|
393
336
|
const visitor = {
|
|
394
337
|
visitQueryExpression: queryExpression => replaceNamesWithIdsInQueryExpression(schema, queryExpression),
|
|
@@ -396,21 +339,17 @@ const replaceNamesWithIdsViewVisitor = schema => {
|
|
|
396
339
|
visitEnums: enums => ___default["default"].entries(enums).reduce((result, [type, queryHolder]) => {
|
|
397
340
|
if (schema.typeObjectsByName.hasOwnProperty(type)) {
|
|
398
341
|
const typeObject = schema.typeObjectsByName[type];
|
|
399
|
-
|
|
400
342
|
const fromType = ___default["default"].get(queryHolder, ["query", "q/from"]);
|
|
401
|
-
|
|
402
343
|
const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
|
|
403
344
|
result[typeObject.id] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
|
|
404
345
|
} else {
|
|
405
346
|
result[type] = queryHolder;
|
|
406
347
|
}
|
|
407
|
-
|
|
408
348
|
return result;
|
|
409
349
|
}, {})
|
|
410
350
|
};
|
|
411
351
|
return visitor;
|
|
412
352
|
};
|
|
413
|
-
|
|
414
353
|
const replaceIdsWithNamesViewVisitor = schema => {
|
|
415
354
|
const visitor = {
|
|
416
355
|
visitQueryExpression: queryExpression => replaceIdsWithNamesInQueryExpression(schema, queryExpression),
|
|
@@ -418,21 +357,17 @@ const replaceIdsWithNamesViewVisitor = schema => {
|
|
|
418
357
|
visitEnums: enums => ___default["default"].entries(enums).reduce((result, [typeId, queryHolder]) => {
|
|
419
358
|
if (schema.typeObjectsById.hasOwnProperty(typeId)) {
|
|
420
359
|
const typeObject = schema.typeObjectsById[typeId];
|
|
421
|
-
|
|
422
360
|
const fromType = ___default["default"].get(queryHolder, ["query", "q/from"]);
|
|
423
|
-
|
|
424
361
|
const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
|
|
425
362
|
result[typeObject.name] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
|
|
426
363
|
} else {
|
|
427
364
|
result[typeId] = queryHolder;
|
|
428
365
|
}
|
|
429
|
-
|
|
430
366
|
return result;
|
|
431
367
|
}, {})
|
|
432
368
|
};
|
|
433
369
|
return visitor;
|
|
434
370
|
};
|
|
435
|
-
|
|
436
371
|
const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = schema => {
|
|
437
372
|
const visitor = {
|
|
438
373
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
@@ -442,23 +377,18 @@ const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = schema => {
|
|
|
442
377
|
if (schema.typeObjectsByName.hasOwnProperty(type)) {
|
|
443
378
|
const typeObject = schema.typeObjectsByName[type];
|
|
444
379
|
const queryHolderResult = visitQueryExpressionHolder(queryHolder, visitor);
|
|
445
|
-
|
|
446
380
|
if (queryHolderResult) {
|
|
447
381
|
result[typeObject.name] = queryHolderResult;
|
|
448
382
|
}
|
|
449
|
-
|
|
450
383
|
return result;
|
|
451
384
|
}
|
|
452
|
-
|
|
453
385
|
return result;
|
|
454
386
|
}, {});
|
|
455
|
-
|
|
456
387
|
return ___default["default"].isEmpty(enumsNew) ? null : enumsNew;
|
|
457
388
|
}
|
|
458
389
|
};
|
|
459
390
|
return visitor;
|
|
460
391
|
};
|
|
461
|
-
|
|
462
392
|
const fixUserSelectedUnitsViewVisitor = schema => {
|
|
463
393
|
return {
|
|
464
394
|
visitQueryExpression: queryExpression => queryExpression,
|
|
@@ -467,24 +397,23 @@ const fixUserSelectedUnitsViewVisitor = schema => {
|
|
|
467
397
|
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
|
|
468
398
|
};
|
|
469
399
|
};
|
|
470
|
-
|
|
471
|
-
const
|
|
472
|
-
const replaceNamesWithIdsInBoardView = (schema, view) => visitView$4(view, replaceNamesWithIdsViewVisitor(schema));
|
|
400
|
+
const replaceIdsWithNamesInBoardView = (schema, view) => visitView$5(view, replaceIdsWithNamesViewVisitor(schema));
|
|
401
|
+
const replaceNamesWithIdsInBoardView = (schema, view) => visitView$5(view, replaceNamesWithIdsViewVisitor(schema));
|
|
473
402
|
const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = (schema, view, ensureAxisInvariant = true) => {
|
|
474
|
-
const viewNew = visitView$
|
|
403
|
+
const viewNew = visitView$5(view, deleteExpressionWithNotFoundFieldsOrTypesViewVisitor(schema));
|
|
475
404
|
return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant$1(viewNew) : viewNew;
|
|
476
405
|
};
|
|
477
406
|
const fixUserSelectedUnitsInBoardView = (schema, view) => {
|
|
478
|
-
return visitView$
|
|
407
|
+
return visitView$5(view, fixUserSelectedUnitsViewVisitor(schema));
|
|
479
408
|
};
|
|
480
|
-
const fixContextExpressionWithBrokenPath$6 = (schema, view, defaultContextExpression) => visitView$
|
|
409
|
+
const fixContextExpressionWithBrokenPath$6 = (schema, view, defaultContextExpression) => visitView$5(view, {
|
|
481
410
|
visitQueryExpression: query => query,
|
|
482
411
|
visitExpression: (fromType, expression) => expression,
|
|
483
412
|
visitEnums: enums => enums,
|
|
484
413
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
485
414
|
});
|
|
486
415
|
const collectGarbage$6 = view => {
|
|
487
|
-
return visitView$
|
|
416
|
+
return visitView$5(view, {
|
|
488
417
|
visitQueryExpression: queryExpression => queryExpression,
|
|
489
418
|
visitExpression: (fromType, expression) => expression,
|
|
490
419
|
visitEnums: enums => enums,
|
|
@@ -492,12 +421,11 @@ const collectGarbage$6 = view => {
|
|
|
492
421
|
});
|
|
493
422
|
};
|
|
494
423
|
|
|
495
|
-
const visitView$
|
|
424
|
+
const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
496
425
|
"fibery/meta": {
|
|
497
426
|
items: {
|
|
498
427
|
$apply: items => items.map(item => {
|
|
499
428
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
500
|
-
|
|
501
429
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
502
430
|
startExpression: {
|
|
503
431
|
$apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
|
|
@@ -531,49 +459,47 @@ const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
531
459
|
}
|
|
532
460
|
}
|
|
533
461
|
});
|
|
534
|
-
|
|
535
462
|
const replaceNamesWithIdsInCalendarView = (schema, view) => {
|
|
536
|
-
return visitView$
|
|
463
|
+
return visitView$4(view, {
|
|
537
464
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
538
465
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
|
|
539
466
|
});
|
|
540
467
|
};
|
|
541
468
|
const replaceIdsWithNamesInCalendarView = (schema, view) => {
|
|
542
|
-
return visitView$
|
|
469
|
+
return visitView$4(view, {
|
|
543
470
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
544
471
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
|
|
545
472
|
});
|
|
546
473
|
};
|
|
547
|
-
const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView$
|
|
474
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView$4(view, {
|
|
548
475
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
549
476
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
550
477
|
});
|
|
551
478
|
const fixUserSelectedUnitsInCalendarView = (schema, view) => {
|
|
552
|
-
return visitView$
|
|
479
|
+
return visitView$4(view, {
|
|
553
480
|
visitExpression: (fromType, expression) => expression,
|
|
554
481
|
visitQueryExpression: query => query,
|
|
555
482
|
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
|
|
556
483
|
});
|
|
557
484
|
};
|
|
558
|
-
const fixContextExpressionWithBrokenPath$5 = (schema, view, defaultContextExpression) => visitView$
|
|
485
|
+
const fixContextExpressionWithBrokenPath$5 = (schema, view, defaultContextExpression) => visitView$4(view, {
|
|
559
486
|
visitQueryExpression: query => query,
|
|
560
487
|
visitExpression: (fromType, expression) => expression,
|
|
561
488
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
562
489
|
});
|
|
563
490
|
const collectGarbage$5 = view => {
|
|
564
|
-
return visitView$
|
|
491
|
+
return visitView$4(view, {
|
|
565
492
|
visitExpression: (fromType, expression) => expression,
|
|
566
493
|
visitQueryExpression: query => query,
|
|
567
494
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
568
495
|
});
|
|
569
496
|
};
|
|
570
497
|
|
|
571
|
-
const visitView$
|
|
498
|
+
const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
572
499
|
"fibery/meta": {
|
|
573
500
|
items: {
|
|
574
501
|
$apply: items => items.map(item => {
|
|
575
502
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
576
|
-
|
|
577
503
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
578
504
|
postExpression: {
|
|
579
505
|
$apply: postExpression => postExpression ? visitor.visitExpression(fromType, postExpression) : postExpression
|
|
@@ -604,37 +530,36 @@ const visitView$2 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
604
530
|
}
|
|
605
531
|
}
|
|
606
532
|
});
|
|
607
|
-
|
|
608
533
|
const replaceNamesWithIdsInFeedView = (schema, view) => {
|
|
609
|
-
return visitView$
|
|
534
|
+
return visitView$3(view, {
|
|
610
535
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
611
536
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
|
|
612
537
|
});
|
|
613
538
|
};
|
|
614
539
|
const replaceIdsWithNamesInFeedView = (schema, view) => {
|
|
615
|
-
return visitView$
|
|
540
|
+
return visitView$3(view, {
|
|
616
541
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
617
542
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
|
|
618
543
|
});
|
|
619
544
|
};
|
|
620
|
-
const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView$
|
|
545
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView$3(view, {
|
|
621
546
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
622
547
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
623
548
|
});
|
|
624
549
|
const fixUserSelectedUnitsInFeedView = (schema, view) => {
|
|
625
|
-
return visitView$
|
|
550
|
+
return visitView$3(view, {
|
|
626
551
|
visitExpression: (fromType, expression) => expression,
|
|
627
552
|
visitQueryExpression: query => query,
|
|
628
553
|
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
|
|
629
554
|
});
|
|
630
555
|
};
|
|
631
|
-
const fixContextExpressionWithBrokenPath$4 = (schema, view, defaultContextExpression) => visitView$
|
|
556
|
+
const fixContextExpressionWithBrokenPath$4 = (schema, view, defaultContextExpression) => visitView$3(view, {
|
|
632
557
|
visitQueryExpression: query => query,
|
|
633
558
|
visitExpression: (fromType, expression) => expression,
|
|
634
559
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
635
560
|
});
|
|
636
561
|
const collectGarbage$4 = view => {
|
|
637
|
-
return visitView$
|
|
562
|
+
return visitView$3(view, {
|
|
638
563
|
visitExpression: (fromType, expression) => expression,
|
|
639
564
|
visitQueryExpression: query => query,
|
|
640
565
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
@@ -643,7 +568,6 @@ const collectGarbage$4 = view => {
|
|
|
643
568
|
|
|
644
569
|
const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
645
570
|
var _view$fiberyMeta, _view$fiberyMeta2;
|
|
646
|
-
|
|
647
571
|
const typeId = (_view$fiberyMeta = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta.typeId;
|
|
648
572
|
const typeObject = schema.typeObjectsByName.hasOwnProperty(typeId) ? schema.typeObjectsByName[typeId] : null;
|
|
649
573
|
const fields = (_view$fiberyMeta2 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta2.fields;
|
|
@@ -651,7 +575,6 @@ const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
|
651
575
|
if (!(typeObject != null && typeObject.fieldObjectsByName.hasOwnProperty(field.id))) {
|
|
652
576
|
return field;
|
|
653
577
|
}
|
|
654
|
-
|
|
655
578
|
return _extends({}, field, {
|
|
656
579
|
id: typeObject.fieldObjectsByName[field.id].id
|
|
657
580
|
});
|
|
@@ -665,7 +588,6 @@ const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
|
665
588
|
};
|
|
666
589
|
const replaceIdsWithNamesInFormView = (schema, view) => {
|
|
667
590
|
var _view$fiberyMeta3, _view$fiberyMeta4;
|
|
668
|
-
|
|
669
591
|
const typeId = (_view$fiberyMeta3 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta3.typeId;
|
|
670
592
|
const typeObject = schema.typeObjectsById.hasOwnProperty(typeId) ? schema.typeObjectsById[typeId] : null;
|
|
671
593
|
const fields = (_view$fiberyMeta4 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta4.fields;
|
|
@@ -673,7 +595,6 @@ const replaceIdsWithNamesInFormView = (schema, view) => {
|
|
|
673
595
|
if (!(typeObject != null && typeObject.fieldObjectsById.hasOwnProperty(field.id))) {
|
|
674
596
|
return field;
|
|
675
597
|
}
|
|
676
|
-
|
|
677
598
|
return _extends({}, field, {
|
|
678
599
|
id: typeObject.fieldObjectsById[field.id].name
|
|
679
600
|
});
|
|
@@ -687,7 +608,6 @@ const replaceIdsWithNamesInFormView = (schema, view) => {
|
|
|
687
608
|
};
|
|
688
609
|
const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
|
|
689
610
|
var _view$fiberyMeta5, _view$fiberyMeta6;
|
|
690
|
-
|
|
691
611
|
// we expect view in names terms here.
|
|
692
612
|
const typeName = (_view$fiberyMeta5 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta5.typeId;
|
|
693
613
|
const typeObject = schema.typeObjectsByName.hasOwnProperty(typeName) ? schema.typeObjectsByName[typeName] : null;
|
|
@@ -701,6 +621,54 @@ const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
|
|
|
701
621
|
});
|
|
702
622
|
};
|
|
703
623
|
|
|
624
|
+
const visitView$2 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
625
|
+
"fibery/meta": {
|
|
626
|
+
items: {
|
|
627
|
+
$apply: items => items.map(item => {
|
|
628
|
+
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
629
|
+
return fromType ? immutableUpdate__default["default"](item, {
|
|
630
|
+
locationExpression: {
|
|
631
|
+
$apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
|
|
632
|
+
},
|
|
633
|
+
contextExpression: {
|
|
634
|
+
$apply: contextExpression => visitContextExpression(fromType, contextExpression, visitor)
|
|
635
|
+
},
|
|
636
|
+
query: {
|
|
637
|
+
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
638
|
+
},
|
|
639
|
+
units: {
|
|
640
|
+
$apply: units => units ? units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit) : undefined
|
|
641
|
+
},
|
|
642
|
+
colorCoding: {
|
|
643
|
+
$apply: colorCodings => {
|
|
644
|
+
return colorCodings && colorCodings.map(colorCoding => _extends({}, colorCoding, {
|
|
645
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
646
|
+
})).filter(colorCoding => colorCoding.expression !== null);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}) : item;
|
|
650
|
+
}).filter(item => {
|
|
651
|
+
const {
|
|
652
|
+
query
|
|
653
|
+
} = item;
|
|
654
|
+
return query ? item : null;
|
|
655
|
+
})
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
const replaceNamesWithIdsInMapView = (schema, view) => {
|
|
660
|
+
return visitView$2(view, {
|
|
661
|
+
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
662
|
+
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
|
|
663
|
+
});
|
|
664
|
+
};
|
|
665
|
+
const replaceIdsWithNamesInMapView = (schema, view) => {
|
|
666
|
+
return visitView$2(view, {
|
|
667
|
+
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
|
|
668
|
+
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
|
|
669
|
+
});
|
|
670
|
+
};
|
|
671
|
+
|
|
704
672
|
const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["default"](smartFolder, {
|
|
705
673
|
"fibery/meta": {
|
|
706
674
|
items: {
|
|
@@ -711,9 +679,7 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
|
|
|
711
679
|
if (isOldSmartFolder) {
|
|
712
680
|
return item;
|
|
713
681
|
}
|
|
714
|
-
|
|
715
682
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
716
|
-
|
|
717
683
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
718
684
|
groupBy: {
|
|
719
685
|
$apply: groupBy => {
|
|
@@ -724,7 +690,6 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
|
|
|
724
690
|
}) : item;
|
|
725
691
|
}).map(item => {
|
|
726
692
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
727
|
-
|
|
728
693
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
729
694
|
query: {
|
|
730
695
|
$apply: query => {
|
|
@@ -756,17 +721,14 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
|
|
|
756
721
|
}
|
|
757
722
|
}
|
|
758
723
|
});
|
|
759
|
-
|
|
760
724
|
const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, groupByExpression, fromType, removedItems) => {
|
|
761
725
|
if (!groupByExpression) {
|
|
762
726
|
return null;
|
|
763
727
|
}
|
|
764
|
-
|
|
765
728
|
const [[index, {
|
|
766
729
|
expression
|
|
767
730
|
}]] = Object.entries(groupByExpression);
|
|
768
731
|
const visitedExpression = deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression);
|
|
769
|
-
|
|
770
732
|
if (visitedExpression) {
|
|
771
733
|
return {
|
|
772
734
|
[`${parseInt(index) - removedItems}`]: {
|
|
@@ -774,19 +736,15 @@ const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, gr
|
|
|
774
736
|
}
|
|
775
737
|
};
|
|
776
738
|
}
|
|
777
|
-
|
|
778
739
|
return null;
|
|
779
740
|
};
|
|
780
|
-
|
|
781
741
|
const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
782
742
|
if (!groupByExpression) {
|
|
783
743
|
return null;
|
|
784
744
|
}
|
|
785
|
-
|
|
786
745
|
const [[index, {
|
|
787
746
|
expression
|
|
788
747
|
}]] = Object.entries(groupByExpression);
|
|
789
|
-
|
|
790
748
|
if (schema.typeObjectsById.hasOwnProperty(fromType)) {
|
|
791
749
|
const typeObject = schema.typeObjectsById[fromType];
|
|
792
750
|
return {
|
|
@@ -795,18 +753,15 @@ const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromT
|
|
|
795
753
|
}
|
|
796
754
|
};
|
|
797
755
|
}
|
|
798
|
-
|
|
799
756
|
return groupByExpression;
|
|
800
757
|
};
|
|
801
758
|
const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
802
759
|
if (!groupByExpression) {
|
|
803
760
|
return null;
|
|
804
761
|
}
|
|
805
|
-
|
|
806
762
|
const [[index, {
|
|
807
763
|
expression
|
|
808
764
|
}]] = Object.entries(groupByExpression);
|
|
809
|
-
|
|
810
765
|
if (schema.typeObjectsByName.hasOwnProperty(fromType)) {
|
|
811
766
|
const typeObject = schema.typeObjectsByName[fromType];
|
|
812
767
|
return {
|
|
@@ -815,7 +770,6 @@ const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromT
|
|
|
815
770
|
}
|
|
816
771
|
};
|
|
817
772
|
}
|
|
818
|
-
|
|
819
773
|
return groupByExpression;
|
|
820
774
|
};
|
|
821
775
|
const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
@@ -861,7 +815,6 @@ const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
861
815
|
items: {
|
|
862
816
|
$apply: items => items.map(item => {
|
|
863
817
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
864
|
-
|
|
865
818
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
866
819
|
query: {
|
|
867
820
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
@@ -889,7 +842,6 @@ const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
889
842
|
}
|
|
890
843
|
}
|
|
891
844
|
});
|
|
892
|
-
|
|
893
845
|
const replaceNamesWithIdsInTableView = (schema, view) => visitView$1(view, {
|
|
894
846
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
895
847
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
|
|
@@ -924,29 +876,22 @@ const visitAxis = (axis, visitor) => {
|
|
|
924
876
|
if (!axis) {
|
|
925
877
|
return axis;
|
|
926
878
|
}
|
|
927
|
-
|
|
928
879
|
const fromType = ___default["default"].get(axis, ["query", "q/from"]);
|
|
929
|
-
|
|
930
880
|
const firstOrNull = x => ___default["default"].first(x) || null;
|
|
931
|
-
|
|
932
881
|
const axisResult = _extends({}, axis, {
|
|
933
882
|
query: axis.query && visitor.visitQueryExpression(axis.query),
|
|
934
883
|
contextExpression: visitContextExpression(fromType, axis.contextExpression, visitor),
|
|
935
884
|
units: axis.units && axis.units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)),
|
|
936
885
|
groupByExpression: axis.groupByExpression && firstOrNull(visitor.visitExpression(fromType, [axis.groupByExpression]))
|
|
937
886
|
});
|
|
938
|
-
|
|
939
887
|
if (!axisResult.query) {
|
|
940
888
|
return null;
|
|
941
889
|
}
|
|
942
|
-
|
|
943
890
|
if (!axisResult.units) {
|
|
944
891
|
delete axisResult.units;
|
|
945
892
|
}
|
|
946
|
-
|
|
947
893
|
return axisResult;
|
|
948
894
|
};
|
|
949
|
-
|
|
950
895
|
const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
951
896
|
"fibery/meta": {
|
|
952
897
|
y: {
|
|
@@ -955,7 +900,6 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
|
955
900
|
items: {
|
|
956
901
|
$apply: items => items.map(item => {
|
|
957
902
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
958
|
-
|
|
959
903
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
960
904
|
yExpression: {
|
|
961
905
|
$apply: yExpression => yExpression ? visitor.visitExpression(fromType, yExpression) : yExpression
|
|
@@ -995,10 +939,8 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
|
995
939
|
if (!milestones) {
|
|
996
940
|
return milestones;
|
|
997
941
|
}
|
|
998
|
-
|
|
999
942
|
return milestones.map(item => {
|
|
1000
943
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
1001
|
-
|
|
1002
944
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
1003
945
|
dateExpression: {
|
|
1004
946
|
$apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
|
|
@@ -1017,7 +959,6 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
|
1017
959
|
}
|
|
1018
960
|
}
|
|
1019
961
|
});
|
|
1020
|
-
|
|
1021
962
|
const replaceNamesWithIdsInTimelineView = (schema, view) => {
|
|
1022
963
|
return visitView(view, {
|
|
1023
964
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
@@ -1030,27 +971,19 @@ const replaceIdsWithNamesInTimelineView = (schema, view) => {
|
|
|
1030
971
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
|
|
1031
972
|
});
|
|
1032
973
|
};
|
|
1033
|
-
|
|
1034
974
|
const ensureAxisAndItemExpressionInvariant = view => {
|
|
1035
975
|
const actions = [];
|
|
1036
|
-
|
|
1037
976
|
const y = ___default["default"].get(view, ["fibery/meta", "y"]);
|
|
1038
|
-
|
|
1039
977
|
const yQuery = ___default["default"].get(view, ["fibery/meta", "y", "query"]);
|
|
1040
|
-
|
|
1041
978
|
const yGroupByExpression = ___default["default"].get(view, ["fibery/meta", "y", "groupByExpression"]);
|
|
1042
|
-
|
|
1043
979
|
const items = ___default["default"].get(view, ["fibery/meta", "items"]);
|
|
1044
|
-
|
|
1045
980
|
if (yQuery === null && yGroupByExpression !== null) {
|
|
1046
981
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y", "groupByExpression"], null));
|
|
1047
982
|
}
|
|
1048
|
-
|
|
1049
983
|
if (y === null) {
|
|
1050
984
|
const resetActions = items.map(item => () => item.yExpression = null);
|
|
1051
985
|
actions.push(...resetActions);
|
|
1052
986
|
}
|
|
1053
|
-
|
|
1054
987
|
if (y !== null && ___default["default"].some(items, ({
|
|
1055
988
|
yExpression
|
|
1056
989
|
}) => yExpression === null)) {
|
|
@@ -1058,15 +991,12 @@ const ensureAxisAndItemExpressionInvariant = view => {
|
|
|
1058
991
|
actions.push(...resetActions);
|
|
1059
992
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
|
|
1060
993
|
}
|
|
1061
|
-
|
|
1062
994
|
if (y !== null && ___default["default"].isEmpty(items)) {
|
|
1063
995
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
|
|
1064
996
|
}
|
|
1065
|
-
|
|
1066
997
|
actions.forEach(action => action());
|
|
1067
998
|
return view;
|
|
1068
999
|
};
|
|
1069
|
-
|
|
1070
1000
|
const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant = true) => {
|
|
1071
1001
|
const viewNew = visitView(view, {
|
|
1072
1002
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
@@ -1098,25 +1028,20 @@ const deleteExpressionWithNotFoundFieldsOrTypesInView = (schema, view, ensureAxi
|
|
|
1098
1028
|
switch (view["fibery/type"]) {
|
|
1099
1029
|
case "board":
|
|
1100
1030
|
return deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView(schema, view, ensureAxisInvariant);
|
|
1101
|
-
|
|
1102
1031
|
case "list":
|
|
1103
1032
|
return deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder(schema, view);
|
|
1104
|
-
|
|
1033
|
+
case "grid":
|
|
1034
|
+
return deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder(schema, view);
|
|
1105
1035
|
case "timeline":
|
|
1106
1036
|
return deleteExpressionWithNotFoundFieldsOrTypesInTimelineView(schema, view, ensureAxisInvariant);
|
|
1107
|
-
|
|
1108
1037
|
case "calendar":
|
|
1109
1038
|
return deleteExpressionWithNotFoundFieldsOrTypesInCalendarView(schema, view);
|
|
1110
|
-
|
|
1111
1039
|
case "table":
|
|
1112
1040
|
return deleteExpressionWithNotFoundFieldsOrTypesInTableView(schema, view);
|
|
1113
|
-
|
|
1114
1041
|
case "feed":
|
|
1115
1042
|
return deleteExpressionWithNotFoundFieldsOrTypesInFeedView(schema, view);
|
|
1116
|
-
|
|
1117
1043
|
case "form":
|
|
1118
1044
|
return deleteExpressionWithNotFoundFieldsOrTypesInFormView(schema, view);
|
|
1119
|
-
|
|
1120
1045
|
default:
|
|
1121
1046
|
return view;
|
|
1122
1047
|
}
|
|
@@ -1125,22 +1050,18 @@ const fixUserSelectedUnits = (schema, view) => {
|
|
|
1125
1050
|
switch (view["fibery/type"]) {
|
|
1126
1051
|
case "board":
|
|
1127
1052
|
return fixUserSelectedUnitsInBoardView(schema, view);
|
|
1128
|
-
|
|
1129
1053
|
case "list":
|
|
1130
1054
|
return fixUserSelectedUnitsInSmartFolder(schema, view);
|
|
1131
|
-
|
|
1055
|
+
case "grid":
|
|
1056
|
+
return fixUserSelectedUnitsInSmartFolder(schema, view);
|
|
1132
1057
|
case "table":
|
|
1133
1058
|
return fixUserSelectedUnitsInTableView(schema, view);
|
|
1134
|
-
|
|
1135
1059
|
case "timeline":
|
|
1136
1060
|
return fixUserSelectedUnitsInTimelineView(schema, view);
|
|
1137
|
-
|
|
1138
1061
|
case "calendar":
|
|
1139
1062
|
return fixUserSelectedUnitsInCalendarView(schema, view);
|
|
1140
|
-
|
|
1141
1063
|
case "feed":
|
|
1142
1064
|
return fixUserSelectedUnitsInFeedView(schema, view);
|
|
1143
|
-
|
|
1144
1065
|
default:
|
|
1145
1066
|
return view;
|
|
1146
1067
|
}
|
|
@@ -1149,65 +1070,54 @@ const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpressi
|
|
|
1149
1070
|
switch (view["fibery/type"]) {
|
|
1150
1071
|
case "board":
|
|
1151
1072
|
return fixContextExpressionWithBrokenPath$6(schema, view, defaultContextExpression);
|
|
1152
|
-
|
|
1153
1073
|
case "list":
|
|
1154
1074
|
return fixContextExpressionWithBrokenPath$3(schema, view, defaultContextExpression);
|
|
1155
|
-
|
|
1075
|
+
case "grid":
|
|
1076
|
+
return fixContextExpressionWithBrokenPath$3(schema, view, defaultContextExpression);
|
|
1156
1077
|
case "table":
|
|
1157
1078
|
return fixContextExpressionWithBrokenPath$2(schema, view, defaultContextExpression);
|
|
1158
|
-
|
|
1159
1079
|
case "timeline":
|
|
1160
1080
|
return fixContextExpressionWithBrokenPath$1(schema, view, defaultContextExpression);
|
|
1161
|
-
|
|
1162
1081
|
case "calendar":
|
|
1163
1082
|
return fixContextExpressionWithBrokenPath$5(schema, view, defaultContextExpression);
|
|
1164
|
-
|
|
1165
1083
|
case "feed":
|
|
1166
1084
|
return fixContextExpressionWithBrokenPath$4(schema, view, defaultContextExpression);
|
|
1167
|
-
|
|
1168
1085
|
default:
|
|
1169
1086
|
return view;
|
|
1170
1087
|
}
|
|
1171
1088
|
};
|
|
1089
|
+
|
|
1172
1090
|
/**
|
|
1173
1091
|
* Removes garbage from view's meta to reduce the size.
|
|
1174
1092
|
*/
|
|
1175
|
-
|
|
1176
1093
|
const collectGarbage = (schema, view) => {
|
|
1177
1094
|
const deleteRemoved = x => {
|
|
1178
1095
|
if (Array.isArray(x)) {
|
|
1179
1096
|
return x.map(deleteRemoved).filter(y => y !== REMOVE);
|
|
1180
1097
|
}
|
|
1181
|
-
|
|
1182
1098
|
if (typeof x === "object" && x !== null) {
|
|
1183
1099
|
let tmp = Object.entries(x);
|
|
1184
1100
|
tmp = tmp.map(e => [e[0], deleteRemoved(e[1])]);
|
|
1185
1101
|
tmp = tmp.filter(e => e[1] !== REMOVE);
|
|
1186
1102
|
return Object.fromEntries(tmp);
|
|
1187
1103
|
}
|
|
1188
|
-
|
|
1189
1104
|
return x;
|
|
1190
1105
|
};
|
|
1191
|
-
|
|
1192
1106
|
switch (view["fibery/type"]) {
|
|
1193
1107
|
case "board":
|
|
1194
1108
|
return deleteRemoved(collectGarbage$6(view));
|
|
1195
|
-
|
|
1196
1109
|
case "list":
|
|
1197
1110
|
return deleteRemoved(collectGarbage$3(view));
|
|
1198
|
-
|
|
1111
|
+
case "grid":
|
|
1112
|
+
return deleteRemoved(collectGarbage$3(view));
|
|
1199
1113
|
case "table":
|
|
1200
1114
|
return deleteRemoved(collectGarbage$2(view));
|
|
1201
|
-
|
|
1202
1115
|
case "timeline":
|
|
1203
1116
|
return deleteRemoved(collectGarbage$1(view));
|
|
1204
|
-
|
|
1205
1117
|
case "calendar":
|
|
1206
1118
|
return deleteRemoved(collectGarbage$5(view));
|
|
1207
|
-
|
|
1208
1119
|
case "feed":
|
|
1209
1120
|
return deleteRemoved(collectGarbage$4(view));
|
|
1210
|
-
|
|
1211
1121
|
default:
|
|
1212
1122
|
return view;
|
|
1213
1123
|
}
|
|
@@ -1216,25 +1126,22 @@ const replaceNamesWithIdsInView = (schema, view) => {
|
|
|
1216
1126
|
switch (view["fibery/type"]) {
|
|
1217
1127
|
case "board":
|
|
1218
1128
|
return replaceNamesWithIdsInBoardView(schema, view);
|
|
1219
|
-
|
|
1220
1129
|
case "list":
|
|
1221
1130
|
return replaceNamesWithIdsInSmartFolder(schema, view);
|
|
1222
|
-
|
|
1131
|
+
case "grid":
|
|
1132
|
+
return replaceNamesWithIdsInSmartFolder(schema, view);
|
|
1223
1133
|
case "table":
|
|
1224
1134
|
return replaceNamesWithIdsInTableView(schema, view);
|
|
1225
|
-
|
|
1226
1135
|
case "timeline":
|
|
1227
1136
|
return replaceNamesWithIdsInTimelineView(schema, view);
|
|
1228
|
-
|
|
1229
1137
|
case "calendar":
|
|
1230
1138
|
return replaceNamesWithIdsInCalendarView(schema, view);
|
|
1231
|
-
|
|
1232
1139
|
case "feed":
|
|
1233
1140
|
return replaceNamesWithIdsInFeedView(schema, view);
|
|
1234
|
-
|
|
1235
1141
|
case "form":
|
|
1236
1142
|
return replaceNamesWithIdsInFormView(schema, view);
|
|
1237
|
-
|
|
1143
|
+
case "map":
|
|
1144
|
+
return replaceNamesWithIdsInMapView(schema, view);
|
|
1238
1145
|
default:
|
|
1239
1146
|
return view;
|
|
1240
1147
|
}
|
|
@@ -1243,25 +1150,22 @@ const replaceIdsWithNamesInView = (schema, view) => {
|
|
|
1243
1150
|
switch (view["fibery/type"]) {
|
|
1244
1151
|
case "board":
|
|
1245
1152
|
return replaceIdsWithNamesInBoardView(schema, view);
|
|
1246
|
-
|
|
1247
1153
|
case "list":
|
|
1248
1154
|
return replaceIdsWithNamesInSmartFolder(schema, view);
|
|
1249
|
-
|
|
1155
|
+
case "grid":
|
|
1156
|
+
return replaceIdsWithNamesInSmartFolder(schema, view);
|
|
1250
1157
|
case "table":
|
|
1251
1158
|
return replaceIdsWithNamesInTableView(schema, view);
|
|
1252
|
-
|
|
1253
1159
|
case "timeline":
|
|
1254
1160
|
return replaceIdsWithNamesInTimelineView(schema, view);
|
|
1255
|
-
|
|
1256
1161
|
case "calendar":
|
|
1257
1162
|
return replaceIdsWithNamesInCalendarView(schema, view);
|
|
1258
|
-
|
|
1259
1163
|
case "feed":
|
|
1260
1164
|
return replaceIdsWithNamesInFeedView(schema, view);
|
|
1261
|
-
|
|
1262
1165
|
case "form":
|
|
1263
1166
|
return replaceIdsWithNamesInFormView(schema, view);
|
|
1264
|
-
|
|
1167
|
+
case "map":
|
|
1168
|
+
return replaceIdsWithNamesInMapView(schema, view);
|
|
1265
1169
|
default:
|
|
1266
1170
|
return view;
|
|
1267
1171
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/views",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.15",
|
|
4
4
|
"description": "Operations on view objects",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Fibery",
|
|
@@ -10,13 +10,16 @@
|
|
|
10
10
|
"/lib"
|
|
11
11
|
],
|
|
12
12
|
"private": false,
|
|
13
|
-
"dependencies": {},
|
|
14
13
|
"devDependencies": {
|
|
15
|
-
"@babel/core": "7.
|
|
14
|
+
"@babel/core": "7.20.5",
|
|
16
15
|
"@fibery/babel-preset": "7.2.0",
|
|
17
|
-
"@fibery/eslint-config": "
|
|
16
|
+
"@fibery/eslint-config": "workspace:*",
|
|
17
|
+
"@fibery/expression-utils": "workspace:*",
|
|
18
|
+
"@fibery/schema": "workspace:*",
|
|
19
|
+
"immutability-helper": "2.4.0",
|
|
18
20
|
"jest": "27.5.1",
|
|
19
21
|
"jest-junit": "13.0.0",
|
|
22
|
+
"lodash": "4.17.21",
|
|
20
23
|
"microbundle": "0.15.0"
|
|
21
24
|
},
|
|
22
25
|
"peerDependencies": {
|
|
@@ -28,7 +31,8 @@
|
|
|
28
31
|
"scripts": {
|
|
29
32
|
"build": "rm -rf lib && microbundle index.js -o lib -f cjs --no-compress --target node --sourcemap false",
|
|
30
33
|
"test": "node scripts/test.js",
|
|
31
|
-
"test:ci": "yarn test --
|
|
34
|
+
"test:ci": "yarn test --reporters=default --reporters=jest-junit",
|
|
35
|
+
"test:coverage": "yarn test --coverage --coverageDirectory=${JEST_COVERAGE_RESULT_DIR:-$(pwd)}/coverage/view --reporters=default --reporters=jest-junit",
|
|
32
36
|
"lint": "eslint ."
|
|
33
37
|
},
|
|
34
38
|
"jest": {
|