parsley/app/javascript/components/TaskListMiniForm.vue

48 lines
996 B
Vue
Raw Normal View History

2018-08-28 16:52:56 -05:00
<template>
<div>
<app-validation-errors :errors="validationErrors"></app-validation-errors>
<label class="label is-small">Add New List</label>
<div class="field has-addons">
<div class="control">
<input class="input is-small" type="text" v-model="taskList.name" @keydown="nameKeydownHandler">
</div>
<div class="control">
<button type="button" class="button is-primary is-small" @click="save">Add</button>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
taskList: {
required: true,
type: Object
},
validationErrors: {
required: false,
type: Object,
default: function() { return {}; }
}
},
methods: {
save() {
this.$emit("save");
},
nameKeydownHandler(evt) {
switch (evt.key) {
case "Enter":
evt.preventDefault();
this.save();
}
}
}
}
</script>