@firecms/core 3.0.0-alpha.48 → 3.0.0-alpha.49

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
- "version": "3.0.0-alpha.48",
3
+ "version": "3.0.0-alpha.49",
4
4
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
5
5
  "funding": {
6
6
  "url": "https://github.com/sponsors/firecmsco"
@@ -133,7 +133,7 @@
133
133
  "dist",
134
134
  "src"
135
135
  ],
136
- "gitHead": "04d4690b0b71a4dd56a01a77e4c639d6af79be86",
136
+ "gitHead": "c9502da4e2caa2c3c896fbae55a7fe788cd0b840",
137
137
  "publishConfig": {
138
138
  "access": "public"
139
139
  }
@@ -10,6 +10,26 @@ import { mergeDeep } from "./objects";
10
10
  import { sortProperties } from "./collections";
11
11
  import { isPropertyBuilder } from "./entities";
12
12
 
13
+ function applyModifyFunction(modifyCollection: ((props: ModifyCollectionProps) => (EntityCollection | void)) | undefined,
14
+ collection: EntityCollection,
15
+ parentPaths: string[]) {
16
+ if (modifyCollection) {
17
+ const modified = modifyCollection({
18
+ collection,
19
+ parentPaths
20
+ });
21
+ const resCollection = modified ?? collection;
22
+ if (resCollection.subcollections) {
23
+ resCollection.subcollections = resCollection.subcollections.map((subcollection) => {
24
+ return applyModifyFunction(modifyCollection, subcollection, [...parentPaths, collection.path]);
25
+ });
26
+ }
27
+ return resCollection;
28
+ } else {
29
+ return collection;
30
+ }
31
+ }
32
+
13
33
  /**
14
34
  *
15
35
  */
@@ -26,15 +46,7 @@ export function joinCollectionLists(targetCollections: EntityCollection[],
26
46
  // return collection.path === codedCollection.path || collection.id && codedCollection.id;
27
47
  });
28
48
  if (!targetCol) {
29
- if (modifyCollection) {
30
- const modified = modifyCollection({
31
- collection: sourceCol,
32
- parentPaths
33
- });
34
- return modified ?? sourceCol;
35
- } else {
36
- return sourceCol;
37
- }
49
+ return applyModifyFunction(modifyCollection, sourceCol, parentPaths);
38
50
  } else {
39
51
  return mergeCollection(targetCol, sourceCol, parentPaths, modifyCollection);
40
52
  }
@@ -45,11 +57,7 @@ export function joinCollectionLists(targetCollections: EntityCollection[],
45
57
  .filter((col) => !updatedCollections.map(c => c.id).includes(col.id))
46
58
  .map((col) => {
47
59
  if (modifyCollection) {
48
- const modified = modifyCollection({
49
- collection: col,
50
- parentPaths
51
- });
52
- return modified ?? col;
60
+ return applyModifyFunction(modifyCollection, col, parentPaths);
53
61
  } else {
54
62
  return col;
55
63
  }