Newer
Older
import {
Switch,
Button,
Card,
TextField,
IconButton,
Toolbar,
ToolbarTitle,
} from 'polythene-mithril';
import { styler } from 'polythene-core-css';
import { eventsignups as signupConfig } from '../config.json';
import TableView from '../views/tableView';
import DatalistController from '../listcontroller';
import { dateFormatter } from '../utils';
import { ResourceHandler } from '../auth';
const viewLayout = [
{
display: 'grid',
'grid-template-columns': '40% 55%',
'grid-gap': '50px',
},
'.propertyTitle': {
color: 'rgba(0, 0, 0, 0.54)',
},
'.propertyText': {
color: 'rgba(0, 0, 0, 0.87)',
},
'.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',
},
'.eventInfoCard': {
padding: '10px',
'font-size': '15sp',
];
styler.add('eventView', viewLayout);
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
class PropertyInfo {
view({ attrs: { title, de, en } }) {
//const text = '';
if(de && en) {
return m('div',
m('p.propertyTitle', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [title]),
m('div', [
m('div', { className: 'propertyLangIndicator' }, 'DE'),
m('p.propertyText', de),
]),
m('div', [
m('div', { className: 'propertyLangIndicator' }, 'EN'),
m('p.propertyText', en ),
]),
)
} else if(de) {
return m('div',
m('p.propertyTitle', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [title]),
m('div', [
m('div', { className: 'propertyLangIndicator' }, 'DE'),
m('p.propertyText', de),
]),
)
} else if(en) {
return m('div',
m('p.propertyTitle', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [title]),
m('div', [
m('div', { className: 'propertyLangIndicator' }, 'EN'),
m('p.propertyText', en),
]),
)
}
}
}
class ParticipantsTable {
constructor({ attrs: { where } }) {
this.ctrl = new DatalistController(
'eventsignups', {
embedded: { user: 1 },
where,
},
[
'email',
'user.firstname',
'user.lastname',
],
false,
);
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
}
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' },
],
}),
});
}
}
view({ attrs: { list } }) {
const emails = list.toString().replace(/,/g, '; ');
return m(Card, {
content: m(TextField, { value: emails, label: '', multiLine: true }, ''),
});
}
constructor() {
super('events');
this.signupHandler = new ResourceHandler('eventsignups');
this.details = 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) {
if (!showAll) {
this.signupHandler.get({ where: { accepted: true } }).then((data) => {
this.emaillist = (data._items.map(item => item.email));
});
} else {
this.signupHandler.get({}).then((data) => {
this.emaillist = (data._items.map(item => item.email));
view() {
if (!this.data) return '';
console.log(Object.keys(this));
console.log(this['data']);
let displayDescriptionButton = m(Toolbar, { compact: true, events: { onclick: () => this.description = !this.description } }, [
m(IconButton, { icon: { svg: m.trust(icons.ArrowRight) } }),
m(ToolbarTitle, { text: "description" }),
]);
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 displayEmailAdressesButton = m(Toolbar, { compact: true, events: { onclick: () => this.emailAdresses = !this.emailAdresses } }, [
m(IconButton, { icon: { svg: m.trust(icons.ArrowRight) } }),
m(ToolbarTitle, { text: "email adresses" }),
if (this.description) {
displayDescriptionButton = m(Toolbar, { compact: true, events: { onclick: () => this.description = !this.description } }, [
className: 'eventInfoCard',
{
any: {
content: [
this.data.allow_email_signup ? m('div', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [m('span.propertyTitle', 'non AMIV-Members allowed')]) : '',
]
}
},
{
any: {
content: [
m(PropertyInfo, {
title: 'Catchphrase',
de: this.data.catchphrase_de,
en: this.data.catchphrase_en,
}),
]
any: {
m(PropertyInfo, {
title: 'Description',
de: this.data.description_de,
en: this.data.description_en,
any: {
content: [
this.data.priority ? m('div', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [m('span.propertyTitle', 'Priority')]) : '',
this.data.priority ? m('div', m('p.propertyText', ` ${this.data.priority}`)) : '',
]
},
{
any: {
content: [
this.data.priority ? m('div', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [m('span.propertyTitle', 'Price')]) : '',
this.data.priority ? m('div', m('p.propertyText', ` ${this.data.price}`)) : '',
]
}
},
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
if (this.details) {
displayDetailsButton = m(Toolbar, { compact: true, events: { onclick: () => this.details = !this.details } }, [
m(IconButton, { icon: { svg: m.trust(icons.ArrowDown) } }),
m(ToolbarTitle, { text: "details" }),
]);
displayDetails = m(Card, {
className: 'eventInfoCard',
content: [
{
any: {
content: [
this.data.time_advertising_start ? m('div', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [m('span.propertyTitle', 'Advertising Time')]) : '',
this.data.time_advertising_start ? m('div', m('p.propertyText', ` ${dateFormatter(this.data.time_advertising_start)} - ${dateFormatter(this.data.time_advertising_end)}`)) : '',
]
}
},
{
any: {
content: [
this.data.time_register_start ? m('div', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [m('span.propertyTitle', 'Registration Time')]) : '',
this.data.time_register_start ? m('div', m('p.propertyText', ` ${dateFormatter(this.data.time_register_start)} - ${dateFormatter(this.data.time_register_end)}`)) : '',
]
}
},
{
any: {
content: [
this.data.selection_strategy ? m('div', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [m('span.propertyTitle', 'Selection strategy')]) : '',
this.data.selection_strategy ? m('div', m('p.propertyText', ` ${this.data.selection_strategy}`)) : '',
]
}
},
{
any: {
content: [
this.data.show_annonce ? m('div', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [m('span.propertyTitle', 'Annonce is shown')]) : '',
this.data.show_annonce ? m('div', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [m('span.propertyTitle', 'Infoscreen is shown')]) : '',
this.data.show_website ? m('div', {style: { 'margin-top': '10px', 'margin-bottom': '3px' } }, [m('span.propertyTitle', 'Website is shown')]) : '',]
}
},
]
})
}
displayEmailAdressesButton = m(Toolbar, { compact: true, events: { onclick: () => this.emailAdresses = !this.emailAdresses } }, [
m(IconButton, { icon: { svg: m.trust(icons.ArrowDown) } }),
m(ToolbarTitle, { text: "email adresses" }),
]);
any:
{
content: m(Switch, {
defaultChecked: false,
label: 'show unaccepted',
onChange: () => {
this.showAllEmails = !this.showAllEmails;
this.setUpEmailList(this.showAllEmails);
},
any:
{
content: m(EmailList, { list: this.emaillist }),
}
},
],
let displaySpots = '-';
if(this.data.spots !== 0) {
displaySpots = this.data.spots;
}
style: { height: '100%', 'overflow-y': 'scroll', padding: '10px'}
m("h1", {style: { 'margin-top': '0px', 'margin-bottom': '0px' } }, [this.data.title_de]),
m('div', { style: { float: 'left', 'margin-right': '20px'} }, [
m('div', this.data.signup_count ? m('span.propertyTitle', `Signups`) : m.trust(' ')),
m('div', this.data.signup_count ? m('p.propertyText', ` ${this.data.signup_count} / ${displaySpots}`) : m.trust(' ')),
]),
m('div', { style: { float: 'left', 'margin-right': '20px'} }, [
m('div', this.data.location ? m('span.propertyTitle', `Location`) : m.trust(' ') ),
m('div', this.data.location ? m('p.propertyText', ` ${this.data.location}`) : m.trust(' ')),
]),
m('div', [
m('div', this.data.time_start ? m('span.propertyTitle', `Time`): m.trust(' ')),
m('div', this.data.time_start ? m('p.propertyText', ` ${dateFormatter(this.data.time_start)} - ${dateFormatter(this.data.time_end)}`): m.trust(' ')),
]),
m('div.eventViewContainer', { style: { 'margin-top': '50px' } }, [
m('div.eventViewLeft', [
displayDescriptionButton,
displayDescription,
displayDetailsButton,
displayDetails,
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 } }),
])
]),