@cocreate/elements 1.22.0 → 1.23.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 +12 -0
- package/package.json +4 -4
- package/src/index.js +11 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# [1.23.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.22.0...v1.23.0) (2023-10-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* removed listener sync ([4b5fa05](https://github.com/CoCreate-app/CoCreate-elements/commit/4b5fa051dfa0f116b2d58f1a990b26e92c7b6d84))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* check element for $<operator> attribute and add to key. ([f7bc8b0](https://github.com/CoCreate-app/CoCreate-elements/commit/f7bc8b0acf140043904a28ba4a6958c4274cdb31))
|
|
12
|
+
|
|
1
13
|
# [1.22.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.21.1...v1.22.0) (2023-09-19)
|
|
2
14
|
|
|
3
15
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.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",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@cocreate/actions": "^1.11.2",
|
|
62
|
-
"@cocreate/crud-client": "^1.
|
|
62
|
+
"@cocreate/crud-client": "^1.27.0",
|
|
63
63
|
"@cocreate/element-prototype": "^1.11.2",
|
|
64
|
-
"@cocreate/filter": "^1.
|
|
64
|
+
"@cocreate/filter": "^1.23.0",
|
|
65
65
|
"@cocreate/observer": "^1.11.2",
|
|
66
|
-
"@cocreate/render": "^1.
|
|
66
|
+
"@cocreate/render": "^1.28.0",
|
|
67
67
|
"@cocreate/utils": "^1.24.2"
|
|
68
68
|
}
|
|
69
69
|
}
|
package/src/index.js
CHANGED
|
@@ -280,6 +280,7 @@ function setData(element, data) {
|
|
|
280
280
|
if (isRead == "false" || isCrdt == "true") continue;
|
|
281
281
|
if (isListen == "false" && !data.method.startsWith('read')) continue;
|
|
282
282
|
}
|
|
283
|
+
// TODO: update.object data returned from server will not include $operator
|
|
283
284
|
el.setValue(value);
|
|
284
285
|
}
|
|
285
286
|
}
|
|
@@ -505,25 +506,18 @@ function getData(form) {
|
|
|
505
506
|
Data[Data.type] = value
|
|
506
507
|
|
|
507
508
|
} else if (Data[Data.type] && Data.key) {
|
|
508
|
-
let
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
Data[Data.type][Data.key] = { $splice: value }
|
|
517
|
-
} else if (slice) {
|
|
518
|
-
Data[Data.type][Data.key] = '$delete'
|
|
519
|
-
} else if (isUpdate) {
|
|
520
|
-
value = Data.key.replace(/\[.*?\]/, '[' + value + ']')
|
|
521
|
-
Data.updateKey[Data.key] = value
|
|
522
|
-
Data[Data.type][Data.key] = { $update: value } // $update is string use the value as the key name
|
|
523
|
-
// Data[Data.type][Data.key] = { $update: {[value]: value} } // $update is an object use the key as the value to use for the new key
|
|
509
|
+
let attributes = element.attributes
|
|
510
|
+
if (!Data.key.startsWith('$')) {
|
|
511
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
512
|
+
let operators = ['$rename', '$inc', '$push', '$each', '$splice', '$unset', '$delete', '$slice', '$pop', '$shift', '$addToSet', '$pull']
|
|
513
|
+
if (!operators.includes(attributes[i].name)) {
|
|
514
|
+
Data.key = attributes[i].name + '.' + Data.key
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
524
517
|
}
|
|
518
|
+
}
|
|
525
519
|
|
|
526
|
-
|
|
520
|
+
if (Data.type = 'object')
|
|
527
521
|
Data.object[Data.key] = value
|
|
528
522
|
else {
|
|
529
523
|
Data[Data.type] = { [Data[Data.type]]: value }
|
|
@@ -767,11 +761,6 @@ function initSocket() {
|
|
|
767
761
|
});
|
|
768
762
|
}
|
|
769
763
|
}
|
|
770
|
-
|
|
771
|
-
CRUD.listen('sync', function (data) {
|
|
772
|
-
setData(null, data);
|
|
773
|
-
});
|
|
774
|
-
|
|
775
764
|
}
|
|
776
765
|
|
|
777
766
|
Observer.init({
|