Browse Source

fix: avoid duplicating record on new row creation

re #779

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/764/head
Pranav C 3 years ago
parent
commit
037e957741
  1. 1
      packages/nc-gui/components/ProjectTreeView.vue
  2. 9
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue
  3. 3
      packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue

1
packages/nc-gui/components/ProjectTreeView.vue

@ -27,6 +27,7 @@
</v-btn>-->
<v-text-field
v-else
v-model="search"
placeholder="Search tables"
dense

9
packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue

@ -933,15 +933,18 @@ export default {
if (!this.data[row]) {
return
}
const { row: rowObj, rowMeta, oldRow } = this.data[row]
const { row: rowObj, rowMeta, oldRow, saving } = this.data[row]
if (rowMeta.new) {
// return if there is no change
if (oldRow[column._cn] === rowObj[column._cn] || saving) {
return
}
await this.save()
} else {
try {
if (!this.api) {
return
}
// return if there is no change
if (oldRow[column._cn] === rowObj[column._cn]) {
return
@ -953,7 +956,7 @@ export default {
return this.$toast.info('Update not allowed for table which doesn\'t have primary Key').goAway(3000)
}
this.$set(this.data[row], 'saving', true)
// eslint-disable-next-line promise/param-names
const newData = await this.api.update(id, {
[column._cn]: rowObj[column._cn]
}, { [column._cn]: oldRow[column._cn] })

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

@ -194,7 +194,6 @@
@save="editEnabled = {}"
@cancel="editEnabled = {}"
@update="onCellValueChange(col, row, columnObj)"
@blur="onCellValueChange(col, row, columnObj,'blur')"
@change="onCellValueChange(col, row, columnObj)"
/>
@ -486,6 +485,8 @@ export default {
}
this.selected.col = null
this.selected.row = null
this.editEnabled.col = null
this.editEnabled.row = null
},
onNewColCreation(col, oldCol) {
this.addNewColMenu = false

Loading…
Cancel
Save