LT-67: Creating checkbox component

This commit is contained in:
Bruno Alves de Faria 2016-08-30 10:37:54 -03:00
parent 4e70e62b7b
commit 18516b47f0
6 changed files with 45 additions and 5 deletions

View File

@ -21,10 +21,7 @@
<div class="form-group">
<div class="form-control">
<div class="checkbox">
<label>
<input type="checkbox" name="">
<span>QIDO supports including fields</span>
</label>
{{>inputCheckbox key='qidoSupportsIncludeField'}}
</div>
</div>
</div>

View File

@ -10,6 +10,7 @@ import './mixins/formItem.js';
import './mixins/group.js';
import './mixins/groupRadio.js';
import './mixins/input.js';
import './mixins/checkbox.js';
import './mixins/schemaData.js';
import './mixins/select.js';
import './mixins/select2.js';

View File

@ -0,0 +1,26 @@
import { OHIF } from 'meteor/ohif:core';
import { Template } from 'meteor/templating';
import { _ } from 'meteor/underscore';
/*
* inputCheckbox: controls a checkbox input
*/
OHIF.mixins.checkbox = new OHIF.Mixin({
dependencies: 'input',
composition: {
onCreated() {
const instance = Template.instance();
const component = instance.component;
// Get or set the checked state using jQuery's prop method
component.value = value => {
const isGet = _.isUndefined(value);
if (isGet) {
return component.$element.is(':checked');
}
component.$element.prop('checked', value);
};
}
}
});

View File

@ -1,6 +1,7 @@
import './form/form.html';
import './form/group.html';
import './input/checkbox.html';
import './input/hidden.html';
import './input/groupRadio.html';
import './input/radio.html';

View File

@ -0,0 +1,15 @@
<template name="inputCheckbox">
{{#baseComponent (extend this
base='baseInput'
type='checkbox'
mixins=(concat 'checkbox ' this.mixins)
labelAfter=(valueIf (isUndefined this.labelAfter) true this.labelAfter)
labelClass=(concat 'checkboxLabel ' this.labelClass)
wrappers=(concat ''
(valueIf reactive this.label 'wrapperLabel ' '')
this.wrappers
)
)}}
{{>UI.contentBlock}}
{{/baseComponent}}
</template>

View File

@ -4,7 +4,7 @@
type='radio'
mixins=(concat 'input ' this.mixins)
labelAfter=(valueIf (isUndefined this.labelAfter) true this.labelAfter)
labelClass=(concat 'checkboxLabel ' this.labelClass)
labelClass=(concat 'radioLabel ' this.labelClass)
wrappers=(concat ''
(valueIf reactive this.label 'wrapperLabel ' '')
this.wrappers