@fibery/views 13.0.3 → 14.0.1
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 +140 -70
- package/package.json +5 -5
package/lib/views.js
CHANGED
|
@@ -1217,14 +1217,14 @@ const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromT
|
|
|
1217
1217
|
const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
1218
1218
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
1219
1219
|
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
1220
|
-
visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType
|
|
1220
|
+
visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType),
|
|
1221
1221
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
1222
1222
|
visitUnitGroupKey: unitGroupKey => replaceNamesWithIdsInUnitGroupKey(unitGroupKey, schema)
|
|
1223
1223
|
});
|
|
1224
1224
|
const replaceIdsWithNamesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
1225
1225
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
|
|
1226
1226
|
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
1227
|
-
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType
|
|
1227
|
+
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType),
|
|
1228
1228
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
1229
1229
|
visitUnitGroupKey: unitGroupKey => replaceIdsWithNamesInUnitGroupKey(unitGroupKey, getFieldObjectsById(smartFolder, schema))
|
|
1230
1230
|
});
|
|
@@ -1292,10 +1292,7 @@ const enableHideWhenEmptyForCheckedUnits = view => {
|
|
|
1292
1292
|
});
|
|
1293
1293
|
};
|
|
1294
1294
|
|
|
1295
|
-
const
|
|
1296
|
-
if (!axis) {
|
|
1297
|
-
return axis;
|
|
1298
|
-
}
|
|
1295
|
+
const visitAxisSingle = (axis, visitor) => {
|
|
1299
1296
|
const fromType = ___default["default"].get(axis, ["query", "q/from"]);
|
|
1300
1297
|
const firstOrNull = x => ___default["default"].first(x) || null;
|
|
1301
1298
|
const axisResult = {
|
|
@@ -1314,62 +1311,92 @@ const visitAxis = (axis, visitor) => {
|
|
|
1314
1311
|
}
|
|
1315
1312
|
return axisResult;
|
|
1316
1313
|
};
|
|
1314
|
+
const visitAxis = (axis, visitor) => {
|
|
1315
|
+
if (axis && axis.hasOwnProperty("query")) {
|
|
1316
|
+
return visitAxisSingle(axis, visitor);
|
|
1317
|
+
}
|
|
1318
|
+
if (axis && axis.hasOwnProperty("enums")) {
|
|
1319
|
+
const axisNew = immutableUpdate__default["default"](axis, {
|
|
1320
|
+
enums: {
|
|
1321
|
+
$apply: enums => visitor.visitEnums(enums)
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
const {
|
|
1325
|
+
enums
|
|
1326
|
+
} = axisNew;
|
|
1327
|
+
return enums ? axisNew : null;
|
|
1328
|
+
}
|
|
1329
|
+
return axis;
|
|
1330
|
+
};
|
|
1317
1331
|
const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
1318
1332
|
"fibery/meta": {
|
|
1319
1333
|
y: {
|
|
1320
1334
|
$apply: y => visitAxis(y, visitor)
|
|
1321
1335
|
},
|
|
1322
1336
|
items: {
|
|
1323
|
-
$apply: items =>
|
|
1324
|
-
const
|
|
1325
|
-
return
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1337
|
+
$apply: items => {
|
|
1338
|
+
const removedItemsIndexes = items.map((item, index) => visitor.visitQueryExpression(item.query) ? null : index).filter(value => value !== null);
|
|
1339
|
+
return items.map(item => {
|
|
1340
|
+
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
1341
|
+
return fromType ? immutableUpdate__default["default"](item, {
|
|
1342
|
+
yExpression: {
|
|
1343
|
+
$apply: yExpression => yExpression ? visitor.visitExpression(fromType, yExpression) : yExpression
|
|
1344
|
+
},
|
|
1345
|
+
startExpression: {
|
|
1346
|
+
$apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
|
|
1347
|
+
},
|
|
1348
|
+
endExpression: {
|
|
1349
|
+
$apply: endExpression => endExpression ? visitor.visitExpression(fromType, endExpression) : endExpression
|
|
1350
|
+
},
|
|
1351
|
+
secondaryStartExpression: {
|
|
1352
|
+
$apply: secondaryStartExpression => secondaryStartExpression ? visitor.visitExpression(fromType, secondaryStartExpression) : secondaryStartExpression
|
|
1353
|
+
},
|
|
1354
|
+
secondaryEndExpression: {
|
|
1355
|
+
$apply: secondaryEndExpression => secondaryEndExpression ? visitor.visitExpression(fromType, secondaryEndExpression) : secondaryEndExpression
|
|
1356
|
+
},
|
|
1357
|
+
contextExpression: {
|
|
1358
|
+
$apply: contextExpression => visitContextExpression(fromType, contextExpression, visitor)
|
|
1359
|
+
},
|
|
1360
|
+
filter: {
|
|
1361
|
+
$apply: filter => filter ? visitor.visitFilter(fromType, filter) : null
|
|
1362
|
+
},
|
|
1363
|
+
query: {
|
|
1364
|
+
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
1365
|
+
},
|
|
1366
|
+
units: {
|
|
1367
|
+
$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
|
|
1368
|
+
},
|
|
1369
|
+
colorCoding: {
|
|
1370
|
+
$apply: colorCodings => {
|
|
1371
|
+
return colorCodings && colorCodings.map(colorCoding => ({
|
|
1372
|
+
...colorCoding,
|
|
1373
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
1374
|
+
})).filter(colorCoding => colorCoding.expression !== null);
|
|
1375
|
+
}
|
|
1376
|
+
},
|
|
1377
|
+
dependencyExpression: {
|
|
1378
|
+
$apply: expression => {
|
|
1379
|
+
return expression && visitor.visitExpression(fromType, expression);
|
|
1380
|
+
}
|
|
1381
|
+
},
|
|
1382
|
+
groupBy: {
|
|
1383
|
+
$apply: groupBy => {
|
|
1384
|
+
if (!groupBy) {
|
|
1385
|
+
return groupBy;
|
|
1386
|
+
}
|
|
1387
|
+
const groupByIndexes = Object.keys(groupBy).map(key => parseInt(key));
|
|
1388
|
+
const removedItemsBeforeTargetLengths = groupByIndexes.map(groupByIndex => removedItemsIndexes.filter(n => n < groupByIndex).length);
|
|
1389
|
+
return visitor.visitGroupByExpression(groupBy, fromType, removedItemsBeforeTargetLengths);
|
|
1390
|
+
}
|
|
1364
1391
|
}
|
|
1365
|
-
}
|
|
1366
|
-
})
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
}
|
|
1392
|
+
}) : item;
|
|
1393
|
+
}).filter(item => {
|
|
1394
|
+
const {
|
|
1395
|
+
query
|
|
1396
|
+
} = item;
|
|
1397
|
+
return query ? item : null;
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1373
1400
|
},
|
|
1374
1401
|
milestones: {
|
|
1375
1402
|
$apply: milestones => {
|
|
@@ -1403,18 +1430,40 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
|
1403
1430
|
}
|
|
1404
1431
|
});
|
|
1405
1432
|
const replaceNamesWithIdsInTimelineView = (schema, view) => {
|
|
1406
|
-
|
|
1433
|
+
const visitor = {
|
|
1407
1434
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
1408
1435
|
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
1409
|
-
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
|
|
1410
|
-
|
|
1436
|
+
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
1437
|
+
visitEnums: enums => ___default["default"].entries(enums).reduce((result, [type, axis]) => {
|
|
1438
|
+
if (schema.typeObjectsByName.hasOwnProperty(type)) {
|
|
1439
|
+
const typeObject = schema.typeObjectsByName[type];
|
|
1440
|
+
result[typeObject.id] = visitAxisSingle(axis, visitor);
|
|
1441
|
+
} else {
|
|
1442
|
+
result[type] = axis;
|
|
1443
|
+
}
|
|
1444
|
+
return result;
|
|
1445
|
+
}, {}),
|
|
1446
|
+
visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType)
|
|
1447
|
+
};
|
|
1448
|
+
return visitView(view, visitor);
|
|
1411
1449
|
};
|
|
1412
1450
|
const replaceIdsWithNamesInTimelineView = (schema, view) => {
|
|
1413
|
-
|
|
1451
|
+
const visitor = {
|
|
1414
1452
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
|
|
1415
1453
|
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
1416
|
-
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
|
|
1417
|
-
|
|
1454
|
+
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
1455
|
+
visitEnums: enums => ___default["default"].entries(enums).reduce((result, [typeId, axis]) => {
|
|
1456
|
+
if (schema.typeObjectsById.hasOwnProperty(typeId)) {
|
|
1457
|
+
const typeObject = schema.typeObjectsById[typeId];
|
|
1458
|
+
result[typeObject.name] = visitAxisSingle(axis, visitor);
|
|
1459
|
+
} else {
|
|
1460
|
+
result[typeId] = axis;
|
|
1461
|
+
}
|
|
1462
|
+
return result;
|
|
1463
|
+
}, {}),
|
|
1464
|
+
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType)
|
|
1465
|
+
};
|
|
1466
|
+
return visitView(view, visitor);
|
|
1418
1467
|
};
|
|
1419
1468
|
const ensureAxisAndItemExpressionInvariant = (view, canGroupMetaItem) => {
|
|
1420
1469
|
const actions = [];
|
|
@@ -1443,12 +1492,27 @@ const ensureAxisAndItemExpressionInvariant = (view, canGroupMetaItem) => {
|
|
|
1443
1492
|
actions.forEach(action => action());
|
|
1444
1493
|
return view;
|
|
1445
1494
|
};
|
|
1446
|
-
const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant, canGroupMetaItem =
|
|
1447
|
-
const
|
|
1495
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant, canGroupMetaItem = metaItem => true) => {
|
|
1496
|
+
const visitor = {
|
|
1448
1497
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
1449
1498
|
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
1450
|
-
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
1451
|
-
|
|
1499
|
+
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression),
|
|
1500
|
+
visitEnums: enums => {
|
|
1501
|
+
const enumsNew = ___default["default"].entries(enums).reduce((result, [type, axis]) => {
|
|
1502
|
+
if (schema.typeObjectsByName.hasOwnProperty(type)) {
|
|
1503
|
+
const typeObject = schema.typeObjectsByName[type];
|
|
1504
|
+
const axisResult = visitAxisSingle(axis, visitor);
|
|
1505
|
+
if (axisResult) {
|
|
1506
|
+
result[typeObject.name] = axisResult;
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
return result;
|
|
1510
|
+
}, {});
|
|
1511
|
+
return ___default["default"].isEmpty(enumsNew) ? null : enumsNew;
|
|
1512
|
+
},
|
|
1513
|
+
visitGroupByExpression: (groupBy, fromType, removedItems) => deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression(schema, groupBy, fromType, removedItems)
|
|
1514
|
+
};
|
|
1515
|
+
const viewNew = visitView(view, visitor);
|
|
1452
1516
|
return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant(viewNew, canGroupMetaItem) : viewNew;
|
|
1453
1517
|
};
|
|
1454
1518
|
const fixUserSelectedUnitsInTimelineView = (schema, view, {
|
|
@@ -1462,31 +1526,37 @@ const fixUserSelectedUnitsInTimelineView = (schema, view, {
|
|
|
1462
1526
|
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
1463
1527
|
unitDefinitions,
|
|
1464
1528
|
getDefaultUnitTypeForField
|
|
1465
|
-
})
|
|
1529
|
+
}),
|
|
1530
|
+
visitEnums: enums => enums,
|
|
1531
|
+
visitGroupByExpression: groupBy => groupBy
|
|
1466
1532
|
});
|
|
1467
1533
|
};
|
|
1468
1534
|
const fixContextExpressionWithBrokenPath$1 = (schema, view, defaultContextExpression) => visitView(view, {
|
|
1469
1535
|
visitExpression: (_fromType, expression) => expression,
|
|
1470
1536
|
visitFilter: (_fromType, filter) => filter,
|
|
1471
1537
|
visitQueryExpression: query => query,
|
|
1472
|
-
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
1538
|
+
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression),
|
|
1539
|
+
visitEnums: enums => enums,
|
|
1540
|
+
visitGroupByExpression: groupBy => groupBy
|
|
1473
1541
|
});
|
|
1474
1542
|
const collectGarbage$1 = view => {
|
|
1475
1543
|
return visitView(view, {
|
|
1476
1544
|
visitQueryExpression: query => query,
|
|
1477
1545
|
visitFilter: (_fromType, filter) => filter,
|
|
1478
1546
|
visitExpression: (_fromType, expression) => expression,
|
|
1479
|
-
visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE
|
|
1547
|
+
visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE,
|
|
1548
|
+
visitEnums: enums => enums,
|
|
1549
|
+
visitGroupByExpression: groupBy => groupBy
|
|
1480
1550
|
});
|
|
1481
1551
|
};
|
|
1482
1552
|
const enableHideWhenEmptyForCheckedEditableUnits = view => {
|
|
1483
1553
|
return visitView(view, {
|
|
1484
1554
|
visitQueryExpression: queryExpression => queryExpression,
|
|
1485
|
-
visitGroupByExpression: groupBy => groupBy,
|
|
1486
1555
|
visitExpression: (_fromType, expression) => expression,
|
|
1487
1556
|
visitFilter: (_fromType, filter) => filter,
|
|
1557
|
+
visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit),
|
|
1488
1558
|
visitEnums: enums => enums,
|
|
1489
|
-
|
|
1559
|
+
visitGroupByExpression: groupBy => groupBy
|
|
1490
1560
|
});
|
|
1491
1561
|
};
|
|
1492
1562
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/views",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.1",
|
|
4
4
|
"description": "Operations on view objects",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Fibery",
|
|
@@ -19,13 +19,13 @@
|
|
|
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.1.5",
|
|
23
22
|
"@fibery/eslint-config": "8.6.1",
|
|
24
|
-
"@fibery/schema": "10.2.
|
|
23
|
+
"@fibery/schema": "10.2.8",
|
|
24
|
+
"@fibery/expression-utils": "9.2.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@fibery/expression-utils": "^9.1
|
|
28
|
-
"@fibery/schema": "^10.2.
|
|
27
|
+
"@fibery/expression-utils": "^9.2.1",
|
|
28
|
+
"@fibery/schema": "^10.2.8",
|
|
29
29
|
"immutability-helper": "^2.4.0",
|
|
30
30
|
"lodash": "^4.17.21"
|
|
31
31
|
},
|