Browse Source

Merge pull request #1640 from mertmit/cell-update-onunload

fix: force cell update on unload if unsaved
pull/1672/head
աɨռɢӄաօռɢ 3 years ago committed by GitHub
parent
commit
abbcf94339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue

16
packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue

@ -225,6 +225,7 @@
@cancel="editEnabled = {};" @cancel="editEnabled = {};"
@update="onCellValueChange(col, row, columnObj, false)" @update="onCellValueChange(col, row, columnObj, false)"
@blur="onCellValueChange(col, row, columnObj, true)" @blur="onCellValueChange(col, row, columnObj, true)"
@input="unsaved = true"
@navigateToNext="navigateToNext" @navigateToNext="navigateToNext"
@navigateToPrev="navigateToPrev" @navigateToPrev="navigateToPrev"
/> />
@ -343,7 +344,8 @@ export default {
}, },
aggCount: [], aggCount: [],
dragOver: false, dragOver: false,
gridViewCols: {} gridViewCols: {},
unsaved: false
}), }),
computed: { computed: {
selectAll: { selectAll: {
@ -419,6 +421,15 @@ export default {
document.addEventListener('keydown', this.onKeyDown) document.addEventListener('keydown', this.onKeyDown)
this.loadGridViewCols() this.loadGridViewCols()
this.xcAuditModelCommentsCount() this.xcAuditModelCommentsCount()
const self = this
window.addEventListener('beforeunload', function() {
if (self.unsaved) {
if (self.editEnabled.row != null && self.editEnabled.row != null) {
const columnObj = self.availableColumns[self.editEnabled.col]
self.onCellValueChange(self.editEnabled.col, self.editEnabled.row, columnObj, true)
}
}
})
}, },
beforeDestroy() { beforeDestroy() {
document.removeEventListener('keydown', this.onKeyDown) document.removeEventListener('keydown', this.onKeyDown)
@ -648,6 +659,9 @@ export default {
}, },
onCellValueChange(col, row, column, saved) { onCellValueChange(col, row, column, saved) {
this.$emit('onCellValueChange', col, row, column, saved) this.$emit('onCellValueChange', col, row, column, saved)
if (saved) {
this.unsaved = false
}
}, },
navigateToNext() { navigateToNext() {
if (this.selected.row < this.rowLength - 1) { if (this.selected.row < this.rowLength - 1) {

Loading…
Cancel
Save