diff --git a/src/views/editView.js b/src/views/editView.js index 0ef3516d90eb2058b350fa1db47114b278344eb5..727a5f4b8ebabd24ae5f0beccdcf62e52777213f 100644 --- a/src/views/editView.js +++ b/src/views/editView.js @@ -2,14 +2,30 @@ import Ajv from 'ajv'; import { ItemView } from './itemView'; import { getSession } from '../auth'; - const m = require('mithril'); +// Mapper for resource vs schema-object names const objectNameForResource = { users: 'User', + groupmembershipds: 'Groupmembership', + groups: 'Group', + eventsignups: 'Eventsignup', + events: 'Event', }; export class EditView extends ItemView { + /* Extension of ItemView to edit a data item + * + * Requires: + * - call constructor with vnode, resource, (valid, true by default) + * - vnode.attrs.onfinish has to be a callback function that is called after + * the edit is finished + * + * Provides Methods: + * - bind(attrs): binds a form-field against this.data + * - patchOnClick: onclick-function for patching + * - postOnClick: onclick-function for posting + */ constructor(vnode, resource, valid = true) { super(resource); this.changed = false; diff --git a/src/views/itemView.js b/src/views/itemView.js index 6cc828033e11db70b3fcc21fb26c3bb98dee7c49..ff4e49d985b6d0fb34ecee4d9fe7a6ae6b9cce9a 100644 --- a/src/views/itemView.js +++ b/src/views/itemView.js @@ -3,6 +3,17 @@ import { getSession } from '../auth'; const m = require('mithril'); export class ItemView { + /* Basic class show a data item + * + * Required Arguments: + * - call constructor with 'resource' + * - either make sure m.route.params('id') exists or set this.id in + * constructor + * + * Provides Methods: + * - loadItemData: Loads data specified by resource and id into this.data + * (is per default called by oninit) + */ constructor(resource) { this.data = null; this.id = m.route.param('id');