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 64e66c87 authored by Sean Goff's avatar Sean Goff
Browse files

fix issue #48 by implementing RadioGroup myself, adding missing functionality in polythene

parent 0949a093
import m from 'mithril';
import { Button, Checkbox, Dropdown, TextField, RadioGroup } from '../components';
import { Button, Checkbox, Dropdown, TextField, RadioButton } from '../components';
/**
* FilterViewComponent
......@@ -172,25 +172,19 @@ export default class FilterViewComponent {
_createRadioGroup(field) {
this.values[field.key] = this.values[field.key] || field.default || [];
const radioValues = JSON.parse(JSON.stringify(field.values));
return m('div.radio', [
field.label ? m('h4', field.label) : m(''),
m(RadioGroup, {
buttons: radioValues.map(value => {
const radioValue = value;
if (this.values[field.key] === value.value) {
radioValue.defaultChecked = true;
}
return radioValue;
}),
name: field.key,
const buttons = field.values.map(value =>
m(RadioButton, {
...value,
checked: this.values[field.key] === value.value,
onChange: state => {
this.values[field.key] = state.value;
if (state.checked) {
this.values[field.key] = value.value;
}
this.notify();
},
}),
]);
})
);
return m('div.radio', [field.label ? m('h4', field.label) : m(''), m('div', buttons)]);
}
_createDropdown(field) {
......
import m from 'mithril';
import { RadioButton } from 'polythene-mithril';
export default class RadioButtonComponent {
constructor() {
this.defaultProps = {
// className: 'blue-RadioButton',
};
}
view(vnode) {
return m(RadioButton, { ...this.defaultProps, ...vnode.attrs });
}
}
import m from 'mithril';
import { RadioGroup } from 'polythene-mithril';
// import { RadioGroupCSS } from 'polythene-css';
// RadioGroupCSS.addStyle('', {})
/**
* Generic RadioGroup component
*
* Attributes:
*
* - `buttons` list of radio button options
* - `name` field name
* - `className` *optional*
* - `onChange` *optional*
*
* Examples:
*
* m(RadioGroupComponent, {
* buttons: ['Option 1', 'Option 2'],
* name: 'optionName',
* })
*
* @return {RadioGroupComponent} generic checkbox as mithril component.
*/
export default class RadioGroupComponent {
constructor() {
this.defaultProps = {
// className: 'blue-RadioGroup',
};
}
view(vnode) {
return m(RadioGroup, { ...this.defaultProps, ...vnode.attrs });
}
}
export { default as Button } from './Button';
export { default as Card } from './Card';
export { default as Checkbox } from './Checkbox';
export { default as RadioGroup } from './RadioGroup';
export { default as RadioButton } from './RadioButton';
export { default as Tabs } from './Tabs';
export { default as Dropdown } from './Dropdown';
export { default as TextField } from './TextField';
......
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