Skip to content

Commit

Permalink
Add global input component.
Browse files Browse the repository at this point in the history
  • Loading branch information
sustained committed Feb 26, 2019
1 parent 2cea8d8 commit 72ef296
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/components/global/CelloInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<template>
<input v-focus v-model="model" @focus="focus" @blur="blur" @keydown="keydown" type="text">
</template>

<script>
export default {
props: ["data", "active"],
data() {
return { model: "", initialValue: "" };
},
mounted() {
this.model = this.initialValue = this.data;
},
methods: {
focus() {
this.$emit("editing", true);
this.$store.commit("DISABLE_NAVIGATION");
},
blur() {
if (this.model !== this.initialValue) this.initialValue = this.model;
this.$emit("edited", this.model);
this.$emit("editing", false);
this.$store.commit("ENABLE_NAVIGATION");
},
keydown(event) {
if (event.key === "Enter" || event.key === "Escape") {
this.blur();
}
}
}
};
</script>

<style scoped>
</style>

0 comments on commit 72ef296

Please sign in to comment.