Browse Source

chore(nc-gui): adopt recent changes from develop

pull/3563/head
Wing-Kam Wong 2 years ago
parent
commit
7cc5660877
  1. 39
      packages/nc-gui/components/smartsheet/Kanban.vue
  2. 2
      packages/nc-gui/composables/useKanbanViewStore.ts

39
packages/nc-gui/components/smartsheet/Kanban.vue

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import Draggable from 'vuedraggable' import Draggable from 'vuedraggable'
import { UITypes, isVirtualCol } from 'nocodb-sdk' import { UITypes, ViewTypes, isVirtualCol } from 'nocodb-sdk'
import { import {
ActiveViewInj, ActiveViewInj,
FieldsInj, FieldsInj,
@ -89,8 +89,6 @@ const fields = inject(FieldsInj, ref([]))
const kanbanContainerRef = ref() const kanbanContainerRef = ref()
let isMounted = false
const isRowEmpty = (record: any, col: any) => { const isRowEmpty = (record: any, col: any) => {
const val = record.row[col.title] const val = record.row[col.title]
if (!val) return true if (!val) return true
@ -245,24 +243,26 @@ openNewRecordFormHook?.on(async (stackTitle) => {
}) })
onMounted(async () => { onMounted(async () => {
// reset state to avoid from showing the previous stacks when switching kanban views
groupingFieldColOptions.value = []
formattedData.value = {}
// load kanban meta
await loadKanbanMeta() await loadKanbanMeta()
// load kanban data
await loadKanbanData() await loadKanbanData()
// update isMounted for below watcher
isMounted = true
}) })
watch( // reset context menu target on hide
() => shouldScrollToRight.value, watch(contextMenu, () => {
() => { if (!contextMenu.value) {
// use `isMounted` to avoid scrolling from switching from other views contextMenuTarget.value = null
// i.e. scroll only when a new option is added within kanban view }
if (isMounted && shouldScrollToRight.value) { })
watch(view, async (nextView) => {
if (nextView?.type === ViewTypes.KANBAN) {
// load kanban meta
await loadKanbanMeta()
// load kanban data
await loadKanbanData()
// horizontally scroll to the end of the kanban container // horizontally scroll to the end of the kanban container
// when a new option is added within kanban view
if (shouldScrollToRight.value) {
kanbanContainerRef.value.scrollTo({ kanbanContainerRef.value.scrollTo({
left: kanbanContainerRef.value.scrollWidth, left: kanbanContainerRef.value.scrollWidth,
behavior: 'smooth', behavior: 'smooth',
@ -270,13 +270,6 @@ watch(
// reset shouldScrollToRight // reset shouldScrollToRight
shouldScrollToRight.value = false shouldScrollToRight.value = false
} }
},
)
// reset context menu target on hide
watch(contextMenu, () => {
if (!contextMenu.value) {
contextMenuTarget.value = null
} }
}) })
</script> </script>

2
packages/nc-gui/composables/useKanbanViewStore.ts

@ -127,7 +127,7 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState(
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), ...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }),
where, where,
}) })
: await fetchSharedViewData(params) : await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value })
formattedData.value[stackTitle] = [...formattedData.value[stackTitle], ...formatData(response.list)] formattedData.value[stackTitle] = [...formattedData.value[stackTitle], ...formatData(response.list)]
} }

Loading…
Cancel
Save