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 3ee421bd authored by boian's avatar boian Committed by Hermann
Browse files

Moderator management

Adds the option to set or edit a moderator for an event and displays it when viewing an event.
parent 6e39acfc
import m from 'mithril';
import { styler } from 'polythene-core-css';
import { RadioGroup, Switch, Dialog, Button, Tabs, Icon } from 'polythene-mithril';
import { FileInput } from 'amiv-web-ui-components';
import {
RadioGroup, Switch, Dialog, Button, Tabs, Icon, TextField,
} from 'polythene-mithril';
import { FileInput, ListSelect, DatalistController } from 'amiv-web-ui-components';
import { TabsCSS, ButtonCSS } from 'polythene-css';
// eslint-disable-next-line import/extensions
import { apiUrl, ownUrl } from 'networkConfig';
import { ResourceHandler } from '../auth';
import { colors } from '../style';
import { loadingScreen } from '../layout';
import { icons } from '../views/elements';
......@@ -55,6 +58,11 @@ export default class newEvent extends EditView {
super(vnode);
this.currentpage = 1;
// Create a usercontroller to handle the moderator field
this.userHandler = new ResourceHandler('users', ['firstname', 'lastname', 'email', 'nethz']);
this.userController = new DatalistController((query, search) =>
this.userHandler.get({ search, ...query }));
// check whether the user has the right to create events or can only propose
this.rightSubmit = !m.route.get().startsWith('/proposeevent');
......@@ -171,6 +179,9 @@ export default class newEvent extends EditView {
else this.form.data.priority = 1;
delete this.form.data.high_priority;
// Change moderator from user object to user id
if (this.form.data.moderator) this.form.data.moderator = this.form.data.moderator._id;
// if spots is not set, also remove 'allow_email_signup'
if (!('spots' in this.form.data) && 'allow_email_signup' in this.form.data
&& !this.form.data.allow_email_signup) {
......@@ -241,7 +252,7 @@ export default class newEvent extends EditView {
console.log(this.form.errors, this.form.valid);
// Define the number of Tabs and their titles
const titles = ['Event Description', 'When and Where?', 'Signups', 'Advertisement'];
const titles = ['Event Description', 'When and Where?', 'Signups', 'Internal Info'];
if (this.rightSubmit) titles.push('Images');
// Data fields of the event in the different tabs. Ordered the same way as the titles
const keysPages = [[
......@@ -254,7 +265,7 @@ export default class newEvent extends EditView {
],
['time_start', 'time_end', 'location'],
['price', 'spots', 'time_register_start', 'time_register_end'],
['time_advertising_start', 'time_advertising_end'],
['moderator', 'time_advertising_start', 'time_advertising_end'],
[],
];
// Look which Tabs have errors
......@@ -448,10 +459,28 @@ export default class newEvent extends EditView {
...this.hasregistration && this.form.renderSchema(['allow_email_signup']),
this.hasregistration && radioButtonSelectionMode,
]),
// page 4: advertisement
// PAGE 4: Internal Info
m('div', {
style: { display: (this.currentpage === 4) ? 'block' : 'none' },
}, [
m('div', { style: { display: 'flex', 'margin-top': '5px' } }, [
m(TextField, {
label: 'Moderator: ',
disabled: true,
style: { width: '200px' },
help: 'Can edit the event and see signups.',
}),
m('div', { style: { 'flex-grow': 1 } }, m(ListSelect, {
controller: this.userController,
selection: this.form.data.moderator,
listTileAttrs: user => Object.assign(
{},
{ title: `${user.firstname} ${user.lastname}` },
),
selectedText: user => `${user.firstname} ${user.lastname}`,
onSelect: (data) => { this.form.data.moderator = data; },
})),
]),
...this.form.renderSchema(['time_advertising_start', 'time_advertising_end']),
...this.form.renderSchema(['show_website', 'show_announce', 'show_infoscreen']),
// pritority update
......
......@@ -6,7 +6,7 @@ import { loadingScreen } from '../layout';
export default class EventItem {
constructor() {
this.controller = new ItemController('events');
this.controller = new ItemController('events', { moderator: 1 });
}
view() {
......
......@@ -342,6 +342,11 @@ export default class viewEvent extends ItemView {
title: 'Time',
style: stdMargin,
}, `${dateFormatter(this.data.time_start)} - ${dateFormatter(this.data.time_end)}`),
this.data.moderator && m(Property, {
title: 'Moderator',
style: stdMargin,
}, m.trust(`${this.data.moderator.firstname} ${this.data.moderator.lastname}
(<a href='mailto:${this.data.moderator.email}'>${this.data.moderator.email}</a>)`)),
]),
// everything else is not listed in DropdownCards, which open only on request
m('div.viewcontainer', [
......
......@@ -72,6 +72,9 @@ const style = [
p: {
margin: '0',
},
a: {
color: 'rgba(0, 0, 0, 0.87)',
},
},
];
styler.add('containers', style);
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