Newer
Older
import { Checkbox, Button, Card, TextField, IconButton, Toolbar, ToolbarTitle } from 'polythene-mithril';
import { events as config, eventsignups as signupConfig } from '../config.json';
import TableView from '../views/tableView';
import DatalistController from '../listcontroller';
import { dateFormatter } from '../utils';
import { styler } from 'polythene-core-css';
const viewLayout = [
{
'.eventViewContainer': {
display: 'grid',
'grid-template-columns': '50% 50%',
'grid-gap': '50px',
},
'.eventViewLeft': {
'grid-column': 1,
},
'.eventViewRight': {
'grid-column': 2,
},
'.eventViewRight h4': {
'margin-top': '0px',
}
}
];
styler.add('eventView', viewLayout);
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
class ParticipantsTable {
constructor({ attrs: { where } }) {
this.ctrl = new DatalistController('eventsignups', {
embedded: { user: 1 },
where,
}, signupConfig.tableKeys);
}
getItemData(data) {
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, {
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' },
],
}),
});
}
}
constructor() {
super('events');
this.details = false;
this.waitlist = false;
this.emailAdresses = false;
}
view() {
if (!this.data) return '';
console.log(Object.keys(this));
console.log(this['data']);
let displayCatchphrase = null;
let displayDescription = null;
/*if(this.data.catchphrase_de) {
displayCatchphraseDe = m("t3", {class: "text"}, "de: " + this.data.catchphrase_de);
displayCatchphraseEn = m("t3", {class: "text"}, "en: " + this.data.catchphrase_en);
}*/
if(this.data.catchphrase_de && this.data.catchphrase_en) {
displayCatchphrase = m("t3", {class: "text"}, "de: " + this.data.catchphrase_de + " / en: " + this.data.catchphrase_en);
} else if(this.data.catchphrase_de) {
displayCatchphrase = m("t3", {class: "text"}, "de: " + this.data.catchphrase_de);
} else if(this.data.catchphrase_en) {
displayCatchphrase = m("t3", {class: "text"}, "en: " + this.data.catchphrase_en);
if(this.data.description_de && this.data.description_en) {
displayDescription = m("t3", {class: "text"}, "de: " + this.data.description_de + " / en: " + this.data.description_en);
} else if(this.data.catchphrase_de) {
displayDescription = m("t3", {class: "text"}, "de: " + this.data.description_de);
} else if(this.data.catchphrase_en) {
displayDescription = m("t3", {class: "text"}, "en: " + this.data.description_en);
}
if(this.data.priority) {
displayPriority = m("t3", {class: "text"}, this.data.priority);
}
let displayDetailsButton = m(Toolbar, { compact: true, events: { onclick: () => this.details = !this.details } }, [
m(IconButton, { icon: { svg: m.trust(icons.ArrowRight) } }),
m(ToolbarTitle, { text: "details" }),
]);
let displayWaitlistButton = m(Toolbar, { compact: true, events: { onclick: () => this.waitlist = !this.waitlist } }, [
m(IconButton, { icon: { svg: m.trust(icons.ArrowRight) } }),
m(ToolbarTitle, { text: "waitlist" }),
]);
let displayEmailAdressesButton = m(Toolbar, { compact: true, events: { onclick: () => this.emailAdresses = !this.emailAdresses } }, [
m(IconButton, { icon: { svg: m.trust(icons.ArrowRight) } }),
m(ToolbarTitle, { text: "email adresses" }),
let displayDetails = null;
let displayWaitlist = null;
let displayEmailAdresses = null;
displayDetailsButton = m(Toolbar, { compact: true, events: { onclick: () => this.details = !this.details } }, [
m(IconButton, { icon: { svg: m.trust(icons.ArrowDown) } }),
m(ToolbarTitle, { text: "details" }),
]);
subtitle: displayCatchphrase,
{
any: {
content: this.data.time_start ? m('p', m('strong', `when: from ${dateFormatter(this.data.time_start)} to ${dateFormatter(this.data.time_end)}`)) : '',
},
},
{
any: {
content: this.data.location ? m('p', m('strong', `where: ${this.data.location}`)) : '',
}
},
title: "Description",
subtitle: displayDescription
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
}
},
{
primary: {
title: "Priority",
subtitle: displayPriority
}
},
{
actions: {
content: [
m(Button, {
label: "Action 1"
}),
m(Button, {
label: "Action 2"
})
]
}
},
{
text: {
content: "More text"
}
}
]
})
}
if (this.waitlist) {
displayWaitlistButton = m(Toolbar, { compact: true, events: { onclick: () => this.waitlist = !this.waitlist } }, [
m(IconButton, { icon: { svg: m.trust(icons.ArrowDown) } }),
m(ToolbarTitle, { text: "waitlist" }),
]);
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
displayWaitlist = m(Card, {
content: [
{
primary: {
title: "Primary title",
subtitle: "Subtitle"
}
},
{
actions: {
content: [
m(Button, {
label: "Action 1"
}),
m(Button, {
label: "Action 2"
})
]
}
},
{
text: {
content: "More text"
}
}
]
})
}
if (this.emailAdresses) {
displayEmailAdressesButton = m(Toolbar, { compact: true, events: { onclick: () => this.emailAdresses = !this.emailAdresses } }, [
m(IconButton, { icon: { svg: m.trust(icons.ArrowDown) } }),
m(ToolbarTitle, { text: "email adresses" }),
]);
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
displayEmailAdresses = m(Card, {
content: [
{
primary: {
title: "Primary title",
subtitle: "Subtitle"
}
},
{
actions: {
content: [
m(Button, {
label: "Action 1"
}),
m(Button, {
label: "Action 2"
})
]
}
},
{
text: {
content: "More text"
}
}
]
})
}
return m("div", {
style: { height: '100%', 'overflow-y': 'scroll'}
},[
m("h1", {class: "title"}, this.data.title_de),
m(Button, {element: 'div', label: "Update Event"}),
m('div.eventViewContainer', [
m('div.eventViewLeft', [
displayDetailsButton,
displayDetails,
displayWaitlistButton,
displayWaitlist,
displayEmailAdressesButton,
displayEmailAdresses,
]),
m('div.eventViewRight', [
m('h4', 'Accepted Participants'),
m(ParticipantsTable, { where: { accepted: true } }),
m('p', ''),
m('h4', 'Participants on Waiting List'),
m(ParticipantsTable, { where: { accepted: false } }),
])
]),