To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit c5e41b6b authored by scmoritz's avatar scmoritz
Browse files

Refactor form into components

parent f855f2e1
......@@ -6,3 +6,6 @@ export { default as Tabs } from './Tabs';
export { default as Dropdown } from './Dropdown';
export { default as TextField } from './TextField';
export { default as FilterView } from './FilterView';
export { default as InputGroupForm } from './form/inputGroup';
export { default as JSONSchemaForm } from './form/jsonSchemaForm';
export { default as SelectGroupForm } from './form/selectGroup';
......@@ -4,9 +4,7 @@ import escape from 'html-escape';
import * as EmailValidator from 'email-validator';
import { log } from '../../models/log';
import { isLoggedIn, login } from '../../models/auth';
import inputGroup from '../form/inputGroup';
import { Button } from '../../components';
import JSONSchemaForm from '../form/jsonSchemaForm';
import { Button, InputGroupForm, JSONSchemaForm } from '../../components';
import { i18n } from '../../models/language';
class EventSignupForm extends JSONSchemaForm {
......@@ -92,7 +90,7 @@ class EventSignupForm extends JSONSchemaForm {
}
_renderEmailField() {
return m(inputGroup, {
return m(InputGroupForm, {
name: 'email',
title: i18n('email'),
args: {
......
......@@ -3,8 +3,7 @@ import { apiUrl } from 'config';
import { log } from '../models/log';
import * as user from '../models/user';
import * as groups from '../models/groups';
import inputGroup from './form/inputGroup';
import { Button } from '../components';
import { Button, InputGroupForm } from '../components';
import { i18n } from '../models/language';
// shows all relevant user information
......@@ -143,7 +142,7 @@ class changePasswordForm {
return m('div', [
m('div', i18n('profile.password_requirements')),
m(inputGroup, {
m(InputGroupForm, {
name: 'password_old',
title: i18n('profile.old_password'),
type: 'password',
......@@ -153,7 +152,7 @@ class changePasswordForm {
this.validate();
},
}),
m(inputGroup, {
m(InputGroupForm, {
name: 'password1',
title: i18n('profile.new_password'),
type: 'password',
......@@ -163,7 +162,7 @@ class changePasswordForm {
this.validate();
},
}),
m(inputGroup, {
m(InputGroupForm, {
name: 'password2',
title: i18n('profile.repeat_password'),
type: 'password',
......@@ -204,7 +203,7 @@ class rfidForm {
}
return m('div', [
m(inputGroup, {
m(InputGroupForm, {
name: 'rfid',
title: i18n('profile.rfid'),
value: this.rfid,
......@@ -261,7 +260,7 @@ class groupMemberships {
view() {
// Searchbar for groups
const filterForm = m('div', [
m(inputGroup, {
m(InputGroupForm, {
name: 'group_search',
title: i18n('profile.search_groups'),
oninput: e => {
......
import m from 'mithril';
import StudydocsController from '../../models/studydocs';
import inputGroup from '../form/inputGroup';
import selectGroup from '../form/selectGroup';
import { Button } from '../../components';
import { Button, InputGroupForm, SelectGroupForm } from '../../components';
import { currentLanguage, i18n } from '../../models/language';
export default class studydocNew {
......@@ -39,7 +37,7 @@ export default class studydocNew {
view() {
return m('form', { onsubmit: () => false }, [
m(inputGroup, {
m(InputGroupForm, {
name: 'title',
title: i18n('studydocs.title'),
oninput: e => {
......@@ -48,7 +46,7 @@ export default class studydocNew {
getSuggestions: (input, callback) =>
studydocNew._getInputSuggestions('title', input, callback),
}),
m(inputGroup, {
m(InputGroupForm, {
name: 'professor',
title: i18n('studydocs.professor'),
oninput: e => {
......@@ -57,7 +55,7 @@ export default class studydocNew {
getSuggestions: (input, callback) =>
studydocNew._getInputSuggestions('professor', input, callback),
}),
m(inputGroup, {
m(InputGroupForm, {
name: 'author',
title: i18n('studydocs.author'),
oninput: e => {
......@@ -66,7 +64,7 @@ export default class studydocNew {
getSuggestions: (input, callback) =>
studydocNew._getInputSuggestions('author', input, callback),
}),
m(selectGroup, {
m(SelectGroupForm, {
name: 'semester',
title: i18n('studydocs.semester'),
type: 'select',
......@@ -81,7 +79,7 @@ export default class studydocNew {
{ value: '5+', text: '5+' },
],
}),
m(selectGroup, {
m(SelectGroupForm, {
name: 'department',
title: i18n('studydocs.department'),
type: 'select',
......@@ -90,7 +88,7 @@ export default class studydocNew {
},
options: [{ value: 'itet', text: 'itet' }, { value: 'mavt', text: 'mavt' }],
}),
m(inputGroup, {
m(InputGroupForm, {
name: 'lecture',
title: i18n('studydocs.lecture'),
oninput: e => {
......@@ -99,7 +97,7 @@ export default class studydocNew {
getSuggestions: (input, callback) =>
studydocNew._getInputSuggestions('lecture', input, callback),
}),
m(inputGroup, {
m(InputGroupForm, {
name: 'course_year',
title: i18n('studydocs.course_year'),
type: 'number',
......@@ -110,7 +108,7 @@ export default class studydocNew {
this.doc.course_year = e.target.value;
},
}),
m(selectGroup, {
m(SelectGroupForm, {
name: 'type',
title: i18n('studydocs.type'),
type: 'select',
......@@ -124,7 +122,7 @@ export default class studydocNew {
{ value: 'exercises', text: i18n('exercises') },
],
}),
m(inputGroup, {
m(InputGroupForm, {
name: 'files',
title: i18n('studydocs.files'),
args: {
......
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