Browse Source

refactor(gui): code cleanup

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4861/head
Pranav C 2 years ago
parent
commit
eadbdab289
  1. 6
      packages/nc-gui/components/smartsheet/Gallery.vue
  2. 5
      packages/nc-gui/components/smartsheet/Grid.vue
  3. 4
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue
  4. 7
      packages/nc-gui/composables/useViewData.ts
  5. 5
      packages/nc-gui/lib/enums.ts

6
packages/nc-gui/components/smartsheet/Gallery.vue

@ -8,12 +8,12 @@ import {
IsGalleryInj,
IsGridInj,
MetaInj,
NavigateDir,
OpenNewRecordFormHookInj,
PaginationDataInj,
ReloadRowDataHookInj,
ReloadViewDataHookInj,
ReloadViewMetaHookInj,
RowNavDir,
computed,
createEventHook,
extractPkFromRow,
@ -273,8 +273,8 @@ watch(view, async (nextView) => {
:row-id="route.query.rowId"
:view="view"
show-next-prev-icons
@next="navigateToSiblingRow(RowNavDir.NEXT)"
@prev="navigateToSiblingRow(RowNavDir.PREV)"
@next="navigateToSiblingRow(NavigateDir.NEXT)"
@prev="navigateToSiblingRow(NavigateDir.PREV)"
/>
</Suspense>
</div>

5
packages/nc-gui/components/smartsheet/Grid.vue

@ -17,7 +17,6 @@ import {
ReadonlyInj,
ReloadRowDataHookInj,
ReloadViewDataHookInj,
RowNavDir,
SmartsheetStoreEvents,
computed,
createEventHook,
@ -921,8 +920,8 @@ const closeAddColumnDropdown = () => {
:row-id="routeQuery.rowId"
:view="view"
show-next-prev-icons
@next="navigateToSiblingRow(RowNavDir.NEXT)"
@prev="navigateToSiblingRow(RowNavDir.PREV)"
@next="navigateToSiblingRow(NavigateDir.NEXT)"
@prev="navigateToSiblingRow(NavigateDir.PREV)"
/>
</Suspense>
</div>

4
packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue

@ -192,7 +192,7 @@ defineExpose({
@click.stop
@change="filterUpdateCondition(filter, i)"
>
<a-select-option v-for="op in logicalOps" :key="op.value" :value="op.value">
<a-select-option v-for="op of logicalOps" :key="op.value" :value="op.value">
{{ op.text }}
</a-select-option>
</a-select>
@ -219,7 +219,7 @@ defineExpose({
dropdown-class-name="nc-dropdown-filter-comp-op"
@change="filterUpdateCondition(filter, i)"
>
<template v-for="compOp in comparisonOpList" :key="compOp.value">
<template v-for="compOp of comparisonOpList" :key="compOp.value">
<a-select-option v-if="isComparisonOpAllowed(filter, compOp)" :value="compOp.value">
{{ compOp.text }}
</a-select-option>

7
packages/nc-gui/composables/useViewData.ts

@ -4,7 +4,7 @@ import type { ComputedRef, Ref } from 'vue'
import {
IsPublicInj,
NOCO,
RowNavDir,
NavigateDir,
computed,
extractPkFromRow,
extractSdkResponseErrorMsg,
@ -478,14 +478,14 @@ export function useViewData(
}
}
const navigateToSiblingRow = async (dir: RowNavDir) => {
const navigateToSiblingRow = async (dir: NavigateDir) => {
// get current expanded row index
const expandedRowIndex = formattedData.value.findIndex(
(row: Row) => routeQuery.rowId === extractPkFromRow(row.row, meta.value?.columns as ColumnType[]),
)
// calculate next row index based on direction
let siblingRowIndex = expandedRowIndex + (dir === RowNavDir.NEXT ? 1 : -1)
let siblingRowIndex = expandedRowIndex + (dir === NavigateDir.NEXT ? 1 : -1)
const currentPage = paginationData?.value?.page || 1
@ -500,7 +500,6 @@ export function useViewData(
// if next row index is greater than total rows in current view
// then load next page of formattedData and set next row index to 0
} else if (siblingRowIndex >= formattedData.value.length) {
console.log(paginationData?.value)
if (paginationData?.value?.isLastPage) return message.info(t('msg.info.noMoreRecords'))
await changePage(currentPage + 1)

5
packages/nc-gui/lib/enums.ts

@ -98,8 +98,3 @@ export enum DataSourcesSubTab {
Misc = 'Misc',
Edit = 'Edit',
}
export enum RowNavDir {
NEXT,
PREV,
}

Loading…
Cancel
Save