@fibery/views 10.3.0 → 10.4.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.
Files changed (2) hide show
  1. package/lib/views.js +14 -6
  2. package/package.json +5 -5
package/lib/views.js CHANGED
@@ -857,7 +857,7 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
857
857
  $apply: (items = []) => {
858
858
  const isOldSmartFolder = !items.every(item => item.hasOwnProperty("groupBy"));
859
859
  const removedItemsIndexes = items.map((item, index) => visitor.visitQueryExpression(item.query) ? null : index).filter(value => value !== null);
860
- return items.map((item, index) => {
860
+ return items.map(item => {
861
861
  if (isOldSmartFolder) {
862
862
  return item;
863
863
  }
@@ -865,12 +865,16 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
865
865
  return fromType ? immutableUpdate__default["default"](item, {
866
866
  groupBy: {
867
867
  $apply: groupBy => {
868
- const removedItemsBeforeCurrent = removedItemsIndexes.filter(n => n < index);
869
- return groupBy ? visitor.visitGroupByExpression(groupBy, fromType, removedItemsBeforeCurrent.length) : null;
868
+ if (!groupBy) {
869
+ return null;
870
+ }
871
+ const groupByIndex = parseInt(Object.keys(groupBy)[0]);
872
+ const removedItemsBeforeTarget = removedItemsIndexes.filter(n => n < groupByIndex);
873
+ return visitor.visitGroupByExpression(groupBy, fromType, removedItemsBeforeTarget.length);
870
874
  }
871
875
  }
872
876
  }) : item;
873
- }).map((item, index) => {
877
+ }).map(item => {
874
878
  if (isOldSmartFolder) {
875
879
  return item;
876
880
  }
@@ -878,8 +882,12 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
878
882
  return fromType ? immutableUpdate__default["default"](item, {
879
883
  groupingExpression: {
880
884
  $apply: groupingExpression => {
881
- const removedItemsBeforeCurrent = removedItemsIndexes.filter(n => n < index);
882
- return groupingExpression ? visitor.visitGroupByExpression(groupingExpression, fromType, removedItemsBeforeCurrent.length) : null;
885
+ if (!groupingExpression) {
886
+ return null;
887
+ }
888
+ const groupingExpressionIndex = parseInt(Object.keys(groupingExpression)[0]);
889
+ const removedItemsBeforeTarget = removedItemsIndexes.filter(n => n < groupingExpressionIndex);
890
+ return visitor.visitGroupByExpression(groupingExpression, fromType, removedItemsBeforeTarget.length);
883
891
  }
884
892
  }
885
893
  }) : item;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/views",
3
- "version": "10.3.0",
3
+ "version": "10.4.0",
4
4
  "description": "Operations on view objects",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Fibery",
@@ -18,13 +18,13 @@
18
18
  "jest-junit": "13.0.0",
19
19
  "lodash": "4.17.21",
20
20
  "microbundle": "0.15.1",
21
+ "@fibery/babel-preset": "7.4.0",
21
22
  "@fibery/eslint-config": "8.6.0",
22
- "@fibery/schema": "10.2.1",
23
- "@fibery/expression-utils": "9.0.4",
24
- "@fibery/babel-preset": "7.4.0"
23
+ "@fibery/expression-utils": "9.0.5",
24
+ "@fibery/schema": "10.2.1"
25
25
  },
26
26
  "peerDependencies": {
27
- "@fibery/expression-utils": "^9.0.4",
27
+ "@fibery/expression-utils": "^9.0.5",
28
28
  "@fibery/schema": "^10.2.1",
29
29
  "immutability-helper": "^2.4.0",
30
30
  "lodash": "^4.17.21"