@cocreate/elements 1.36.2 → 1.37.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.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +17 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.37.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.36.2...v1.37.0) (2024-09-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* update="" attribute support. improved data type handling ([fa478b0](https://github.com/CoCreate-app/CoCreate-elements/commit/fa478b008c85a78014f16f4800270af933767615))
|
|
7
|
+
|
|
1
8
|
## [1.36.2](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.36.1...v1.36.2) (2024-08-24)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.0",
|
|
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
|
@@ -373,7 +373,7 @@ async function setData(element, data) {
|
|
|
373
373
|
let action = el.getAttribute('actions')
|
|
374
374
|
if (action && ['database', 'array', 'object', 'key'].includes(action)) continue;
|
|
375
375
|
|
|
376
|
-
const { key, isRead, isListen, isCrdt } = getAttributes(el);
|
|
376
|
+
const { key, isRead, isUpdate, isListen, isCrdt } = getAttributes(el);
|
|
377
377
|
if (el.getFilter || el.renderValue)
|
|
378
378
|
await filterData(el, data, type, key)
|
|
379
379
|
else {
|
|
@@ -398,8 +398,8 @@ async function setData(element, data) {
|
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
if (!data[type].length) continue;
|
|
401
|
-
if (isRead
|
|
402
|
-
if (isListen
|
|
401
|
+
if (isRead === "false" || isCrdt === "true") continue;
|
|
402
|
+
if (isUpdate === "false" || isListen === "false" && !data.method.endsWith('.read')) continue;
|
|
403
403
|
// TODO: object.update data returned from server will not include $operator
|
|
404
404
|
el.setValue(value);
|
|
405
405
|
|
|
@@ -527,7 +527,8 @@ async function checkFilters(element, data, type) {
|
|
|
527
527
|
// TODO: fix: getObject as this is related to render or form, but filter could exist on an input which does not have getObject
|
|
528
528
|
// TODO: generate an object of current element key: value to use with filter. because filter is used object is not defined
|
|
529
529
|
Data = getObject(element)
|
|
530
|
-
|
|
530
|
+
if (Array.isArray(Data[type]))
|
|
531
|
+
Data = Data[type][0]
|
|
531
532
|
} else
|
|
532
533
|
Data = await element.getData()
|
|
533
534
|
|
|
@@ -569,9 +570,20 @@ async function checkFilters(element, data, type) {
|
|
|
569
570
|
primaryKey = 'name';
|
|
570
571
|
}
|
|
571
572
|
|
|
572
|
-
if (
|
|
573
|
+
if (Array.isArray(newData)) {
|
|
574
|
+
for (let i = 0; i < newData.length; i++) {
|
|
575
|
+
if (typeof Data === 'string' && Data === newData[i][primaryKey]) {
|
|
576
|
+
Data = newData[i]
|
|
577
|
+
} else if (Data[primaryKey] === newData[i][primaryKey]) {
|
|
578
|
+
Data = dotNotationToObject(newData[i], Data)
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
} else if (typeof Data === 'string' && Data === newData[primaryKey]) {
|
|
582
|
+
Data = newData
|
|
583
|
+
} else if (Data[primaryKey] === newData[primaryKey]) {
|
|
573
584
|
Data = dotNotationToObject(newData, Data)
|
|
574
585
|
}
|
|
586
|
+
|
|
575
587
|
if (element.renderValue)
|
|
576
588
|
element.renderValue(data);
|
|
577
589
|
// render({ element, data, key: type });
|