Commit cd0880ca authored by Hermann's avatar Hermann
Browse files

working changes for updated ui-components in user edit

parent 255d8e32
...@@ -18,14 +18,14 @@ ...@@ -18,14 +18,14 @@
"@material/drawer": "^0.30.0", "@material/drawer": "^0.30.0",
"@material/select": "^0.35.1", "@material/select": "^0.35.1",
"ajv": "^5.5.0", "ajv": "^5.5.0",
"amiv-web-ui-components": "git+https://git@gitlab.ethz.ch/amiv/web-ui-components.git#b1fb1eba5b149a7f083c70b949437a067fee8e5d", "amiv-web-ui-components": "git+https://git@gitlab.ethz.ch/amiv/web-ui-components.git#441f87aa23892fd6e92d878aa9f7725cf9e385ea",
"axios": "^0.17.1", "axios": "^0.17.1",
"client-oauth2": "^4.2.0", "client-oauth2": "^4.2.0",
"mithril": "^1.1.6", "mithril": "^1.1.6",
"mithril-infinite": "^1.2.4", "mithril-infinite": "^1.2.4",
"polythene-core-css": "^1.2.0", "polythene-core-css": "^1.2.0",
"polythene-css": "^1.2.0", "polythene-css": "^1.2.0",
"polythene-mithril": "^1.2.0", "polythene-mithril": "^1.5.2",
"querystring": "^0.2.0" "querystring": "^0.2.0"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -5,19 +5,6 @@ import { apiUrl } from 'networkConfig'; ...@@ -5,19 +5,6 @@ import { apiUrl } from 'networkConfig';
import EditView from '../views/editView'; import EditView from '../views/editView';
export default class UserEdit extends EditView { export default class UserEdit extends EditView {
constructor(vnode) {
super(vnode);
this.pw = new Form();
}
oninit() {
// load schema
m.request(`${apiUrl}/docs/api-docs`).then((schema) => {
this.pw.setSchema(JSON.parse(JSON.stringify(schema.definitions.User)));
this.form.setSchema(schema.definitions.User);
}).catch((error) => { console.log(error); });
}
beforeSubmit() { beforeSubmit() {
if ('rfid' in this.form.data && !this.form.data.rfid) delete this.form.data.rfid; if ('rfid' in this.form.data && !this.form.data.rfid) delete this.form.data.rfid;
this.submit(); this.submit();
...@@ -25,51 +12,16 @@ export default class UserEdit extends EditView { ...@@ -25,51 +12,16 @@ export default class UserEdit extends EditView {
view() { view() {
const style = 'display: inline-block; vertical-align: top; padding-right: 80px'; const style = 'display: inline-block; vertical-align: top; padding-right: 80px';
if (!this.form.schema) return '';
return this.layout([ return this.layout([
...this.form.renderPage({ ...this.form.renderSchema(['lastname', 'firstname', 'email', 'nethz']),
lastname: { type: 'text', label: 'Last Name' },
firstname: { type: 'text', label: 'First Name' },
email: { type: 'text', label: 'Email' },
nethz: { type: 'text', label: 'NETHZ' },
}),
m(TextInput, this.form.bind({ m(TextInput, this.form.bind({
type: 'password', type: 'password',
name: 'password', name: 'password',
label: 'New password', label: 'New password',
floatingLabel: true, floatingLabel: true,
})), })),
...this.form.renderPage({ ...this.form.renderSchema(['rfid', 'membership']),
rfid: { type: 'text', label: 'RFID Code' },
}),
m(
'div', { style },
m(RadioGroup, {
name: 'Membership',
default: this.form.data.membership,
values: [
{
value: 'none',
label: 'No Member',
},
{
value: 'regular',
label: 'Regular AMIV Member',
},
{
value: 'extraordinary',
label: 'Extraordinary Member',
},
{
value: 'honorary',
label: 'Honorary Member',
},
],
onchange: (value) => {
this.form.data.membership = value;
this.form.validate();
},
}),
),
m( m(
'div', { style }, 'div', { style },
m(RadioGroup, { m(RadioGroup, {
......
...@@ -35,7 +35,7 @@ export default class EditView extends ItemView { ...@@ -35,7 +35,7 @@ export default class EditView extends ItemView {
// the form is valid in case that the item controller is in edit mode // the form is valid in case that the item controller is in edit mode
const validInitially = this.controller.modus === 'edit'; const validInitially = this.controller.modus === 'edit';
// start a form to collect the submit data // start a form to collect the submit data
this.form = new Form({}, validInitially, Object.assign({}, this.controller.data)); this.form = new Form({}, validInitially, 0, Object.assign({}, this.controller.data));
} }
oninit() { oninit() {
...@@ -102,10 +102,12 @@ export default class EditView extends ItemView { ...@@ -102,10 +102,12 @@ export default class EditView extends ItemView {
events: { onclick: () => { this.beforeSubmit(); } }, events: { onclick: () => { this.beforeSubmit(); } },
}), }),
]), ]),
wrapInContainer && m('div.maincontainer', { ...!this.form.schema ? [''] : [
style: { height: 'calc(100vh - 130px)', 'overflow-y': 'scroll', padding: '10px' }, wrapInContainer && m('div.maincontainer', {
}, children), style: { height: 'calc(100vh - 130px)', 'overflow-y': 'scroll', padding: '10px' },
!wrapInContainer && children, }, children),
!wrapInContainer && children,
],
]); ]);
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment