diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000000000000000000000000000000000000..c6cc8c8196a2226f7e8c986e437830c7e56949a2 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ +<component name="InspectionProjectProfileManager"> + <profile version="1.0"> + <option name="myName" value="Project Default" /> + <inspection_tool class="Eslint" enabled="true" level="ERROR" enabled_by_default="true" /> + </profile> +</component> \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..35eb1ddfbbc029bcab630581847471d7f238ec53 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/src/config.json b/src/config.json index 91e740875945e126e5b51c791d31a56674c99ca2..511510749233da02e7452d8e86f14f17544617da 100644 --- a/src/config.json +++ b/src/config.json @@ -83,6 +83,15 @@ "patchableKeys": ["user", "group"] }, "eventsignups": { - "patchableKeys": ["event"] + "patchableKeys": ["event"], + "tableKeys": [ + "_created", + "user.lastname", + "user.firstname", + "email" + ], + "searchKeys": [ + "email" + ] } } diff --git a/src/events/table.js b/src/events/table.js index 9b3d2247f4b679ab6f9c5820a1b10bb755fb3338..c913134220052a60762e7fd8b6547ad730c66d23 100644 --- a/src/events/table.js +++ b/src/events/table.js @@ -2,6 +2,7 @@ import m from 'mithril'; import { events as config } from '../config.json'; import TableView from '../views/tableView'; import DatalistController from '../listcontroller'; +import { dateFormatter } from '../utils'; /* Table of all Events @@ -10,20 +11,6 @@ import DatalistController from '../listcontroller'; */ -function dateFormatter(datestring) { - // converts an API datestring into the standard format 01.01.1990, 10:21 - if (!datestring) return ''; - const date = new Date(datestring); - return date.toLocaleString('de-DE', { - day: '2-digit', - month: '2-digit', - year: '2-digit', - hour: '2-digit', - minute: '2-digit', - }); -} - - export default class EventTable { constructor() { this.ctrl = new DatalistController('events', {}, config.tableKeys); diff --git a/src/events/viewEvent.js b/src/events/viewEvent.js index a00caa5dc74544e946a4a7631b54777b056b9aa0..fece3982ed3b26f8aa780e9ad93dbe527a30b2a1 100644 --- a/src/events/viewEvent.js +++ b/src/events/viewEvent.js @@ -1,13 +1,72 @@ import m from 'mithril'; +import { Checkbox, Button, Card, TextField, IconButton, Toolbar, ToolbarTitle } from 'polythene-mithril'; import ItemView from '../views/itemView'; -import {Button, Card, 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 { icons } from '../views/elements'; +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); + + +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' }, + ], + }), + }); + } +} export default class viewEvent extends ItemView { constructor() { super('events'); this.details = false; - this.participants = false; this.waitlist = false; this.emailAdresses = false; } @@ -53,10 +112,6 @@ export default class viewEvent extends ItemView { m(IconButton, { icon: { svg: m.trust(icons.ArrowRight) } }), m(ToolbarTitle, { text: "details" }), ]); - let displayParticipantsButton = m(Toolbar, { compact: true, events: { onclick: () => this.participants = !this.participants } }, [ - m(IconButton, { icon: { svg: m.trust(icons.ArrowRight) } }), - m(ToolbarTitle, { text: "participants" }), - ]); let displayWaitlistButton = m(Toolbar, { compact: true, events: { onclick: () => this.waitlist = !this.waitlist } }, [ m(IconButton, { icon: { svg: m.trust(icons.ArrowRight) } }), m(ToolbarTitle, { text: "waitlist" }), @@ -69,7 +124,6 @@ export default class viewEvent extends ItemView { let displayDetails = null; - let displayParticipants = null; let displayWaitlist = null; let displayEmailAdresses = null; @@ -83,54 +137,29 @@ export default class viewEvent extends ItemView { { primary: { title: "Catchphrase", - subtitle: displayCatchphrase + subtitle: displayCatchphrase, } }, { - primary: { - title: "Description", - subtitle: displayDescription - } + any: { + content: this.data.time_start ? m('p', m('strong', `when: from ${dateFormatter(this.data.time_start)} to ${dateFormatter(this.data.time_end)}`)) : '', + }, }, { - primary: { - title: "Priority", - subtitle: displayPriority + any: { + content: this.data.location ? m('p', m('strong', `where: ${this.data.location}`)) : '', } }, { - actions: { - content: [ - m(Button, { - label: "Action 1" - }), - m(Button, { - label: "Action 2" - }) - ] + primary: { + title: "Description", + subtitle: displayDescription } }, - { - text: { - content: "More text" - } - } - ] - - }) - } - - if (this.participants) { - displayParticipantsButton = m(Toolbar, { compact: true, events: { onclick: () => this.participants = !this.participants } }, [ - m(IconButton, { icon: { svg: m.trust(icons.ArrowDown) } }), - m(ToolbarTitle, { text: "participants" }), - ]); - displayParticipants = m(Card, { - content: [ { primary: { - title: "Primary title", - subtitle: "Subtitle" + title: "Priority", + subtitle: displayPriority } }, { @@ -232,20 +261,26 @@ export default class viewEvent extends ItemView { m("h1", {class: "title"}, this.data.title_de), m(Button, {element: 'div', label: "Update Event"}), - displayDetailsButton, - displayDetails, + m('div.eventViewContainer', [ + m('div.eventViewLeft', [ + displayDetailsButton, + displayDetails, - displayParticipantsButton, - displayParticipants, + displayWaitlistButton, + displayWaitlist, - displayWaitlistButton, - displayWaitlist, - - displayEmailAdressesButton, - displayEmailAdresses, + 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 } }), + ]) + ]), ]) } - - } diff --git a/src/utils.js b/src/utils.js index 0844554c3394f8eb10130d35cd701c4dcd8d49c3..577facb26af4ab08eb5dfffa3f45f25e0a02d5dc 100644 --- a/src/utils.js +++ b/src/utils.js @@ -17,3 +17,16 @@ export function debounce(func, wait, immediate) { if (callNow) func.apply(context, args); }; } + +export function dateFormatter(datestring) { + // converts an API datestring into the standard format 01.01.1990, 10:21 + if (!datestring) return ''; + const date = new Date(datestring); + return date.toLocaleString('de-DE', { + day: '2-digit', + month: '2-digit', + year: '2-digit', + hour: '2-digit', + minute: '2-digit', + }); +} \ No newline at end of file diff --git a/src/views/tableView.js b/src/views/tableView.js index a7ef8ef525c36d4d1d633a10491ed64ba8bfe016..5b7584f9d48a1ae5625c44f6abc84ad44ed00899 100644 --- a/src/views/tableView.js +++ b/src/views/tableView.js @@ -61,18 +61,25 @@ export default class TableView { } item() { - return (data, opts) => m(ListTile, { - className: 'themed-list-tile', - hoverable: true, - compactFront: true, - content: m('div', { - onclick() { m.route.set(`/${data._links.self.href}`); }, - className: 'tableTile', - style: { width: '100%', display: 'flex' }, - }, this.tileContent ? this.tileContent(data) : this.getItemData(data)), - }); + return (data, opts) => { + console.log(data); + console.log(this.tileContent); + return m(ListTile, { + className: 'themed-list-tile', + hoverable: true, + compactFront: true, + content: m('div', { + onclick() { + m.route.set(`/${data._links.self.href}`); + }, + className: 'tableTile', + style: { width: '100%', display: 'flex' }, + }, this.tileContent ? this.tileContent(data) : this.getItemData(data)), + }); + }; } + view({ attrs: { controller,