parsley/app/javascript/components/TaskItemEdit.vue

64 lines
1.2 KiB
Vue
Raw Normal View History

2018-09-05 17:49:21 -05:00
<template>
<div>
<div class="field">
<label class="label is-small">Name</label>
<div class="control">
<input class="input is-small" type="text" placeholder="Name" v-model="taskItem.name" @keydown="inputKeydown" ref="nameInput">
</div>
</div>
<div class="field">
<label class="label is-small">Quantity</label>
<div class="control">
<input class="input is-small" type="text" placeholder="Qty" v-model="taskItem.quantity" @keydown="inputKeydown">
</div>
</div>
<div class="field">
<div class="control">
2018-09-06 18:16:13 -05:00
<button class="button is-primary" @click="save">Add</button>
2018-09-05 17:49:21 -05:00
</div>
</div>
</div>
</template>
<script>
export default {
props: {
taskItem: {
required: true,
type: Object
}
},
methods: {
inputKeydown(evt) {
switch (evt.key) {
case "Enter":
evt.preventDefault();
this.save();
}
},
save() {
this.$emit("save", this.taskItem);
2018-09-06 18:16:13 -05:00
},
focus() {
this.$refs.nameInput.focus();
2018-09-05 17:49:21 -05:00
}
},
mounted() {
2018-09-06 18:16:13 -05:00
this.focus();
2018-09-05 17:49:21 -05:00
}
}
</script>
<style lang="scss" scoped>
</style>