To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit c1057436 authored by Hermann's avatar Hermann
Browse files

use new relationlistcontroller and add some filters to relation tables

parent 45d7f251
......@@ -12,6 +12,8 @@ import { colors } from '../style';
import ItemView from '../views/itemView';
import TableView from '../views/tableView';
import DatalistController from '../listcontroller';
import RelationlistController from '../relationlistcontroller';
import SelectList from '../views/selectList';
import { ResourceHandler } from '../auth';
......@@ -21,10 +23,7 @@ import { ResourceHandler } from '../auth';
class MembersTable {
constructor({ attrs: { group } }) {
this.group_id = group;
this.ctrl = new DatalistController('groupmemberships', {
embedded: { user: 1 },
where: { group },
}, ['user.email', 'user.firstname', 'user.lastname'], false);
this.ctrl = new RelationlistController('groupmemberships', 'users', { where: { group } });
// true while in the modus of adding a member
this.addmode = false;
this.userController = new DatalistController(
......@@ -203,8 +202,8 @@ export default class viewGroup extends ItemView {
m('h1', this.data.name),
this.data.requires_storage && m(chip, {
svg: icons.cloud,
color: '#ffffff',
background: colors.orange,
svgColor: '#ffffff',
svgBackground: colors.orange,
...stdMargin,
}, 'has a folder on the AMIV Cloud'),
m('div', { style: { display: 'flex' } }, [
......
......@@ -4,6 +4,7 @@ import ItemView from '../views/itemView';
import TableView from '../views/tableView';
import SelectList from '../views/selectList';
import DatalistController from '../listcontroller';
import RelationlistController from '../relationlistcontroller';
import { chip, icons, Property } from '../views/elements';
import { colors } from '../style';
......@@ -11,15 +12,13 @@ export default class UserView extends ItemView {
constructor(vnode) {
super(vnode);
// a controller to handle the groupmemberships of this user
this.groupmemberships = new DatalistController('groupmemberships', {
this.groupmemberships = new RelationlistController('groupmemberships', 'groups', {
where: { user: this.data._id },
embedded: { group: 1 },
}, ['group.name'], false);
});
// a controller to handle the eventsignups of this user
this.eventsignups = new DatalistController('eventsignups', {
this.eventsignups = new RelationlistController('eventsignups', 'events', {
where: { user: this.data._id },
embedded: { event: 1 },
}, ['event.title_de', 'event.title_en'], false);
});
// initially, don't display the choice field for a new group
// (this will be displayed once the user clicks on 'new')
this.groupchoice = false;
......@@ -85,6 +84,8 @@ export default class UserView extends ItemView {
onCancel: () => { this.groupchoice = false; m.redraw(); },
});
const now = new Date();
return this.layout([
m('div.maincontainer', [
m('h1', `${this.data.firstname} ${this.data.lastname}`),
......@@ -116,6 +117,13 @@ export default class UserView extends ItemView {
keys: ['event.title_de'],
titles: ['event'],
clickOnRows: (data) => { m.route.set(`/events/${data.event._id}`); },
filters: [[{
name: 'upcoming',
query: { time_start: { $gte: `${now.toISOString().slice(0, -5)}Z` } },
}, {
name: 'past',
query: { time_start: { $lt: `${now.toISOString().slice(0, -5)}Z` } },
}]],
}),
]),
})),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment