@cocreate/organizations 1.2.1 → 1.2.4
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 +22 -0
- package/CoCreate.config.js +1 -1
- package/demo/CoCreate-createUser.html +1 -1
- package/demo/index.html +2 -2
- package/demo/industries/industries.html +1 -1
- package/demo/industries/industry-datatable.html +1 -1
- package/demo/industries/industry-documents-datatable.1.html +1 -1
- package/package.json +1 -1
- package/src/client.js +4 -7
- package/src/server.js +13 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [1.2.4](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.2.3...v1.2.4) (2022-05-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* insert returns insertedId instead of [0]._id ([3a604ed](https://github.com/CoCreate-app/CoCreate-organizations/commit/3a604ed3759f3d607243b29b9ee568bb459ab40f))
|
|
7
|
+
|
|
8
|
+
## [1.2.3](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.2.2...v1.2.3) (2022-05-06)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* replace ObjectID with ObjectId due to mongodb depreciation ([675f499](https://github.com/CoCreate-app/CoCreate-organizations/commit/675f49949d338e735e5d6df8a1be01b9b5f71751))
|
|
14
|
+
* update config organization_Id to organization_id ([be77abe](https://github.com/CoCreate-app/CoCreate-organizations/commit/be77abe662b7839f3f97ad1dcc54835d85dc67c1))
|
|
15
|
+
|
|
16
|
+
## [1.2.2](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.2.1...v1.2.2) (2022-03-21)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* update class sortable to attribute sortable ([8257806](https://github.com/CoCreate-app/CoCreate-organizations/commit/825780670c4a40eac352e5c83067df9dcea686bd))
|
|
22
|
+
|
|
1
23
|
## [1.2.1](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.2.0...v1.2.1) (2022-03-06)
|
|
2
24
|
|
|
3
25
|
|
package/CoCreate.config.js
CHANGED
package/demo/index.html
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
<div class="padding:25px background:gainsboro text-align:left">
|
|
72
72
|
|
|
73
73
|
<!-- Industry select -->
|
|
74
|
-
<cocreate-select class="
|
|
74
|
+
<cocreate-select sortable class="floating-label" collection="organizations" name="industry" placeholder="Industry" realtime="false" save="false">
|
|
75
75
|
<input placeholder="Search" template_id="industries">
|
|
76
76
|
<ul fetch-collection="industries"
|
|
77
77
|
template_id="industries"
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
<script>
|
|
99
99
|
var config = {
|
|
100
100
|
apiKey: 'c2b08663-06e3-440c-ef6f-13978b42883a',
|
|
101
|
-
|
|
101
|
+
organization_id: '5de0387b12e200ea63204d6c',
|
|
102
102
|
host: 'ws.cocreate.app'
|
|
103
103
|
}
|
|
104
104
|
</script>
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -3,7 +3,6 @@ import crud from '@cocreate/crud-client';
|
|
|
3
3
|
import action from '@cocreate/actions';
|
|
4
4
|
|
|
5
5
|
const CoCreateOrganization = {
|
|
6
|
-
// masterDB: '5ae0cfac6fb8c4e656fdaf92', // '5ae0cfac6fb8c4e656fdaf92' /** masterDB **/,
|
|
7
6
|
init: function() {
|
|
8
7
|
const self = this;
|
|
9
8
|
crud.listen('createOrgNew', function(data) {
|
|
@@ -24,11 +23,11 @@ const CoCreateOrganization = {
|
|
|
24
23
|
if (!form) return;
|
|
25
24
|
let newOrg_id = form.querySelector("input[collection='organizations'][name='_id']");
|
|
26
25
|
|
|
27
|
-
const room = config.
|
|
26
|
+
const room = config.organization_id;
|
|
28
27
|
|
|
29
28
|
crud.send('createOrgNew', {
|
|
30
29
|
apiKey: config.apiKey,
|
|
31
|
-
organization_id: config.
|
|
30
|
+
organization_id: config.organization_id,
|
|
32
31
|
collection: 'organizations',
|
|
33
32
|
newOrg_id: newOrg_id,
|
|
34
33
|
}, room);
|
|
@@ -52,13 +51,11 @@ const CoCreateOrganization = {
|
|
|
52
51
|
}
|
|
53
52
|
data[name] = value;
|
|
54
53
|
});
|
|
55
|
-
const room = config.
|
|
54
|
+
const room = config.organization_id;
|
|
56
55
|
|
|
57
56
|
crud.send('createOrg', {
|
|
58
57
|
apiKey: config.apiKey,
|
|
59
|
-
organization_id: config.
|
|
60
|
-
// orgDb: newOrg,
|
|
61
|
-
mdb: '5ae0cfac6fb8c4e656fdaf92',
|
|
58
|
+
organization_id: config.organization_id,
|
|
62
59
|
collection: 'organizations',
|
|
63
60
|
data: data
|
|
64
61
|
}, room);
|
package/src/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {ObjectId} = require("mongodb");
|
|
2
2
|
|
|
3
3
|
class CoCreateOrganization {
|
|
4
4
|
constructor(wsManager, dbClient) {
|
|
@@ -24,7 +24,7 @@ class CoCreateOrganization {
|
|
|
24
24
|
const db = this.dbClient.db(req_data['organization_id']);
|
|
25
25
|
const collection = db.collection(req_data["collection"]);
|
|
26
26
|
const query = {
|
|
27
|
-
"_id": new
|
|
27
|
+
"_id": new ObjectId(newOrg_id)
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
collection.find(query).toArray(function(error, result) {
|
|
@@ -33,7 +33,7 @@ class CoCreateOrganization {
|
|
|
33
33
|
// Create new user in config db users collection
|
|
34
34
|
newOrgDb.insertOne({...result.ops[0], organization_id : newOrg_id}, function(error, result) {
|
|
35
35
|
if(!error && result){
|
|
36
|
-
const response = { ...data, document_id: result.
|
|
36
|
+
const response = { ...data, document_id: `${result.insertedId}`, data: result.ops[0]}
|
|
37
37
|
self.wsManager.send(socket, 'createOrgNew', response, data['organization_id']);
|
|
38
38
|
}
|
|
39
39
|
});
|
|
@@ -54,20 +54,23 @@ class CoCreateOrganization {
|
|
|
54
54
|
// create new org in config db organization collection
|
|
55
55
|
collection.insertOne({ ...data.data, organization_id: data.organization_id }, function(error, result) {
|
|
56
56
|
if(!error && result){
|
|
57
|
-
const orgId = result.
|
|
57
|
+
const orgId = `${result.insertedId}`
|
|
58
|
+
data.data['_id'] = result.insertedId
|
|
58
59
|
const anotherCollection = self.dbClient.db(orgId).collection(data['collection']);
|
|
59
60
|
// Create new org db and insert organization
|
|
60
|
-
anotherCollection.insertOne({...
|
|
61
|
+
anotherCollection.insertOne({...data.data, organization_id : orgId});
|
|
61
62
|
|
|
62
|
-
const response = { ...data, document_id:
|
|
63
|
+
const response = { ...data, document_id: orgId }
|
|
63
64
|
|
|
64
65
|
self.wsManager.send(socket, 'createOrg', response );
|
|
65
66
|
self.wsManager.broadcast(socket, data.namespace || data['organization_id'] , data.room, 'createDocument', response);
|
|
66
|
-
}
|
|
67
|
-
// add new org to masterDb
|
|
68
|
-
const masterOrgDb = self.dbClient.db(data.mdb).collection(data['collection']);
|
|
69
|
-
masterOrgDb.insertOne({...result.ops[0], organization_id : data['mdb']});
|
|
70
67
|
|
|
68
|
+
// add new org to platformDB
|
|
69
|
+
if (data.organization_id != process.env.organization_id) {
|
|
70
|
+
const platformDB = self.dbClient.db(process.env.organization_id).collection(data['collection']);
|
|
71
|
+
platformDB.insertOne({...data.data, organization_id: process.env.organization_id});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
71
74
|
});
|
|
72
75
|
}catch(error){
|
|
73
76
|
console.log('createDocument error', error);
|