Commit 50648575 authored by Hermann's avatar Hermann
Browse files

update editUser to new ui components

parent cd0880ca
import m from 'mithril';
import { RadioGroup, TextInput, Form } from 'amiv-web-ui-components';
// eslint-disable-next-line import/extensions
import { apiUrl } from 'networkConfig';
import { RadioGroup, TextInput } from 'amiv-web-ui-components';
import EditView from '../views/editView';
export default class UserEdit extends EditView {
beforeSubmit() {
if ('rfid' in this.form.data && !this.form.data.rfid) delete this.form.data.rfid;
this.submit();
this.submit(this.form.data);
}
view() {
const style = 'display: inline-block; vertical-align: top; padding-right: 80px';
if (!this.form.schema) return '';
return this.layout([
...this.form.renderSchema(['lastname', 'firstname', 'email', 'nethz']),
......@@ -21,38 +18,7 @@ export default class UserEdit extends EditView {
label: 'New password',
floatingLabel: true,
})),
...this.form.renderSchema(['rfid', 'membership']),
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();
},
}),
),
...this.form.renderSchema(['rfid', 'membership', 'gender', 'department']),
]);
}
}
......@@ -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, 0, Object.assign({}, this.controller.data));
this.form = new Form({}, validInitially, 4, Object.assign({}, this.controller.data));
}
oninit() {
......
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