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'; ...@@ -12,6 +12,8 @@ import { colors } from '../style';
import ItemView from '../views/itemView'; import ItemView from '../views/itemView';
import TableView from '../views/tableView'; import TableView from '../views/tableView';
import DatalistController from '../listcontroller'; import DatalistController from '../listcontroller';
import RelationlistController from '../relationlistcontroller';
import SelectList from '../views/selectList'; import SelectList from '../views/selectList';
import { ResourceHandler } from '../auth'; import { ResourceHandler } from '../auth';
...@@ -21,10 +23,7 @@ import { ResourceHandler } from '../auth'; ...@@ -21,10 +23,7 @@ import { ResourceHandler } from '../auth';
class MembersTable { class MembersTable {
constructor({ attrs: { group } }) { constructor({ attrs: { group } }) {
this.group_id = group; this.group_id = group;
this.ctrl = new DatalistController('groupmemberships', { this.ctrl = new RelationlistController('groupmemberships', 'users', { where: { group } });
embedded: { user: 1 },
where: { group },
}, ['user.email', 'user.firstname', 'user.lastname'], false);
// true while in the modus of adding a member // true while in the modus of adding a member
this.addmode = false; this.addmode = false;
this.userController = new DatalistController( this.userController = new DatalistController(
...@@ -203,8 +202,8 @@ export default class viewGroup extends ItemView { ...@@ -203,8 +202,8 @@ export default class viewGroup extends ItemView {
m('h1', this.data.name), m('h1', this.data.name),
this.data.requires_storage && m(chip, { this.data.requires_storage && m(chip, {
svg: icons.cloud, svg: icons.cloud,
color: '#ffffff', svgColor: '#ffffff',
background: colors.orange, svgBackground: colors.orange,
...stdMargin, ...stdMargin,
}, 'has a folder on the AMIV Cloud'), }, 'has a folder on the AMIV Cloud'),
m('div', { style: { display: 'flex' } }, [ m('div', { style: { display: 'flex' } }, [
......
...@@ -4,6 +4,7 @@ import ItemView from '../views/itemView'; ...@@ -4,6 +4,7 @@ import ItemView from '../views/itemView';
import TableView from '../views/tableView'; import TableView from '../views/tableView';
import SelectList from '../views/selectList'; import SelectList from '../views/selectList';
import DatalistController from '../listcontroller'; import DatalistController from '../listcontroller';
import RelationlistController from '../relationlistcontroller';
import { chip, icons, Property } from '../views/elements'; import { chip, icons, Property } from '../views/elements';
import { colors } from '../style'; import { colors } from '../style';
...@@ -11,15 +12,13 @@ export default class UserView extends ItemView { ...@@ -11,15 +12,13 @@ export default class UserView extends ItemView {
constructor(vnode) { constructor(vnode) {
super(vnode); super(vnode);
// a controller to handle the groupmemberships of this user // 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 }, where: { user: this.data._id },
embedded: { group: 1 }, });
}, ['group.name'], false);
// a controller to handle the eventsignups of this user // 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 }, 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 // initially, don't display the choice field for a new group
// (this will be displayed once the user clicks on 'new') // (this will be displayed once the user clicks on 'new')
this.groupchoice = false; this.groupchoice = false;
...@@ -85,6 +84,8 @@ export default class UserView extends ItemView { ...@@ -85,6 +84,8 @@ export default class UserView extends ItemView {
onCancel: () => { this.groupchoice = false; m.redraw(); }, onCancel: () => { this.groupchoice = false; m.redraw(); },
}); });
const now = new Date();
return this.layout([ return this.layout([
m('div.maincontainer', [ m('div.maincontainer', [
m('h1', `${this.data.firstname} ${this.data.lastname}`), m('h1', `${this.data.firstname} ${this.data.lastname}`),
...@@ -116,6 +117,13 @@ export default class UserView extends ItemView { ...@@ -116,6 +117,13 @@ export default class UserView extends ItemView {
keys: ['event.title_de'], keys: ['event.title_de'],
titles: ['event'], titles: ['event'],
clickOnRows: (data) => { m.route.set(`/events/${data.event._id}`); }, 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