@cocreate/elements 1.15.8 → 1.15.10
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 +14 -0
- package/package.json +1 -1
- package/src/index.js +4 -37
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.15.10](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.15.9...v1.15.10) (2023-02-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* setData valueType handeled by setValue ([34d196f](https://github.com/CoCreate-app/CoCreate-elements/commit/34d196ffe6e477f8d9e499e9c32e86532c632cd7))
|
|
7
|
+
|
|
8
|
+
## [1.15.9](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.15.8...v1.15.9) (2023-02-01)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* bump dependencies ([df0dab7](https://github.com/CoCreate-app/CoCreate-elements/commit/df0dab7e71b34a241f2eaab2cd01ba12c97ba7a1))
|
|
14
|
+
|
|
1
15
|
## [1.15.8](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.15.7...v1.15.8) (2023-02-01)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.10",
|
|
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
|
@@ -103,17 +103,10 @@ async function read(documents) {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
function setData(elements, data) {
|
|
106
|
-
let isRendered = false;
|
|
107
106
|
if (!data.document || !data.document[0]) return;
|
|
108
107
|
let key = getKey(data)
|
|
109
|
-
|
|
110
108
|
if (!elements) {
|
|
111
|
-
// ToDo: handle db and database, create key and get elements by key
|
|
112
109
|
elements = els.get(key)
|
|
113
|
-
// let collection = data.document[0].collection;
|
|
114
|
-
// let document_id = data.document[0]._id;
|
|
115
|
-
// let selector = `[collection='${collection}'][document_id='${document_id}']:not(cocreate-select, link)`;
|
|
116
|
-
// elements = document.querySelectorAll(selector);
|
|
117
110
|
} else {
|
|
118
111
|
let eles = els.get(key)
|
|
119
112
|
if (eles && eles.length)
|
|
@@ -126,41 +119,15 @@ function setData(elements, data) {
|
|
|
126
119
|
|
|
127
120
|
for (let el of elements) {
|
|
128
121
|
const { collection, document_id, name, isRead, isUpdate, isCrdt } = crud.getAttributes(el);
|
|
122
|
+
|
|
129
123
|
if (el.hasAttribute('actions')) continue;
|
|
130
|
-
if (isRead == "false" || isUpdate == "false" || isCrdt == "true") continue;
|
|
124
|
+
if (!name || isRead == "false" || isUpdate == "false" || isCrdt == "true") continue;
|
|
131
125
|
|
|
132
126
|
if (data.document[0]['collection'] == collection && data.document[0]['_id'] == document_id) {
|
|
133
|
-
let value;
|
|
134
|
-
let valueType = el.getAttribute('value-type');
|
|
135
|
-
if (valueType == 'object' || valueType == 'json'){
|
|
136
|
-
// if (name == 'data')
|
|
137
|
-
// value = JSON.stringify(data[name])
|
|
138
|
-
// else
|
|
139
|
-
value = JSON.stringify(data.document[0][name])
|
|
140
|
-
value = decodeURIComponent(value)
|
|
141
|
-
} else {
|
|
142
|
-
value = crud.getValueFromObject(data.document[0], name);
|
|
143
|
-
}
|
|
144
|
-
|
|
127
|
+
let value = crud.getValueFromObject(data.document[0], name);
|
|
145
128
|
el.setValue(value);
|
|
146
|
-
|
|
129
|
+
initializing.delete(el)
|
|
147
130
|
}
|
|
148
|
-
|
|
149
|
-
initializing.delete(el)
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (isRendered) {
|
|
155
|
-
// ToDo: Replace with custom event
|
|
156
|
-
const event = new CustomEvent('CoCreateElements-rendered', {
|
|
157
|
-
eventType: 'rendered',
|
|
158
|
-
detail: {
|
|
159
|
-
data
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
document.dispatchEvent(event);
|
|
164
131
|
}
|
|
165
132
|
}
|
|
166
133
|
|