Browse Source

refactor(gui): code refactoring

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/865/head
Pranav C 3 years ago
parent
commit
29a577d231
  1. 4
      packages/nc-gui/components/ProjectTreeView.vue
  2. 8
      packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js
  3. 8
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue

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

@ -170,11 +170,11 @@
<template <template
v-else v-else
> >
<span v-if="item.type === 'tableDir'" class="caption font-weight-regular" v-on="on"> <span v-if="item.type === 'tableDir'" class="caption font-weight-regular">
Tables<template v-if="item.children && item.children.length"> ({{ Tables<template v-if="item.children && item.children.length"> ({{
item.children.filter(child => !search || child.name.toLowerCase().includes(search.toLowerCase())).length item.children.filter(child => !search || child.name.toLowerCase().includes(search.toLowerCase())).length
}})</template></span> }})</template></span>
<span v-else class="caption font-weight-regular" v-on="on"> <span v-else class="caption font-weight-regular">
{{ item.name }}</span> {{ item.name }}</span>
</template> </template>
</v-list-item-title> </v-list-item-title>

8
packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js

@ -9,7 +9,10 @@ export default {
showFields: {}, showFields: {},
// fieldList: [], // fieldList: [],
// meta: {}, // meta: {},
data: [] data: [],
syncDataDebounce() {
// not implemented
}
}), }),
methods: { methods: {
mapFieldsAndShowFields() { mapFieldsAndShowFields() {
@ -19,9 +22,6 @@ export default {
return obj return obj
}, {}) }, {})
}, },
syncDataDebounce() {
// not implemented
},
onKeyDown(e) { onKeyDown(e) {
if (this.selected.col === null || this.selected.row === null) { if (this.selected.col === null || this.selected.row === null) {
return return

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

@ -1040,14 +1040,14 @@ export default {
await this.api.delete(id) await this.api.delete(id)
} }
this.data.splice(this.rowContextMenu.index, 1) this.data.splice(this.rowContextMenu.index, 1)
this.$toast.success('Deleted row successfully').goAway(3000) // this.$toast.success('Deleted row successfully').goAway(3000)
} catch (e) { } catch (e) {
this.$toast.error(`Failed to delete row : ${e.message}`).goAway(3000) this.$toast.error(`Failed to delete row : ${e.message}`).goAway(3000)
} }
}, },
async deleteSelectedRows() { async deleteSelectedRows() {
let row = this.rowLength let row = this.rowLength
let success = 0 // let success = 0
while (row--) { while (row--) {
try { try {
const { row: rowObj, rowMeta } = this.data[row] const { row: rowObj, rowMeta } = this.data[row]
@ -1064,12 +1064,12 @@ export default {
await this.api.delete(id) await this.api.delete(id)
} }
this.data.splice(row, 1) this.data.splice(row, 1)
success++ // success++
} catch (e) { } catch (e) {
return this.$toast.error(`Failed to delete row : ${e.message}`).goAway(3000) return this.$toast.error(`Failed to delete row : ${e.message}`).goAway(3000)
} }
} }
if (success) { this.$toast.success(`Deleted ${success} selected row${success > 1 ? 's' : ''} successfully`).goAway(3000) } // if (success) { this.$toast.success(`Deleted ${success} selected row${success > 1 ? 's' : ''} successfully`).goAway(3000) }
}, },
async clearCellValue() { async clearCellValue() {

Loading…
Cancel
Save