Browse Source

refactor(gui): update debounce time, show loader instead of toaster(on save)

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/865/head
Pranav C 3 years ago
parent
commit
2cfcfe0100
  1. 12
      packages/nc-gui/components/project/spreadsheet/components/editableCell.vue
  2. 8
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue
  3. 14
      packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue

12
packages/nc-gui/components/project/spreadsheet/components/editableCell.vue

@ -5,7 +5,7 @@
@keydown.stop.right @keydown.stop.right
@keydown.stop.up @keydown.stop.up
@keydown.stop.down @keydown.stop.down
@keydown.stop.enter="$emit('save')" @keydown.stop.enter="cahnged=false,$emit('save')"
> >
<editable-attachment-cell <editable-attachment-cell
v-if="isAttachment" v-if="isAttachment"
@ -170,7 +170,7 @@ export default {
destroyed: false, destroyed: false,
syncDataDebounce: debounce(async function(self) { syncDataDebounce: debounce(async function(self) {
await self.syncData() await self.syncData()
}, 500) }, 1000)
}), }),
computed: { computed: {
localState: { localState: {
@ -180,10 +180,14 @@ export default {
set(val) { set(val) {
this.changed = true this.changed = true
if (val !== this.value) { if (val !== this.value) {
this.$emit('input', val)
// debugger // debugger
this.syncDataDebounce(this) if (this.isAttachment || this.isEnum || this.isBoolean || this.isSet || this.isTime) {
this.syncData()
} else {
this.syncDataDebounce(this)
}
} }
this.$emit('input', val)
} }
}, },
parentListeners() { parentListeners() {

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

@ -951,9 +951,9 @@ export default {
oldRow: { ...insertedData } oldRow: { ...insertedData }
}) })
this.$toast.success(`${insertedData[this.primaryValueColumn] ? `${insertedData[this.primaryValueColumn]}'s r` : 'R'}ow saved successfully.`, { /* this.$toast.success(`${insertedData[this.primaryValueColumn] ? `${insertedData[this.primaryValueColumn]}'s r` : 'R'}ow saved successfully.`, {
position: 'bottom-center' position: 'bottom-center'
}).goAway(3000) }).goAway(3000) */
} catch (e) { } catch (e) {
if (e.response && e.response.data && e.response.data.msg) { if (e.response && e.response.data && e.response.data.msg) {
this.$toast.error(e.response.data.msg).goAway(3000) this.$toast.error(e.response.data.msg).goAway(3000)
@ -1008,9 +1008,9 @@ export default {
this.$set(this.data[row], 'row', { ...rowObj, ...newData }) this.$set(this.data[row], 'row', { ...rowObj, ...newData })
this.$set(oldRow, column._cn, rowObj[column._cn]) this.$set(oldRow, column._cn, rowObj[column._cn])
this.$toast.success(`${rowObj[this.primaryValueColumn] ? `${rowObj[this.primaryValueColumn]}'s c` : 'C'}olumn '${column.cn}' updated successfully.`, { /* this.$toast.success(`${rowObj[this.primaryValueColumn] ? `${rowObj[this.primaryValueColumn]}'s c` : 'C'}olumn '${column.cn}' updated successfully.`, {
position: 'bottom-center' position: 'bottom-center'
}).goAway(3000) }).goAway(3000) */
} catch (e) { } catch (e) {
if (e.response && e.response.data && e.response.data.msg) { if (e.response && e.response.data && e.response.data.msg) {
this.$toast.error(e.response.data.msg).goAway(3000) this.$toast.error(e.response.data.msg).goAway(3000)

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

@ -97,7 +97,7 @@
</thead> </thead>
<tbody v-click-outside="onClickOutside"> <tbody v-click-outside="onClickOutside">
<tr <tr
v-for="({row:rowObj, rowMeta},row) in data" v-for="({row:rowObj, rowMeta, saving},row) in data"
:key="row" :key="row"
class=" nc-grid-row" class=" nc-grid-row"
> >
@ -112,6 +112,7 @@
class="ml-2 grey--text" class="ml-2 grey--text"
:class="{ 'row-no' : !isPublicView }" :class="{ 'row-no' : !isPublicView }"
>{{ row + 1 }}</span> >{{ row + 1 }}</span>
<template v-if="!isPublicView"> <template v-if="!isPublicView">
<v-checkbox <v-checkbox
v-if="rowMeta" v-if="rowMeta"
@ -122,7 +123,7 @@
/> />
<v-spacer /> <v-spacer />
<v-icon <v-icon
v-if="!groupedAggCount[ids[row]] && !isLocked" v-if="!groupedAggCount[ids[row]] && !isLocked && !saving"
color="pink" color="pink"
small small
class="row-expand-icon nc-row-expand-icon mr-1 pointer" class="row-expand-icon nc-row-expand-icon mr-1 pointer"
@ -132,13 +133,20 @@
</v-icon> </v-icon>
</template> </template>
<v-chip <v-chip
v-if="groupedAggCount[ids[row]]" v-if="groupedAggCount[ids[row]] && !saving"
x-small x-small
:color="colors[ groupedAggCount[ids[row]] % colors.length]" :color="colors[ groupedAggCount[ids[row]] % colors.length]"
@click="expandRow(row,rowMeta)" @click="expandRow(row,rowMeta)"
> >
{{ groupedAggCount[ids[row]] }} {{ groupedAggCount[ids[row]] }}
</v-chip> </v-chip>
<template v-if="saving">
<v-spacer />
<v-icon small>
mdi-spin mdi-loading
</v-icon>
</template>
</div> </div>
</td> </td>
<td <td

Loading…
Cancel
Save