Browse Source

chore(gui-v2): resolve conflicts

pull/2885/head
Wing-Kam Wong 2 years ago
parent
commit
d6d3903c5c
  1. 12
      packages/nc-gui-v2/assets/style-v2.scss
  2. 63
      packages/nc-gui-v2/components/dashboard/TreeView.vue
  3. 4
      packages/nc-gui-v2/components/dlg/TableCreate.vue
  4. 2
      packages/nc-gui-v2/components/dlg/TableRename.vue
  5. 12
      packages/nc-gui-v2/components/smartsheet-header/CellIcon.vue
  6. 8
      packages/nc-gui-v2/components/smartsheet-header/VirtualCellIcon.vue
  7. 203
      packages/nc-gui-v2/components/smartsheet-toolbar/ColumnFilter.vue
  8. 38
      packages/nc-gui-v2/components/smartsheet-toolbar/ColumnFilterMenu.vue
  9. 8
      packages/nc-gui-v2/components/smartsheet-toolbar/DeleteTable.vue
  10. 50
      packages/nc-gui-v2/components/smartsheet-toolbar/FieldListAutoCompleteDropdown.vue
  11. 72
      packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue
  12. 83
      packages/nc-gui-v2/components/smartsheet-toolbar/LockMenu.vue
  13. 76
      packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue
  14. 44
      packages/nc-gui-v2/components/smartsheet-toolbar/SearchData.vue
  15. 164
      packages/nc-gui-v2/components/smartsheet-toolbar/ShareView.vue
  16. 156
      packages/nc-gui-v2/components/smartsheet-toolbar/SharedViewList.vue
  17. 46
      packages/nc-gui-v2/components/smartsheet-toolbar/SortListMenu.vue
  18. 4
      packages/nc-gui-v2/components/smartsheet/Grid.vue
  19. 10
      packages/nc-gui-v2/components/tabs/Smartsheet.vue
  20. 4
      packages/nc-gui-v2/composables/index.ts
  21. 10
      packages/nc-gui-v2/composables/useDashboard.ts
  22. 53
      packages/nc-gui-v2/composables/useSmartsheetStore.ts
  23. 112
      packages/nc-gui-v2/composables/useTable.ts
  24. 3
      packages/nc-gui-v2/composables/useUIPermission/index.ts
  25. 9
      packages/nc-gui-v2/composables/useViewColumns.ts
  26. 15
      packages/nc-gui-v2/composables/useViewData.ts
  27. 83
      packages/nc-gui-v2/composables/useViewFilters.ts
  28. 33
      packages/nc-gui-v2/package-lock.json
  29. 2
      packages/nc-gui-v2/package.json
  30. 35
      packages/nc-gui-v2/utils/sortUtils.ts
  31. 4
      packages/nocodb-sdk/src/lib/Api.ts
  32. 2
      packages/nocodb/src/lib/models/View.ts
  33. 4
      packages/nocodb/src/lib/version-upgrader/ncProjectUpgraderV2_0090000.ts
  34. 32
      scripts/sdk/swagger.json

12
packages/nc-gui-v2/assets/style-v2.scss

@ -72,6 +72,8 @@ html {
overflow-y: auto !important;
}
// menu item styling
.nc-menu-item {
@apply cursor-pointer text-xs flex align-center gap-2 px-4 py-3 relative after:(content-[''] absolute top-0 left-0 w-full h-full right 0 bg-current opacity-0 transition transition-opactity duration-100) hover:(after:(opacity-5));
}
@ -92,3 +94,13 @@ html {
@apply z-1 text-xl p-1 text-gray-500;
}
}
// show a dot badge if some change present
.nc-badge {
@apply relative after:(absolute top-[-2px] right-[-2px] w-[8px] h-[8px] rounded-full bg-primary content-[''] !z-20);
}
// for highlighting toolbar menu item
.nc-active-btn > .ant-btn{
@apply bg-primary/20;
}

63
packages/nc-gui-v2/components/dashboard/TreeView.vue

@ -1,14 +1,10 @@
<script setup lang="ts">
import { computed } from '@vue/reactivity'
import { Modal } from 'ant-design-vue'
import type { LinkToAnotherRecordType, TableType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk'
import type { TableType } from 'nocodb-sdk'
import Sortable from 'sortablejs'
import { useToast } from 'vue-toastification'
import SettingsModal from './settings/SettingsModal.vue'
import { useProject, useTabs, useUIPermission, watchEffect } from '#imports'
import { computed, useProject, useTable, useTabs, useUIPermission, watchEffect } from '#imports'
import { useNuxtApp, useRoute } from '#app'
import { extractSdkResponseErrorMsg } from '~/utils'
import MdiSettingIcon from '~icons/mdi/cog'
import MdiTable from '~icons/mdi/table'
import MdiView from '~icons/mdi/eye-circle-outline'
@ -18,7 +14,6 @@ import MdiPlus from '~icons/mdi/plus-circle-outline'
import MdiDrag from '~icons/mdi/drag-vertical'
import MdiMenuIcon from '~icons/mdi/dots-vertical'
import MdiAPIDocIcon from '~icons/mdi/open-in-new'
import { TabType } from '~/composables'
const { addTab } = useTabs()
const toast = useToast()
@ -27,6 +22,7 @@ const { isUIAllowed } = useUIPermission()
const route = useRoute()
const { tables, loadTables } = useProject(route.params.projectId as string)
const { closeTab } = useTabs()
const { deleteTable } = useTable()
const tablesById = $computed<Record<string, TableType>>(() =>
tables?.value?.reduce((acc: Record<string, TableType>, table: TableType) => {
@ -128,59 +124,6 @@ const setMenuContext = (type: 'table' | 'main', value?: any) => {
$e('c:table:create:navdraw:right-click')
}
const deleteTable = (table: TableType) => {
$e('c:table:delete')
// 'Click Submit to Delete The table'
Modal.confirm({
title: `Click Yes to Delete The table : ${table.title}`,
okText: 'Yes',
okType: 'danger',
cancelText: 'No',
async onOk() {
const { getMeta, removeMeta } = useMetas()
try {
const meta = (await getMeta(table.id as string)) as TableType
const relationColumns = meta?.columns?.filter((c) => c.uidt === UITypes.LinkToAnotherRecord)
if (relationColumns?.length) {
const refColMsgs = await Promise.all(
relationColumns.map(async (c, i) => {
const refMeta = (await getMeta(
(c?.colOptions as LinkToAnotherRecordType)?.fk_related_model_id as string,
)) as TableType
return `${i + 1}. ${c.title} is a LinkToAnotherRecord of ${(refMeta && refMeta.title) || c.title}`
}),
)
toast.info(
h('div', {
innerHTML: `<div style="padding:10px 4px">Unable to delete tables because of the following.
<br><br>${refColMsgs.join('<br>')}<br><br>
Delete them & try again</div>`,
}),
)
return
}
await $api.dbTable.delete(table?.id as string)
closeTab({
type: TabType.TABLE,
id: table.id,
title: table.title,
})
await loadTables()
removeMeta(table.id as string)
toast.info(`Deleted table ${table.title} successfully`)
$e('a:table:delete')
} catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e))
}
},
})
}
const renameTableDlg = ref(false)
const renameTableMeta = ref()
const showRenameTableDlg = (table: TableType, rightClick = false) => {

4
packages/nc-gui-v2/components/dlg/TableCreate.vue

@ -1,7 +1,7 @@
<script setup lang="ts">
import { Form } from 'ant-design-vue'
import { useToast } from 'vue-toastification'
import { onMounted, useProject, useTableCreate, useTabs } from '#imports'
import { onMounted, useProject, useTable, useTabs } from '#imports'
import { validateTableName } from '~/utils/validation'
import { TabType } from '~/composables'
@ -27,7 +27,7 @@ const { addTab } = useTabs()
const { loadTables } = useProject()
const { table, createTable, generateUniqueTitle, tables, project } = useTableCreate(async (table) => {
const { table, createTable, generateUniqueTitle, tables, project } = useTable(async (table) => {
await loadTables()
addTab({

2
packages/nc-gui-v2/components/dlg/TableRename.vue

@ -3,7 +3,7 @@ import { watchEffect } from '@vue/runtime-core'
import { Form } from 'ant-design-vue'
import type { TableType } from 'nocodb-sdk'
import { useToast } from 'vue-toastification'
import { useProject, useTableCreate, useTabs } from '#imports'
import { useProject, useTabs } from '#imports'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
import { validateTableName } from '~/utils/validation'
import { useNuxtApp } from '#app'

12
packages/nc-gui-v2/components/smartsheet-header/CellIcon.vue

@ -6,7 +6,7 @@ import KeyIcon from '~icons/mdi/key-variant'
import JSONIcon from '~icons/mdi/code-json'
// import FKIcon from '~icons/mdi/link-variant'
import TextAreaIcon from '~icons/mdi/card-text-outline'
import StringIcon from '~icons/mdi/alpha-a'
import StringIcon from '~icons/mdi/alpha-a-box-outline'
import BooleanIcon from '~icons/mdi/check-box-outline'
import SingleSelectIcon from '~icons/mdi/radiobox-marked'
import MultiSelectIcon from '~icons/mdi/checkbox-multiple-marked'
@ -19,7 +19,9 @@ import URLIcon from '~icons/mdi/link'
import EmailIcon from '~icons/mdi/email'
import CurrencyIcon from '~icons/mdi/currency-usd-circle-outline'
const column = inject(ColumnInj)
const { columnMeta } = defineProps<{ columnMeta?: ColumnType }>()
const column = inject(ColumnInj, columnMeta)
const additionalColMeta = useColumn(column as ColumnType)
@ -55,9 +57,7 @@ const icon = computed(() => {
} else if (additionalColMeta.isCurrency) {
return CurrencyIcon
} else if (additionalColMeta.isString) {
return h(StringIcon, {
class: 'text-[1.5rem]',
})
return StringIcon
} else {
return GenericIcon
}
@ -65,5 +65,5 @@ const icon = computed(() => {
</script>
<template>
<component :is="icon" class="text-grey mx-1" />
<component :is="icon" class="text-grey mx-1 !text-sm" />
</template>

8
packages/nc-gui-v2/components/smartsheet-header/VirtualCellIcon.vue

@ -1,5 +1,5 @@
<script setup lang="ts">
import type { LinkToAnotherRecordType } from 'nocodb-sdk'
import type { ColumnType, LinkToAnotherRecordType } from 'nocodb-sdk'
import { RelationTypes, UITypes } from 'nocodb-sdk'
import { ColumnInj } from '~/context'
import GenericIcon from '~icons/mdi/square-rounded'
@ -9,7 +9,9 @@ import MMIcon from '~icons/mdi/table-network'
import FormulaIcon from '~icons/mdi/math-integral'
import RollupIcon from '~icons/mdi/movie-roll'
const column = inject(ColumnInj)
const { columnMeta } = defineProps<{ columnMeta?: ColumnType }>()
const column = inject(ColumnInj, columnMeta)
const icon = computed(() => {
switch (column?.uidt) {
@ -35,5 +37,5 @@ const icon = computed(() => {
</script>
<template>
<component :is="icon" class="text-grey mx-1" />
<component :is="icon" class="text-grey mx-1 !text-sm" />
</template>

203
packages/nc-gui-v2/components/smartsheet-toolbar/ColumnFilter.vue

@ -5,24 +5,35 @@ import FieldListAutoCompleteDropdown from './FieldListAutoCompleteDropdown.vue'
import { useNuxtApp } from '#app'
import { inject, useViewFilters } from '#imports'
import { comparisonOpList } from '~/utils/filterUtils'
import { ActiveViewInj, MetaInj, ReloadViewDataHookInj } from '~/context'
import { ActiveViewInj, IsLockedInj, MetaInj, ReloadViewDataHookInj } from '~/context'
import MdiDeleteIcon from '~icons/mdi/close-box'
import MdiAddIcon from '~icons/mdi/plus'
const { nested = false, parentId } = defineProps<{ nested?: boolean; parentId?: string }>()
const { nested = false, parentId, autoSave = true } = defineProps<{ nested?: boolean; parentId?: string; autoSave: boolean }>()
const emit = defineEmits(['update:filtersLength'])
const meta = inject(MetaInj)
const activeView = inject(ActiveViewInj)
const reloadDataHook = inject(ReloadViewDataHookInj)
const isLocked = inject(IsLockedInj)
// todo: replace with inject or get from state
const shared = ref(false)
const { $e } = useNuxtApp()
const { filters, deleteFilter, saveOrUpdate, loadFilters, addFilter } = useViewFilters(activeView, parentId, () => {
reloadDataHook?.trigger()
})
const { filters, deleteFilter, saveOrUpdate, loadFilters, addFilter, addFilterGroup, sync } = useViewFilters(
activeView,
parentId,
computed(() => autoSave),
() => {
reloadDataHook?.trigger()
},
)
const filterUpdateCondition = (filter: FilterType, i: number) => {
saveOrUpdate(filter, i)
$e('a:filter:update', {
logical: filter.logical_op,
comparison: filter.comparison_op,
@ -70,64 +81,81 @@ watch(
},
{ immediate: true },
)
const nestedFilters = ref()
const logicalOps = [
{ value: 'and', text: 'AND' },
{ value: 'or', text: 'OR' },
]
watch(
() => filters?.value?.length,
(length) => {
emit('update:filtersLength', length ?? 0)
},
)
const applyChanges = async () => {
await sync()
for (const nestedFilter of nestedFilters?.value || []) {
if (nestedFilter.parentId) {
await nestedFilter.applyChanges(true)
}
}
}
defineExpose({
applyChanges,
parentId,
})
</script>
<template>
<div class="bg-white shadow pa-2 menu-filter-dropdown" :style="{ width: nested ? '100%' : '630px' }">
<div v-if="filters && filters.length" class="grid" @click.stop>
<div
class="pa-2 menu-filter-dropdown bg-gray-50"
:class="{ 'shadow-xl min-w-[430px] max-w-[630px] max-h-[max(80vh,500px)] overflow-auto': !nested, 'border-1 w-full': nested }"
>
<div v-if="filters && filters.length" class="nc-filter-grid mb-2" @click.stop>
<template v-for="(filter, i) in filters" :key="filter.id || i">
<template v-if="filter.status !== 'delete'">
<div v-if="filter.is_group" :key="i" style="grid-column: span 4; padding: 6px" class="elevation-4">
<div class="d-flex" style="gap: 6px; padding: 0 6px">
<!-- <v-icon
v-if="!filter.readOnly"
:key="`${i}_3`"
small
class="nc-filter-item-remove-btn"
@click.stop="deleteFilter(filter, i)"
>
mdi-close-box
</v-icon> -->
<MdiDeleteIcon
v-if="!filter.readOnly"
small
class="nc-filter-item-remove-btn"
@click.stop="deleteFilter(filter, i)"
/>
<span v-else :key="`${i}_1`" />
<template v-if="filter.is_group">
<MdiDeleteIcon
v-if="!filter.readOnly"
:key="i"
small
class="nc-filter-item-remove-btn text-grey"
@click.stop="deleteFilter(filter, i)"
/>
<span v-else :key="`${i}dummy`" />
<div :key="`${i}nested`" class="d-flex">
<a-select
v-model:value="filter.logical_op"
class="flex-shrink-1 flex-grow-0 elevation-0 caption"
:items="['and', 'or']"
density="compact"
variant="solo"
hide-details
:dropdown-match-select-width="false"
size="small"
class="flex-shrink-1 flex-grow-0 elevation-0 caption !text-xs"
placeholder="Group op"
@click.stop
@change="saveOrUpdate(filter, i)"
>
<!-- <template #item="{ item }"> -->
<!-- <span class="caption font-weight-regular">{{ item }}</span> -->
<!-- </template> -->
<a-select-option v-for="op in logicalOps" :key="op.value" :value="op.value" class="!text-xs">
{{ op.text }}
</a-select-option>
</a-select>
</div>
<!-- <column-filter
v-if="filter.id || shared"
ref="nestedFilter"
v-model="filter.children"
:parent-id="filter.id"
:view-id="viewId"
nested
:meta="meta"
:shared="shared"
:web-hook="webHook"
:hook-id="hookId"
@updated="$emit('updated')"
@input="$emit('input', filters)"
/> -->
</div>
<span class="col-span-3" />
<div class="col-span-5">
<SmartsheetToolbarColumnFilter
v-if="filter.id || shared"
ref="nestedFilters"
v-model="filter.children"
:parent-id="filter.id"
nested
:auto-save="autoSave"
/>
</div>
</template>
<template v-else>
<!-- <v-icon
v-if="!filter.readOnly"
@ -151,21 +179,23 @@ watch(
<a-select
v-else
v-model:value="filter.logical_op"
class="h-full"
:options="[
{ value: 'and', text: 'AND' },
{ value: 'or', text: 'OR' },
]"
:dropdown-match-select-width="false"
size="small"
class="h-full !text-xs"
hide-details
:disabled="filter.readOnly"
@click.stop
@change="filterUpdateCondition(filter, i)"
/>
>
<a-select-option v-for="op in logicalOps" :key="op.value" :value="op.value" class="!text-xs">
{{ op.text }}
</a-select-option>
</a-select>
<FieldListAutoCompleteDropdown
:key="`${i}_6`"
v-model="filter.fk_column_id"
class="caption text-sm nc-filter-field-select"
class="caption nc-filter-field-select"
:columns="columns"
:disabled="filter.readOnly"
@click.stop
@ -174,15 +204,21 @@ watch(
<a-select
v-model:value="filter.comparison_op"
class="caption nc-filter-operation-select text-sm"
:options="comparisonOpList"
:dropdown-match-select-width="false"
size="small"
class="caption nc-filter-operation-select !text-xs"
:placeholder="$t('labels.operation')"
density="compact"
variant="solo"
:disabled="filter.readOnly"
hide-details
@change="filterUpdateCondition(filter, i)"
/><!--
>
<a-select-option v-for="compOp in comparisonOpList" :key="compOp.value" :value="compOp.value" class="!text-xs">
{{ compOp.text }}
</a-select-option>
</a-select>
<!--
todo: filter based on column type
item-value="value"
@ -196,7 +232,8 @@ watch(
<span v-if="['null', 'notnull', 'empty', 'notempty'].includes(filter.comparison_op)" :key="`span${i}`" />
<a-checkbox
v-else-if="types[filter.field] === 'boolean'"
v-model:value="filter.value"
v-model:checked="filter.value"
size="small"
dense
:disabled="filter.readOnly"
@change="saveOrUpdate(filter, i)"
@ -204,8 +241,9 @@ watch(
<a-input
v-else
:key="`${i}_7`"
v-model="filter.value"
class="caption text-sm nc-filter-value-select"
v-model:value="filter.value"
size="small"
class="caption nc-filter-value-select"
:disabled="filter.readOnly"
@click.stop
@input="saveOrUpdate(filter, i)"
@ -215,23 +253,42 @@ watch(
</template>
</div>
<a-button small class="elevation-0 text-sm text-capitalize text-grey my-3" @click.stop="addFilter">
<div class="flex align-center gap-1">
<!-- <v-icon small color="grey"> mdi-plus </v-icon> -->
<MdiAddIcon />
<!-- Add Filter -->
{{ $t('activity.addFilter') }}
</div>
</a-button>
<div class="flex gap-2 my-2">
<a-button size="small" class="elevation-0 text-capitalize text-grey" @click.stop="addFilter">
<div class="flex align-center gap-1">
<!-- <v-icon small color="grey"> mdi-plus </v-icon> -->
<MdiAddIcon />
<!-- Add Filter -->
{{ $t('activity.addFilter') }}
</div>
</a-button>
<a-button size="small" class="elevation-0 text-capitalize text-grey" @click.stop="addFilterGroup">
<div class="flex align-center gap-1">
<!-- <v-icon small color="grey"> mdi-plus </v-icon> -->
<MdiAddIcon />
Add Filter Group
<!-- todo: add i18n {{ $t('activity.addFilterGroup') }} -->
</div>
</a-button>
</div>
<slot />
</div>
</template>
<style scoped>
.grid {
.nc-filter-grid {
display: grid;
grid-template-columns: 30px 130px auto auto auto;
grid-template-columns: 18px 70px auto auto auto;
column-gap: 6px;
row-gap: 6px;
align-items: center;
}
:deep(.ant-btn, .ant-select, .ant-input) {
@apply "!text-xs";
}
:deep(.ant-select-item-option) {
@apply "!min-w-min";
}
</style>

38
packages/nc-gui-v2/components/smartsheet-toolbar/ColumnFilterMenu.vue

@ -1,5 +1,6 @@
<script setup lang="ts">
// todo: move to persisted state
import type ColumnFilter from './ColumnFilter.vue'
import { useState } from '#app'
import { IsLockedInj } from '~/context'
import MdiFilterIcon from '~icons/mdi/filter-outline'
@ -9,26 +10,49 @@ const autoApplyFilter = useState('autoApplyFilter', () => false)
const isLocked = inject(IsLockedInj)
// todo: emit from child
const filters = []
const filtersLength = ref(0)
// todo: sync with store
const autosave = ref(true)
const filterComp = ref<typeof ColumnFilter>()
// todo: implement
const applyChanges = () => {}
const applyChanges = async () => {
await filterComp?.value?.applyChanges()
}
</script>
<template>
<a-dropdown :trigger="['click']">
<v-badge :value="filters.length" color="primary" dot overlap>
<a-button v-t="['c:filter']" class="nc-filter-menu-btn nc-toolbar-btn" :disabled="isLocked" size="small">
<div :class="{ 'nc-badge nc-active-btn': filtersLength }">
<a-button v-t="['c:filter']" class="text-xs nc-filter-menu-btn nc-toolbar-btn" :disabled="isLocked" size="small">
<div class="flex align-center gap-1">
<MdiFilterIcon class="text-grey" />
<!-- Filter -->
<span class="text-capitalize nc-filter-menu-btn">{{ $t('activity.filter') }}</span>
<span class="text-capitalize">{{ $t('activity.filter') }}</span>
<MdiMenuDownIcon class="text-grey" />
</div>
</a-button>
</v-badge>
</div>
<template #overlay>
<SmartsheetToolbarColumnFilter />
<SmartsheetToolbarColumnFilter
ref="filterComp"
class="nc-table-toolbar-menu"
:auto-save="autosave"
@update:filters-length="filtersLength = $event"
>
<div class="d-flex align-end mt-2 min-h-[30px]" @click.stop>
<a-checkbox id="col-filter-checkbox" v-model:checked="autosave" class="col-filter-checkbox" hide-details dense>
<span class="text-grey text-xs">
{{ $t('msg.info.filterAutoApply') }}
<!-- Auto apply -->
</span>
</a-checkbox>
<div class="flex-1" />
<a-button v-show="!autosave" size="small" class="text-xs ml-2" @click="applyChanges"> Apply changes </a-button>
</div>
</SmartsheetToolbarColumnFilter>
</template>
</a-dropdown>
</template>

8
packages/nc-gui-v2/components/smartsheet-toolbar/DeleteTable.vue

@ -1,5 +1,11 @@
<script setup lang="ts">
import { inject, useTable } from '#imports'
import { MetaInj } from '~/context'
import MdiDeleteIcon from '~icons/mdi/delete-outline'
const meta = inject(MetaInj)
const { deleteTable } = useTable()
</script>
<template>
@ -7,7 +13,7 @@ import MdiDeleteIcon from '~icons/mdi/delete-outline'
<template #title> {{ $t('activity.deleteTable') }} </template>
<div class="nc-sidebar-right-item hover:after:bg-red-500 group">
<MdiDeleteIcon class="group-hover:(!text-white)" />
<MdiDeleteIcon class="group-hover:(!text-white)" @click="deleteTable(meta)" />
</div>
</a-tooltip>
</template>

50
packages/nc-gui-v2/components/smartsheet-toolbar/FieldListAutoCompleteDropdown.vue

@ -1,7 +1,10 @@
<script setup lang="ts">
import type { SelectProps } from 'ant-design-vue'
import { isVirtualCol } from 'nocodb-sdk'
import { computed } from 'vue'
import { MetaInj } from '~/context'
import VirtualCellIcon from '~/components/smartsheet-header/VirtualCellIcon.vue'
import CellIcon from '~/components/smartsheet-header/CellIcon.vue'
interface Props {
modelValue?: string
@ -48,6 +51,10 @@ const options = computed<SelectProps['options']>(() =>
meta?.value?.columns?.map((c) => ({
value: c.id,
label: c.title,
icon: h(isVirtualCol(c) ? VirtualCellIcon : CellIcon, {
columnMeta: c,
}),
c,
})),
)
@ -59,40 +66,17 @@ const filterOption = (input: string, option: any) => {
<template>
<a-select
v-model:value="localValue"
:dropdown-match-select-width="false"
size="small"
show-search
class="!text-xs"
placeholder="Select a field"
:options="options"
:filter-option="filterOption"
></a-select>
<!-- <v-autocomplete
ref="field"
v-model="localValue"
class="caption"
:items="meta.columns"
item-value="id"
item-text="title"
:label="$t('objects.field')"
variant="solo"
hide-details
@click.stop
>
&lt;!&ndash; &lt;!&ndash; @change="$emit('change')" &ndash;&gt; &ndash;&gt;
&lt;!&ndash; <template #selection="{ item }"> &ndash;&gt;
&lt;!&ndash; <v-icon small class="mr-1"> &ndash;&gt;
&lt;!&ndash; {{ item.icon }} &ndash;&gt;
&lt;!&ndash; </v-icon> &ndash;&gt;
&lt;!&ndash; {{ item.title }} &ndash;&gt;
&lt;!&ndash; </template> &ndash;&gt;
&lt;!&ndash; <template #item="{ item }"> &ndash;&gt;
&lt;!&ndash; <span :class="`caption font-weight-regular nc-fld-${item.title}`"> &ndash;&gt;
&lt;!&ndash; <v-icon color="grey" small class="mr-1"> &ndash;&gt;
&lt;!&ndash; {{ item.icon }} &ndash;&gt;
&lt;!&ndash; </v-icon> &ndash;&gt;
&lt;!&ndash; {{ item.title }} &ndash;&gt;
&lt;!&ndash; </span> &ndash;&gt;
&lt;!&ndash; </template> &ndash;&gt;
</v-autocomplete> -->
>
<a-select-option v-for="option in options" :key="option.value" :value="option.value">
<div class="flex gap-2 text-xs items-center align-center h-full">
<component :is="option.icon" class="min-w-5 !mx-0" /> <span class="min-w-0"> {{ option.label }}</span>
</div>
</a-select-option>
</a-select>
</template>
<style scoped></style>

72
packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue

@ -1,6 +1,4 @@
<script setup lang="ts">
import type { TableType } from 'nocodb-sdk'
import type { ComputedRef } from 'vue'
import { computed, inject } from 'vue'
import Draggable from 'vuedraggable'
import { ActiveViewInj, FieldsInj, IsLockedInj, MetaInj, ReloadViewDataHookInj } from '~/context'
@ -18,14 +16,8 @@ const { fieldsOrder, coverImageField, modelValue } = defineProps<{
const meta = inject(MetaInj)
const activeView = inject(ActiveViewInj)
const reloadDataHook = inject(ReloadViewDataHookInj)
const isLocked = inject(IsLockedInj)
const rootFields = inject(FieldsInj)
const isAnyFieldHidden = computed(() => {
return false
// todo: implement
// return meta?.fields?.some(field => field.hidden)
})
const isLocked = inject(IsLockedInj)
const { $e } = useNuxtApp()
@ -39,8 +31,8 @@ const {
showAll,
hideAll,
saveOrUpdate,
sortedFields,
} = useViewColumns(activeView, meta as ComputedRef<TableType>, false, () => reloadDataHook?.trigger())
// sortedFields,
} = useViewColumns(activeView, meta, false, () => reloadDataHook?.trigger())
watch(
() => (activeView?.value as any)?.id,
@ -59,43 +51,52 @@ watch(
{ immediate: true },
)
const onMove = (event: unknown) => {
const isAnyFieldHidden = computed(() => {
return fields?.value?.some((f) => !(!showSystemFields && f.system) && !f.show)
})
const onMove = (event: { moved: { newIndex: number } }) => {
// todo : sync with server
// if (!sortedFields?.value) return
// if (sortedFields?.value.length - 1 === event.moved.newIndex) {
// sortedFields.value[event.moved.newIndex].order = sortedFields.value[event.moved.newIndex - 1].order + 1
// } else if (event.moved.newIndex === 0) {
// sortedFields.value[event.moved.newIndex].order = sortedFields.value[1].order / 2
// } else {
// sortedFields.value[event.moved.newIndex].order =
// (sortedFields?.value[event.moved.newIndex - 1].order + sortedFields?.value[event.moved.newIndex + 1].order) / 2
// // );
// }
// saveOrUpdate(sortedFields[event.moved.newIndex], event.moved.newIndex);
if (!fields?.value) return
if (fields.value.length < 2) return
if (fields?.value.length - 1 === event.moved.newIndex) {
fields.value[event.moved.newIndex].order = (fields.value[event.moved.newIndex - 1].order || 1) + 1
} else if (event.moved.newIndex === 0) {
fields.value[event.moved.newIndex].order = (fields?.value[1].order || 1) / 2
} else {
fields.value[event.moved.newIndex].order =
((fields?.value[event.moved.newIndex - 1].order || 1) + (fields?.value[event.moved.newIndex + 1].order || 1)) / 2
// );
}
saveOrUpdate(fields.value[event.moved.newIndex], event.moved.newIndex)
$e('a:fields:reorder')
}
</script>
<template>
<a-dropdown :trigger="['click']">
<v-badge :value="isAnyFieldHidden" color="primary" dot overlap>
<div :class="{ 'nc-badge nc-active-btn': isAnyFieldHidden }">
<a-button v-t="['c:fields']" class="nc-fields-menu-btn nc-toolbar-btn" :disabled="isLocked" size="small">
<div class="flex align-center gap-1">
<!-- <v-icon small class="mr-1" color="#777"> mdi-eye-off-outline </v-icon> -->
<MdiEyeIcon class="text-grey"></MdiEyeIcon>
<!-- Fields -->
<span class="text-sm text-capitalize nc-fields-menu-btn">{{ $t('objects.fields') }}</span>
<span class="text-xs text-capitalize">{{ $t('objects.fields') }}</span>
<MdiMenuDownIcon class="text-grey"></MdiMenuDownIcon>
</div>
</a-button>
</v-badge>
</div>
<template #overlay>
<div class="pt-0 min-w-[280px] bg-white shadow" @click.stop>
<div class="pt-0 min-w-[280px] bg-gray-50 shadow nc-table-toolbar-menu max-h-[max(80vh,500px)] overflow-auto" @click.stop>
<div class="p-1" @click.stop>
<a-input v-model:value="filterQuery" size="small" :placeholder="$t('placeholder.searchFields')" />
</div>
<div class="nc-fields-list py-1">
<Draggable :list="sortedFields" @change="onMove($event)">
<Draggable :list="fields" item-key="id" @change="onMove($event)">
<template #item="{ element: field }">
<div :key="field.id" class="px-2 py-1 flex" @click.stop>
<div v-show="filteredFieldList.includes(field)" :key="field.id" class="px-2 py-1 flex" @click.stop>
<a-checkbox v-model:checked="field.show" class="flex-shrink" @change="saveOrUpdate(field, i)">
<span class="text-xs">{{ field.title }}</span>
</a-checkbox>
@ -113,11 +114,11 @@ const onMove = (event: unknown) => {
</a-checkbox>
</div>
<div class="p-2 flex gap-2" @click.stop>
<a-button size="small" class="text-gray-500 text-sm text-capitalize" @click.stop="showAll">
<a-button size="small" class="!text-xs text-gray-500 text-capitalize" @click.stop="showAll">
<!-- Show All -->
{{ $t('general.showAll') }}
</a-button>
<a-button size="small" class="text-gray-500 text-sm text-capitalize" @click.stop="hideAll">
<a-button size="small" class="!text-xs text-gray-500 text-capitalize" @click.stop="hideAll">
<!-- Hide All -->
{{ $t('general.hideAll') }}
</a-button>
@ -128,7 +129,10 @@ const onMove = (event: unknown) => {
</template>
<style scoped lang="scss">
:deep(.ant-checkbox-input) {
transform: scale(0.7);
:deep(.ant-checkbox-inner) {
@apply transform scale-60;
}
:deep(::placeholder) {
@apply !text-xs;
}
</style>

83
packages/nc-gui-v2/components/smartsheet-toolbar/LockMenu.vue

@ -1,29 +1,21 @@
<script lang="ts" setup>
import { computed } from '@vue/reactivity'
import { useToast } from 'vue-toastification'
import { useSmartsheetStoreOrThrow } from '~/composables/useSmartsheetStore'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
import MdiLockOutlineIcon from '~icons/mdi/lock-outline'
import MdiAccountIcon from '~icons/mdi/account'
import MdiAccountGroupIcon from '~icons/mdi/account-group'
import MdiCheckIcon from '~icons/mdi/check-bold'
interface Props {
modelValue?: LockType
}
const props = defineProps<Props>()
const emits = defineEmits(['update:modelValue'])
enum LockType {
Personal = 'personal',
Locked = 'locked',
Collaborative = 'collaborative',
}
const vModel = useVModel(props, 'modelValue', emits)
const { view, $api } = useSmartsheetStoreOrThrow()
const { $e } = useNuxtApp()
const toast = useToast()
function changeLockType(type: LockType) {
@ -32,14 +24,20 @@ function changeLockType(type: LockType) {
if (type === 'personal') {
return toast.info('Coming soon', { timeout: 3000 })
}
vModel.value = type
toast.success(`Successfully Switched to ${type} view`, { timeout: 3000 })
try {
view.value.lock_type = type
$api.dbView.update(view.value.id as string, {
lock_type: type,
})
toast.success(`Successfully Switched to ${type} view`, { timeout: 3000 })
} catch (e) {
toast.error(extractSdkResponseErrorMsg(e))
}
}
const Icon = computed(() => {
switch (vModel.value) {
switch (view?.value?.lock_type) {
case LockType.Personal:
return MdiAccountIcon
case LockType.Locked:
@ -59,33 +57,38 @@ const Icon = computed(() => {
<template #overlay>
<div class="min-w-[350px] max-w-[500px] shadow bg-white">
<div>
<div class="nc-menu-item">
<MdiCheckIcon v-if="!vModel || vModel === LockType.Collaborative" />
<span v-else />
<div class="nc-menu-item" @click="changeLockType(LockType.Collaborative)">
<div>
<MdiAccountGroupIcon />
Collaborative view
<div class="nc-subtitle">Collaborators with edit permissions or higher can change the view configuration.</div>
<MdiCheckIcon v-if="!view?.lock_type || view?.lock_type === LockType.Collaborative" />
<span v-else />
<div>
<MdiAccountGroupIcon />
Collaborative view
<div class="nc-subtitle">Collaborators with edit permissions or higher can change the view configuration.</div>
</div>
</div>
</div>
<div class="nc-menu-item">
<MdiCheckIcon v-if="vModel === LockType.Locked" />
<span v-else />
<div class="nc-menu-item" @click="changeLockType(LockType.Locked)">
<div>
<MdiLockOutlineIcon />
Locked View
<div class="nc-subtitle">No one can edit the view configuration until it is unlocked.</div>
<MdiCheckIcon v-if="view.lock_type === LockType.Locked" />
<span v-else />
<div>
<MdiLockOutlineIcon />
Locked View
<div class="nc-subtitle">No one can edit the view configuration until it is unlocked.</div>
</div>
</div>
</div>
<div class="nc-menu-item">
<MdiCheckIcon v-if="vModel === LockType.Personal" />
<span v-else />
<div class="nc-menu-item" @click="changeLockType(LockType.Personal)">
<div>
<MdiAccountIcon />
Personal view
<div class="nc-subtitle">
Only you can edit the view configuration. Other collaborators personal views are hidden by default.
<MdiCheckIcon v-if="view.lock_type === LockType.Personal" />
<span v-else />
<div>
<MdiAccountIcon />
Personal view
<div class="nc-subtitle">
Only you can edit the view configuration. Other collaborators personal views are hidden by default.
</div>
</div>
</div>
</div>
@ -96,8 +99,12 @@ const Icon = computed(() => {
</template>
<style scoped>
.nc-menu-item {
@apply grid grid-cols-[30px,auto] gap-2 p-4;
.nc-menu-item > div {
@apply grid grid-cols-[30px,auto] gap-2 p-2 align-center;
}
.nc-menu-item > div > svg {
align-self: center;
}
.nc-menu-option > :first-child {

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

@ -13,6 +13,8 @@ import MdiUploadIcon from '~icons/mdi/upload-outline'
import MdiHookIcon from '~icons/mdi/hook'
import MdiViewListIcon from '~icons/mdi/view-list-outline'
const sharedViewListDlg = ref(false)
// todo : replace with inject
const publicViewId = null
const { project } = useProject()
@ -87,40 +89,46 @@ const exportCsv = async () => {
</script>
<template>
<a-dropdown>
<a-button v-t="['c:actions']" class="nc-actions-menu-btn nc-toolbar-btn">
<div class="flex gap-1 align-center">
<MdiFlashIcon class="text-grey" />
<!-- More -->
{{ $t('general.more') }}
<MdiMenuDownIcon class="text-grey" />
</div>
</a-button>
<template #overlay>
<div class="bg-white shadow">
<div>
<div class="nc-menu-item" @click.stop="exportCsv">
<MdiDownloadIcon />
<!-- Download as CSV -->
{{ $t('activity.downloadCSV') }}
</div>
<div class="nc-menu-item" @click.stop>
<MdiUploadIcon />
<!-- Upload CSV -->
{{ $t('activity.uploadCSV') }}
</div>
<div class="nc-menu-item" @click.stop>
<MdiViewListIcon />
<!-- Shared View List -->
{{ $t('activity.listSharedView') }}
</div>
<div class="nc-menu-item" @click.stop>
<MdiHookIcon />
<!-- todo: i18n -->
Webhook
<div>
<a-dropdown>
<a-button v-t="['c:actions']" class="nc-actions-menu-btn nc-toolbar-btn">
<div class="flex gap-1 align-center">
<MdiFlashIcon class="text-grey" />
<!-- More -->
{{ $t('general.more') }}
<MdiMenuDownIcon class="text-grey" />
</div>
</a-button>
<template #overlay>
<div class="bg-white shadow">
<div>
<div class="nc-menu-item" @click="exportCsv">
<MdiDownloadIcon />
<!-- Download as CSV -->
{{ $t('activity.downloadCSV') }}
</div>
<div class="nc-menu-item" @click.stop>
<MdiUploadIcon />
<!-- Upload CSV -->
{{ $t('activity.uploadCSV') }}
</div>
<div class="nc-menu-item" @click="sharedViewListDlg = true">
<MdiViewListIcon />
<!-- Shared View List -->
{{ $t('activity.listSharedView') }}
</div>
<div class="nc-menu-item" @click.stop>
<MdiHookIcon />
<!-- todo: i18n -->
Webhook
</div>
</div>
</div>
</div>
</template>
</a-dropdown>
</template>
</a-dropdown>
<a-modal v-model:visible="sharedViewListDlg" title="Shared view list" width="max(900px,60vw)" :footer="null">
<SmartsheetToolbarSharedViewList v-if="sharedViewListDlg" />
</a-modal>
</div>
</template>

44
packages/nc-gui-v2/components/smartsheet-toolbar/SearchData.vue

@ -1,23 +1,12 @@
<script lang="ts" setup>
import { MetaInj } from '~/context'
import { useProvideSmartsheetStore, useSmartsheetStoreOrThrow } from '~/composables/useSmartsheetStore'
import { MetaInj, ReloadViewDataHookInj } from '~/context'
import MdiSearchIcon from '~icons/mdi/magnify'
import MdiMenuDownIcon from '~icons/mdi/menu-down'
const { modelValue, field } = defineProps<{
modelValue?: string
field?: any
}>()
const reloadData = inject(ReloadViewDataHookInj)
const { search, meta } = useSmartsheetStoreOrThrow()
const emit = defineEmits(['update:modelValue', 'update:field'])
const localValue = computed({
get: () => modelValue,
set: (val) => emit('update:modelValue', val),
})
const localField = computed({
get: () => field,
set: (val) => emit('update:field', val),
})
const meta = inject(MetaInj)
const columns = computed(() =>
meta?.value?.columns?.map((c) => ({
value: c.id,
@ -27,9 +16,26 @@ const columns = computed(() =>
</script>
<template>
<a-input v-model:value="localValue" size="small" class="max-w-[250px]" placeholder="Filter query">
<a-input
v-model:value="search.query"
size="small"
class="max-w-[200px]"
placeholder="Filter query"
@press-enter="reloadData.trigger()"
>
<template #addonBefore>
<a-select v-model:value="localField" :options="columns" style="width: 80px" class="!text-xs" size="small" />
<div class="flex align-center relative" @click="isDropdownOpen = true">
<MdiSearchIcon class="text-grey" />
<MdiMenuDownIcon class="text-grey" />
<a-select
v-model:value="search.field"
size="small"
:dropdown-match-select-width="false"
:options="columns"
class="!absolute top-0 left-0 w-full h-full z-10 !text-xs opacity-0"
>
</a-select>
</div>
</template>
</a-input>
</template>

164
packages/nc-gui-v2/components/smartsheet-toolbar/ShareView.vue

@ -1,13 +1,167 @@
<script lang="ts" setup>
import MdiOpenInNew from '~icons/mdi/open-in-new'
import { useUIPermission } from '#imports'
import { useClipboard } from '@vueuse/core'
import { ViewTypes } from 'nocodb-sdk'
import { computed } from 'vue'
import { message } from 'ant-design-vue'
import { useToast } from 'vue-toastification'
import { useNuxtApp } from '#app'
import { useSmartsheetStoreOrThrow } from '#imports'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
import MdiOpenInNewIcon from '~icons/mdi/open-in-new'
import MdiCopyIcon from '~icons/mdi/content-copy'
const { isUIAllowed } = useUIPermission()
const { view, $api } = useSmartsheetStoreOrThrow()
const { copy } = useClipboard()
const { $e } = useNuxtApp()
const toast = useToast()
const { dashboardUrl } = useDashboard()
let showShareModel = $ref(false)
const passwordProtected = $ref(false)
const shared = ref()
const allowCSVDownload = computed({
get() {
return !!(shared.value?.meta && typeof shared.value.meta === 'string' ? JSON.parse(shared.value.meta) : shared.value.meta)
?.allowCSVDownload
},
set(allow) {
shared.value.meta = { allowCSVDownload: allow }
saveAllowCSVDownload()
},
})
const genShareLink = async () => {
shared.value = await $api.dbViewShare.create(view.value.id as string)
// shared.meta = shared.meta && typeof shared.meta === 'string' ? JSON.parse(shared.meta) : shared.meta;
// // todo: url
// shareLink = shared;
// passwordProtect = shared.password !== null;
// allowCSVDownload = shared.meta.allowCSVDownload;
showShareModel = true
}
const sharedViewUrl = computed(() => {
if (!shared.value) return
let viewType
switch (shared.value.type) {
case ViewTypes.FORM:
viewType = 'form'
break
case ViewTypes.KANBAN:
viewType = 'kanban'
break
default:
viewType = 'view'
}
// todo: get dashboard url
return `${dashboardUrl?.value}/nc/${viewType}/${shared.value.uuid}`
})
async function saveAllowCSVDownload() {
try {
const meta = shared.value.meta && typeof shared.value.meta === 'string' ? JSON.parse(shared.value.meta) : shared.value.meta
// todo: update swagger
await $api.dbViewShare.update(shared.value.id, {
meta,
} as any)
toast.success('Successfully updated')
} catch (e) {
toast.error(await extractSdkResponseErrorMsg(e))
}
if (allowCSVDownload?.value) {
$e('a:view:share:enable-csv-download')
} else {
$e('a:view:share:disable-csv-download')
}
}
const saveShareLinkPassword = async () => {
try {
await $api.dbViewShare.update(shared.value.id, {
password: shared.value.password,
})
toast.success('Successfully updated')
} catch (e) {
toast.error(await extractSdkResponseErrorMsg(e))
}
$e('a:view:share:enable-pwd')
}
const copyLink = () => {
copy(sharedViewUrl?.value as string)
message.success('Copied to clipboard')
}
</script>
<template>
<div v-t="['c:view:share']" class="nc-sidebar-right-item hover:after:bg-secondary/75 group">
<MdiOpenInNew class="group-hover:(!text-white)" />
{{ $t('activity.shareView') }}
<div>
<a-button v-t="['c:view:share']" outlined class="nc-btn-share-view nc-toolbar-btn" size="small">
<div class="flex align-center gap-1" @click="genShareLink">
<MdiOpenInNewIcon class="text-grey" />
<!-- Share View -->
{{ $t('activity.shareView') }}
</div>
</a-button>
<!-- This view is shared via a private link -->
<a-modal
v-model:visible="showShareModel"
size="small"
:title="$t('msg.info.privateLink')"
:footer="null"
width="min(100vw,640px)"
>
<div class="share-link-box nc-share-link-box bg-primary-50">
<div class="flex-1 h-min text-xs">{{ sharedViewUrl }}</div>
<!-- <v-spacer /> -->
<a v-t="['c:view:share:open-url']" :href="sharedViewUrl" target="_blank">
<MdiOpenInNewIcon class="text-sm text-gray-500 mt-2" />
</a>
<MdiCopyIcon class="text-gray-500 text-sm cursor-pointer" @click="copyLink" />
</div>
<a-collapse ghost>
<a-collapse-panel key="1" header="More Options">
<div class="mb-2">
<a-checkbox v-model:checked="passwordProtected" class="!text-xs">{{ $t('msg.info.beforeEnablePwd') }} </a-checkbox>
<!-- todo: add password toggle -->
<div v-if="passwordProtected" class="flex gap-2 mt-2 mb-4">
<a-input
v-model:value="shared.password"
size="small"
class="!text-xs max-w-[250px]"
type="password"
:placeholder="$t('placeholder.password.enter')"
/>
<a-button size="small" class="!text-xs" @click="saveShareLinkPassword"
>{{ $t('placeholder.password.save') }}
</a-button>
</div>
</div>
<div>
<a-checkbox v-if="shared && shared.type === ViewTypes.GRID" v-model:checked="allowCSVDownload" class="!text-xs"
>Allow Download
</a-checkbox>
</div>
</a-collapse-panel>
</a-collapse>
</a-modal>
</div>
</template>
<style scoped>
.share-link-box {
@apply flex p-2 w-full items-center align-center gap-1 bg-gray-100 rounded;
}
:deep(.ant-collapse-header) {
@apply !text-xs;
}
</style>

156
packages/nc-gui-v2/components/smartsheet-toolbar/SharedViewList.vue

@ -0,0 +1,156 @@
<script lang="ts" setup>
import { useClipboard } from '@vueuse/core'
import { ViewTypes } from 'nocodb-sdk'
import { useToast } from 'vue-toastification'
import { message } from 'ant-design-vue'
import { useRoute } from '#app'
import { onMounted, useSmartsheetStoreOrThrow } from '#imports'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
import MdiVisibilityOnIcon from '~icons/mdi/visibility'
import MdiVisibilityOffIcon from '~icons/mdi/visibility-off'
import MdiCopyIcon from '~icons/mdi/content-copy'
import MdiDeleteIcon from '~icons/mdi/delete-outline'
interface SharedViewType {
password: string
title: string
uuid: string
type: ViewTypes
meta: string | Record<string, any>
showPassword?: boolean
}
const { view, $api, meta } = useSmartsheetStoreOrThrow()
const { copy } = useClipboard()
const toast = useToast()
const route = useRoute()
const { dashboardUrl } = useDashboard()
let isLoading = $ref(false)
// let activeSharedView = $ref(null)
const sharedViewList = ref<SharedViewType[]>()
const loadSharedViewsList = async () => {
isLoading = true
const list = await $api.dbViewShare.list(meta.value?.id as string)
console.log(unref(sharedViewList))
console.log(list)
sharedViewList.value = list
// todo: show active view in list separately
// const index = sharedViewList.value.findIndex((v) => {
// return view?.value?.id === v.id
// })
//
// if (index > -1) {
// activeSharedView = sharedViewList.value.splice(index, 1)[0]
// } else {
// activeSharedView = null
// }
isLoading = false
}
onMounted(loadSharedViewsList)
const sharedViewUrl = (view: SharedViewType) => {
let viewType
switch (view.type) {
case ViewTypes.FORM:
viewType = 'form'
break
case ViewTypes.KANBAN:
viewType = 'kanban'
break
default:
viewType = 'view'
}
return `/nc/${viewType}/${view.uuid}`
}
const renderAllowCSVDownload = (view: SharedViewType) => {
if (view.type === ViewTypes.GRID) {
view.meta = (view.meta && typeof view.meta === 'string' ? JSON.parse(view.meta) : view.meta) as Record<string, any>
return view.meta.allowCSVDownload ? '✔' : '❌'
} else {
return 'N/A'
}
}
const copyLink = (view: SharedViewType) => {
copy(`${dashboardUrl?.value as string}/${sharedViewUrl(view)}`)
message.success('Copied to clipboard')
}
const deleteLink = async (id: string) => {
try {
await $api.dbViewShare.delete(id)
toast.success('Deleted shared view successfully')
await loadSharedViewsList()
} catch (e) {
toast.error(await extractSdkResponseErrorMsg(e))
}
}
</script>
<template>
<div class="w-full">
<a-table class="" size="small" :data-source="sharedViewList" :pagination="{ position: ['bottomCenter'] }">
<!-- View name -->
<a-table-column key="title" :title="$t('labels.viewName')" data-index="title">
<template #default="{ text }">
<div class="text-xs" :title="text">
{{ text }}
</div>
</template>
</a-table-column>
<!-- View Link -->
<a-table-column key="title" :title="$t('labels.viewLink')" data-index="title">
<template #default="{ record }">
<nuxt-link :to="sharedViewUrl(record)" class="text-xs">
{{ `${dashboardUrl}/${sharedViewUrl(record)}` }}
</nuxt-link>
</template>
</a-table-column>
<!-- Password -->
<a-table-column key="password" :title="$t('labels.password')" data-index="title">
<template #default="{ record }">
<div class="flex align-center items-center gap-1">
<template v-if="record.password">
<span class="h-min">{{ record.showPassword ? record.password : '***************************' }}</span>
<component
:is="record.showPassword ? MdiVisibilityOffIcon : MdiVisibilityOnIcon"
@click="record.showPassword = !record.showPassword"
/>
</template>
</div>
</template>
</a-table-column>
<!-- Todo: i18n -->
<a-table-column key="meta" title="Download allowed" data-index="title">
<template #default="{ record }">
<template v-if="'meta' in record">
<div class="text-center">{{ renderAllowCSVDownload(record) }}</div>
</template>
</template>
</a-table-column>
<!-- Actions -->
<a-table-column key="id" :title="$t('labels.actions')" data-index="title">
<template #default="{ record }">
<div class="text-sm flex gap-2" :title="text">
<MdiCopyIcon class="cursor-pointer" @click="copyLink(record)" />
<MdiDeleteIcon class="cursor-pointer" @click="deleteLink(record.id)" />
</div>
</template>
</a-table-column>
</a-table>
</div>
</template>
<style scoped>
:deep(.ant-pagination-item > a) {
@apply leading-normal;
}
</style>

46
packages/nc-gui-v2/components/smartsheet-toolbar/SortListMenu.vue

@ -1,5 +1,7 @@
<script setup lang="ts">
import type { ColumnType } from 'nocodb-sdk'
import FieldListAutoCompleteDropdown from './FieldListAutoCompleteDropdown.vue'
import { getSortDirectionOptions } from '~/utils/sortUtils'
import { computed, inject, useViewSorts } from '#imports'
import { ActiveViewInj, IsLockedInj, MetaInj, ReloadViewDataHookInj } from '~/context'
import MdiMenuDownIcon from '~icons/mdi/menu-down'
@ -15,6 +17,12 @@ const reloadDataHook = inject(ReloadViewDataHookInj)
const { sorts, saveOrUpdate, loadSorts, addSort, deleteSort } = useViewSorts(view, () => reloadDataHook?.trigger())
const columns = computed(() => meta?.value?.columns || [])
const columnByID = computed<Record<string, ColumnType>>(() =>
columns?.value?.reduce((obj: any, col: any) => {
obj[col.id] = col
return obj
}, {}),
)
watch(
() => (view?.value as any)?.id,
@ -27,19 +35,19 @@ watch(
<template>
<a-dropdown offset-y class="" :trigger="['click']">
<v-badge :value="sorts && sorts.length" color="primary" dot overlap>
<div :class="{ 'nc-badge nc-active-btn': sorts?.length }">
<a-button v-t="['c:sort']" size="small" class="nc-sort-menu-btn nc-toolbar-btn" :disabled="isLocked"
><div class="flex align-center gap-1">
<MdiSortIcon class="text-grey" />
<!-- Sort -->
<span class="text-capitalize nc-sort-menu-btn">{{ $t('activity.sort') }}</span>
<span class="text-capitalize">{{ $t('activity.sort') }}</span>
<MdiMenuDownIcon class="text-grey" />
</div>
</a-button>
</v-badge>
</div>
<template #overlay>
<div class="bg-white shadow p-2 menu-filter-dropdown min-w-[400px]">
<div class="sort-grid" @click.stop>
<div class="bg-gray-50 shadow p-2 menu-filter-dropdown min-w-[400px] max-h-[max(80vh,500px)] overflow-auto">
<div v-if="sorts?.length" class="sort-grid mb-2" @click.stop>
<template v-for="(sort, i) in sorts || []" :key="i">
<!-- <v-icon :key="`${i}icon`" class="nc-sort-item-remove-btn" small @click.stop="deleteSort(sort)"> mdi-close-box </v-icon> -->
<MdiDeleteIcon
@ -56,25 +64,27 @@ watch(
/>
<a-select
v-model:value="sort.direction"
class="flex-shrink-1 flex-grow-0 caption nc-sort-dir-select"
:items="[
{ text: 'asc', value: 'asc' },
{ text: 'desc', value: 'desc' },
]"
size="small"
class="flex-shrink-1 flex-grow-0 caption nc-sort-dir-select !text-xs"
:label="$t('labels.operation')"
density="compact"
variant="solo"
hide-details
@click.stop
@update:model-value="saveOrUpdate(sort, i)"
/>
@update:value="saveOrUpdate(sort, i)"
>
<a-select-option
v-for="(option, j) in getSortDirectionOptions(columnByID[sort.fk_column_id]?.uidt)"
:key="j"
:value="option.value"
>
<span class="text-xs">{{ option.text }}</span>
</a-select-option>
</a-select>
<!-- <template #item="{ item }"> -->
<!-- <span class="caption font-weight-regular">{{ item.text }}</span> -->
<!-- </template> -->
<!-- </v-select> -->
</template>
</div>
<a-button size="small" class="text-grey text-capitalize text-sm my-3" @click.stop="addSort">
<a-button size="small" class="text-xs text-grey text-capitalize my-2" @click.stop="addSort">
<div class="flex gap-1 align-center">
<MdiAddIcon />
<!-- Add Sort Option -->
@ -93,4 +103,8 @@ watch(
column-gap: 6px;
row-gap: 6px;
}
:deep(.ant-btn, .ant-select, .ant-input, ::placeholder) {
@apply "!text-xs";
}
</style>

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

@ -32,9 +32,11 @@ const isPublicView = false
const selected = reactive<{ row?: number | null; col?: number | null }>({})
const editEnabled = ref(false)
const { sqlUi } = useProject()
const { xWhere } = useSmartsheetStoreOrThrow()
const addColumnDropdown = ref(false)
const { loadData, paginationData, formattedData: data, updateRowProperty, changePage } = useViewData(meta, view as any)
const { loadData, paginationData, formattedData: data, updateRowProperty, changePage } = useViewData(meta, view as any, xWhere)
const { loadGridViewColumns, updateWidth, resizingColWidth, resizingCol } = useGridViewColumnWidth(view)
onMounted(loadGridViewColumns)

10
packages/nc-gui-v2/components/tabs/Smartsheet.vue

@ -1,8 +1,9 @@
<script setup lang="ts">
import type { ColumnType } from 'nocodb-sdk'
import type { ColumnType, TableType, ViewType } from 'nocodb-sdk'
import { ViewTypes } from 'nocodb-sdk'
import type { Ref } from 'vue'
import SmartsheetGrid from '../smartsheet/Grid.vue'
import { computed, inject, provide, useMetas, watch, watchEffect } from '#imports'
import { computed, inject, provide, useMetas, useProvideSmartsheetStore, watch, watchEffect } from '#imports'
import { ActiveViewInj, FieldsInj, IsLockedInj, MetaInj, ReloadViewDataHookInj, RightSidebarInj, TabMetaInj } from '~/context'
import type { TabItem } from '~/composables'
@ -19,7 +20,7 @@ const tabMeta = inject(
computed(() => ({} as TabItem)),
)
const meta = computed(() => metas.value?.[tabMeta?.value?.id as string])
const meta = computed<TableType>(() => metas.value?.[tabMeta?.value?.id as string])
watchEffect(async () => {
await getMeta(tabMeta?.value?.id as string)
@ -27,6 +28,7 @@ watchEffect(async () => {
const reloadEventHook = createEventHook<void>()
// todo: move to store
provide(MetaInj, meta)
provide(TabMetaInj, tabMeta)
provide(ActiveViewInj, activeView)
@ -35,6 +37,8 @@ provide(ReloadViewDataHookInj, reloadEventHook)
provide(FieldsInj, fields)
provide(RightSidebarInj, ref(true))
useProvideSmartsheetStore(activeView as Ref<TableType>, meta)
watch(tabMeta, async (newTabMeta, oldTabMeta) => {
if (newTabMeta !== oldTabMeta && newTabMeta.id) await getMeta(newTabMeta.id)
})

4
packages/nc-gui-v2/composables/index.ts

@ -11,7 +11,7 @@ export * from './useHasMany'
export * from './useManyToMany'
export * from './useMetas'
export * from './useProject'
export * from './useTableCreate'
export * from './useTable'
export * from './useTabs'
export * from './useViewColumns'
export * from './useViewData'
@ -19,3 +19,5 @@ export * from './useViewFilters'
export * from './useViews'
export * from './useViewSorts'
export * from './useVirtualCell'
export * from './useColumnCreateStore'
export * from './useSmartsheetStore'

10
packages/nc-gui-v2/composables/useDashboard.ts

@ -0,0 +1,10 @@
export function useDashboard() {
const route = useRoute()
const dashboardUrl = computed(() => {
// todo: test in different scenarios
// get base path of app
return `${location.origin}${(location.pathname || '').replace(route.path, '')}`
})
return { dashboardUrl }
}

53
packages/nc-gui-v2/composables/useSmartsheetStore.ts

@ -0,0 +1,53 @@
import { computed } from '@vue/reactivity'
import { createInjectionState } from '@vueuse/core'
import type { TableType, ViewType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import { useNuxtApp } from '#app'
import { useProject } from '#imports'
const [useProvideSmartsheetStore, useSmartsheetStore] = createInjectionState((view: Ref<ViewType>, meta: Ref<TableType>) => {
const { $api } = useNuxtApp()
const { sqlUi } = useProject()
// state
// todo: move to grid view store
const search = reactive({
field: '',
query: '',
})
// getters
const isLocked = computed(() => (view?.value as any)?.lock_type === 'locked')
const xWhere = computed(() => {
let where
const col = meta?.value?.columns?.find(({ id }) => id === search.field) || meta?.value?.columns?.find((v) => v.pv)
if (!col) return
if (!search.query.trim()) return
if (['text', 'string'].includes(sqlUi.value.getAbstractType(col)) && col.dt !== 'bigint') {
where = `(${col.title},like,%${search.query.trim()}%)`
} else {
where = `(${col.title},eq,${search.query.trim()})`
}
return where
})
// actions
return {
view,
meta,
isLocked,
$api,
search,
xWhere,
}
})
export { useProvideSmartsheetStore }
export function useSmartsheetStoreOrThrow() {
const smartsheetStore = useSmartsheetStore()
if (smartsheetStore == null) throw new Error('Please call `useSmartsheetStore` on the appropriate parent component')
return smartsheetStore
}

112
packages/nc-gui-v2/composables/useTable.ts

@ -0,0 +1,112 @@
import { Modal } from 'ant-design-vue'
import type { LinkToAnotherRecordType, TableType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk'
import { useToast } from 'vue-toastification'
import { useProject } from './useProject'
import { TabType } from '~/composables/useTabs'
import { extractSdkResponseErrorMsg } from '~/utils'
import { useNuxtApp } from '#app'
export function useTable(onTableCreate?: (tableMeta: TableType) => void) {
const table = reactive<{ title: string; table_name: string; columns: string[] }>({
title: '',
table_name: '',
columns: ['id', 'title', 'created_at', 'updated_at'],
})
const { $e, $api } = useNuxtApp()
const toast = useToast()
const { getMeta, removeMeta } = useMetas()
const { loadTables } = useProject()
const { closeTab } = useTabs()
const { sqlUi, project, tables } = useProject()
const createTable = async () => {
if (!sqlUi?.value) return
const columns = sqlUi?.value?.getNewTableColumns().filter((col) => {
if (col.column_name === 'id' && table.columns.includes('id_ag')) {
Object.assign(col, sqlUi?.value?.getDataTypeForUiType({ uidt: UITypes.ID }, 'AG'))
col.dtxp = sqlUi?.value?.getDefaultLengthForDatatype(col.dt)
col.dtxs = sqlUi?.value?.getDefaultScaleForDatatype(col.dt)
return true
}
return table.columns.includes(col.column_name)
})
const tableMeta = await $api.dbTable.create(project?.value?.id as string, {
...table,
columns,
})
onTableCreate?.(tableMeta)
}
watch(
() => table.title,
(title) => {
table.table_name = `${project?.value?.prefix || ''}${title}`
},
)
const generateUniqueTitle = () => {
let c = 1
while (tables?.value?.some((t) => t.title === `Sheet${c}`)) {
c++
}
table.title = `Sheet${c}`
}
const deleteTable = (table: TableType) => {
$e('c:table:delete')
// 'Click Submit to Delete The table'
Modal.confirm({
title: `Click Yes to Delete The table : ${table.title}`,
okText: 'Yes',
okType: 'danger',
cancelText: 'No',
async onOk() {
try {
const meta = (await getMeta(table.id as string)) as TableType
const relationColumns = meta?.columns?.filter((c) => c.uidt === UITypes.LinkToAnotherRecord)
if (relationColumns?.length) {
const refColMsgs = await Promise.all(
relationColumns.map(async (c, i) => {
const refMeta = (await getMeta(
(c?.colOptions as LinkToAnotherRecordType)?.fk_related_model_id as string,
)) as TableType
return `${i + 1}. ${c.title} is a LinkToAnotherRecord of ${(refMeta && refMeta.title) || c.title}`
}),
)
toast.info(
h('div', {
innerHTML: `<div style="padding:10px 4px">Unable to delete tables because of the following.
<br><br>${refColMsgs.join('<br>')}<br><br>
Delete them & try again</div>`,
}),
)
return
}
await $api.dbTable.delete(table?.id as string)
closeTab({
type: TabType.TABLE,
id: table.id,
title: table.title,
})
await loadTables()
removeMeta(table.id as string)
toast.info(`Deleted table ${table.title} successfully`)
$e('a:table:delete')
} catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e))
}
},
})
}
return { table, createTable, generateUniqueTitle, tables, project, deleteTable }
}

3
packages/nc-gui-v2/composables/useUIPermission/index.ts

@ -10,7 +10,6 @@ export function useUIPermission() {
const isUIAllowed = (permission: Permission, _skipPreviewAs = false) => {
const user = $state.user
let userRoles = user?.value?.roles || {}
// if string populate key-value paired object
if (typeof userRoles === 'string') {
userRoles = userRoles.split(',').reduce<Record<string, boolean>>((acc, role) => {
@ -35,7 +34,7 @@ export function useUIPermission() {
return Object.entries<boolean>(roles).some(([role, hasRole]) => {
const rolePermission = rolePermissions[role as keyof typeof rolePermissions] as '*' | Record<Permission, true>
return hasRole && (rolePermission === '*' || rolePermission[permission])
return hasRole && (rolePermission === '*' || rolePermission?.[permission])
})
}

9
packages/nc-gui-v2/composables/useViewColumns.ts

@ -16,6 +16,7 @@ export function useViewColumns(
show: number | boolean
title: string
fk_column_id?: string
system?: boolean
}[]
>()
@ -42,6 +43,7 @@ export function useViewColumns(
fk_column_id: c.id,
...(fieldById[c.id as string] ? fieldById[c.id as string] : {}),
order: (fieldById[c.id as string] && fieldById[c.id as string].order) || order++,
system: isSystemColumn(fieldById[c.fk_model_id as string]?.type as ColumnType),
}))
.sort((a, b) => a.order - b.order)
} else if (isPublic) {
@ -104,7 +106,7 @@ export function useViewColumns(
return false
}
return !filterQuery?.value || field.title.toLowerCase().includes(filterQuery.value)
return !filterQuery?.value || field.title.toLowerCase().includes(filterQuery.value.toLowerCase())
})
})
@ -125,10 +127,6 @@ export function useViewColumns(
?.sort((c1, c2) => c1.order - c2.order)
?.map((c) => metaColumnById?.value?.[c.fk_column_id as string]) || []) as ColumnType[]
})
const sortedFields = computed<ColumnType[]>(() => {
return (fields?.value?.sort((c1, c2) => c1.order - c2.order)?.map((c) => metaColumnById?.value?.[c.fk_column_id as string]) ||
[]) as ColumnType[]
})
// reload view columns when table meta changes
watch(meta, () => loadViewColumns())
@ -143,6 +141,5 @@ export function useViewColumns(
saveOrUpdate,
sortedAndFilteredFields,
showSystemFields,
sortedFields,
}
}

15
packages/nc-gui-v2/composables/useViewData.ts

@ -1,4 +1,4 @@
import type { Api, FormType, GalleryType, GridType, PaginatedType, TableType } from 'nocodb-sdk'
import type { Api, PaginatedType, TableType, ViewType } from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue'
import { useNuxtApp } from '#app'
import { useProject } from '#imports'
@ -13,10 +13,8 @@ const formatData = (list: Record<string, any>[]) =>
export function useViewData(
meta: Ref<TableType> | ComputedRef<TableType> | undefined,
viewMeta:
| Ref<(GridType | GalleryType | FormType) & { id: string }>
| ComputedRef<(GridType | GalleryType | FormType) & { id: string }>
| undefined,
viewMeta: Ref<ViewType & { id: string }> | ComputedRef<ViewType & { id: string }> | undefined,
where?: ComputedRef<string | undefined>,
) {
const data = ref<Record<string, any>[]>()
const formattedData = ref<{ row: Record<string, any>; oldRow: Record<string, any>; rowMeta?: any }[]>()
@ -27,7 +25,10 @@ export function useViewData(
const loadData = async (params: Parameters<Api<any>['dbViewRow']['list']>[4] = {}) => {
if (!project?.value?.id || !meta?.value?.id || !viewMeta?.value?.id) return
const response = await $api.dbViewRow.list('noco', project.value.id, meta.value.id, viewMeta.value.id, params)
const response = await $api.dbViewRow.list('noco', project.value.id, meta.value.id, viewMeta.value.id, {
...params,
where: where?.value,
})
data.value = response.list
formattedData.value = formatData(response.list)
paginationData.value = response.pageInfo
@ -97,7 +98,7 @@ export function useViewData(
const changePage = async (page: number) => {
paginationData.value.page = page
await loadData({ offset: (page - 1) * (paginationData.value.pageSize || 25) } as any)
await loadData({ offset: (page - 1) * (paginationData.value.pageSize || 25), where: where?.value } as any)
}
return { data, loadData, paginationData, formattedData, insertRow, updateRowProperty, changePage }

83
packages/nc-gui-v2/composables/useViewFilters.ts

@ -1,15 +1,19 @@
import type { FilterType, GalleryType, GridType, KanbanType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import { useNuxtApp } from '#imports'
import type { ComputedRef, Ref } from 'vue'
import { useNuxtApp, useUIPermission } from '#imports'
export function useViewFilters(
view: Ref<(GridType | KanbanType | GalleryType) & { id?: string }> | undefined,
parentId?: string,
autoApply?: ComputedRef<boolean>,
reloadData?: () => void,
shared = false,
) {
const filters = ref<(FilterType & { status?: 'update' | 'delete' })[]>([])
// todo: update swagger
const filters = ref<(FilterType & { status?: 'update' | 'delete' | 'create'; parentId?: string })[]>([])
const { $api } = useNuxtApp()
const { isUIAllowed } = useUIPermission()
const loadFilters = async () => {
if (parentId) {
@ -28,7 +32,7 @@ export function useViewFilters(
...filter,
fk_parent_id: parentId,
})
} else {
} else if (filter.status === 'create') {
filters.value[+i] = (await $api.dbTableFilter.create(view?.value?.id as string, {
...filter,
fk_parent_id: parentId,
@ -38,55 +42,41 @@ export function useViewFilters(
reloadData?.()
}
const deleteFilter = async (filter: FilterType, i: number) => {
// if (this.shared || !this._isUIAllowed('filterSync')) {
// this.filters.splice(i, 1)
// this.$emit('updated')
// } else
if (filter.id) {
// if (!this.autoApply) {
// this.$set(filter, 'status', 'delete')
// } else {
await $api.dbTableFilter.delete(filter.id) /**/
// await this.loadFilter()
// this.$emit('updated')
// }
} else {
// this.$emit('updated')
const deleteFilter = async (filter: FilterType & { status: string }, i: number) => {
if (shared || !isUIAllowed('filterSync')) {
const _filters = unref(filters.value)
_filters.splice(i, 1)
filters.value = _filters
} else if (filter.id) {
if (!autoApply?.value) {
filter.status = 'delete'
} else {
await $api.dbTableFilter.delete(filter.id)
const _filters = unref(filters.value)
_filters.splice(i, 1)
filters.value = _filters
reloadData?.()
}
}
const _filters = unref(filters.value)
_filters.splice(i, 1)
filters.value = _filters
// this.$e('a:filter:delete')
// // },
reloadData?.()
}
const saveOrUpdate = async (filter: FilterType, i: number) => {
const saveOrUpdate = async (filter: FilterType & { status?: string }, i: number, force = false) => {
if (!view?.value) return
// if (this.shared || !this._isUIAllowed('filterSync')) {
// this.$emit('input', this.filters.filter(f => f.fk_column_id && f.comparison_op))
// this.$emit('updated')
// } else if (!this.autoApply) {
// filter.status = 'update'
// } else
if (filter.id) {
if (shared || !isUIAllowed('filterSync')) {
// skip
} else if (!autoApply?.value && !force) {
filter.status = filter.id ? 'update' : 'create'
} else if (filter.id) {
await $api.dbTableFilter.update(filter.id, {
...filter,
fk_parent_id: parentId,
})
// this.$emit('updated')
} else {
// todo: return type correction
filters.value[i] = (await $api.dbTableFilter.create(view?.value?.id as string, {
...filter,
fk_parent_id: parentId,
})) as any
// this.$emit('updated')
}
reloadData?.()
}
@ -95,10 +85,21 @@ export function useViewFilters(
filters.value.push({
comparison_op: 'eq',
value: '',
status: 'update',
status: 'create',
logical_op: 'and',
})
}
const addFilterGroup = async (parentId?: string) => {
filters.value.push({
parentId,
is_group: true,
status: 'create',
logical_op: 'and',
})
const index = filters.value.length - 1
await saveOrUpdate(filters.value[index], index, true)
}
return { filters, loadFilters, sync, deleteFilter, saveOrUpdate, addFilter }
return { filters, loadFilters, sync, deleteFilter, saveOrUpdate, addFilter, addFilterGroup }
}

33
packages/nc-gui-v2/package-lock.json generated

@ -19,7 +19,7 @@
"unique-names-generator": "^4.7.1",
"vue-i18n": "^9.1.10",
"vue-toastification": "^2.0.0-rc.5",
"vuedraggable": "^2.24.3",
"vuedraggable": "^4.1.0",
"vuetify": "^3.0.0-alpha.13",
"xlsx": "^0.17.3"
},
@ -13869,17 +13869,20 @@
}
},
"node_modules/vuedraggable": {
"version": "2.24.3",
"resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-2.24.3.tgz",
"integrity": "sha512-6/HDXi92GzB+Hcs9fC6PAAozK1RLt1ewPTLjK0anTYguXLAeySDmcnqE8IC0xa7shvSzRjQXq3/+dsZ7ETGF3g==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-4.1.0.tgz",
"integrity": "sha512-FU5HCWBmsf20GpP3eudURW3WdWTKIbEIQxh9/8GE806hydR9qZqRRxRE3RjqX7PkuLuMQG/A7n3cfj9rCEchww==",
"dependencies": {
"sortablejs": "1.10.2"
"sortablejs": "1.14.0"
},
"peerDependencies": {
"vue": "^3.0.1"
}
},
"node_modules/vuedraggable/node_modules/sortablejs": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.10.2.tgz",
"integrity": "sha512-YkPGufevysvfwn5rfdlGyrGjt7/CRHwvRPogD/lC+TnvcN29jDpCifKP+rBqf+LRldfXSTh+0CGLcSg0VIxq3A=="
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.14.0.tgz",
"integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w=="
},
"node_modules/vuetify": {
"version": "3.0.0-beta.5",
@ -24681,17 +24684,17 @@
}
},
"vuedraggable": {
"version": "2.24.3",
"resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-2.24.3.tgz",
"integrity": "sha512-6/HDXi92GzB+Hcs9fC6PAAozK1RLt1ewPTLjK0anTYguXLAeySDmcnqE8IC0xa7shvSzRjQXq3/+dsZ7ETGF3g==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-4.1.0.tgz",
"integrity": "sha512-FU5HCWBmsf20GpP3eudURW3WdWTKIbEIQxh9/8GE806hydR9qZqRRxRE3RjqX7PkuLuMQG/A7n3cfj9rCEchww==",
"requires": {
"sortablejs": "1.10.2"
"sortablejs": "1.14.0"
},
"dependencies": {
"sortablejs": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.10.2.tgz",
"integrity": "sha512-YkPGufevysvfwn5rfdlGyrGjt7/CRHwvRPogD/lC+TnvcN29jDpCifKP+rBqf+LRldfXSTh+0CGLcSg0VIxq3A=="
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.14.0.tgz",
"integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w=="
}
}
},

2
packages/nc-gui-v2/package.json

@ -25,7 +25,7 @@
"unique-names-generator": "^4.7.1",
"vue-i18n": "^9.1.10",
"vue-toastification": "^2.0.0-rc.5",
"vuedraggable": "^2.24.3",
"vuedraggable": "^4.1.0",
"vuetify": "^3.0.0-alpha.13",
"xlsx": "^0.17.3"
},

35
packages/nc-gui-v2/utils/sortUtils.ts

@ -0,0 +1,35 @@
import { UITypes } from 'nocodb-sdk'
export const getSortDirectionOptions = (uidt: UITypes) => {
switch (uidt) {
case UITypes.Year:
case UITypes.Number:
case UITypes.Decimal:
case UITypes.Rating:
case UITypes.Count:
case UITypes.AutoNumber:
case UITypes.Time:
case UITypes.Currency:
case UITypes.Percent:
case UITypes.Duration:
case UITypes.PhoneNumber:
case UITypes.Date:
case UITypes.DateTime:
case UITypes.CreateTime:
case UITypes.LastModifiedTime:
return [
{ text: '1 → 9', value: 'asc' },
{ text: '9 → 1', value: 'desc' },
]
case UITypes.Checkbox:
return [
{ text: '▢ → ✓', value: 'asc' },
{ text: '✓ → ▢', value: 'desc' },
]
default:
return [
{ text: 'A → Z', value: 'asc' },
{ text: 'Z → A', value: 'desc' },
]
}
}

4
packages/nocodb-sdk/src/lib/Api.ts

@ -127,6 +127,7 @@ export interface ViewType {
order?: number;
fk_model_id?: string;
slug?: string;
lock_type?: 'collaborative' | 'locked' | 'personal';
}
export interface TableInfoType {
@ -313,6 +314,7 @@ export interface GridType {
alias?: string;
deleted?: boolean;
order?: number;
lock_type?: 'collaborative' | 'locked' | 'personal';
}
export interface GalleryType {
@ -331,6 +333,7 @@ export interface GalleryType {
columns?: GalleryColumnType[];
fk_model_id?: string;
fk_cover_image_col_id?: string;
lock_type?: 'collaborative' | 'locked' | 'personal';
}
export interface GalleryColumnType {
@ -382,6 +385,7 @@ export interface FormType {
submit_another_form?: boolean;
columns?: FormColumnType[];
fk_model_id?: string;
lock_type?: 'collaborative' | 'locked' | 'personal';
}
export interface FormColumnType {

2
packages/nocodb/src/lib/models/View.ts

@ -30,7 +30,7 @@ export default class View implements ViewType {
is_default: boolean;
order: number;
type: ViewTypes;
lock_type?: string;
lock_type?: ViewType['lock_type'];
fk_model_id: string;
model?: Model;

4
packages/nocodb/src/lib/version-upgrader/ncProjectUpgraderV2_0090000.ts

@ -8,6 +8,7 @@ import {
ModelTypes,
substituteColumnAliasWithIdInFormula,
UITypes,
ViewType,
ViewTypes,
} from 'nocodb-sdk';
import Column from '../models/Column';
@ -1029,7 +1030,8 @@ async function migrateViewsParams(
},
ncMeta
);
view.lock_type = queryParams?.viewStatus?.type;
view.lock_type = queryParams?.viewStatus
?.type as ViewType['lock_type'];
}
// migrate view sort list
for (const sort of queryParams.sortList || []) {

32
scripts/sdk/swagger.json

@ -6024,6 +6024,14 @@
},
"slug": {
"type": "string"
},
"lock_type": {
"type": "string",
"enum": [
"collaborative",
"locked",
"personal"
]
}
}
},
@ -6852,6 +6860,14 @@
},
"order": {
"type": "number"
},
"lock_type": {
"type": "string",
"enum": [
"collaborative",
"locked",
"personal"
]
}
},
"description": ""
@ -6908,6 +6924,14 @@
},
"fk_cover_image_col_id": {
"type": "string"
},
"lock_type": {
"type": "string",
"enum": [
"collaborative",
"locked",
"personal"
]
}
}
},
@ -7057,6 +7081,14 @@
},
"fk_model_id": {
"type": "string"
},
"lock_type": {
"type": "string",
"enum": [
"collaborative",
"locked",
"personal"
]
}
}
},

Loading…
Cancel
Save