@cocreate/elements 1.24.2 → 1.24.3
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 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.24.3](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.24.2...v1.24.3) (2023-10-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* condition on read ([fe53a8e](https://github.com/CoCreate-app/CoCreate-elements/commit/fe53a8ea9808502af64a8298a14dd38bbfd07940))
|
|
7
|
+
|
|
1
8
|
## [1.24.2](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.24.1...v1.24.2) (2023-10-19)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.3",
|
|
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
|
@@ -233,11 +233,10 @@ async function read(element, data, dataKey) {
|
|
|
233
233
|
if (!data.$filter && data.type === 'object') {
|
|
234
234
|
if (typeof data.object === 'string')
|
|
235
235
|
data.object = { _id: data.object }
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (!data.object._id.match(/^[0-9a-fA-F]{24}$/))
|
|
236
|
+
else if (Array.isArray(data.object)) {
|
|
237
|
+
if (data.object.length)
|
|
238
|
+
data.object = { _id: data.object[0]._id }
|
|
239
|
+
} else if (!data.object._id.match(/^[0-9a-fA-F]{24}$/))
|
|
241
240
|
return
|
|
242
241
|
}
|
|
243
242
|
|
|
@@ -284,7 +283,7 @@ async function setData(element, data) {
|
|
|
284
283
|
if (key) {
|
|
285
284
|
if (!data[type].length) continue;
|
|
286
285
|
if (isRead == "false" || isCrdt == "true") continue;
|
|
287
|
-
if (isListen == "false" && !data.method.startsWith('read')) continue;
|
|
286
|
+
if (isListen == "false" && !data.method.startsWith('read.')) continue;
|
|
288
287
|
}
|
|
289
288
|
// TODO: update.object data returned from server will not include $operator
|
|
290
289
|
el.setValue(value);
|
|
@@ -311,7 +310,7 @@ async function filterData(element, data, type, key) {
|
|
|
311
310
|
}
|
|
312
311
|
}
|
|
313
312
|
|
|
314
|
-
if (element.getFilter && data.method && !data.method.startsWith('read'))
|
|
313
|
+
if (element.getFilter && data.method && !data.method.startsWith('read.'))
|
|
315
314
|
await checkFilters(element, data, type)
|
|
316
315
|
else if (element.renderValue)
|
|
317
316
|
element.renderValue(data);
|
|
@@ -697,9 +696,9 @@ async function save(element) {
|
|
|
697
696
|
}
|
|
698
697
|
}
|
|
699
698
|
|
|
700
|
-
if (data[i].method && data[i].method.startsWith('create')) {
|
|
699
|
+
if (data[i].method && data[i].method.startsWith('create.')) {
|
|
701
700
|
element.setAttribute(data[i].type, 'pending');
|
|
702
|
-
} else if (data[i].method && data[i].method.startsWith('update') && data[i].type == 'object' && typeof value == 'string' && window.CoCreate.crdt && !'crdt') {
|
|
701
|
+
} else if (data[i].method && data[i].method.startsWith('update.') && data[i].type == 'object' && typeof value == 'string' && window.CoCreate.crdt && !'crdt') {
|
|
703
702
|
return window.CoCreate.crdt.replaceText({
|
|
704
703
|
array: data[i].array,
|
|
705
704
|
key: data[i].key,
|
|
@@ -713,7 +712,7 @@ async function save(element) {
|
|
|
713
712
|
|
|
714
713
|
Data.push(data[i])
|
|
715
714
|
|
|
716
|
-
if (data[i] && (data[i].method.startsWith('create') || data[i].type !== 'object' && data[i].method.startsWith('update'))) {
|
|
715
|
+
if (data[i] && (data[i].method.startsWith('create.') || data[i].type !== 'object' && data[i].method.startsWith('update.'))) {
|
|
717
716
|
setTypeValue(element, data[i])
|
|
718
717
|
} else if (data[i])
|
|
719
718
|
document.dispatchEvent(new CustomEvent('saved', {
|
|
@@ -822,7 +821,10 @@ async function remove(element) {
|
|
|
822
821
|
element = [element]
|
|
823
822
|
for (let i = 0; i < element.length; i++) {
|
|
824
823
|
if (element[i].tagName === 'FORM') {
|
|
825
|
-
let form = forms.get(element[i])
|
|
824
|
+
let form = forms.get(element[i])
|
|
825
|
+
if (!form) return
|
|
826
|
+
|
|
827
|
+
form = form.elements
|
|
826
828
|
for (let el of form.keys()) {
|
|
827
829
|
let key = elements.get(el)
|
|
828
830
|
if (key) {
|