From 5623bb4285b338fd73a55e2c3cc6388ee027360d Mon Sep 17 00:00:00 2001 From: Hermann Blum <hermannsblum@yahoo.de> Date: Sun, 18 Mar 2018 12:16:01 +0100 Subject: [PATCH] editing loads event into edit form --- src/events/eventModal.js | 16 ++++++++++++++++ src/events/viewEvent.js | 8 ++++++-- src/index.js | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 src/events/eventModal.js diff --git a/src/events/eventModal.js b/src/events/eventModal.js new file mode 100644 index 0000000..057151e --- /dev/null +++ b/src/events/eventModal.js @@ -0,0 +1,16 @@ +import m from 'mithril'; +import viewEvent from './viewEvent'; +import newEvent from './newEvent'; + +export default class EventModal { + constructor() { + this.edit = false; + } + + view() { + if (this.edit) { + return m(newEvent); + } + return m(viewEvent, { onEdit: () => { this.edit = true; } }); + } +} diff --git a/src/events/viewEvent.js b/src/events/viewEvent.js index 955c984..f782c9c 100644 --- a/src/events/viewEvent.js +++ b/src/events/viewEvent.js @@ -178,7 +178,7 @@ export default class viewEvent extends ItemView { } } - view() { + view({ attrs: { onEdit } }) { if (!this.data) return ''; console.log(Object.keys(this)); console.log(this['data']); @@ -280,7 +280,11 @@ export default class viewEvent extends ItemView { return m("div", { style: { height: '100%', 'overflow-y': 'scroll', padding: '10px'} },[ - m(Button, {element: 'div', label: "Update Event"}), + m(Button, { + element: 'div', + label: 'Update Event', + events: { onclick: onEdit }, + }), m("h1", {style: { 'margin-top': '0px', 'margin-bottom': '0px' } }, [this.data.title_de]), m('div', { style: { float: 'left', 'margin-right': '20px'} }, [ this.data.time_start ? m('div', m('span.propertyTitle', `Time`)) : '', diff --git a/src/index.js b/src/index.js index 4d9ef91..75ea31c 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,7 @@ import { UserModal, UserTable, NewUser } from './userTool'; import { MembershipView } from './membershipTool'; import EventTable from './events/table'; import newEvent from './events/newEvent'; -import viewEvent from './events/viewEvent'; +import EventModal from './events/eventModal'; import eventDraft from './events/eventDraft'; import eventWithExport from './events/eventWithExport'; import Layout from './layout'; @@ -28,7 +28,7 @@ m.route(root, '/users', { '/newuser': layoutWith(NewUser), '/groupmemberships/:id': layoutWith(MembershipView), '/events': layoutWith(EventTable), - '/events/:id': layoutWith(viewEvent), + '/events/:id': layoutWith(EventModal), '/newevent': layoutWith(newEvent), '/draftevent': layoutWith(eventDraft), '/eventwithexport': layoutWith(eventWithExport), -- GitLab