Skip to content

Commit

Permalink
Add an option to hide the none selected text
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Bijaoui committed Jun 21, 2017
1 parent c30cbbf commit b4d2b34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/fields/core/fieldSelect.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="pug">
select.form-control(v-model="value", :disabled="disabled", :name="schema.inputName", :id="getFieldID(schema)")
option(:disabled="schema.required", :value="null", :selected="value == undefined") {{ selectOptions.noneSelectedText || "&lt;Nothing selected&gt;" }}
option(v-if="!selectOptions.hideNoneSelectedText", :disabled="schema.required", :value="null", :selected="value == undefined") {{ selectOptions.noneSelectedText || "&lt;Nothing selected&gt;" }}
option(v-for="item in items", :value="getItemID(item)") {{ getItemName(item) }}
</template>

Expand Down
16 changes: 16 additions & 0 deletions test/unit/specs/fields/fieldSelect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,22 @@ describe("fieldSelect.vue", function() {
});
});

it("should hide the customized <non selected> text", (done) => {
Vue.set(vm.schema, "selectOptions", {
noneSelectedText: "Empty list",
hideNoneSelectedText: true
});
vm.$nextTick( () => {
let options = input.querySelectorAll("option");
expect(options[0].disabled).to.be.false;
expect(options[0].textContent).to.not.be.equal("Empty list");

schema.selectOptions = null;

done();
});
});

});

describe("check static values with { id, name } objects", () => {
Expand Down

0 comments on commit b4d2b34

Please sign in to comment.