Skip to content

Commit 24ba82c

Browse files
committed
small tweaks to 2.0.1
1 parent dcb3789 commit 24ba82c

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/fields/fieldInput.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="form-group formly-input" :class="[ to.type, {'formly-has-value': model[field.key], 'formly-has-focus': form[field.key].$active}]">
2+
<div class="form-group formly-input" :class="[ to.inputType, {'formly-has-value': model[field.key], 'formly-has-focus': form[field.key].$active}]">
33
<label v-if="to.label" :for="to.id ? to.id : null">{{to.label}}</label>
44
<input class="form-control" :class="to.classes" :id="to.id ? to.id : null" type="text" v-model="model[field.key]" @blur="onBlur" @focus="onFocus" @click="onClick" @change="onChange" @keyup="onKeyup" @keydown="onKeydown" v-formly-atts="to.atts" v-formly-input-type="to.inputType">
55
</div>
@@ -14,7 +14,7 @@
1414
1515
this.$set(this.form[this.field.key], '$dirty', true);
1616
this.runFunction('onChange', e);
17-
if ( this.to.type == 'file' ){
17+
if ( this.to.inputType == 'file' ){
1818
this.$set(this.model, this.field.key, this.$el.querySelector('input').files);
1919
}
2020

src/fields/fieldList.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<div class="checkbox formly-list" :id="to.id" :class="to.classes">
33

44
<label v-for="option in field.options">
5-
<input v-if="!to.type || to.type == 'checkbox'" type="checkbox" v-model="model[field.key]" :value="option.value || option" @blur="onBlur" @focus="onFocus" @click="onClick" @change="onChange" @keyup="onKeyup" @keydown="onKeydown" v-formly-atts="to.atts">
6-
<input v-if="to.type == 'radio'" type="radio" v-model="model[field.key]" :value="option.value || option" @blur="onBlur" @focus="onFocus" @click="onClick" @change="onChange" @keyup="onKeyup" @keydown="onKeydown" v-formly-atts="to.atts">
5+
<input v-if="!to.inputType || to.inputType == 'checkbox'" type="checkbox" v-model="model[field.key]" :value="option.value || option" @blur="onBlur" @focus="onFocus" @click="onClick" @change="onChange" @keyup="onKeyup" @keydown="onKeydown" v-formly-atts="to.atts">
6+
<input v-if="to.inputType == 'radio'" type="radio" v-model="model[field.key]" :value="option.value || option" @blur="onBlur" @focus="onFocus" @click="onClick" @change="onChange" @keyup="onKeyup" @keydown="onKeydown" v-formly-atts="to.atts">
77
{{option.label || option}}
88
</label>
99

@@ -16,7 +16,7 @@
1616
mixins: [baseField],
1717
created: function(){
1818
//set the default value to be an array if it's a checkbox
19-
let type = this.to.type;
19+
let type = this.to.inputType;
2020
if ( (!type || type == 'checkbox') && this.model[ this.field.key ] == '') this.$set(this.model, this.field.key, []);
2121
}
2222
}

test/unit/specs/index.spec.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function trigger (target, event, process) {
3333
function describeFunctions(formlyElement, inputElement, inputType = 'text', options){
3434
beforeEach(() => {
3535
data.fields[0].type = formlyElement;
36-
data.fields[0].templateOptions.type = inputType;
36+
data.fields[0].templateOptions.inputType = inputType;
3737
if ( typeof options != 'undefined' ) data.fields[0].options = options;
3838
spy = sinon.spy();
3939
});
@@ -103,7 +103,7 @@ function describeFunctions(formlyElement, inputElement, inputType = 'text', opti
103103
function describeAttributes(inputElement, testPlaceholder = true){
104104
beforeEach(()=>{
105105
data.fields[0].type = inputElement;
106-
data.fields[0].templateOptions.type = 'text';
106+
data.fields[0].templateOptions.inputType = 'text';
107107
});
108108

109109
it('attributes', () => {
@@ -142,7 +142,7 @@ function describeAttributes(inputElement, testPlaceholder = true){
142142
function describeConditional(inputElement){
143143
it('label', (done) => {
144144
data.fields[0].type = inputElement;
145-
data.fields[0].templateOptions.type = 'text';
145+
data.fields[0].templateOptions.inputType = 'text';
146146
data.fields[0].templateOptions.label = '';
147147
createForm(data);
148148

@@ -187,7 +187,7 @@ describe('Bootstrap Field Inputs', () => {
187187
describeAttributes('input');
188188
it('should have input type as a class', () => {
189189
data.fields[0].type = 'input';
190-
data.fields[0].templateOptions.type = 'text';
190+
data.fields[0].templateOptions.inputType = 'text';
191191
createForm(data);
192192

193193
let els = vm.$el.querySelectorAll('.text');
@@ -203,7 +203,7 @@ describe('Bootstrap Field Inputs', () => {
203203

204204
it('layout', (done) => {
205205
data.fields[0].type = 'input';
206-
data.fields[0].templateOptions.type = 'text';
206+
data.fields[0].templateOptions.inputType = 'text';
207207
createForm(data);
208208

209209
let inputs = vm.$el.querySelectorAll('input');
@@ -226,7 +226,7 @@ describe('Bootstrap Field Inputs', () => {
226226

227227
it('adds active and focus classes', (done) => {
228228
data.fields[0].type = 'input';
229-
data.fields[0].templateOptions.type = 'text';
229+
data.fields[0].templateOptions.inputType = 'text';
230230
createForm(data);
231231

232232
expect(vm.$el.querySelectorAll('.formly-has-focus')).to.be.length(0);
@@ -243,7 +243,7 @@ describe('Bootstrap Field Inputs', () => {
243243

244244
it('defaults to text', () => {
245245
data.fields[0].type = 'input';
246-
data.fields[0].templateOptions.type = undefined;
246+
data.fields[0].templateOptions.inputType = undefined;
247247
createForm(data);
248248

249249
let inputs = vm.$el.querySelectorAll('input');
@@ -363,7 +363,7 @@ describe('Bootstrap Field Inputs', () => {
363363

364364
it('array options', () => {
365365
data.fields[0].type = 'list';
366-
data.fields[0].templateOptions.type = 'checkbox';
366+
data.fields[0].templateOptions.inputType = 'checkbox';
367367
data.fields[0].options = ['one', 'two', 'three'];
368368
createForm();
369369

@@ -378,7 +378,7 @@ describe('Bootstrap Field Inputs', () => {
378378

379379
it('object options', () => {
380380
data.fields[0].type = 'list';
381-
data.fields[0].templateOptions.type = 'checkbox'
381+
data.fields[0].templateOptions.inputType = 'checkbox'
382382
data.fields[0].options = [
383383
{ label: 'Foo', value: 'bar' },
384384
{ label: 'Bar', value: 'foo' }
@@ -418,7 +418,7 @@ describe('Bootstrap Field Inputs', () => {
418418

419419
it('multiple values', (done) => {
420420
data.fields[0].type = 'list';
421-
data.fields[0].templateOptions.type = 'checkbox';
421+
data.fields[0].templateOptions.inputType = 'checkbox';
422422
data.fields[0].options = ['one', 'two'];
423423
createForm();
424424

@@ -433,7 +433,7 @@ describe('Bootstrap Field Inputs', () => {
433433

434434
it('single value', (done) => {
435435
data.fields[0].type = 'list';
436-
data.fields[0].templateOptions.type = 'radio';
436+
data.fields[0].templateOptions.inputType = 'radio';
437437
data.fields[0].options = ['one', 'two'];
438438
createForm();
439439

0 commit comments

Comments
 (0)