Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
import m from 'mithril';
import {
Switch,
Button,
Card,
TextField,
Icon,
} from 'polythene-mithril';
import { styler } from 'polythene-core-css';
import { apiUrl } from 'networkConfig';
import ItemView from '../views/itemView';
import { eventsignups as signupConfig } from '../resourceConfig.json';
import TableView from '../views/tableView';
import DatalistController from '../listcontroller';
import { dateFormatter } from '../utils';
import { icons, DropdownCard, Property } from '../views/elements';
import { ResourceHandler } from '../auth';
const viewLayout = [
{
'.propertyLangIndicator': {
width: '30px',
height: '20px',
float: 'left',
'background-color': 'rgb(031,045,084)',
'border-radius': '10px',
'text-align': 'center',
'line-height': '20px',
color: 'rgb(255,255,255)',
'margin-right': '10px',
'font-size': '11px',
},
'.eventViewLeft': {
'grid-column': 1,
},
'.eventViewRight': {
'grid-column': 2,
},
'.eventViewRight h4': {
'margin-top': '0px',
},
},
];
styler.add('eventView', viewLayout);
// small helper class to display both German and English content together, dependent
// on which content is available.
class DuoLangProperty {
view({ attrs: { title, de, en } }) {
// TODO Lang indicators should be smaller and there should be less margin
// between languages
return m(
Property,
{ title },
de ? m('div', [
m('div', { className: 'propertyLangIndicator' }, 'DE'),
m('p', de),
]) : '',
en ? m('div', [
m('div', { className: 'propertyLangIndicator' }, 'EN'),
m('p', en),
]) : '',
);
}
}
// Helper class to either display the signed up participants or those on the
// waiting list.
class ParticipantsTable {
constructor({ attrs: { where } }) {
this.ctrl = new DatalistController('eventsignups', {
embedded: { user: 1 },
where,
}, ['email', 'user.firstname', 'user.lastname'], false);
}
getItemData(data) {
// TODO list should not have hardcoded size outside of stylesheet
return [
m('div', { style: { width: '9em' } }, dateFormatter(data._created)),
m('div', { style: { width: '9em' } }, data.user.lastname),
m('div', { style: { width: '9em' } }, data.user.firstname),
m('div', { style: { width: '9em' } }, data.email),
];
}
view() {
return m(Card, {
style: { height: '300px' },
content: m(TableView, {
controller: this.ctrl,
keys: signupConfig.tableKeys,
tileContent: this.getItemData,
titles: [
{ text: 'Date of Signup', width: '9em' },
{ text: 'Name', width: '9em' },
{ text: 'First Name', width: '9em' },
{ text: 'Email', width: '9em' },
],
}),
});
}
}
class EmailList {
view({ attrs: { list } }) {
const emails = list.toString().replace(/,/g, '; ');
return m(Card, {
content: m(TextField, { value: emails, label: '', multiLine: true }, ''),
});
}
}
export default class viewEvent extends ItemView {
constructor() {
super('events');
this.signupHandler = new ResourceHandler('eventsignups');
this.description = false;
this.advertisement = false;
this.registration = false;
this.emailAdresses = false;
this.emaillist = [''];
this.showAllEmails = false;
}
oninit() {
this.handler.getItem(this.id, this.embedded).then((item) => {
this.data = item;
m.redraw();
});
this.setUpEmailList(this.showAllEmails);
}
setUpEmailList(showAll) {
// setup where query
const where = { event: this.id };
if (!showAll) {
// only show accepted
where.accepted = true;
}
this.signupHandler.get({ where }).then((data) => {
this.emaillist = (data._items.map(item => item.email));
m.redraw();
});
}
view({ attrs: { onEdit } }) {
if (!this.data) return '';
let displaySpots = '-';
if (this.data.spots !== 0) {
displaySpots = this.data.spots;
}
return m('div', {
style: { height: '100%', 'overflow-y': 'scroll', padding: '10px' },
}, [
m(Button, {
element: 'div',
label: 'Update Event',
events: { onclick: onEdit },
}),
// this div is the title line
m('div', [
// event image if existing
this.data.img_thumbnail ? m('img', {
src: `${apiUrl}${this.data.img_thumbnail.file}`,
height: '50px',
style: { float: 'left' },
}) : '',
m('h1', { style: { 'margin-top': '0px', 'margin-bottom': '0px' } }, [this.data.title_de || this.data.title_en]),
]),
// below the title, most important details are listed
this.data.signup_count ? m(Property, {
style: { float: 'left', 'margin-right': '20px' },
title: 'Signups',
}, `${this.data.signup_count} / ${displaySpots}`) : m.trust(' '),
this.data.location ? m(Property, {
style: { float: 'left', 'margin-right': '20px' },
title: 'Location',
}, `${this.data.location}`) : m.trust(' '),
this.data.time_start ? m(Property, {
title: 'Time',
}, `${dateFormatter(this.data.time_start)} - ${dateFormatter(this.data.time_end)}`) : m.trust(' '),
// everything else is not listed in DropdownCards, which open only on request
m('div.viewcontainer', { style: { 'margin-top': '50px' } }, [
m('div.viewcontainercolumn', [
m(DropdownCard, { title: 'description' }, [
m(DuoLangProperty, {
title: 'Catchphrase',
de: this.data.catchphrase_de,
en: this.data.catchphrase_en,
}),
m(DuoLangProperty, {
title: 'Description',
de: this.data.description_de,
en: this.data.description_en,
}),
]),
m(DropdownCard, { title: 'advertisement' }, [
[
m(Icon, {
style: { float: 'left' },
svg: m.trust(this.data.show_annonce ? icons.checked : icons.clear),
}),
m('span', { style: { float: 'left' } }, 'annonce'),
m(Icon, {
style: { float: 'left' },
svg: m.trust(this.data.show_infoscreen ? icons.checked : icons.clear),
}),
m('span', { style: { float: 'left' } }, 'infoscreen'),
m(Icon, {
style: { float: 'left' },
svg: m.trust(this.data.show_website ? icons.checked : icons.clear),
}),
m('span', { style: { float: 'left' } }, 'website'),
],
this.data.time_advertising_start ? m(
Property,
'Advertising Time',
`${dateFormatter(this.data.time_advertising_start)} - ${dateFormatter(this.data.time_advertising_end)}`,
) : '',
this.data.priority ? m(
Property,
{ title: 'Priority' },
`${this.data.priority}`,
) : '',
]),
m(DropdownCard, { title: 'Registration' }, [
this.data.price ? m(Property, 'Price', `${this.data.price}`) : '',
this.data.time_register_start ? m(
Property,
{ title: 'Registration Time' },
`${dateFormatter(this.data.time_register_start)} - ${dateFormatter(this.data.time_register_end)}`,
) : '',
this.data.selection_strategy ? m(
Property,
{ title: 'Selection Mode' },
m.trust(this.data.selection_strategy),
) : '',
this.data.allow_email_signup ? m(Property, 'non AMIV-Members allowed') : '',
]),
// a list of email adresses of all participants, easy to copy-paste
m(DropdownCard, { title: 'Email Adresses' }, [
m(Switch, {
defaultChecked: false,
label: 'show unaccepted',
onChange: () => {
this.showAllEmails = !this.showAllEmails;
this.setUpEmailList(this.showAllEmails);
},
}),
m(EmailList, { list: this.emaillist }),
]),
]),
m('div.viewcontainercolumn', [
m('h4', { style: { 'margin-top': '0px' } }, 'Accepted Participants'),
m(ParticipantsTable, { where: { accepted: true, event: this.data._id } }),
m('p', ''),
m('h4', 'Participants on Waiting List'),
m(ParticipantsTable, { where: { accepted: false, event: this.data._id } }),
]),
]),
]);
}
}