Skip to content

Commit 5efca2a

Browse files
committed
patchGroup
1 parent 0be0661 commit 5efca2a

File tree

2 files changed

+22
-32
lines changed

2 files changed

+22
-32
lines changed

services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationDetails.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,11 @@ qx.Class.define("osparc.desktop.organizations.OrganizationDetails", {
113113
const name = orgEditor.getLabel();
114114
const description = orgEditor.getDescription();
115115
const thumbnail = orgEditor.getThumbnail();
116-
const params = {
117-
url: {
118-
"gid": groupId
119-
},
120-
data: {
121-
"label": name,
122-
"description": description,
123-
"thumbnail": thumbnail || null
124-
}
125-
};
126-
osparc.data.Resources.fetch("organizations", "patch", params)
116+
osparc.store.Groups.getInstance().patchGroup(groupId, name, description, thumbnail)
127117
.then(() => {
128118
osparc.FlashMessenger.getInstance().logAs(name + this.tr(" successfully edited"));
129119
button.setFetching(false);
130120
win.close();
131-
osparc.store.Store.getInstance().reset("organizations");
132-
this.__orgModel.set({
133-
label: name,
134-
description: description,
135-
thumbnail: thumbnail || null
136-
});
137121
})
138122
.catch(err => {
139123
osparc.FlashMessenger.getInstance().logAs(this.tr("Something went wrong editing ") + name, "ERROR");

services/static-webserver/client/source/class/osparc/store/Groups.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ qx.Class.define("osparc.store.Groups", {
247247
return null;
248248
},
249249

250+
// CRUD GROUP
250251
postGroup: function(name, parentGroupId = null, workspaceId = null) {
251252
const newGroupData = {
252253
name,
@@ -281,28 +282,32 @@ qx.Class.define("osparc.store.Groups", {
281282
.catch(console.error);
282283
},
283284

284-
putGroup: function(groupId, updateData) {
285-
const group = this.getOrganization(groupId);
286-
const oldParentGroupId = group.getParentGroupId();
285+
patchGroup: function(groupId, name, description, thumbnail) {
287286
const params = {
288-
"url": {
289-
groupId
287+
url: {
288+
"gid": groupId
290289
},
291-
data: updateData
290+
data: {
291+
"label": name,
292+
"description": description,
293+
"thumbnail": thumbnail || null
294+
}
292295
};
293-
return osparc.data.Resources.getInstance().fetch("groups", "update", params)
294-
.then(groupData => {
295-
this.__addToGroupsCache(groupData);
296-
if (updateData.parentGroupId !== oldParentGroupId) {
297-
this.fireDataEvent("groupMoved", {
298-
group,
299-
oldParentGroupId,
296+
return osparc.data.Resources.fetch("organizations", "patch", params)
297+
.then(() => {
298+
const organization = this.getOrganization(groupId);
299+
if (organization) {
300+
organization.set({
301+
label: name,
302+
description: description,
303+
thumbnail: thumbnail || null
300304
});
301305
}
302-
})
303-
.catch(console.error);
306+
});
304307
},
308+
// CRUD GROUP
305309

310+
// CRUD GROUP MEMBERS
306311
postMember: function(orgId, newMemberEmail) {
307312
const gid = parseInt(orgId);
308313
const params = {
@@ -363,6 +368,7 @@ qx.Class.define("osparc.store.Groups", {
363368
this.__removeUserFromCache(parseInt(userId), parseInt(orgId));
364369
});
365370
},
371+
// CRUD GROUP MEMBERS
366372

367373
__addToGroupsCache: function(groupData, groupType) {
368374
let group = this.groupsCached.find(f => f.getGroupId() === groupData["gid"]);

0 commit comments

Comments
 (0)