@cocreate/elements 1.29.0 → 1.29.1
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 +14 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.29.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.29.0...v1.29.1) (2023-12-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* handle arrays ([7ea1e12](https://github.com/CoCreate-app/CoCreate-elements/commit/7ea1e12d89d95aae1dca23b38d80b899fa4cddd6))
|
|
7
|
+
|
|
1
8
|
# [1.29.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.28.0...v1.29.0) (2023-11-25)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.1",
|
|
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
|
@@ -333,6 +333,12 @@ async function filterData(element, data, type, key) {
|
|
|
333
333
|
if (Array.isArray(data[type])) {
|
|
334
334
|
let Data = []
|
|
335
335
|
for (let doc of data[type]) {
|
|
336
|
+
// TODO: should have been handled by getDataElements()
|
|
337
|
+
if (type === 'object') {
|
|
338
|
+
let _id = element.getAttribute('object')
|
|
339
|
+
if (_id && doc._id !== _id)
|
|
340
|
+
return
|
|
341
|
+
}
|
|
336
342
|
if (doc[key]) {
|
|
337
343
|
if (Array.isArray(doc[key]))
|
|
338
344
|
Data.push(...doc[key])
|
|
@@ -602,13 +608,20 @@ async function getData(form) {
|
|
|
602
608
|
}
|
|
603
609
|
}
|
|
604
610
|
|
|
605
|
-
|
|
606
611
|
if (Data.type = 'object') {
|
|
607
612
|
if (typeof Data[Data.type] === 'string')
|
|
608
613
|
if (Data.key == '{}')
|
|
609
614
|
Data[Data.type] = { _id: Data[Data.type], ...value }
|
|
610
615
|
else
|
|
611
616
|
Data[Data.type] = { _id: Data[Data.type], [Data.key]: value }
|
|
617
|
+
else if (Array.isArray(Data[Data.type]))
|
|
618
|
+
if (Data.key == '{}')
|
|
619
|
+
Data[Data.type][0] = { ...Data[Data.type][0], ...value }
|
|
620
|
+
else {
|
|
621
|
+
Data[Data.type][0][Data.key] = value
|
|
622
|
+
if (!Data[Data.type][0]._id)
|
|
623
|
+
Data.method = Data.type + '.create'
|
|
624
|
+
}
|
|
612
625
|
else if (typeof Data[Data.type] === 'object')
|
|
613
626
|
if (Data.key == '{}')
|
|
614
627
|
Data[Data.type] = { ...Data[Data.type], ...value }
|