diff --git a/src/auth.js b/src/auth.js index 8f15d4cf948d303bf2ad0688e5b7677b71a19176..86af03e6d1718f0fa2ad329b8d9b13ebabc7b28e 100644 --- a/src/auth.js +++ b/src/auth.js @@ -125,7 +125,7 @@ export class ResourceHandler { 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 // The search-string may match any of the keys in the object specified in the // constructor @@ -134,7 +134,7 @@ export class ResourceHandler { const fieldQuery = {}; fieldQuery[key] = { $regex: `${query.search}`, - $options: 'i' + $options: 'i', }; return fieldQuery; }), @@ -146,7 +146,7 @@ export class ResourceHandler { } else { fullQuery.where = JSON.stringify(searchQuery); } - } else if (query.where) { + } else if ('where' in query) { fullQuery.where = JSON.stringify(query.where); } diff --git a/src/users/viewUser.js b/src/users/viewUser.js index f2571637929c3998d9fd65e6a9c7e3ad956d4510..44d32ee15f913100a2b52750868b5cf7dbc90d15 100644 --- a/src/users/viewUser.js +++ b/src/users/viewUser.js @@ -26,7 +26,7 @@ export default class UserView extends ItemView { // a controller to handle the list of possible groups to join this.groupcontroller = new DatalistController('groups', {}, ['name']); // 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) => { const groupIds = data._items.map(item => item.group); this.groupcontroller.setQuery({ @@ -71,7 +71,8 @@ export default class UserView extends ItemView { // groupmemberships. Selects a group to request membership for. const groupSelect = m(SelectList, { controller: this.groupcontroller, - listTileAttrs: data => Object.assign({}, { title: data.name }), + listTileAttrs: group => Object.assign({}, { title: group.name }), + selectedText: group => group.name, onSubmit: (group) => { this.groupchoice = false; this.groupmemberships.handler.post({ @@ -81,6 +82,7 @@ export default class UserView extends ItemView { this.groupmemberships.refresh(); }); }, + onCancel: () => { this.groupchoice = false; m.redraw(); }, }); return this.layout([ @@ -119,7 +121,7 @@ export default class UserView extends ItemView { m('div.viewcontainercolumn', m(Card, { style: { height: '300px' }, content: m('div', [ - this.groupchoice ? groupSelect : '', + this.groupchoice && groupSelect, m(Toolbar, { compact: true }, [ m(ToolbarTitle, { text: 'Group Memberships' }), m(Button, {