@cocreate/organizations 1.11.9 → 1.13.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
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.13.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.12.0...v1.13.0) (2023-05-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* form getData and setDocumentId ([5ed4371](https://github.com/CoCreate-app/CoCreate-organizations/commit/5ed4371103578249764add885bcc0cd7e896ab7d))
|
|
7
|
+
|
|
8
|
+
# [1.12.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.11.9...v1.12.0) (2023-05-10)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* createOrg in local and platform ([85f62ed](https://github.com/CoCreate-app/CoCreate-organizations/commit/85f62ed74f511f3f15acbe3aa6825c314abde46d))
|
|
14
|
+
|
|
1
15
|
## [1.11.9](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.11.8...v1.11.9) (2023-05-07)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
template_id="datatable"
|
|
34
34
|
placeholder="Industry_id"/>
|
|
35
35
|
<span class="position:absolute bottom:20px right:20px float:right z-index:6" >
|
|
36
|
-
<a filter-sort-name="_id" value="" filter-sort-direction="asc"
|
|
36
|
+
<a filter-sort-name="_id" value="" filter-sort-direction="asc" click-value="desc, asc" click-attribute="filter-sort-direction" template_id="datatable">
|
|
37
37
|
</a>
|
|
38
38
|
</span>
|
|
39
39
|
</td>
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
template_id="datatable"
|
|
36
36
|
placeholder="Industry_id"/>
|
|
37
37
|
<span class="position:absolute bottom:20px right:20px float:right z-index:6" >
|
|
38
|
-
<a filter-sort-name="_id" value="" filter-sort-direction="asc"
|
|
38
|
+
<a filter-sort-name="_id" value="" filter-sort-direction="asc" click-value="desc, asc" click-attribute="filter-sort-direction" template_id="datatable">
|
|
39
39
|
</a>
|
|
40
40
|
</span>
|
|
41
41
|
</td>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/organizations",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "A simple organizations component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"organizations",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@cocreate/actions": "^1.8.8",
|
|
63
63
|
"@cocreate/crud-client": "^1.20.4",
|
|
64
64
|
"@cocreate/docs": "^1.7.8",
|
|
65
|
-
"@cocreate/
|
|
66
|
-
"@cocreate/
|
|
65
|
+
"@cocreate/form": "^1.14.6",
|
|
66
|
+
"@cocreate/indexeddb": "^1.8.6"
|
|
67
67
|
}
|
|
68
68
|
}
|
package/src/client.js
CHANGED
|
@@ -1,74 +1,32 @@
|
|
|
1
1
|
import crud from '@cocreate/crud-client';
|
|
2
|
-
import '@cocreate/
|
|
2
|
+
import indexeddb from '@cocreate/indexeddb';
|
|
3
3
|
import action from '@cocreate/actions';
|
|
4
|
-
import
|
|
5
|
-
import localStorage from '@cocreate/local-storage';
|
|
4
|
+
import form from '@cocreate/form';
|
|
6
5
|
|
|
7
6
|
const CoCreateOrganization = {
|
|
8
|
-
init: function() {
|
|
9
|
-
const self = this;
|
|
10
|
-
crud.listen('createOrg', function(data) {
|
|
11
|
-
self.setDocumentId('organizations', data.document[0]._id);
|
|
12
|
-
document.dispatchEvent(new CustomEvent('createdOrg', {
|
|
13
|
-
detail: data
|
|
14
|
-
}));
|
|
15
|
-
});
|
|
16
|
-
},
|
|
17
7
|
|
|
18
|
-
createOrg: function(btn) {
|
|
19
|
-
let
|
|
20
|
-
if (!
|
|
8
|
+
createOrg: async function(btn) {
|
|
9
|
+
let formEl = btn.closest("form");
|
|
10
|
+
if (!formEl) return;
|
|
11
|
+
|
|
12
|
+
let organization = form.getData(formEl, 'organizations')
|
|
13
|
+
let user = form.getData(formEl, 'users')
|
|
21
14
|
|
|
22
|
-
let
|
|
15
|
+
let documents = indexeddb.generateDB(organization, user)
|
|
23
16
|
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let value = el.getValue();
|
|
28
|
-
if (!name || !value) return;
|
|
29
|
-
data.document[name] = value;
|
|
17
|
+
let response = await crud.socket.send('createOrg', {
|
|
18
|
+
documents,
|
|
19
|
+
broadcastBrowser: false
|
|
30
20
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// data.database = data.document[0]['_id']
|
|
41
|
-
// data.organization_id = data.document[0]['_id']
|
|
42
|
-
// crud.createDocument(data).then((response) => {
|
|
43
|
-
|
|
44
|
-
document.dispatchEvent(new CustomEvent('createdOrg', {
|
|
45
|
-
detail: response
|
|
46
|
-
}));
|
|
47
|
-
|
|
48
|
-
// })
|
|
49
|
-
})
|
|
50
|
-
// } else {
|
|
51
|
-
// crud.socket.send('createOrg', {
|
|
52
|
-
// collection: 'organizations',
|
|
53
|
-
// ...data,
|
|
54
|
-
// broadcastBrowser: false
|
|
55
|
-
// });
|
|
56
|
-
// }
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
setDocumentId: function(collection, id) {
|
|
60
|
-
let orgIdElements = document.querySelectorAll(`[collection='${collection}']`);
|
|
61
|
-
if (orgIdElements && orgIdElements.length > 0) {
|
|
62
|
-
orgIdElements.forEach((el) => {
|
|
63
|
-
if (!el.getAttribute('document_id')) {
|
|
64
|
-
el.setAttribute('document_id', id);
|
|
65
|
-
}
|
|
66
|
-
if (el.getAttribute('name') == "_id") {
|
|
67
|
-
el.value = id;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
},
|
|
21
|
+
|
|
22
|
+
form.setDocumentId(formEl, organization)
|
|
23
|
+
form.setDocumentId(formEl, user)
|
|
24
|
+
|
|
25
|
+
document.dispatchEvent(new CustomEvent('createdOrg', {
|
|
26
|
+
detail: response
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
},
|
|
72
30
|
|
|
73
31
|
deleteOrg: async function(btn) {
|
|
74
32
|
const { collection, document_id } = crud.getAttributes(btn);
|
|
@@ -149,6 +107,4 @@ action.init({
|
|
|
149
107
|
},
|
|
150
108
|
});
|
|
151
109
|
|
|
152
|
-
CoCreateOrganization.init();
|
|
153
|
-
|
|
154
110
|
export default CoCreateOrganization;
|
package/src/server.js
CHANGED
|
@@ -17,29 +17,21 @@ class CoCreateOrganization {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async createOrg(socket, data) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.crud.createDocument(data).then((data) => {
|
|
25
|
-
// const orgId = `${data.document[0]._id}`
|
|
26
|
-
|
|
27
|
-
// Create new org db and insert organization
|
|
28
|
-
// self.crud.createDocument({...data, database: orgId, organization_id: orgId}).then((data) => {
|
|
29
|
-
// self.wsManager.send(socket, 'createOrg', data);
|
|
30
|
-
// self.wsManager.broadcast(socket, 'createDocument', data);
|
|
31
|
-
// })
|
|
32
|
-
|
|
33
|
-
self.wsManager.broadcast(socket, 'updateDocument', data);
|
|
34
|
-
self.wsManager.send(socket, 'createOrg', data);
|
|
35
|
-
|
|
36
|
-
// add new org to platformDB
|
|
37
|
-
if (data.organization_id != process.env.organization_id) {
|
|
38
|
-
self.crud.createDocument({ ...data, database: process.env.organization_id, organization_id: process.env.organization_id })
|
|
20
|
+
try {
|
|
21
|
+
const platformSocket = {
|
|
22
|
+
config: {
|
|
23
|
+
organization_id: process.env.organization_id,
|
|
39
24
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
for(let document of data.documents) {
|
|
28
|
+
document.database = process.env.organization_id
|
|
29
|
+
document.organization_id = process.env.organization_id
|
|
30
|
+
let response = await this.crud.createDocument(document)
|
|
31
|
+
this.wsManager.broadcast(platformSocket, 'createDocument', response);
|
|
32
|
+
}
|
|
33
|
+
this.wsManager.send(socket, 'createOrg', data);
|
|
34
|
+
} catch(error) {
|
|
43
35
|
console.log('createDocument error', error);
|
|
44
36
|
}
|
|
45
37
|
}
|