@vonaffenfels/contentful-teasermanager 1.2.15 → 1.2.17
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.
|
|
3
|
+
"version": "1.2.17",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublish": "yarn run build",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"contentful-resolve-response": "^1.9.2",
|
|
103
103
|
"webpack": "5.88.2"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "a954d2810be5635ab95a6630152130beb04cea87",
|
|
106
106
|
"publishConfig": {
|
|
107
107
|
"access": "public"
|
|
108
108
|
}
|
|
@@ -120,6 +120,11 @@ const LogicEditorInner = ({
|
|
|
120
120
|
isOver: isAndOver,
|
|
121
121
|
node: andNode,
|
|
122
122
|
} = useDroppable({id: "and"});
|
|
123
|
+
const {
|
|
124
|
+
setNodeRef: setExcludeNodeRef,
|
|
125
|
+
isOver: isExcludeOver,
|
|
126
|
+
node: excludeNode,
|
|
127
|
+
} = useDroppable({id: "exclude"});
|
|
123
128
|
|
|
124
129
|
useEffect(() => {
|
|
125
130
|
setLoading(true);
|
|
@@ -185,6 +190,7 @@ const LogicEditorInner = ({
|
|
|
185
190
|
|
|
186
191
|
const andTags = selectedTags.filter((t) => t.type === "and");
|
|
187
192
|
const orTags = selectedTags.filter((t) => t.type === "or");
|
|
193
|
+
const excludeTags = selectedTags.filter((t) => t.type === "exclude");
|
|
188
194
|
|
|
189
195
|
return <div className="flex flex-col gap-2 p-4">
|
|
190
196
|
<div className="z-10 flex w-full flex-col gap-4 border-b border-gray-200 bg-white py-4">
|
|
@@ -229,7 +235,7 @@ const LogicEditorInner = ({
|
|
|
229
235
|
</div>
|
|
230
236
|
<div className="flex w-full flex-row items-center gap-2" style={{minHeight: 36}}>
|
|
231
237
|
<SectionHeading style={{marginBottom: 0}}>Gewählte Kategorien & Tags:</SectionHeading>
|
|
232
|
-
<div className="grid w-full grid-cols-
|
|
238
|
+
<div className="grid w-full grid-cols-5 gap-4">
|
|
233
239
|
<div className="flex w-full flex-col gap-2">
|
|
234
240
|
<div>
|
|
235
241
|
<SectionHeading style={{marginBottom: 0}}>Oder</SectionHeading>
|
|
@@ -279,6 +285,30 @@ const LogicEditorInner = ({
|
|
|
279
285
|
})}
|
|
280
286
|
</div>
|
|
281
287
|
</div>
|
|
288
|
+
<div className="flex w-full flex-col gap-2">
|
|
289
|
+
<SectionHeading style={{marginBottom: 0}}>Ausschließen</SectionHeading>
|
|
290
|
+
<div
|
|
291
|
+
ref={setExcludeNodeRef}
|
|
292
|
+
style={{
|
|
293
|
+
minHeight: 36,
|
|
294
|
+
backgroundColor: isExcludeOver ? "rgba(0, 255, 0, 0.3)" : "transparent",
|
|
295
|
+
}}
|
|
296
|
+
className="flex h-full w-full flex-row flex-wrap gap-2"
|
|
297
|
+
>
|
|
298
|
+
{excludeTags.map((tag) => {
|
|
299
|
+
return <DraggablePill
|
|
300
|
+
key={tag.id}
|
|
301
|
+
id={tag.id}
|
|
302
|
+
testId={tag.id}
|
|
303
|
+
variant="active"
|
|
304
|
+
label={(`${tag.label}`)}
|
|
305
|
+
onClose={() => {
|
|
306
|
+
setSelectedTags(selectedTags.filter((t) => t.id !== tag.id));
|
|
307
|
+
}}
|
|
308
|
+
/>;
|
|
309
|
+
})}
|
|
310
|
+
</div>
|
|
311
|
+
</div>
|
|
282
312
|
<div className="col-span-2 flex w-full flex-col gap-4">
|
|
283
313
|
<div>
|
|
284
314
|
<SectionHeading style={{marginBottom: 0}}>Artikel</SectionHeading>
|
package/src/queryFromLogic.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const queryFromLogic = (logic) => {
|
|
2
2
|
const orTags = logic.tags.filter(v => v.type === "or").map(v => v.id);
|
|
3
3
|
const andTags = logic.tags.filter(v => v.type === "and").map(v => v.id);
|
|
4
|
+
const excludeTags = logic.tags.filter(v => v.type === "exclude").map(v => v.id);
|
|
4
5
|
const timeZoneOffsetInHours = new Date().getTimezoneOffset() / 60;
|
|
5
6
|
const differenceToGermanTime = timeZoneOffsetInHours + 2;
|
|
6
7
|
const hours = [...(logic.timepoints || [])].map(v => parseInt(v)).sort((a, b) => a - b);
|
|
@@ -19,6 +20,10 @@ export const queryFromLogic = (logic) => {
|
|
|
19
20
|
logicQuery["fields.tags.sys.id[all]"] = andTags.join(",");
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
if (excludeTags.length) {
|
|
24
|
+
logicQuery["fields.tags.sys.id[nin]"] = excludeTags.join(",");
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
if (nearestPassedTime && hours.length) {
|
|
23
28
|
logicQuery["fields.date[lte]"] = new Date(new Date().setHours(
|
|
24
29
|
nearestPassedTime + differenceToGermanTime, 0, 0, 0,
|