@cocreate/organizations 1.4.0 → 1.5.2
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,26 @@
|
|
|
1
|
+
## [1.5.2](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.5.1...v1.5.2) (2022-06-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update dependencies ([e67c74d](https://github.com/CoCreate-app/CoCreate-organizations/commit/e67c74df65e782adc22b19ea3dbca226e795b695))
|
|
7
|
+
* update modal btn to actions ([e40a303](https://github.com/CoCreate-app/CoCreate-organizations/commit/e40a303710dc73dd614c659c084d339d5797dc16))
|
|
8
|
+
|
|
9
|
+
## [1.5.1](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.5.0...v1.5.1) (2022-06-02)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* update padding of datables td element ([4adf0fe](https://github.com/CoCreate-app/CoCreate-organizations/commit/4adf0fe02212df759b333da837c616e473b1d9b1))
|
|
15
|
+
|
|
16
|
+
# [1.5.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.4.0...v1.5.0) (2022-05-29)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* deleteDocument broadcasted after orgDeleted ([be1ecee](https://github.com/CoCreate-app/CoCreate-organizations/commit/be1ecee732ce71a3877dfbb06df9b19c0148eb16))
|
|
22
|
+
* deleteOrgs action to select and delete many organizations ([0abaa20](https://github.com/CoCreate-app/CoCreate-organizations/commit/0abaa2061ac7575c51314f5011aa6031022b6d7f))
|
|
23
|
+
|
|
1
24
|
# [1.4.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.3.2...v1.4.0) (2022-05-28)
|
|
2
25
|
|
|
3
26
|
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
|
|
16
16
|
<ul class="overflow:auto display:inline-flex direction:rtl font-size:20px align-items:center list-style-type:none width:100% height:50px">
|
|
17
17
|
<li class="margin-right:15px">
|
|
18
|
-
<a
|
|
18
|
+
<a actions="closeModal"><i class="fas fa-times"></i></a>
|
|
19
19
|
</li>
|
|
20
20
|
<li class="margin-right:15px">
|
|
21
|
-
<a
|
|
21
|
+
<a actions="minMaxModal"><i toggle="fa-window-restore, fa-window-maximize" class="far fa-window-maximize"></i></a>
|
|
22
22
|
</li>
|
|
23
23
|
<li class="margin-right:15px">
|
|
24
|
-
<a
|
|
24
|
+
<a actions="parkModal"><i class="far fa-window-minimize"></i></a>
|
|
25
25
|
</li>
|
|
26
26
|
<li class="margin-right:15px">
|
|
27
27
|
<a fullscreen><i toggle="fa-compress, fa-expand" class="fas fa-expand"></i></a>
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<div content_id="content" class="padding:5px">
|
|
13
13
|
<table class="width:100% border-collapse:collapse">
|
|
14
14
|
<tr class="border-bottom:1px_solid_darkgray">
|
|
15
|
-
<td class="position:sticky top:0 background:white padding
|
|
15
|
+
<td class="position:sticky top:0 background:white padding:0px_10px_10px">
|
|
16
16
|
<input type="text" class="floating-label"
|
|
17
17
|
filter-name="name"
|
|
18
18
|
template_id="datatable"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
</a>
|
|
25
25
|
</span>
|
|
26
26
|
</td>
|
|
27
|
-
<td class="position:sticky top:0 background:white padding:
|
|
27
|
+
<td class="position:sticky top:0 background:white padding:0px_10px_10px">
|
|
28
28
|
<input type="text" class="floating-label"
|
|
29
29
|
filter-name="_id"
|
|
30
30
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<div content_id="content" class="padding:5px">
|
|
13
13
|
<table class="width:100% border-collapse:collapse">
|
|
14
14
|
<tr class="border-bottom:1px_solid_darkgray">
|
|
15
|
-
<td class="position:sticky top:0 background:white padding
|
|
15
|
+
<td class="position:sticky top:0 background:white padding:0px_10px_10px">
|
|
16
16
|
<input type="text" class="floating-label"
|
|
17
17
|
filter-name="name"
|
|
18
18
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</a>
|
|
27
27
|
</span>
|
|
28
28
|
</td>
|
|
29
|
-
<td class="position:sticky top:0 background:white padding:
|
|
29
|
+
<td class="position:sticky top:0 background:white padding:0px_10px_10px">
|
|
30
30
|
<input type="text" class="floating-label"
|
|
31
31
|
filter-name="_id"
|
|
32
32
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/organizations",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
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",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"webpack-log": "^3.0.1"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@cocreate/actions": "^1.4.
|
|
65
|
-
"@cocreate/crud-client": "^1.
|
|
66
|
-
"@cocreate/docs": "^1.3.
|
|
67
|
-
"@cocreate/elements": "^1.
|
|
64
|
+
"@cocreate/actions": "^1.4.2",
|
|
65
|
+
"@cocreate/crud-client": "^1.7.0",
|
|
66
|
+
"@cocreate/docs": "^1.3.2",
|
|
67
|
+
"@cocreate/elements": "^1.8.0",
|
|
68
68
|
"mongodb": "^4.4.0"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/src/client.js
CHANGED
|
@@ -30,14 +30,11 @@ const CoCreateOrganization = {
|
|
|
30
30
|
}
|
|
31
31
|
data[name] = value;
|
|
32
32
|
});
|
|
33
|
-
const room = config.organization_id;
|
|
34
33
|
|
|
35
34
|
crud.send('createOrg', {
|
|
36
|
-
apiKey: config.apiKey,
|
|
37
|
-
organization_id: config.organization_id,
|
|
38
35
|
collection: 'organizations',
|
|
39
36
|
data: data
|
|
40
|
-
}
|
|
37
|
+
});
|
|
41
38
|
},
|
|
42
39
|
|
|
43
40
|
setDocumentId: function(collection, id) {
|
|
@@ -53,9 +50,63 @@ const CoCreateOrganization = {
|
|
|
53
50
|
});
|
|
54
51
|
}
|
|
55
52
|
},
|
|
53
|
+
|
|
54
|
+
deleteOrg: async function(btn) {
|
|
55
|
+
const { collection, document_id } = crud.getAttr(btn);
|
|
56
|
+
const organization_id = document_id;
|
|
57
|
+
|
|
58
|
+
if(crud.checkAttrValue(collection) && crud.checkAttrValue(document_id)) {
|
|
59
|
+
|
|
60
|
+
crud.send('deleteOrg', {
|
|
61
|
+
collection,
|
|
62
|
+
document_id,
|
|
63
|
+
data: {
|
|
64
|
+
organization_id,
|
|
65
|
+
},
|
|
66
|
+
'metadata': 'deleteOrg-action'
|
|
67
|
+
}).then(response => {
|
|
68
|
+
|
|
69
|
+
// ToDo: replace with custom event
|
|
70
|
+
document.dispatchEvent(new CustomEvent('deletedOrg', {
|
|
71
|
+
detail: {}
|
|
72
|
+
}));
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
deleteOrgs: async function(btn) {
|
|
78
|
+
const collection = btn.getAttribute('collection');
|
|
79
|
+
if(crud.checkAttrValue(collection)) {
|
|
80
|
+
const dataTemplateid = btn.getAttribute('template_id');
|
|
81
|
+
if(!dataTemplateid) return;
|
|
82
|
+
|
|
83
|
+
const selectedEls = document.querySelectorAll(`.selected[templateid="${dataTemplateid}"]`);
|
|
84
|
+
|
|
85
|
+
selectedEls.forEach((el) => {
|
|
86
|
+
const document_id = el.getAttribute('document_id');
|
|
87
|
+
const organization_id = document_id;
|
|
88
|
+
|
|
89
|
+
if(crud.checkAttrValue(document_id)) {
|
|
90
|
+
crud.send('deleteOrg', {
|
|
91
|
+
collection,
|
|
92
|
+
document_id,
|
|
93
|
+
data: {
|
|
94
|
+
organization_id,
|
|
95
|
+
},
|
|
96
|
+
'metadata': 'deleteOrgs-action'
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
document.dispatchEvent(new CustomEvent('deletedOrgs', {
|
|
102
|
+
detail: {}
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
56
106
|
|
|
57
107
|
};
|
|
58
108
|
|
|
109
|
+
|
|
59
110
|
action.init({
|
|
60
111
|
name: "createOrg",
|
|
61
112
|
endEvent: "createdOrg",
|
|
@@ -64,6 +115,22 @@ action.init({
|
|
|
64
115
|
},
|
|
65
116
|
});
|
|
66
117
|
|
|
118
|
+
action.init({
|
|
119
|
+
name: "deleteOrg",
|
|
120
|
+
endEvent: "deletedOrg",
|
|
121
|
+
callback: (btn, data) => {
|
|
122
|
+
CoCreateOrganization.deleteOrg(btn);
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
action.init({
|
|
127
|
+
name: "deleteOrgs",
|
|
128
|
+
endEvent: "deletedOrgs",
|
|
129
|
+
callback: (btn, data) => {
|
|
130
|
+
CoCreateOrganization.deleteOrgs(btn);
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
67
134
|
CoCreateOrganization.init();
|
|
68
135
|
|
|
69
136
|
export default CoCreateOrganization;
|
package/src/server.js
CHANGED
|
@@ -9,8 +9,12 @@ class CoCreateOrganization {
|
|
|
9
9
|
|
|
10
10
|
init() {
|
|
11
11
|
if (this.wsManager) {
|
|
12
|
-
this.wsManager.on('createOrg',
|
|
13
|
-
|
|
12
|
+
this.wsManager.on('createOrg', (socket, data, socketInfo) =>
|
|
13
|
+
this.createOrg(socket, data, socketInfo)
|
|
14
|
+
);
|
|
15
|
+
this.wsManager.on('deleteOrg', (socket, data, socketInfo) =>
|
|
16
|
+
this.deleteOrg(socket, data, socketInfo)
|
|
17
|
+
);
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
|
|
@@ -54,16 +58,14 @@ class CoCreateOrganization {
|
|
|
54
58
|
if(!data.data) return;
|
|
55
59
|
const organization_id = data.data.organization_id
|
|
56
60
|
if(!organization_id || organization_id == process.env.organization_id) return;
|
|
57
|
-
|
|
61
|
+
if(data.organization_id != process.env.organization_id) return;
|
|
58
62
|
try{
|
|
59
63
|
const db = this.dbClient.db(organization_id);
|
|
60
64
|
db.dropDatabase().then(response => {
|
|
61
65
|
if (response === true){
|
|
62
|
-
|
|
63
|
-
}
|
|
66
|
+
process.emit('deleteOrg', organization_id)
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
// if (organization_id != process.env.organization_id) {
|
|
68
|
+
// delete org from platformDB
|
|
67
69
|
const platformDB = self.dbClient.db(process.env.organization_id).collection(data['collection']);
|
|
68
70
|
const query = {
|
|
69
71
|
"_id": new ObjectId(organization_id)
|
|
@@ -72,12 +74,13 @@ class CoCreateOrganization {
|
|
|
72
74
|
platformDB.deleteOne(query, function(error, result) {
|
|
73
75
|
if (!error) {
|
|
74
76
|
let response = { ...data }
|
|
75
|
-
self.
|
|
77
|
+
self.wsManager.send(socket, 'deleteOrg', response, socketInfo);
|
|
78
|
+
self.wsManager.broadcast(socket, response.namespace || response['organization_id'], response.room, 'deleteDocument', response, socketInfo);
|
|
76
79
|
} else {
|
|
77
80
|
self.wsManager.send(socket, 'ServerError', error, socketInfo);
|
|
78
81
|
}
|
|
79
82
|
})
|
|
80
|
-
|
|
83
|
+
}
|
|
81
84
|
})
|
|
82
85
|
}catch(error){
|
|
83
86
|
console.log('deleteOrg error', error);
|