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 @@
"@material/drawer": "^0.30.0",
"@material/select": "^0.35.1",
"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",
"client-oauth2": "^4.2.0",
"mithril": "^1.1.6",
"mithril-infinite": "^1.2.4",
"polythene-core-css": "^1.2.0",
"polythene-css": "^1.2.0",
"polythene-mithril": "^1.2.0",
"polythene-mithril": "^1.5.2",
"querystring": "^0.2.0"
},
"devDependencies": {
......
......@@ -5,19 +5,6 @@ import { apiUrl } from 'networkConfig';
import EditView from '../views/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() {
if ('rfid' in this.form.data && !this.form.data.rfid) delete this.form.data.rfid;
this.submit();
......@@ -25,51 +12,16 @@ export default class UserEdit extends EditView {
view() {
const style = 'display: inline-block; vertical-align: top; padding-right: 80px';
if (!this.form.schema) return '';
return this.layout([
...this.form.renderPage({
lastname: { type: 'text', label: 'Last Name' },
firstname: { type: 'text', label: 'First Name' },
email: { type: 'text', label: 'Email' },
nethz: { type: 'text', label: 'NETHZ' },
}),
...this.form.renderSchema(['lastname', 'firstname', 'email', 'nethz']),
m(TextInput, this.form.bind({
type: 'password',
name: 'password',
label: 'New password',
floatingLabel: true,
})),
...this.form.renderPage({
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();
},
}),
),
...this.form.renderSchema(['rfid', 'membership']),
m(
'div', { style },
m(RadioGroup, {
......
......@@ -35,7 +35,7 @@ export default class EditView extends ItemView {
// the form is valid in case that the item controller is in edit mode
const validInitially = this.controller.modus === 'edit';
// 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() {
......@@ -102,10 +102,12 @@ export default class EditView extends ItemView {
events: { onclick: () => { this.beforeSubmit(); } },
}),
]),
wrapInContainer && m('div.maincontainer', {
style: { height: 'calc(100vh - 130px)', 'overflow-y': 'scroll', padding: '10px' },
}, children),
!wrapInContainer && children,
...!this.form.schema ? [''] : [
wrapInContainer && m('div.maincontainer', {
style: { height: 'calc(100vh - 130px)', 'overflow-y': 'scroll', padding: '10px' },
}, children),
!wrapInContainer && children,
],
]);
}
}
Supports Markdown
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