@fibery/views 10.0.1 → 10.2.0
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 +280 -59
- package/package.json +3 -3
package/lib/views.js
CHANGED
|
@@ -127,17 +127,14 @@ const isUnitExpressionValid = unit => {
|
|
|
127
127
|
return true;
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
+
const getField = (schema, fromType, field) => Object.hasOwn(schema.typeObjectsByName, fromType) && Object.hasOwn(schema.typeObjectsByName[fromType].fieldObjectsByName, field) ? schema.typeObjectsByName[fromType].fieldObjectsByName[field] : undefined;
|
|
130
131
|
const getFieldType = (schema, fromType, field) => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
return schema.typeObjectsByName[fromType].fieldObjectsByName[field].type;
|
|
132
|
+
var _getField;
|
|
133
|
+
return (_getField = getField(schema, fromType, field)) == null ? void 0 : _getField.type;
|
|
135
134
|
};
|
|
136
135
|
const getFieldMeta = (schema, fromType, field) => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
return schema.typeObjectsByName[fromType].fieldObjectsByName[field].rawMeta;
|
|
136
|
+
var _getField2;
|
|
137
|
+
return (_getField2 = getField(schema, fromType, field)) == null ? void 0 : _getField2.rawMeta;
|
|
141
138
|
};
|
|
142
139
|
const getUnitTypeForTextField = fieldMeta => {
|
|
143
140
|
switch (fieldMeta["ui/type"]) {
|
|
@@ -151,7 +148,7 @@ const getUnitTypeForTextField = fieldMeta => {
|
|
|
151
148
|
return "text";
|
|
152
149
|
}
|
|
153
150
|
};
|
|
154
|
-
const
|
|
151
|
+
const migrateUnit = (schema, fromType, unit, units) => {
|
|
155
152
|
const {
|
|
156
153
|
type,
|
|
157
154
|
expression
|
|
@@ -202,23 +199,6 @@ const fixViewUnit = (schema, fromType, unit, units, view) => {
|
|
|
202
199
|
};
|
|
203
200
|
}
|
|
204
201
|
}
|
|
205
|
-
if (type === "progress-bar") {
|
|
206
|
-
const [field] = expression;
|
|
207
|
-
const fieldMeta = getFieldMeta(schema, fromType, field);
|
|
208
|
-
if (!fieldMeta || fieldMeta["ui/number-format"] !== "Percent") {
|
|
209
|
-
return REMOVE;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
if (type === "rich-text" && (view == null ? void 0 : view["fibery/type"]) === "grid") {
|
|
213
|
-
if (unit.checked) {
|
|
214
|
-
const snippetsUnits = units == null ? void 0 : units.filter(x => x.type === "rich-text-snippet");
|
|
215
|
-
const snippetUnitForField = snippetsUnits == null ? void 0 : snippetsUnits.find(x => ___default["default"].isEqual(x.expression, expression));
|
|
216
|
-
if (snippetUnitForField && !snippetUnitForField.checked) {
|
|
217
|
-
snippetUnitForField.checked = true;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return REMOVE;
|
|
221
|
-
}
|
|
222
202
|
if (type === "avatar" && !expression) {
|
|
223
203
|
var _schema$typeObjectsBy;
|
|
224
204
|
const isAvatarExntensionEnabled = (_schema$typeObjectsBy = schema.typeObjectsByName[fromType]) == null ? void 0 : _schema$typeObjectsBy.installedMixins.has("avatar/avatar-mixin");
|
|
@@ -232,6 +212,47 @@ const fixViewUnit = (schema, fromType, unit, units, view) => {
|
|
|
232
212
|
}
|
|
233
213
|
return unit;
|
|
234
214
|
};
|
|
215
|
+
const fixViewUnit = (schema, fromType, unit, units, {
|
|
216
|
+
unitDefinitions,
|
|
217
|
+
getDefaultUnitTypeForField
|
|
218
|
+
}) => {
|
|
219
|
+
var _unit$expression;
|
|
220
|
+
const migrated = migrateUnit(schema, fromType, unit);
|
|
221
|
+
const field = (_unit$expression = unit.expression) == null ? void 0 : _unit$expression[0];
|
|
222
|
+
const fieldObject = getField(schema, fromType, field);
|
|
223
|
+
if (fieldObject) {
|
|
224
|
+
const allowedUnits = unitDefinitions.getUnitsForField(fieldObject);
|
|
225
|
+
if (allowedUnits.some(u => u.type === migrated.type)) {
|
|
226
|
+
return migrated;
|
|
227
|
+
} else {
|
|
228
|
+
if (unit.checked) {
|
|
229
|
+
const otherUnitsForField = units.filter(u => u !== unit && u.expression && u.expression[0] === field);
|
|
230
|
+
const hasEnabledUnitForField = otherUnitsForField.some(u => u.checked);
|
|
231
|
+
if (hasEnabledUnitForField) {
|
|
232
|
+
return REMOVE;
|
|
233
|
+
}
|
|
234
|
+
const defaultUnitType = getDefaultUnitTypeForField(fieldObject, allowedUnits);
|
|
235
|
+
const defaultUnit = defaultUnitType && otherUnitsForField.find(u => u.type === defaultUnitType) || otherUnitsForField[0];
|
|
236
|
+
if (defaultUnit) {
|
|
237
|
+
defaultUnit.checked = true;
|
|
238
|
+
return REMOVE;
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
return REMOVE;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return migrated;
|
|
246
|
+
};
|
|
247
|
+
const enableHideWhenEmptyForCheckedEditableUnit = unit => {
|
|
248
|
+
if (unit.checked) {
|
|
249
|
+
return {
|
|
250
|
+
...unit,
|
|
251
|
+
hideWhenEmpty: true
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
return unit;
|
|
255
|
+
};
|
|
235
256
|
|
|
236
257
|
const visitQueryExpressionHolder = (queryHolder, visitor) => {
|
|
237
258
|
if (queryHolder) {
|
|
@@ -257,7 +278,7 @@ const visitAxisUnits = (axis, fromType, visitor) => {
|
|
|
257
278
|
$apply: contextExpression => visitContextExpression(fromType, contextExpression, visitor)
|
|
258
279
|
},
|
|
259
280
|
units: {
|
|
260
|
-
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
281
|
+
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
261
282
|
}
|
|
262
283
|
}) : axis;
|
|
263
284
|
};
|
|
@@ -362,7 +383,7 @@ const visitView$5 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
362
383
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
363
384
|
},
|
|
364
385
|
units: {
|
|
365
|
-
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
386
|
+
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
366
387
|
},
|
|
367
388
|
colorCoding: {
|
|
368
389
|
$apply: colorCodings => {
|
|
@@ -439,12 +460,18 @@ const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = schema => {
|
|
|
439
460
|
};
|
|
440
461
|
return visitor;
|
|
441
462
|
};
|
|
442
|
-
const fixUserSelectedUnitsViewVisitor = schema
|
|
463
|
+
const fixUserSelectedUnitsViewVisitor = (schema, {
|
|
464
|
+
unitDefinitions,
|
|
465
|
+
getDefaultUnitTypeForField
|
|
466
|
+
}) => {
|
|
443
467
|
return {
|
|
444
468
|
visitQueryExpression: queryExpression => queryExpression,
|
|
445
469
|
visitExpression: (fromType, expression) => expression,
|
|
446
470
|
visitEnums: enums => enums,
|
|
447
|
-
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit
|
|
471
|
+
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
472
|
+
unitDefinitions,
|
|
473
|
+
getDefaultUnitTypeForField
|
|
474
|
+
})
|
|
448
475
|
};
|
|
449
476
|
};
|
|
450
477
|
const replaceIdsWithNamesInBoardView = (schema, view) => visitView$5(view, replaceIdsWithNamesViewVisitor(schema));
|
|
@@ -453,8 +480,14 @@ const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = (schema, v
|
|
|
453
480
|
const viewNew = visitView$5(view, deleteExpressionWithNotFoundFieldsOrTypesViewVisitor(schema));
|
|
454
481
|
return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant$1(viewNew) : viewNew;
|
|
455
482
|
};
|
|
456
|
-
const fixUserSelectedUnitsInBoardView = (schema, view
|
|
457
|
-
|
|
483
|
+
const fixUserSelectedUnitsInBoardView = (schema, view, {
|
|
484
|
+
unitDefinitions,
|
|
485
|
+
getDefaultUnitTypeForField
|
|
486
|
+
}) => {
|
|
487
|
+
return visitView$5(view, fixUserSelectedUnitsViewVisitor(schema, {
|
|
488
|
+
unitDefinitions,
|
|
489
|
+
getDefaultUnitTypeForField
|
|
490
|
+
}));
|
|
458
491
|
};
|
|
459
492
|
const fixContextExpressionWithBrokenPath$7 = (schema, view, defaultContextExpression) => visitView$5(view, {
|
|
460
493
|
visitQueryExpression: query => query,
|
|
@@ -470,6 +503,32 @@ const collectGarbage$7 = view => {
|
|
|
470
503
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
471
504
|
});
|
|
472
505
|
};
|
|
506
|
+
const enableHideWhenEmptyForCovers = view => {
|
|
507
|
+
return immutableUpdate__default["default"](view, {
|
|
508
|
+
"fibery/meta": {
|
|
509
|
+
items: {
|
|
510
|
+
$apply: items => items.map(item => {
|
|
511
|
+
if (!item.coverExpression) {
|
|
512
|
+
return item;
|
|
513
|
+
}
|
|
514
|
+
return {
|
|
515
|
+
...item,
|
|
516
|
+
coverHideWhenEmpty: true
|
|
517
|
+
};
|
|
518
|
+
})
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
};
|
|
523
|
+
const enableHideWhenEmptyForCheckedEditableUnits$1 = view => {
|
|
524
|
+
return visitView$5(view, {
|
|
525
|
+
visitQueryExpression: queryExpression => queryExpression,
|
|
526
|
+
visitGroupByExpression: groupBy => groupBy,
|
|
527
|
+
visitExpression: (fromType, expression) => expression,
|
|
528
|
+
visitEnums: enums => enums,
|
|
529
|
+
visitViewUnit: (fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
530
|
+
});
|
|
531
|
+
};
|
|
473
532
|
|
|
474
533
|
const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
475
534
|
"fibery/meta": {
|
|
@@ -490,7 +549,7 @@ const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
490
549
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
491
550
|
},
|
|
492
551
|
units: {
|
|
493
|
-
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
552
|
+
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
494
553
|
},
|
|
495
554
|
colorCoding: {
|
|
496
555
|
$apply: colorCodings => {
|
|
@@ -526,11 +585,17 @@ const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) =
|
|
|
526
585
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
527
586
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
528
587
|
});
|
|
529
|
-
const fixUserSelectedUnitsInCalendarView = (schema, view
|
|
588
|
+
const fixUserSelectedUnitsInCalendarView = (schema, view, {
|
|
589
|
+
unitDefinitions,
|
|
590
|
+
getDefaultUnitTypeForField
|
|
591
|
+
}) => {
|
|
530
592
|
return visitView$4(view, {
|
|
531
593
|
visitExpression: (fromType, expression) => expression,
|
|
532
594
|
visitQueryExpression: query => query,
|
|
533
|
-
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit
|
|
595
|
+
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
596
|
+
unitDefinitions,
|
|
597
|
+
getDefaultUnitTypeForField
|
|
598
|
+
})
|
|
534
599
|
});
|
|
535
600
|
};
|
|
536
601
|
const fixContextExpressionWithBrokenPath$6 = (schema, view, defaultContextExpression) => visitView$4(view, {
|
|
@@ -545,6 +610,15 @@ const collectGarbage$6 = view => {
|
|
|
545
610
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
546
611
|
});
|
|
547
612
|
};
|
|
613
|
+
const enableHideWhenEmptyForCheckedUnits$3 = view => {
|
|
614
|
+
return visitView$4(view, {
|
|
615
|
+
visitQueryExpression: queryExpression => queryExpression,
|
|
616
|
+
visitGroupByExpression: groupBy => groupBy,
|
|
617
|
+
visitExpression: (fromType, expression) => expression,
|
|
618
|
+
visitEnums: enums => enums,
|
|
619
|
+
visitViewUnit: (fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
620
|
+
});
|
|
621
|
+
};
|
|
548
622
|
|
|
549
623
|
const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
550
624
|
"fibery/meta": {
|
|
@@ -562,7 +636,7 @@ const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
562
636
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
563
637
|
},
|
|
564
638
|
units: {
|
|
565
|
-
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
639
|
+
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
566
640
|
},
|
|
567
641
|
colorCoding: {
|
|
568
642
|
$apply: colorCodings => {
|
|
@@ -598,11 +672,17 @@ const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => vi
|
|
|
598
672
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
599
673
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
600
674
|
});
|
|
601
|
-
const fixUserSelectedUnitsInFeedView = (schema, view
|
|
675
|
+
const fixUserSelectedUnitsInFeedView = (schema, view, {
|
|
676
|
+
unitDefinitions,
|
|
677
|
+
getDefaultUnitTypeForField
|
|
678
|
+
}) => {
|
|
602
679
|
return visitView$3(view, {
|
|
603
680
|
visitExpression: (fromType, expression) => expression,
|
|
604
681
|
visitQueryExpression: query => query,
|
|
605
|
-
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit
|
|
682
|
+
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
683
|
+
unitDefinitions,
|
|
684
|
+
getDefaultUnitTypeForField
|
|
685
|
+
})
|
|
606
686
|
});
|
|
607
687
|
};
|
|
608
688
|
const fixContextExpressionWithBrokenPath$5 = (schema, view, defaultContextExpression) => visitView$3(view, {
|
|
@@ -617,6 +697,15 @@ const collectGarbage$5 = view => {
|
|
|
617
697
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
618
698
|
});
|
|
619
699
|
};
|
|
700
|
+
const enableHideWhenEmptyForCheckedUnits$2 = view => {
|
|
701
|
+
return visitView$3(view, {
|
|
702
|
+
visitQueryExpression: queryExpression => queryExpression,
|
|
703
|
+
visitGroupByExpression: groupBy => groupBy,
|
|
704
|
+
visitExpression: (fromType, expression) => expression,
|
|
705
|
+
visitEnums: enums => enums,
|
|
706
|
+
visitViewUnit: (fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
707
|
+
});
|
|
708
|
+
};
|
|
620
709
|
|
|
621
710
|
const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
622
711
|
var _view$fiberyMeta, _view$fiberyMeta2;
|
|
@@ -697,7 +786,7 @@ const visitView$2 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
697
786
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
698
787
|
},
|
|
699
788
|
units: {
|
|
700
|
-
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
789
|
+
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
701
790
|
},
|
|
702
791
|
colorCoding: {
|
|
703
792
|
$apply: colorCodings => {
|
|
@@ -733,11 +822,17 @@ const deleteExpressionWithNotFoundFieldsOrTypesInMapView = (schema, view) => vis
|
|
|
733
822
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
734
823
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
735
824
|
});
|
|
736
|
-
const fixUserSelectedUnitsInMapView = (schema, view
|
|
825
|
+
const fixUserSelectedUnitsInMapView = (schema, view, {
|
|
826
|
+
unitDefinitions,
|
|
827
|
+
getDefaultUnitTypeForField
|
|
828
|
+
}) => {
|
|
737
829
|
return visitView$2(view, {
|
|
738
830
|
visitQueryExpression: query => query,
|
|
739
831
|
visitExpression: (fromType, expression) => expression,
|
|
740
|
-
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit
|
|
832
|
+
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
833
|
+
unitDefinitions,
|
|
834
|
+
getDefaultUnitTypeForField
|
|
835
|
+
})
|
|
741
836
|
});
|
|
742
837
|
};
|
|
743
838
|
const fixContextExpressionWithBrokenPath$4 = (schema, view, defaultContextExpression) => visitView$2(view, {
|
|
@@ -752,6 +847,15 @@ const collectGarbage$4 = view => {
|
|
|
752
847
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
753
848
|
});
|
|
754
849
|
};
|
|
850
|
+
const enableHideWhenEmptyForCheckedUnits$1 = view => {
|
|
851
|
+
return visitView$2(view, {
|
|
852
|
+
visitQueryExpression: queryExpression => queryExpression,
|
|
853
|
+
visitGroupByExpression: groupBy => groupBy,
|
|
854
|
+
visitExpression: (fromType, expression) => expression,
|
|
855
|
+
visitEnums: enums => enums,
|
|
856
|
+
visitViewUnit: (fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
857
|
+
});
|
|
858
|
+
};
|
|
755
859
|
|
|
756
860
|
const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["default"](smartFolder, {
|
|
757
861
|
"fibery/meta": {
|
|
@@ -897,12 +1001,34 @@ const fixContextExpressionWithBrokenPath$3 = (schema, view, defaultContextExpres
|
|
|
897
1001
|
visitExpression: (fromType, expression) => expression,
|
|
898
1002
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
899
1003
|
});
|
|
900
|
-
const fixUserSelectedUnitsInSmartFolder = (schema, view
|
|
1004
|
+
const fixUserSelectedUnitsInSmartFolder = (schema, view, {
|
|
1005
|
+
unitDefinitions,
|
|
1006
|
+
getDefaultUnitTypeForField
|
|
1007
|
+
}) => {
|
|
901
1008
|
return visitSmartFolder(view, {
|
|
902
1009
|
visitQueryExpression: query => query,
|
|
903
1010
|
visitGroupByExpression: groupBy => groupBy,
|
|
904
1011
|
visitExpression: (fromType, expression) => expression,
|
|
905
|
-
visitViewUnit: (fromType, unit, units) =>
|
|
1012
|
+
visitViewUnit: (fromType, unit, units) => {
|
|
1013
|
+
const {
|
|
1014
|
+
type,
|
|
1015
|
+
expression
|
|
1016
|
+
} = unit;
|
|
1017
|
+
if (type === "rich-text" && (view == null ? void 0 : view["fibery/type"]) === "grid") {
|
|
1018
|
+
if (unit.checked) {
|
|
1019
|
+
const snippetsUnits = units == null ? void 0 : units.filter(x => x.type === "rich-text-snippet");
|
|
1020
|
+
const snippetUnitForField = snippetsUnits == null ? void 0 : snippetsUnits.find(x => ___default["default"].isEqual(x.expression, expression));
|
|
1021
|
+
if (snippetUnitForField && !snippetUnitForField.checked) {
|
|
1022
|
+
snippetUnitForField.checked = true;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
return REMOVE;
|
|
1026
|
+
}
|
|
1027
|
+
return fixViewUnit(schema, fromType, unit, units, {
|
|
1028
|
+
unitDefinitions,
|
|
1029
|
+
getDefaultUnitTypeForField
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
906
1032
|
});
|
|
907
1033
|
};
|
|
908
1034
|
const collectGarbage$3 = view => {
|
|
@@ -913,6 +1039,15 @@ const collectGarbage$3 = view => {
|
|
|
913
1039
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
914
1040
|
});
|
|
915
1041
|
};
|
|
1042
|
+
const enableHideWhenEmptyForCheckedUnits = view => {
|
|
1043
|
+
return visitSmartFolder(view, {
|
|
1044
|
+
visitQueryExpression: queryExpression => queryExpression,
|
|
1045
|
+
visitGroupByExpression: groupBy => groupBy,
|
|
1046
|
+
visitExpression: (fromType, expression) => expression,
|
|
1047
|
+
visitEnums: enums => enums,
|
|
1048
|
+
visitViewUnit: (fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
1049
|
+
});
|
|
1050
|
+
};
|
|
916
1051
|
|
|
917
1052
|
const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
918
1053
|
"fibery/meta": {
|
|
@@ -927,7 +1062,7 @@ const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
927
1062
|
$apply: contextExpression => contextExpression ? visitor.visitExpression(fromType, contextExpression) : contextExpression
|
|
928
1063
|
},
|
|
929
1064
|
units: {
|
|
930
|
-
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
1065
|
+
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
931
1066
|
},
|
|
932
1067
|
colorCoding: {
|
|
933
1068
|
$apply: colorCodings => {
|
|
@@ -959,10 +1094,16 @@ const deleteExpressionWithNotFoundFieldsOrTypesInTableView = (schema, view) => v
|
|
|
959
1094
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
960
1095
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
961
1096
|
});
|
|
962
|
-
const fixUserSelectedUnitsInTableView = (schema, view
|
|
1097
|
+
const fixUserSelectedUnitsInTableView = (schema, view, {
|
|
1098
|
+
unitDefinitions,
|
|
1099
|
+
getDefaultUnitTypeForField
|
|
1100
|
+
}) => visitView$1(view, {
|
|
963
1101
|
visitExpression: (fromType, expression) => expression,
|
|
964
1102
|
visitQueryExpression: query => query,
|
|
965
|
-
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit
|
|
1103
|
+
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
1104
|
+
unitDefinitions,
|
|
1105
|
+
getDefaultUnitTypeForField
|
|
1106
|
+
})
|
|
966
1107
|
});
|
|
967
1108
|
const fixContextExpressionWithBrokenPath$2 = (schema, view, defaultContextExpression) => visitView$1(view, {
|
|
968
1109
|
visitExpression: (fromType, expression) => expression,
|
|
@@ -987,7 +1128,7 @@ const visitAxis = (axis, visitor) => {
|
|
|
987
1128
|
...axis,
|
|
988
1129
|
query: axis.query && visitor.visitQueryExpression(axis.query),
|
|
989
1130
|
contextExpression: visitContextExpression(fromType, axis.contextExpression, visitor),
|
|
990
|
-
units: axis.units && axis.units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).filter(unit => unit !== REMOVE),
|
|
1131
|
+
units: axis.units && axis.units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE),
|
|
991
1132
|
groupByExpression: axis.groupByExpression && firstOrNull(visitor.visitExpression(fromType, [axis.groupByExpression]))
|
|
992
1133
|
};
|
|
993
1134
|
if (!axisResult.query) {
|
|
@@ -1029,7 +1170,7 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
|
1029
1170
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
1030
1171
|
},
|
|
1031
1172
|
units: {
|
|
1032
|
-
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
1173
|
+
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
1033
1174
|
},
|
|
1034
1175
|
colorCoding: {
|
|
1035
1176
|
$apply: colorCodings => {
|
|
@@ -1120,11 +1261,17 @@ const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, e
|
|
|
1120
1261
|
});
|
|
1121
1262
|
return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant(viewNew) : viewNew;
|
|
1122
1263
|
};
|
|
1123
|
-
const fixUserSelectedUnitsInTimelineView = (schema, view
|
|
1264
|
+
const fixUserSelectedUnitsInTimelineView = (schema, view, {
|
|
1265
|
+
unitDefinitions,
|
|
1266
|
+
getDefaultUnitTypeForField
|
|
1267
|
+
}) => {
|
|
1124
1268
|
return visitView(view, {
|
|
1125
1269
|
visitQueryExpression: query => query,
|
|
1126
1270
|
visitExpression: (fromType, expression) => expression,
|
|
1127
|
-
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit
|
|
1271
|
+
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
1272
|
+
unitDefinitions,
|
|
1273
|
+
getDefaultUnitTypeForField
|
|
1274
|
+
})
|
|
1128
1275
|
});
|
|
1129
1276
|
};
|
|
1130
1277
|
const fixContextExpressionWithBrokenPath$1 = (schema, view, defaultContextExpression) => visitView(view, {
|
|
@@ -1139,6 +1286,15 @@ const collectGarbage$1 = view => {
|
|
|
1139
1286
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
1140
1287
|
});
|
|
1141
1288
|
};
|
|
1289
|
+
const enableHideWhenEmptyForCheckedEditableUnits = view => {
|
|
1290
|
+
return visitView(view, {
|
|
1291
|
+
visitQueryExpression: queryExpression => queryExpression,
|
|
1292
|
+
visitGroupByExpression: groupBy => groupBy,
|
|
1293
|
+
visitExpression: (fromType, expression) => expression,
|
|
1294
|
+
visitEnums: enums => enums,
|
|
1295
|
+
visitViewUnit: (fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
1296
|
+
});
|
|
1297
|
+
};
|
|
1142
1298
|
|
|
1143
1299
|
const deleteExpressionWithNotFoundFieldsOrTypesInView = (schema, view, ensureAxisInvariant = true) => {
|
|
1144
1300
|
switch (view["fibery/type"]) {
|
|
@@ -1164,24 +1320,51 @@ const deleteExpressionWithNotFoundFieldsOrTypesInView = (schema, view, ensureAxi
|
|
|
1164
1320
|
return view;
|
|
1165
1321
|
}
|
|
1166
1322
|
};
|
|
1167
|
-
const fixUserSelectedUnits = (schema, view
|
|
1323
|
+
const fixUserSelectedUnits = (schema, view, {
|
|
1324
|
+
unitDefinitions,
|
|
1325
|
+
getDefaultUnitTypeForField
|
|
1326
|
+
}) => {
|
|
1168
1327
|
switch (view["fibery/type"]) {
|
|
1169
1328
|
case "board":
|
|
1170
|
-
return fixUserSelectedUnitsInBoardView(schema, view
|
|
1329
|
+
return fixUserSelectedUnitsInBoardView(schema, view, {
|
|
1330
|
+
unitDefinitions,
|
|
1331
|
+
getDefaultUnitTypeForField
|
|
1332
|
+
});
|
|
1171
1333
|
case "list":
|
|
1172
|
-
return fixUserSelectedUnitsInSmartFolder(schema, view
|
|
1334
|
+
return fixUserSelectedUnitsInSmartFolder(schema, view, {
|
|
1335
|
+
unitDefinitions,
|
|
1336
|
+
getDefaultUnitTypeForField
|
|
1337
|
+
});
|
|
1173
1338
|
case "grid":
|
|
1174
|
-
return fixUserSelectedUnitsInSmartFolder(schema, view
|
|
1339
|
+
return fixUserSelectedUnitsInSmartFolder(schema, view, {
|
|
1340
|
+
unitDefinitions,
|
|
1341
|
+
getDefaultUnitTypeForField
|
|
1342
|
+
});
|
|
1175
1343
|
case "table":
|
|
1176
|
-
return fixUserSelectedUnitsInTableView(schema, view
|
|
1344
|
+
return fixUserSelectedUnitsInTableView(schema, view, {
|
|
1345
|
+
unitDefinitions,
|
|
1346
|
+
getDefaultUnitTypeForField
|
|
1347
|
+
});
|
|
1177
1348
|
case "timeline":
|
|
1178
|
-
return fixUserSelectedUnitsInTimelineView(schema, view
|
|
1349
|
+
return fixUserSelectedUnitsInTimelineView(schema, view, {
|
|
1350
|
+
unitDefinitions,
|
|
1351
|
+
getDefaultUnitTypeForField
|
|
1352
|
+
});
|
|
1179
1353
|
case "calendar":
|
|
1180
|
-
return fixUserSelectedUnitsInCalendarView(schema, view
|
|
1354
|
+
return fixUserSelectedUnitsInCalendarView(schema, view, {
|
|
1355
|
+
unitDefinitions,
|
|
1356
|
+
getDefaultUnitTypeForField
|
|
1357
|
+
});
|
|
1181
1358
|
case "feed":
|
|
1182
|
-
return fixUserSelectedUnitsInFeedView(schema, view
|
|
1359
|
+
return fixUserSelectedUnitsInFeedView(schema, view, {
|
|
1360
|
+
unitDefinitions,
|
|
1361
|
+
getDefaultUnitTypeForField
|
|
1362
|
+
});
|
|
1183
1363
|
case "map":
|
|
1184
|
-
return fixUserSelectedUnitsInMapView(schema, view
|
|
1364
|
+
return fixUserSelectedUnitsInMapView(schema, view, {
|
|
1365
|
+
unitDefinitions,
|
|
1366
|
+
getDefaultUnitTypeForField
|
|
1367
|
+
});
|
|
1185
1368
|
default:
|
|
1186
1369
|
return view;
|
|
1187
1370
|
}
|
|
@@ -1303,6 +1486,43 @@ const getViewCardTypes = ({
|
|
|
1303
1486
|
"q/from": type
|
|
1304
1487
|
}
|
|
1305
1488
|
}) => type);
|
|
1489
|
+
const migrateHideWhenEmptyToUnitsLevel = view => {
|
|
1490
|
+
const viewTypesToTransform = ["board", "list", "timeline", "calendar", "feed", "map"];
|
|
1491
|
+
const viewType = view["fibery/type"];
|
|
1492
|
+
if (!viewTypesToTransform.includes(viewType)) {
|
|
1493
|
+
return view;
|
|
1494
|
+
}
|
|
1495
|
+
const showEmptyUnitValues = ___default["default"].get(view, ["fibery/meta", "showEmptyUnitValues"]);
|
|
1496
|
+
if (showEmptyUnitValues === undefined) {
|
|
1497
|
+
return view;
|
|
1498
|
+
}
|
|
1499
|
+
let result = immutableUpdate__default["default"](view, {
|
|
1500
|
+
"fibery/meta": {
|
|
1501
|
+
$apply: x => ___default["default"].omit(x, "showEmptyUnitValues")
|
|
1502
|
+
}
|
|
1503
|
+
});
|
|
1504
|
+
if (showEmptyUnitValues === true) {
|
|
1505
|
+
return result;
|
|
1506
|
+
}
|
|
1507
|
+
switch (result["fibery/type"]) {
|
|
1508
|
+
case "board":
|
|
1509
|
+
result = enableHideWhenEmptyForCovers(result);
|
|
1510
|
+
result = enableHideWhenEmptyForCheckedEditableUnits$1(result);
|
|
1511
|
+
return result;
|
|
1512
|
+
case "list":
|
|
1513
|
+
return enableHideWhenEmptyForCheckedUnits(result);
|
|
1514
|
+
case "timeline":
|
|
1515
|
+
return enableHideWhenEmptyForCheckedEditableUnits(result);
|
|
1516
|
+
case "calendar":
|
|
1517
|
+
return enableHideWhenEmptyForCheckedUnits$3(result);
|
|
1518
|
+
case "feed":
|
|
1519
|
+
return enableHideWhenEmptyForCheckedUnits$2(result);
|
|
1520
|
+
case "map":
|
|
1521
|
+
return enableHideWhenEmptyForCheckedUnits$1(result);
|
|
1522
|
+
default:
|
|
1523
|
+
return result;
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1306
1526
|
|
|
1307
1527
|
exports.collectGarbage = collectGarbage;
|
|
1308
1528
|
exports.deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder = deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder;
|
|
@@ -1310,6 +1530,7 @@ exports.deleteExpressionWithNotFoundFieldsOrTypesInView = deleteExpressionWithNo
|
|
|
1310
1530
|
exports.fixContextExpressionWithBrokenPath = fixContextExpressionWithBrokenPath;
|
|
1311
1531
|
exports.fixUserSelectedUnits = fixUserSelectedUnits;
|
|
1312
1532
|
exports.getViewCardTypes = getViewCardTypes;
|
|
1533
|
+
exports.migrateHideWhenEmptyToUnitsLevel = migrateHideWhenEmptyToUnitsLevel;
|
|
1313
1534
|
exports.replaceIdsWithNamesInSmartFolder = replaceIdsWithNamesInSmartFolder;
|
|
1314
1535
|
exports.replaceIdsWithNamesInView = replaceIdsWithNamesInView;
|
|
1315
1536
|
exports.replaceNamesWithIdsInSmartFolder = replaceNamesWithIdsInSmartFolder;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/views",
|
|
3
|
-
"version": "10.0
|
|
3
|
+
"version": "10.2.0",
|
|
4
4
|
"description": "Operations on view objects",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Fibery",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"lodash": "4.17.21",
|
|
20
20
|
"microbundle": "0.15.1",
|
|
21
21
|
"@fibery/babel-preset": "7.4.0",
|
|
22
|
-
"@fibery/expression-utils": "9.0.1",
|
|
23
22
|
"@fibery/eslint-config": "8.6.0",
|
|
23
|
+
"@fibery/expression-utils": "9.0.4",
|
|
24
24
|
"@fibery/schema": "10.2.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@fibery/expression-utils": "^9.0.
|
|
27
|
+
"@fibery/expression-utils": "^9.0.4",
|
|
28
28
|
"@fibery/schema": "^10.2.1",
|
|
29
29
|
"immutability-helper": "^2.4.0",
|
|
30
30
|
"lodash": "^4.17.21"
|