Skip to content

Commit

Permalink
fix data reseting, simpler/better ce
Browse files Browse the repository at this point in the history
  • Loading branch information
ctf0 committed Nov 2, 2017
1 parent e507c45 commit 56d5f9e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 31 deletions.
3 changes: 1 addition & 2 deletions src/resources/assets/js/Tabs/ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default {
selectedFileData: '',
selectedFileDataClone: '',
newKeys: '',
currentInputRef: '',
dataChanged: false,
newItemCounter: 0
}
Expand Down Expand Up @@ -127,7 +126,7 @@ export default {
selectedFile(val) {
this.$parent.selectedFileName = val
this.dataChanged = false
this.resetAll(['newKeys', 'currentInputRef'])
this.resetAll(['newKeys'])

if (val) {
this.getFileContent()
Expand Down
2 changes: 1 addition & 1 deletion src/resources/assets/js/Tabs/vendor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default {
},
selectedDir(val) {
this.$parent.selectedDirName = val
this.resetAll(['newKeys', 'currentInputRef'])
this.resetAll(['newKeys'])
if (val) {
this.newItemCounter = 0
Expand Down
40 changes: 12 additions & 28 deletions src/resources/assets/js/shared/content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@
:data-main-key="mainK"
v-html="mainK"
@keydown.enter.prevent
@keyup.tab="getPos($event)"
@input="getPos($event)"
@click="getPos($event)"
@blur="saveNewKey($event)"
@mouseleave="updateText($event)">
@input="newEntry()"
@blur="saveNewKey($event)">
</td>

<td v-for="(nestV, nestK, nestI) in mainV" :key="nestI"
Expand All @@ -75,11 +72,8 @@
:data-code="nestK"
v-html="nestV"
@keydown.enter.prevent
@keyup.tab="getPos($event)"
@input="getPos($event)"
@click="getPos($event)"
@blur="saveNewValue($event)"
@mouseleave="updateText($event)">
@input="newEntry()"
@blur="saveNewValue($event)">
</td>
<td width="1%">
<button class="button is-danger" @click="removeItem(mainK)">
Expand Down Expand Up @@ -146,7 +140,7 @@ export default{
}
},
updated() {
this.tableFloatHead($('table'), $('#menu').outerHeight(true))
this.tableFloatHead($('table'), 0)
this.tableColumnResize()
},
methods: {
Expand Down Expand Up @@ -236,28 +230,18 @@ export default{
setTimeout(() => {
this.selectedFile = old
}, 10)
}
this.parentMethod('resetAll', ['newKeys', 'currentInputRef', 'selectedFile'])
},
// contenteditable
getPos(e) {
// save a reference of current item
this.currentInputRef = e
},
updateText(e) {
let old = this.currentInputRef
if (old) {
// save changes on mouse move
e.target.blur()
// set focus back
old.target.focus()
this.parentMethod('resetAll', ['newKeys', 'selectedFile'])
}
this.parentMethod('resetAll', ['newKeys'])
},
// util
newEntry() {
this.dataChanged = true
this.parentMethod('reflowTable')
},
saveNewKey(e) {
this.parentMethod('reflowTable')
let old_key = e.target.dataset.mainKey
Expand Down

0 comments on commit 56d5f9e

Please sign in to comment.