Browse Source

refactor/gui-v2 added more options

pull/3083/head
Muhammed Mustafa 2 years ago
parent
commit
d6fbce8a59
  1. 37
      packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue
  2. 9
      packages/nc-gui-v2/components/smartsheet/Grid.vue
  3. 4
      packages/nc-gui-v2/components/smartsheet/Toolbar.vue
  4. 26
      packages/nc-gui-v2/composables/useSharedView.ts

37
packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue

@ -6,6 +6,8 @@ import FileSaver from 'file-saver'
import { message } from 'ant-design-vue'
import {
ActiveViewInj,
FieldsInj,
IsPublicInj,
MetaInj,
extractSdkResponseErrorMsg,
inject,
@ -22,7 +24,7 @@ enum ExportTypes {
const sharedViewListDlg = ref(false)
const publicViewId = null
const isPublicView = inject(IsPublicInj, ref(false))
const isView = false
@ -33,7 +35,7 @@ const { project } = useProject()
const { $api } = useNuxtApp()
const meta = inject(MetaInj)
const fields = inject(FieldsInj, ref([]))
const selectedView = inject(ActiveViewInj)
const showWebhookDrawer = ref(false)
@ -46,31 +48,12 @@ const exportFile = async (exportType: ExportTypes) => {
let offset = 0
let c = 1
const responseType = exportType === ExportTypes.EXCEL ? 'base64' : 'blob'
try {
while (!isNaN(offset) && offset > -1) {
let res
if (publicViewId) {
// TODO: pending for shared view
// const { data, headers } = await $api.public.csvExport(publicViewId, exportType, {
// format: responseType,
// query: {
// fields:
// queryParams && queryParams.fieldsOrder && queryParams.fieldsOrder.filter((c: number) => queryParams.showFields[c]),
// offset,
// sortArrJson: JSON.stringify(
// reqPayload &&
// reqPayload.sorts &&
// reqPayload.sorts.map(({ fk_column_id, direction }) => ({
// direction,
// fk_column_id,
// })),
// ),
// filterArrJson: JSON.stringify(reqPayload && reqPayload.filters),
// },
// headers: {
// 'xc-password': reqPayload && reqPayload.password,
// },
// } as Record<string, any>)
if (isPublicView.value) {
res = await exportFile(fields.value, offset, exportType, responseType)
} else {
res = await $api.dbViewRow.export(
'noco',
@ -137,7 +120,7 @@ const exportFile = async (exportType: ExportTypes) => {
</div>
<div
v-if="isUIAllowed('csvImport') && !isView"
v-if="isUIAllowed('csvImport') && !isView && !isPublicView"
v-t="['a:actions:upload-csv']"
class="nc-menu-item"
@click="quickImportDialog = true"
@ -148,7 +131,7 @@ const exportFile = async (exportType: ExportTypes) => {
</div>
<div
v-if="isUIAllowed('SharedViewList') && !isView"
v-if="isUIAllowed('SharedViewList') && !isView && !isPublicView"
v-t="['a:actions:shared-view-list']"
class="nc-menu-item"
@click="sharedViewListDlg = true"
@ -159,7 +142,7 @@ const exportFile = async (exportType: ExportTypes) => {
</div>
<div
v-if="isUIAllowed('webhook') && !isView"
v-if="isUIAllowed('webhook') && !isView && !isPublicView"
v-t="['c:actions:webhook']"
class="nc-menu-item"
@click="showWebhookDrawer = true"

9
packages/nc-gui-v2/components/smartsheet/Grid.vue

@ -26,6 +26,7 @@ import {
IsPublicInj,
MetaInj,
PaginationDataInj,
ReadonlyInj,
ReloadViewDataHookInj,
} from '~/context'
import { NavigateDir } from '~/lib'
@ -40,7 +41,7 @@ const isPublicView = inject(IsPublicInj, ref(false))
// keep a root fields variable and will get modified from
// fields menu and get used in grid and gallery
const fields = inject(FieldsInj, ref([]))
const readonly = inject(ReadonlyInj, ref(false))
const isLocked = inject(IsLockedInj, false)
const reloadViewDataHook = inject(ReloadViewDataHookInj)
@ -325,14 +326,14 @@ const expandForm = (row: Row, state: Record<string, any>) => {
@xcresized="resizingCol = null"
>
<div class="w-full h-full bg-gray-100 flex items-center">
<SmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" />
<SmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" :hide-menu="readonly" />
<SmartsheetHeaderCell v-else :column="col" />
<SmartsheetHeaderCell v-else :column="col" :hide-menu="readonly" />
</div>
</th>
<!-- v-if="!isLocked && !isVirtual && !isPublicView && _isUIAllowed('add-column')" -->
<th
v-if="isUIAllowed('add-column')"
v-if="!readonly && isUIAllowed('add-column')"
v-t="['c:column:add']"
class="cursor-pointer"
@click.stop="addColumnDropdown = true"

4
packages/nc-gui-v2/components/smartsheet/Toolbar.vue

@ -7,8 +7,8 @@ const isPublic = inject(IsPublicInj, ref(false))
</script>
<template>
<div class="nc-table-toolbar w-full py-1 flex gap-1 items-center h-[48px] px-2 border-b" style="z-index: 7">
<SmartsheetToolbarFieldsMenu v-if="(isGrid && !isPublic) || isGallery" :show-system-fields="false" class="ml-1" />
<div class="nc-table-toolbar w-full py-1 flex gap-1 items-center" style="z-index: 7">
<SmartsheetToolbarSearchData v-if="isGrid && !isPublic" class="flex-shrink" />
<SmartsheetToolbarColumnFilterMenu v-if="(isGrid && !isPublic) || isGallery" />

26
packages/nc-gui-v2/composables/useSharedView.ts

@ -1,10 +1,11 @@
import type { ColumnType, FilterType, PaginatedType, SortType, TableType, ViewType } from 'nocodb-sdk'
import type { ColumnType, ExportTypes, FilterType, PaginatedType, SortType, TableType, ViewType } from 'nocodb-sdk'
import { useNuxtApp } from '#app'
const nestedFilters = ref<(FilterType & { status?: 'update' | 'delete' | 'create'; parentId?: string })[]>([])
const paginationData = ref<PaginatedType>({ page: 1, pageSize: 25 })
const sharedView = ref<ViewType>()
const sorts = ref<SortType[]>([])
const password = ref<string | undefined>()
export function useSharedView() {
const meta = ref<TableType>(() => sharedView.value?.model)
@ -39,5 +40,26 @@ export function useSharedView() {
return data
}
return { sharedView, loadSharedView, meta, columns, nestedFilters, fetchSharedViewData, paginationData, sorts }
const exportFile = async (
fields: any[],
offset: number,
type: ExportTypes.EXCEL | ExportTypes.CSV,
responseType: 'base64' | 'blob',
) => {
return await $api.public.csvExport(sharedView.value?.uuid, type, {
format: responseType as any,
query: {
fields: fields.map((field) => field.title),
offset,
sortArrJson: JSON.stringify(sorts.value),
filterArrJson: JSON.stringify(nestedFilters.value),
},
headers: {
'xc-password': password,
},
})
}
return { sharedView, loadSharedView, meta, columns, nestedFilters, fetchSharedViewData, paginationData, sorts, exportFile }
}

Loading…
Cancel
Save