-
-
Notifications
You must be signed in to change notification settings - Fork 135
/
scrapcode.txt
65 lines (57 loc) · 1.92 KB
/
scrapcode.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<template>
<v-tabs>
<!-- v-tab-item component is used to define the content of a specific tab in a tab group -->
<v-tab-item>
<!-- if the tab is in editMode, become a text field for project name entry -->
<v-tab v-if="editMode" class="has-background-white tab-entry">
<!-- if we're editing, bind editedProjectName state to text field -->
<!-- call onEdit when in edit mode -->
<!-- @blur event listener is used to handle the blur event on the v-text-field.
The onBlur method is called when the field loses focus
when the user clicks outside the field or presses the Tab key -->
<v-text-field v-model="editedProjectName" @input="onEdit" @blur="onBlur" class="tab-entry"/>
</v-tab>
<!-- if not already editing, click to edit and display project getter return val -->
<v-tab v-else @click="enterEditMode" class="has-background-white tab-entry">{{ editedProjectName }}</v-tab>
</v-tab-item>
</v-tabs>
</template>
<script>
import { mapActions } from 'vuex';
export default {
name: 'ProjectTabs',
data() {
return {
// initial local state values
editMode: false,
editedProjectName: this.$store.state.editedProjectName,
};
},
methods: {
...mapActions(['updateProjectName']),
// on click
enterEditMode() {
this.editMode = true;
this.editedProjectName = this.$store.state.editedProjectName;
},
onEdit(event) {
this.editedProjectName = event.target.value;
},
// Exit edit mode on blur
onBlur() {
this.editMode = false;
this.updateProjectName(this.editedProjectName);
console.log('this.editedProjectName is', this.editedProjectName);
console.log('this.$store.state.editedProjectName is', this.$store.state.editedProjectName);
},
},
};
</script>
<style lang="scss" scoped>
.has-background-white {
font-weight: 700;
}
.tab-entry {
width: 135px;
}
</style>