Browse Source

fix(gui-v2): add isUIAllowed('sortSync')

pull/3087/head
Wing-Kam Wong 2 years ago
parent
commit
eef898dbe5
  1. 12
      packages/nc-gui-v2/composables/useViewSorts.ts

12
packages/nc-gui-v2/composables/useViewSorts.ts

@ -18,12 +18,15 @@ export function useViewSorts(
} }
const saveOrUpdate = async (sort: SortType, i: number) => { const saveOrUpdate = async (sort: SortType, i: number) => {
if (!isUIAllowed('sortSync') || !sorts?.value) return // TODO:
// if (!this.shared && this._isUIAllowed('sortSync')) {
if (isUIAllowed('sortSync')) {
if (sort.id) { if (sort.id) {
await $api.dbTableSort.update(sort.id, sort) await $api.dbTableSort.update(sort.id, sort)
} else { } else {
sorts.value[i] = (await $api.dbTableSort.create(view?.value?.id as string, sort)) as any sorts.value[i] = (await $api.dbTableSort.create(view?.value?.id as string, sort)) as any
} }
}
reloadData?.() reloadData?.()
} }
const addSort = () => { const addSort = () => {
@ -33,12 +36,13 @@ export function useViewSorts(
} }
const deleteSort = async (sort: SortType, i: number) => { const deleteSort = async (sort: SortType, i: number) => {
// TOOD:
// if (!this.shared && sort.id && this._isUIAllowed('sortSync')) { // if (!this.shared && sort.id && this._isUIAllowed('sortSync')) {
if (!isUIAllowed('sortSync')) return if (isUIAllowed('sortSync') && sort.id) {
if (sort.id) {
await $api.dbTableSort.delete(sort.id) await $api.dbTableSort.delete(sort.id)
} } else {
sorts.value.splice(i, 1) sorts.value.splice(i, 1)
} }
}
return { sorts, loadSorts, addSort, deleteSort, saveOrUpdate } return { sorts, loadSorts, addSort, deleteSort, saveOrUpdate }
} }

Loading…
Cancel
Save