Commit 50648575 authored by Hermann's avatar Hermann
Browse files

update editUser to new ui components

parent cd0880ca
import m from 'mithril'; import m from 'mithril';
import { RadioGroup, TextInput, Form } from 'amiv-web-ui-components'; import { RadioGroup, TextInput } from 'amiv-web-ui-components';
// eslint-disable-next-line import/extensions
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 {
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(this.form.data);
} }
view() { view() {
const style = 'display: inline-block; vertical-align: top; padding-right: 80px';
if (!this.form.schema) return ''; if (!this.form.schema) return '';
return this.layout([ return this.layout([
...this.form.renderSchema(['lastname', 'firstname', 'email', 'nethz']), ...this.form.renderSchema(['lastname', 'firstname', 'email', 'nethz']),
...@@ -21,38 +18,7 @@ export default class UserEdit extends EditView { ...@@ -21,38 +18,7 @@ export default class UserEdit extends EditView {
label: 'New password', label: 'New password',
floatingLabel: true, floatingLabel: true,
})), })),
...this.form.renderSchema(['rfid', 'membership']), ...this.form.renderSchema(['rfid', 'membership', 'gender', 'department']),
m(
'div', { style },
m(RadioGroup, {
name: 'Sex',
default: this.form.data.gender,
values: [
{ value: 'female', label: 'Female' },
{ value: 'male', label: 'Male' },
],
onchange: (value) => {
this.form.data.gender = value;
this.form.validate();
},
}),
),
m(
'div', { style },
m(RadioGroup, {
name: 'Departement',
default: this.form.data.department,
values: [
{ value: 'itet', label: 'ITET' },
{ value: 'mavt', label: 'MAVT' },
{ value: null, label: 'None' },
],
onchange: (value) => {
this.form.data.department = value;
this.form.validate();
},
}),
),
]); ]);
} }
} }
...@@ -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, 0, Object.assign({}, this.controller.data)); this.form = new Form({}, validInitially, 4, Object.assign({}, this.controller.data));
} }
oninit() { oninit() {
......
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