@cocreate/elements 1.35.3 → 1.35.4
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +13 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.35.4](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.35.3...v1.35.4) (2024-05-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* handle if item is already read ([2407f9b](https://github.com/CoCreate-app/CoCreate-elements/commit/2407f9b3789173fddb8f8ed6b4bb90f7f8d17864))
|
|
7
|
+
|
|
1
8
|
## [1.35.3](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.35.2...v1.35.3) (2024-05-08)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.4",
|
|
4
4
|
"description": "Fetch content into any html element by using html5 attributes to query data stored in CoCreate headless CMS. If data is changed it will instantly reflect in html tags as changes are broadcasted in realtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"elements",
|
package/src/index.js
CHANGED
|
@@ -119,6 +119,7 @@ async function initElement(el) {
|
|
|
119
119
|
|
|
120
120
|
el.setFilter = (filter) => {
|
|
121
121
|
data.$filter = filter
|
|
122
|
+
el.hasRead = false
|
|
122
123
|
// let dataKey = initDataKey(el, data)
|
|
123
124
|
read(el, data)
|
|
124
125
|
}
|
|
@@ -233,8 +234,12 @@ async function read(element, data, dataKey) {
|
|
|
233
234
|
|
|
234
235
|
for (let el of element) {
|
|
235
236
|
const isRead = el.getAttribute('read');
|
|
236
|
-
if (isRead !== 'false')
|
|
237
|
+
if (isRead !== 'false' && !el.hasRead) {
|
|
238
|
+
el.hasRead = true
|
|
237
239
|
delay.elements.set(el, true)
|
|
240
|
+
} else {
|
|
241
|
+
console.log('read skipped', el)
|
|
242
|
+
}
|
|
238
243
|
}
|
|
239
244
|
|
|
240
245
|
if (!delay.elements.size)
|
|
@@ -409,7 +414,7 @@ async function filterData(element, data, type, key) {
|
|
|
409
414
|
let property = key.replace(operator + '.', '')
|
|
410
415
|
|
|
411
416
|
if (Array.isArray(data[type])) {
|
|
412
|
-
let Data = []
|
|
417
|
+
let Data = [], isObject
|
|
413
418
|
for (let doc of data[type]) {
|
|
414
419
|
// TODO: should have been handled by getDataElements()
|
|
415
420
|
if (type === 'object') {
|
|
@@ -426,14 +431,17 @@ async function filterData(element, data, type, key) {
|
|
|
426
431
|
if (doc[property]) {
|
|
427
432
|
if (Array.isArray(doc[property]))
|
|
428
433
|
Data.push(...doc[property])
|
|
429
|
-
else
|
|
434
|
+
else {
|
|
435
|
+
isObject = true
|
|
430
436
|
Data.push(doc[property])
|
|
437
|
+
}
|
|
431
438
|
} else
|
|
432
439
|
return
|
|
433
440
|
}
|
|
434
|
-
|
|
441
|
+
|
|
442
|
+
// if (isObject && Data.length === 1) {
|
|
435
443
|
// data = { [property]: Data[0] }
|
|
436
|
-
// } else
|
|
444
|
+
// } else
|
|
437
445
|
if (!operator)
|
|
438
446
|
data = Data
|
|
439
447
|
else if (operator === '$sum') {
|