@vonaffenfels/contentful-teasermanager 1.2.1 → 1.2.3

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": "@vonaffenfels/contentful-teasermanager",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "prepublish": "yarn run build",
@@ -101,7 +101,7 @@
101
101
  "contentful-resolve-response": "^1.9.2",
102
102
  "webpack": "5.88.2"
103
103
  },
104
- "gitHead": "b06b79ed032fecf1dfeef2e7e312eb0d42f2e84e",
104
+ "gitHead": "89b263e6c6a0b3a1bb39eeb63abf8a8c00207416",
105
105
  "publishConfig": {
106
106
  "access": "public"
107
107
  }
@@ -53,10 +53,7 @@ export const LogicEditor = (props) => {
53
53
  const LogicEditorInner = ({
54
54
  onSave = () => alert("onSave missing"),
55
55
  sdk,
56
- logicData = {
57
- timepoints: [7, 12, 18],
58
- tags: [],
59
- },
56
+ logicData,
60
57
  selectedTags,
61
58
  setSelectedTags,
62
59
  }) => {
@@ -69,8 +66,12 @@ const LogicEditorInner = ({
69
66
  const debouncedSearch = useDebounce(searchQuery, 500);
70
67
  const [selectedTimepoints, setSelectedTimepoints] = useState([]);
71
68
  useEffect(() => {
72
- setSelectedTimepoints(logicData?.timepoints || []);
73
- }, [logicData?.timepoints]);
69
+ if (logicData?.timepoints) {
70
+ setSelectedTimepoints(logicData?.timepoints);
71
+ } else {
72
+ setSelectedTimepoints([7, 12, 18]);
73
+ }
74
+ }, [logicData]);
74
75
  const {
75
76
  setNodeRef: setOrNodeRef,
76
77
  isOver: isOrOver,
@@ -124,7 +125,7 @@ const LogicEditorInner = ({
124
125
  return [];
125
126
  }
126
127
 
127
- const references = await sdk.cma.entry.references({entryId: response.items[0].sys.id}, {include: 7});
128
+ const references = await sdk.cma.entry.references({entryId: response.items[0].sys.id}, {include: 10});
128
129
  const resolved = contentfulResolveResponse(references);
129
130
  const allCategories = {};
130
131
 
@@ -140,7 +141,7 @@ const LogicEditorInner = ({
140
141
  }
141
142
  }
142
143
 
143
- return Object.values(allCategories);
144
+ return Object.values(allCategories).filter((c) => c.tags.length > 0);
144
145
  }),
145
146
  ]).then(([tags, categories]) => {
146
147
  setLoading(false);
@@ -288,7 +289,8 @@ const LogicEditorInner = ({
288
289
  setSelectedTags(newTags);
289
290
  }}
290
291
  >
291
- {category.title} ({selectedTags.filter((t) => category.tags.some((c) => c.id === t.id)).length}/{category.tags.length})
292
+ {category.title} ({selectedTags.filter((t) =>
293
+ category.tags.some((c) => c.id === t.id)).length}/{category.tags.length})
292
294
  </Checkbox>
293
295
  );
294
296
  })}
@@ -342,15 +344,16 @@ const LogicEditorInner = ({
342
344
  </div>;
343
345
  };
344
346
 
345
- function getAllTagsFromCategory(categoryNode, allCategories = {}) {
347
+ function getAllTagsFromCategory(categoryNode, allCategories = {}, parentCategoryTitle = null) {
346
348
  if (!categoryNode || !categoryNode.fields?.children) {
347
349
  return allCategories;
348
350
  }
349
351
 
350
352
  const children = categoryNode.fields.children.de || [];
353
+ const title = parentCategoryTitle ? `${parentCategoryTitle} > ${categoryNode.fields.title.de}` : categoryNode.fields.title.de;
351
354
 
352
355
  allCategories[categoryNode.sys.id] = {
353
- title: categoryNode.fields.title.de,
356
+ title,
354
357
  tags: [],
355
358
  id: categoryNode.sys.id,
356
359
  };
@@ -390,7 +393,7 @@ function getAllTagsFromCategory(categoryNode, allCategories = {}) {
390
393
  }
391
394
  }
392
395
 
393
- getAllTagsFromCategory(child, allCategories);
396
+ getAllTagsFromCategory(child, allCategories, title);
394
397
  }
395
398
 
396
399
  allCategories[categoryNode.sys.id].tags = [...new Set(allCategories[categoryNode.sys.id].tags)];