Browse Source

fix: avoid mutating hooks meta object, handle consecutive checkbox click

re #809, #734

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/764/head
Pranav C 3 years ago
parent
commit
1cbaaab6bf
  1. 56
      packages/nc-gui/components/project/spreadsheet/components/editableCell.vue
  2. 12
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue
  3. 2
      packages/nc-gui/components/project/tableTabs/webhooks.vue
  4. 2
      packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts

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

@ -167,28 +167,11 @@ export default {
}, },
data: () => ({ data: () => ({
changed: false, changed: false,
destroyed: false destroyed: false,
}),
mounted() {
// this.$refs.input.focus();
},
beforeDestroy() {
if (this.changed && !(this.isAttachment || this.isEnum || this.isBoolean || this.isSet || this.isTime)) {
this.$emit('change')
}
this.destroyed = true
},
methods: {
syncDataDebounce: debounce(async function(self) { syncDataDebounce: debounce(async function(self) {
await self.syncData() await self.syncData()
}, 1000), }, 500)
syncData() { }),
if (!this.destroyed) {
this.$emit('update')
}
}
},
computed: { computed: {
localState: { localState: {
get() { get() {
@ -196,7 +179,10 @@ export default {
}, },
set(val) { set(val) {
this.changed = true this.changed = true
if (val !== this.value) { this.syncDataDebounce(this) } if (val !== this.value) {
// debugger
this.syncDataDebounce(this)
}
this.$emit('input', val) this.$emit('input', val)
} }
}, },
@ -221,6 +207,23 @@ export default {
return $listeners return $listeners
} }
},
mounted() {
// this.$refs.input.focus();
},
beforeDestroy() {
if (this.changed && !(this.isAttachment || this.isEnum || this.isBoolean || this.isSet || this.isTime)) {
this.$emit('change')
}
this.destroyed = true
},
methods: {
syncData() {
if (!this.destroyed) {
this.$emit('update')
}
}
} }
} }
</script> </script>
@ -232,21 +235,22 @@ div {
color: var(--v-textColor-base); color: var(--v-textColor-base);
} }
.nc-hint{ .nc-hint {
font-size: .61rem; font-size: .61rem;
color:grey; color: grey;
} }
.nc-cell { .nc-cell {
position: relative; position: relative;
} }
.nc-locked-overlay { .nc-locked-overlay {
position: absolute; position: absolute;
z-index: 2; z-index: 2;
height: 100%; height: 100%;
width: 100%; width: 100%;
top:0; top: 0;
left:0; left: 0;
} }
</style> </style>
<!-- <!--

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

@ -597,6 +597,12 @@ export default {
showTabs: [Boolean, Number] showTabs: [Boolean, Number]
}, },
data: () => ({ data: () => ({
syncDataDebounce: debounce(async function(self) {
await self.syncData()
}, 500),
loadTableDataDeb: debounce(async function(self) {
await self.loadTableDataFn()
}, 200),
viewKey: 0, viewKey: 0,
extraViewParams: {}, extraViewParams: {},
debug: false, debug: false,
@ -779,9 +785,6 @@ export default {
this.$refs.ncgridview.xcAuditModelCommentsCount() this.$refs.ncgridview.xcAuditModelCommentsCount()
} }
}, },
syncDataDebounce: debounce(async function(self) {
await self.syncData()
}, 500),
async syncData() { async syncData() {
if (this.relation) { if (this.relation) {
return return
@ -1102,9 +1105,6 @@ export default {
} }
} }
}, },
loadTableDataDeb: debounce(async function(self) {
await self.loadTableDataFn()
}, 200),
loadTableData() { loadTableData() {
this.loadTableDataDeb(this) this.loadTableDataDeb(this)
}, },

2
packages/nc-gui/components/project/tableTabs/webhooks.vue

@ -529,7 +529,7 @@ export default {
type type
} }
} }
this.enableCondition = !!this.hook.condition this.enableCondition = !!(this.hook && Object.keys(this.hook.condition).length)
await this.onNotTypeChange() await this.onNotTypeChange()
this.notification = payload this.notification = payload
if (this.hook.notification.type === 'Slack') { if (this.hook.notification.type === 'Slack') {

2
packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts

@ -2165,7 +2165,7 @@ class BaseModelSql extends BaseModel {
); );
obj.offset = Math.max(+(args.offset || args.o) || 0, 0); obj.offset = Math.max(+(args.offset || args.o) || 0, 0);
obj.fields = args.fields || args.f || '*'; obj.fields = args.fields || args.f || '*';
obj.sort = args.sort || args.s; obj.sort = args.sort || args.s || this.pks?.[0]?.cn;
return obj; return obj;
} }

Loading…
Cancel
Save