Skip to content

enhancement: add missing "autocomplete", "placeholder" and "readonly"… #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 6, 2016
Merged
8 changes: 4 additions & 4 deletions src/fields/fieldChecklist.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<template lang="jade">
.wrapper
.listbox.form-control(v-if="schema.listBox")
.listbox.form-control(v-if="schema.listBox", :disabled="disabled")
.list-row(v-for="item in items")
label
input(type="checkbox", :checked="getItemIsChecked(item)", @change="onChanged($event, item)")
input(type="checkbox", :checked="getItemIsChecked(item)", :disabled="disabled", @change="onChanged($event, item)")
| {{ getItemName(item) }}

.combobox.form-control(v-if="!schema.listBox")
.combobox.form-control(v-if="!schema.listBox", :disabled="disabled")
.mainRow(@click="onExpandCombo", :class="{ expanded: comboExpanded }")
.info {{ selectedCount }} selected
.arrow

.dropList
.list-row(v-if="comboExpanded", v-for="item in items")
label
input(type="checkbox", :checked="getItemIsChecked(item)", @change="onChanged($event, item)")
input(type="checkbox", :checked="getItemIsChecked(item)", :disabled="disabled", @change="onChanged($event, item)")
| {{ getItemName(item) }}
</template>

Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldText.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="jade">
input.form-control(type="text", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :maxlength="schema.max", :placeholder="schema.placeholder", :readonly="schema.readonly")
input.form-control(type="text", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :maxlength="schema.max", :pattern="schema.pattern", :placeholder="schema.placeholder", :readonly="schema.readonly")
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldTextArea.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="jade">
textarea.form-control(v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :maxlength="schema.max", :minlength="schema.min", :placeholder="schema.placeholder", :readonly="schema.readonly", :rows="schema.rows || 2")
textarea.form-control(v-model="value", :disabled="disabled", :maxlength="schema.max", :minlength="schema.min", :placeholder="schema.placeholder", :readonly="schema.readonly", :rows="schema.rows || 2")
</template>

<script>
Expand Down
20 changes: 12 additions & 8 deletions test/unit/specs/fields/fieldCheckbox.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";

import Vue from "vue";
import FieldCheckbox from "src/fields/fieldCheckbox.vue";
Expand All @@ -18,7 +18,8 @@ describe("FieldCheckbox.vue", function() {
let schema = {
type: "checkbox",
label: "Status",
model: "status"
model: "status",
autocomplete: "off"
};
let model = { status: true };
let input;
Expand All @@ -34,7 +35,7 @@ describe("FieldCheckbox.vue", function() {

expect(input).to.be.defined;
expect(input.type).to.be.equal("checkbox");
expect(input.disabled).to.be.false;
// expect(input.disabled).to.be.false;
});

it("should contain the value", (done) => {
Expand All @@ -44,11 +45,14 @@ describe("FieldCheckbox.vue", function() {
});
});

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
done();
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete", "disabled"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});

Expand Down
8 changes: 0 additions & 8 deletions test/unit/specs/fields/fieldChecklist.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ describe("fieldChecklist.vue", function() {
expect(isChecked(6)).to.be.true;
});

/*it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(listbox.disabled).to.be.true;
done();
});
});*/

it("listbox value should be the model value after changed", (done) => {
model.skills = ["ReactJS"];
vm.$nextTick( () => {
Expand Down
32 changes: 13 additions & 19 deletions test/unit/specs/fields/fieldCleave.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";

import Vue from "vue";
import FieldCleave from "src/fields/fieldCleave.vue";
Expand All @@ -19,8 +19,9 @@ describe("fieldCleave.vue", function() {
type: "masked",
label: "Phone",
model: "phone",
autocomplete: "off",
placeholder: "",
readonly: false,
placeholder: "Field placeholder",
cleaveOptions: {
phone: true,
phoneRegionCode: "HU",
Expand All @@ -41,9 +42,9 @@ describe("fieldCleave.vue", function() {
expect(input).to.be.defined;
expect(input.type).to.be.equal("text");
expect(input.classList.contains("form-control")).to.be.true;
expect(input.placeholder).to.be.equal(schema.placeholder);
expect(input.readOnly).to.be.false;
expect(input.disabled).to.be.false;
// expect(input.placeholder).to.be.equal(schema.placeholder);
// expect(input.readOnly).to.be.false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this old commented rows (other files too).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wasn't sure you wanted to delete them or not, so meanwhile, I commented them. I will clean things now !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are mindful. But if we covered with your new code we can delete them. Because after 3 months, we won't know it is a skipped tests (what need to fix) or unneccessary :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, make sense, sorry about that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nop, if you ready, I will merge it. 🎉

// expect(input.disabled).to.be.false;
});

it("should contain the value", (done) => {
Expand All @@ -53,21 +54,14 @@ describe("fieldCleave.vue", function() {
});
});

it("should set readOnly", (done) => {
schema.readonly = true;
vm.$nextTick( () => {
expect(input.readOnly).to.be.true;
schema.readonly = false;
done();
});
});
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete", "disabled", "readonly"];

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
field.disabled = false;
done();
attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});

Expand Down
20 changes: 12 additions & 8 deletions test/unit/specs/fields/fieldColor.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";

import Vue from "vue";
import FieldColor from "src/fields/fieldColor.vue";
Expand All @@ -18,7 +18,8 @@ describe("fieldColor.vue", function() {
let schema = {
type: "color",
label: "Color",
model: "color"
model: "color",
autocomplete: "off"
};
let model = { color: "#ff8822" };
let input;
Expand All @@ -35,7 +36,7 @@ describe("fieldColor.vue", function() {
expect(input).to.be.defined;
expect(input.type).to.be.equal("color");
//expect(input.classList.contains("form-control")).to.be.true;
expect(input.disabled).to.be.false;
// expect(input.disabled).to.be.false;
});

it("should contain the value", (done) => {
Expand All @@ -45,11 +46,14 @@ describe("fieldColor.vue", function() {
});
});

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
done();
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});

Expand Down
21 changes: 11 additions & 10 deletions test/unit/specs/fields/fieldDateTime.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";
import moment from "moment";

import Vue from "vue";
Expand All @@ -19,7 +19,10 @@ describe("fieldDateTime.vue", function() {
let schema = {
type: "dateTime",
label: "Event",
model: "event"
model: "event",
autocomplete: "off",
placeholder: "",
readonly: false
};
let model = { event: 1462799081231 };
let input;
Expand All @@ -46,15 +49,13 @@ describe("fieldDateTime.vue", function() {
});
});

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];

// Rollback
field.disabled = false;
vm.$nextTick( () => {
done();
attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});
Expand Down
32 changes: 14 additions & 18 deletions test/unit/specs/fields/fieldEmail.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";

import Vue from "vue";
import FieldEmail from "src/fields/fieldEmail.vue";
Expand All @@ -20,8 +20,9 @@ describe("fieldEmail.vue", function() {
type: "text",
label: "E-mail",
model: "email",
readonly: false,
placeholder: "Field placeholder"
autocomplete: "off",
placeholder: "Field placeholder",
readonly: false
};
let model = { email: "[email protected]" };
let input;
Expand All @@ -38,9 +39,9 @@ describe("fieldEmail.vue", function() {
expect(input).to.be.defined;
expect(input.type).to.be.equal("email");
expect(input.classList.contains("form-control")).to.be.true;
expect(input.placeholder).to.be.equal(schema.placeholder);
expect(input.readOnly).to.be.false;
expect(input.disabled).to.be.false;
// expect(input.placeholder).to.be.equal(schema.placeholder);
// expect(input.readOnly).to.be.false;
// expect(input.disabled).to.be.false;
});

it("should contain the value", (done) => {
Expand All @@ -50,19 +51,14 @@ describe("fieldEmail.vue", function() {
});
});

it("should set readOnly", (done) => {
schema.readonly = true;
vm.$nextTick( () => {
expect(input.readOnly).to.be.true;
done();
});
});
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
done();
attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});

Expand Down
34 changes: 14 additions & 20 deletions test/unit/specs/fields/fieldGoogleAddress.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";

import Vue from "vue";
import FieldGoogleAddress from "src/fields/fieldGoogleAddress.vue";
Expand All @@ -19,8 +19,9 @@ describe("fieldGoogleAddress.vue", function() {
type: "text",
label: "Address",
model: "address",
readonly: false,
placeholder: "Field placeholder"
autocomplete: "off",
placeholder: "Field placeholder",
readonly: false
};
let model = { address: "Paris, France" };
let input;
Expand All @@ -37,9 +38,9 @@ describe("fieldGoogleAddress.vue", function() {
expect(input).to.be.defined;
expect(input.type).to.be.equal("text");
expect(input.classList.contains("form-control")).to.be.true;
expect(input.placeholder).to.be.equal(schema.placeholder);
expect(input.readOnly).to.be.false;
expect(input.disabled).to.be.false;
// expect(input.placeholder).to.be.equal(schema.placeholder);
// expect(input.readOnly).to.be.false;
// expect(input.disabled).to.be.false;
});

it("should contain the value", (done) => {
Expand All @@ -49,21 +50,14 @@ describe("fieldGoogleAddress.vue", function() {
});
});

it("should set readOnly", (done) => {
schema.readonly = true;
vm.$nextTick( () => {
expect(input.readOnly).to.be.true;
schema.readonly = false;
done();
});
});
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
field.disabled = false;
done();
attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});

Expand Down
Loading