Skip to content
Snippets Groups Projects
Commit 48ad8d6d authored by Hermann's avatar Hermann
Browse files

add more documentation

parent 1f99b470
No related branches found
No related tags found
No related merge requests found
...@@ -2,14 +2,30 @@ import Ajv from 'ajv'; ...@@ -2,14 +2,30 @@ import Ajv from 'ajv';
import { ItemView } from './itemView'; import { ItemView } from './itemView';
import { getSession } from '../auth'; import { getSession } from '../auth';
const m = require('mithril'); const m = require('mithril');
// Mapper for resource vs schema-object names
const objectNameForResource = { const objectNameForResource = {
users: 'User', users: 'User',
groupmembershipds: 'Groupmembership',
groups: 'Group',
eventsignups: 'Eventsignup',
events: 'Event',
}; };
export class EditView extends ItemView { 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) { constructor(vnode, resource, valid = true) {
super(resource); super(resource);
this.changed = false; this.changed = false;
......
...@@ -3,6 +3,17 @@ import { getSession } from '../auth'; ...@@ -3,6 +3,17 @@ import { getSession } from '../auth';
const m = require('mithril'); const m = require('mithril');
export class ItemView { 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) { constructor(resource) {
this.data = null; this.data = null;
this.id = m.route.param('id'); this.id = m.route.param('id');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment