@cocreate/unique 1.17.0 → 1.18.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 +15 -0
- package/package.json +3 -3
- package/src/client.js +11 -13
- package/src/server.js +7 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.18.1](https://github.com/CoCreate-app/CoCreate-unique/compare/v1.18.0...v1.18.1) (2023-12-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* cleaned code ([32c00ba](https://github.com/CoCreate-app/CoCreate-unique/commit/32c00ba27355be92d25ec45f8426f79d865ff211))
|
|
7
|
+
* set unique true or ffalse ([e368594](https://github.com/CoCreate-app/CoCreate-unique/commit/e368594e1acb473fadf54e31e8ebed351ac9b8c6))
|
|
8
|
+
|
|
9
|
+
# [1.18.0](https://github.com/CoCreate-app/CoCreate-unique/compare/v1.17.0...v1.18.0) (2023-11-25)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* upgrade dependencies for latest features and fixes ([dc1b88f](https://github.com/CoCreate-app/CoCreate-unique/commit/dc1b88f0f14f162208656ac78ba19c426edf165c))
|
|
15
|
+
|
|
1
16
|
# [1.17.0](https://github.com/CoCreate-app/CoCreate-unique/compare/v1.16.0...v1.17.0) (2023-11-25)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/unique",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.1",
|
|
4
4
|
"description": "A simple unique component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unique",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"webpack-log": "^3.0.1"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@cocreate/crud-client": "^1.
|
|
62
|
-
"@cocreate/uuid": "^1.
|
|
61
|
+
"@cocreate/crud-client": "^1.31.0",
|
|
62
|
+
"@cocreate/uuid": "^1.9.0"
|
|
63
63
|
}
|
|
64
64
|
}
|
package/src/client.js
CHANGED
|
@@ -44,36 +44,34 @@ function setInputEvent(input) {
|
|
|
44
44
|
async function isUnique(element) {
|
|
45
45
|
let key = element.getAttribute('key');
|
|
46
46
|
let value = await element.getValue();
|
|
47
|
-
let
|
|
47
|
+
let data = {
|
|
48
48
|
method: 'object.read',
|
|
49
|
-
|
|
49
|
+
storage: 'indexeddb',
|
|
50
50
|
array: element.getAttribute('array'),
|
|
51
51
|
$filter: {
|
|
52
52
|
query: [{
|
|
53
53
|
key,
|
|
54
54
|
value,
|
|
55
55
|
operator: '$eq'
|
|
56
|
-
}]
|
|
56
|
+
}],
|
|
57
|
+
limit: 1
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
let response = {
|
|
62
|
-
element,
|
|
63
|
-
key,
|
|
64
|
-
unique: true
|
|
65
|
-
};
|
|
61
|
+
data = await crud.send(data)
|
|
66
62
|
|
|
63
|
+
let response = {}
|
|
67
64
|
// If a object is returned, unique is set to false
|
|
68
65
|
if (data.object && data.object.length) {
|
|
69
66
|
response.unique = false;
|
|
70
|
-
}
|
|
67
|
+
} else
|
|
68
|
+
response.unique = true
|
|
71
69
|
|
|
72
70
|
// If indexedb response is unique is true, check server response
|
|
73
71
|
if (response.unique) {
|
|
74
|
-
delete
|
|
75
|
-
|
|
76
|
-
response = await crud.socket.send(
|
|
72
|
+
delete data.unique
|
|
73
|
+
response.method = 'isUnique'
|
|
74
|
+
response = await crud.socket.send(response)
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
// Set unique attribute on the element
|
package/src/server.js
CHANGED
|
@@ -28,16 +28,14 @@ class CoCreateUnique {
|
|
|
28
28
|
try {
|
|
29
29
|
data.method = 'object.read'
|
|
30
30
|
this.crud.send(data).then((data) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
unique: true,
|
|
34
|
-
uid: data.uid
|
|
35
|
-
};
|
|
36
|
-
// If the object is unique
|
|
31
|
+
data.method = 'isUnique'
|
|
32
|
+
|
|
37
33
|
if (data.object.length) {
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
34
|
+
data.unique = false;
|
|
35
|
+
} else
|
|
36
|
+
data.unique = true;
|
|
37
|
+
|
|
38
|
+
return self.wsManager.send(data);
|
|
41
39
|
})
|
|
42
40
|
} catch (error) {
|
|
43
41
|
console.log(error);
|