Skip to content
Snippets Groups Projects
Commit a084d7dc authored by Hermann's avatar Hermann
Browse files

fix bug: adding group to a user

parent 8c6e767b
No related branches found
No related tags found
No related merge requests found
...@@ -125,7 +125,7 @@ export class ResourceHandler { ...@@ -125,7 +125,7 @@ export class ResourceHandler {
const fullQuery = {}; const fullQuery = {};
if ('search' in query && query.search.length > 0) { if ('search' in query && query.search && query.search.length > 0) {
// translate search into where, we just look if any field contains search // translate search into where, we just look if any field contains search
// The search-string may match any of the keys in the object specified in the // The search-string may match any of the keys in the object specified in the
// constructor // constructor
...@@ -134,7 +134,7 @@ export class ResourceHandler { ...@@ -134,7 +134,7 @@ export class ResourceHandler {
const fieldQuery = {}; const fieldQuery = {};
fieldQuery[key] = { fieldQuery[key] = {
$regex: `${query.search}`, $regex: `${query.search}`,
$options: 'i' $options: 'i',
}; };
return fieldQuery; return fieldQuery;
}), }),
...@@ -146,7 +146,7 @@ export class ResourceHandler { ...@@ -146,7 +146,7 @@ export class ResourceHandler {
} else { } else {
fullQuery.where = JSON.stringify(searchQuery); fullQuery.where = JSON.stringify(searchQuery);
} }
} else if (query.where) { } else if ('where' in query) {
fullQuery.where = JSON.stringify(query.where); fullQuery.where = JSON.stringify(query.where);
} }
......
...@@ -26,7 +26,7 @@ export default class UserView extends ItemView { ...@@ -26,7 +26,7 @@ export default class UserView extends ItemView {
// a controller to handle the list of possible groups to join // a controller to handle the list of possible groups to join
this.groupcontroller = new DatalistController('groups', {}, ['name']); this.groupcontroller = new DatalistController('groups', {}, ['name']);
// exclude the groups where the user is already a member // exclude the groups where the user is already a member
this.groupmemberships.handler.get({ where: { user: this.id } }) this.groupmemberships.handler.get({ where: { user: this.data._id } })
.then((data) => { .then((data) => {
const groupIds = data._items.map(item => item.group); const groupIds = data._items.map(item => item.group);
this.groupcontroller.setQuery({ this.groupcontroller.setQuery({
...@@ -71,7 +71,8 @@ export default class UserView extends ItemView { ...@@ -71,7 +71,8 @@ export default class UserView extends ItemView {
// groupmemberships. Selects a group to request membership for. // groupmemberships. Selects a group to request membership for.
const groupSelect = m(SelectList, { const groupSelect = m(SelectList, {
controller: this.groupcontroller, controller: this.groupcontroller,
listTileAttrs: data => Object.assign({}, { title: data.name }), listTileAttrs: group => Object.assign({}, { title: group.name }),
selectedText: group => group.name,
onSubmit: (group) => { onSubmit: (group) => {
this.groupchoice = false; this.groupchoice = false;
this.groupmemberships.handler.post({ this.groupmemberships.handler.post({
...@@ -81,6 +82,7 @@ export default class UserView extends ItemView { ...@@ -81,6 +82,7 @@ export default class UserView extends ItemView {
this.groupmemberships.refresh(); this.groupmemberships.refresh();
}); });
}, },
onCancel: () => { this.groupchoice = false; m.redraw(); },
}); });
return this.layout([ return this.layout([
...@@ -119,7 +121,7 @@ export default class UserView extends ItemView { ...@@ -119,7 +121,7 @@ export default class UserView extends ItemView {
m('div.viewcontainercolumn', m(Card, { m('div.viewcontainercolumn', m(Card, {
style: { height: '300px' }, style: { height: '300px' },
content: m('div', [ content: m('div', [
this.groupchoice ? groupSelect : '', this.groupchoice && groupSelect,
m(Toolbar, { compact: true }, [ m(Toolbar, { compact: true }, [
m(ToolbarTitle, { text: 'Group Memberships' }), m(ToolbarTitle, { text: 'Group Memberships' }),
m(Button, { m(Button, {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment