Skip to content

Commit

Permalink
Implement #78
Browse files Browse the repository at this point in the history
Add `name` attr to input, select and textarea fields
  • Loading branch information
icebob committed Sep 26, 2016
1 parent deb50b6 commit f92b193
Show file tree
Hide file tree
Showing 41 changed files with 55 additions and 52 deletions.
4 changes: 3 additions & 1 deletion dev/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module.exports = {
type: "input",
inputType: "hidden",
label: "Hidden",
model: "id"
model: "id",
inputName: "hiddenField"
},
{
type: "input",
Expand Down Expand Up @@ -57,6 +58,7 @@ module.exports = {
label: "URL",
model: "website",
placeholder: "Enter your website",
inputName: "website",
validator: validators.url
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldCheckbox.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="jade">
input(type="checkbox", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled")
input(type="checkbox", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :name="schema.inputName")
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldCleave.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", :placeholder="schema.placeholder", :readonly="schema.readonly")
input.form-control(type="text", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :placeholder="schema.placeholder", :readonly="schema.readonly", :name="schema.inputName")
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldColor.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="jade">
.wrapper
input(type="color", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled")
input(type="color", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :name="schema.inputName")
span.helper {{ value }}
</template>

Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldDateTimePicker.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="jade">
.input-group.date
input.form-control(type="text", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :placeholder="schema.placeholder", :readonly="schema.readonly")
input.form-control(type="text", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :placeholder="schema.placeholder", :readonly="schema.readonly", :name="schema.inputName")
span.input-group-addon
span.glyphicon.glyphicon-calendar
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldEmail.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="jade">
input.form-control(type="email", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :placeholder="schema.placeholder", :readonly="schema.readonly")
input.form-control(type="email", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :placeholder="schema.placeholder", :readonly="schema.readonly", :name="schema.inputName")
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldGoogleAddress.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", :placeholder="schema.placeholder", :readonly="schema.readonly", debounce="500", @focus="geolocate()")
input.form-control(type="text", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :placeholder="schema.placeholder", :readonly="schema.readonly", :name="schema.inputName", debounce="500", @focus="geolocate()")
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldImage.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template lang="jade">
div.wrapper
input.form-control.link(type="text", v-show="schema.hideInput !== true", v-model="wrappedValue", :autocomplete="schema.autocomplete", :disabled="disabled", :placeholder="schema.placeholder", :readonly="schema.readonly")
input.form-control.file(type="file", v-if="schema.browse !== false", :disabled="disabled", @change="fileChanged")
input.form-control.file(type="file", v-if="schema.browse !== false", :disabled="disabled", @change="fileChanged", :name="schema.inputName")
.preview(:style="previewStyle")
.remove(title="Remove image", @click="remove")
</template>
Expand Down
1 change: 1 addition & 0 deletions src/fields/fieldInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
:maxlength="schema.maxlength",
:min="schema.min",
:multiple="schema.multiple",
:name="schema.inputName",
:pattern="schema.pattern",
:placeholder="schema.placeholder",
:readonly="schema.readonly",
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldMasked.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", :placeholder="schema.placeholder", :readonly="schema.readonly")
input.form-control(type="text", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :placeholder="schema.placeholder", :readonly="schema.readonly", :name="schema.inputName")
</template>

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

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

<script>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldPikaday.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", :placeholder="schema.placeholder", :readonly="schema.readonly")
input.form-control(type="text", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :placeholder="schema.placeholder", :readonly="schema.readonly", :name="schema.inputName")
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldRange.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="jade">
.wrapper
input.form-control(type="range", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :max="schema.max", :min="schema.min")
input.form-control(type="range", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :max="schema.max", :min="schema.min", :name="schema.inputName")
.helpText {{ value }}
</template>

Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldRangeSlider.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="jade">
input(type="text", :autocomplete="schema.autocomplete", :data-disable="disabled", :data-max="schema.max", :data-min="schema.min", :data-step="schema.step", :placeholder="schema.placeholder", :readonly="schema.readonly")
input(type="text", :autocomplete="schema.autocomplete", :data-disable="disabled", :data-max="schema.max", :data-min="schema.min", :data-step="schema.step", :placeholder="schema.placeholder", :readonly="schema.readonly", :name="schema.inputName")
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldSelect.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="jade">
select.form-control(v-model="value", :disabled="disabled")
select.form-control(v-model="value", :disabled="disabled", :name="schema.inputName")
option(:disabled="schema.required", :value="null", :selected="value == undefined") &lt;Not selected&gt;
option(v-for="item in items", :value="getItemID(item)") {{ getItemName(item) }}
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldSelectEx.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="jade">
select.selectpicker(v-model="value", :disabled="disabled", :multiple="schema.multiSelect", :title="schema.placeholder", data-width="100%")
select.selectpicker(v-model="value", :disabled="disabled", :multiple="schema.multiSelect", :title="schema.placeholder", data-width="100%", :name="schema.inputName")
option(:disabled="schema.required", v-if="schema.multiSelect !== true", :value="null", :selected="value == undefined") &lt;Not selected&gt;
option(v-for="item in items", :value="getItemID(item)") {{ getItemName(item) }}
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldSpectrum.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="jade">
input(type="text", :autocomplete="schema.autocomplete", :disabled="disabled", :placeholder="schema.placeholder", :readonly="schema.readonly")
input(type="text", :autocomplete="schema.autocomplete", :disabled="disabled", :placeholder="schema.placeholder", :readonly="schema.readonly", :name="schema.inputName")
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldSubmit.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="jade">
input(type="submit", :value="schema.buttonText", @click="click")
input(type="submit", :value="schema.buttonText", @click="click", :name="schema.inputName")
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fieldSwitch.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="jade">
label
input(type="checkbox", v-model="value", :disabled="disabled")
input(type="checkbox", v-model="value", :disabled="disabled", :name="schema.inputName")
span.label(:data-on="schema.textOn || 'On'", :data-off="schema.textOff || 'Off'")
span.handle
</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", :pattern="schema.pattern", :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", :name="schema.inputName")
</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", :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", :name="schema.inputName")
</template>

<script>
Expand Down
5 changes: 2 additions & 3 deletions test/unit/specs/fields/fieldCheckbox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ describe("FieldCheckbox.vue", function() {
let schema = {
type: "checkbox",
label: "Status",
model: "status",
autocomplete: "off"
model: "status"
};
let model = { status: true };
let input;
Expand All @@ -45,7 +44,7 @@ describe("FieldCheckbox.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled"];
let attributes = ["autocomplete", "disabled", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldCleave.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("fieldCleave.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled", "readonly"];
let attributes = ["autocomplete", "disabled", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldColor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("fieldColor.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete"];
let attributes = ["autocomplete", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldDateTimePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("fieldDateTimePicker.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];
let attributes = ["autocomplete", "disabled", "placeholder", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldEmail.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("fieldEmail.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];
let attributes = ["autocomplete", "disabled", "placeholder", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldGoogleAddress.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("fieldGoogleAddress.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];
let attributes = ["autocomplete", "disabled", "placeholder", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
16 changes: 8 additions & 8 deletions test/unit/specs/fields/fieldInput.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ describe("fieldInput.vue", function() {
});

let inputTypes = new Map([
["text", ["autocomplete", "disabled", "placeholder", "readonly"]],
["password", ["autocomplete", "disabled", "placeholder", "readonly"]],
["checkbox", ["autocomplete", "disabled"]],
["text", ["autocomplete", "disabled", "placeholder", "readonly", "inputName"]],
["password", ["autocomplete", "disabled", "placeholder", "readonly", "inputName"]],
["checkbox", ["autocomplete", "disabled", "inputName"]],
// ["radio", [] ],
// ["button", [] ],
// ["submit", [] ],
Expand All @@ -65,13 +65,13 @@ describe("fieldInput.vue", function() {
// ["month", ],
// ["time", ],
// ["week", ],
["number", ["autocomplete", "disabled", "placeholder", "readonly"]],
["number", ["autocomplete", "disabled", "placeholder", "readonly", "inputName"]],
// ["range", ["autocomplete"]],
["email", ["autocomplete", "disabled", "placeholder", "readonly"]],
["url", ["autocomplete", "disabled", "placeholder", "readonly"]],
["email", ["autocomplete", "disabled", "placeholder", "readonly", "inputName"]],
["url", ["autocomplete", "disabled", "placeholder", "readonly", "inputName"]],
// ["search", ],
["tel", ["autocomplete", "disabled", "placeholder", "readonly"]],
["color", ["autocomplete"]]
["tel", ["autocomplete", "disabled", "placeholder", "readonly", "inputName"]],
["color", ["autocomplete", "inputName"]]
]);
for (let [inputType, attributes] of inputTypes) {

Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldMasked.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("fieldMasked.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];
let attributes = ["autocomplete", "disabled", "placeholder", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldNumber.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("fieldNumber.vue", function() {
});
});
describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];
let attributes = ["autocomplete", "disabled", "placeholder", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldPassword.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("fieldPassword.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];
let attributes = ["autocomplete", "disabled", "placeholder", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldPikaday.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("fieldPikaday.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];
let attributes = ["autocomplete", "disabled", "placeholder", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldRange.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("fieldRange.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled"];
let attributes = ["autocomplete", "disabled", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldRangeSlider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("fieldRangeSlider.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "placeholder", "readonly"];
let attributes = ["autocomplete", "placeholder", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldSelect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("fieldSelect.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["disabled"];
let attributes = ["disabled", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldSelectEx.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("fieldSelectEx.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["disabled", "multiSelect"];
let attributes = ["disabled", "multiSelect", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldSpectrum.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("fieldSpectrum.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];
let attributes = ["autocomplete", "disabled", "placeholder", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldText.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("fieldText.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];
let attributes = ["autocomplete", "disabled", "placeholder", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/fields/fieldTextArea.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("fieldTextArea.vue", function() {
});

describe("check optional attribute", () => {
let attributes = ["disabled", "placeholder", "readonly"];
let attributes = ["disabled", "placeholder", "readonly", "inputName"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
Expand Down
9 changes: 5 additions & 4 deletions test/unit/specs/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export let attributesList = {
"disabled": { before: true, after: false, field: true },
"multiSelect": { before: true, after: false, name: "multiple" },
"placeholder": { before: "Field placeholder", after: "" },
"readonly": { before: true, after: false, name: "readOnly" }

"readonly": { before: true, after: false, name: "readOnly" },
"inputName": { before: "test-name", after: "", name: "name" }
};

export function checkAttribute(name, vm, input, field, schema, done) {
Expand All @@ -66,14 +66,15 @@ export function checkAttribute(name, vm, input, field, schema, done) {
} else {
schematic = schema;
}
schematic[name] = attr.before;

vm.$set("schema." + name, attr.before);
vm.$nextTick(() => {
if (attr.name) {
expect(input[attr.name]).to.be.equal(schematic[name]);
} else {
expect(input[name]).to.be.equal(schematic[name]);
}
schematic[name] = attr.after;
vm.$set("schema." + name, attr.after);
return done();
});
}

0 comments on commit f92b193

Please sign in to comment.