@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 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
 
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  "config": {
3
3
  "apiKey": "2061acef-0451-4545-f754-60cf8160",
4
- "organization_Id": "5ff747727005da1c272740ab",
4
+ "organization_id": "5ff747727005da1c272740ab",
5
5
  "host": "general.cocreate.app"
6
6
  },
7
7
 
@@ -48,7 +48,7 @@
48
48
  <script>
49
49
  var config = {
50
50
  apiKey: 'c2b08663-06e3-440c-ef6f-13978b42883a',
51
- organization_Id: '5de0387b12e200ea63204d6c'
51
+ organization_id: '5de0387b12e200ea63204d6c'
52
52
  }
53
53
  </script>
54
54
 
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="sortable floating-label" collection="organizations" name="industry" placeholder="Industry" realtime="false" save="false">
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
- organization_Id: '5de0387b12e200ea63204d6c',
101
+ organization_id: '5de0387b12e200ea63204d6c',
102
102
  host: 'ws.cocreate.app'
103
103
  }
104
104
  </script>
@@ -75,7 +75,7 @@
75
75
  var config = {
76
76
  apiKey: '2061acef-0451-4545-f754-60cf8160',
77
77
  securityKey: '073daff2-5142-4402-cf59-48e205ef',
78
- organization_Id: '5ff747727005da1c272740ab'
78
+ organization_id: '5ff747727005da1c272740ab'
79
79
  }
80
80
  </script>
81
81
 
@@ -112,7 +112,7 @@
112
112
  <script>
113
113
  var config = {
114
114
  apiKey: 'c2b08663-06e3-440c-ef6f-13978b42883a',
115
- organization_Id: '5de0387b12e200ea63204d6c'
115
+ organization_id: '5de0387b12e200ea63204d6c'
116
116
  }
117
117
  </script>
118
118
 
@@ -117,7 +117,7 @@
117
117
  <script>
118
118
  var config = {
119
119
  apiKey: 'c2b08663-06e3-440c-ef6f-13978b42883a',
120
- organization_Id: '5de0387b12e200ea63204d6c'
120
+ organization_id: '5de0387b12e200ea63204d6c'
121
121
  }
122
122
  </script>
123
123
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/organizations",
3
- "version": "1.2.1",
3
+ "version": "1.2.4",
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",
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.organization_Id;
26
+ const room = config.organization_id;
28
27
 
29
28
  crud.send('createOrgNew', {
30
29
  apiKey: config.apiKey,
31
- organization_id: config.organization_Id,
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.organization_Id;
54
+ const room = config.organization_id;
56
55
 
57
56
  crud.send('createOrg', {
58
57
  apiKey: config.apiKey,
59
- organization_id: config.organization_Id,
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 {ObjectID} = require("mongodb");
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 ObjectID(newOrg_id)
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.ops[0]._id, data: result.ops[0]}
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.ops[0]._id + "";
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({...result.ops[0], organization_id : orgId});
61
+ anotherCollection.insertOne({...data.data, organization_id : orgId});
61
62
 
62
- const response = { ...data, document_id: result.ops[0]._id, data: result.ops[0] }
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);