Browse Source

refactor(gui): bring back missing code

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3830/head
Pranav C 2 years ago
parent
commit
a4a5c2d6bc
  1. 7
      packages/nc-gui/components/smartsheet/Gallery.vue
  2. 22
      packages/nc-gui/components/smartsheet/Grid.vue
  3. 7
      packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue
  4. 2
      packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
  5. 12
      packages/nc-gui/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue
  6. 1
      packages/nc-gui/pages/[projectType]/form/[viewId]/index.vue

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

@ -160,9 +160,10 @@ onMounted(async () => {
// provide view data reload hook as fallback to row data reload // provide view data reload hook as fallback to row data reload
provide(ReloadRowDataHookInj, reloadViewDataHook) provide(ReloadRowDataHookInj, reloadViewDataHook)
watch(view, (nextView) => { watch(view, async (nextView) => {
if (nextView?.type === ViewTypes.FORM) { if (nextView?.type === ViewTypes.GALLERY) {
reloadEventHook.trigger() await loadData()
await loadGalleryData()
} }
}) })
</script> </script>

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

@ -230,6 +230,7 @@ useEventListener(document, 'keyup', async (e: KeyboardEvent) => {
/** On clicking outside of table reset active cell */ /** On clicking outside of table reset active cell */
const smartTable = ref(null) const smartTable = ref(null)
onClickOutside(smartTable, () => { onClickOutside(smartTable, () => {
clearRangeRows()
if (selected.col === null) return if (selected.col === null) return
const activeCol = fields.value[selected.col] const activeCol = fields.value[selected.col]
@ -411,7 +412,8 @@ watch(
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <!-- this prevent select text from field if not in edit mode -->
<tbody @selectstart.prevent>
<LazySmartsheetRow v-for="(row, rowIndex) of data" ref="rowRefs" :key="rowIndex" :row="row"> <LazySmartsheetRow v-for="(row, rowIndex) of data" ref="rowRefs" :key="rowIndex" :row="row">
<template #default="{ state }"> <template #default="{ state }">
<tr class="nc-grid-row"> <tr class="nc-grid-row">
@ -460,14 +462,17 @@ watch(
:key="columnObj.id" :key="columnObj.id"
class="cell relative cursor-pointer nc-grid-cell" class="cell relative cursor-pointer nc-grid-cell"
:class="{ :class="{
active: isUIAllowed('xcDatatableEditable') && selected.col === colIndex && selected.row === rowIndex, active:
(isUIAllowed('xcDatatableEditable') && selected.col === colIndex && selected.row === rowIndex) ||
(isUIAllowed('xcDatatableEditable') && selectedRange(rowIndex, colIndex)),
}" }"
:data-key="rowIndex + columnObj.id" :data-key="rowIndex + columnObj.id"
:data-col="columnObj.id" :data-col="columnObj.id"
:data-title="columnObj.title" :data-title="columnObj.title"
@click="selectCell(rowIndex, colIndex)" @click="selectCell(rowIndex, colIndex)"
@dblclick="makeEditable(row, columnObj)" @dblclick="makeEditable(row, columnObj)"
@contextmenu="showContextMenu($event, { row: rowIndex, col: colIndex })" @mousedown="startSelectRange($event, rowIndex, colIndex)"
@mouseover="selectBlock(rowIndex, colIndex)"
> >
<div class="w-full h-full"> <div class="w-full h-full">
<LazySmartsheetVirtualCell <LazySmartsheetVirtualCell
@ -483,12 +488,7 @@ watch(
v-else v-else
v-model="row.row[columnObj.title]" v-model="row.row[columnObj.title]"
:column="columnObj" :column="columnObj"
:edit-enabled=" :edit-enabled="hasEditPermission && editEnabled && selected.col === colIndex && selected.row === rowIndex"
isUIAllowed('xcDatatableEditable') &&
editEnabled &&
selected.col === colIndex &&
selected.row === rowIndex
"
:row-index="rowIndex" :row-index="rowIndex"
:active="selected.col === colIndex && selected.row === rowIndex" :active="selected.col === colIndex && selected.row === rowIndex"
@update:edit-enabled="editEnabled = false" @update:edit-enabled="editEnabled = false"
@ -502,7 +502,7 @@ watch(
</template> </template>
</LazySmartsheetRow> </LazySmartsheetRow>
<tr v-if="!isView && !isLocked && isUIAllowed('xcDatatableEditable') && !isSqlView"> <tr v-if="!isView && !isLocked && hasEditPermission && !isSqlView">
<td <td
v-e="['c:row:add:grid-bottom']" v-e="['c:row:add:grid-bottom']"
:colspan="visibleColLength + 1" :colspan="visibleColLength + 1"
@ -521,7 +521,7 @@ watch(
</tbody> </tbody>
</table> </table>
<template v-if="!isLocked && isUIAllowed('xcDatatableEditable')" #overlay> <template v-if="!isLocked && hasEditPermission" #overlay>
<a-menu class="shadow !rounded !py-0" @click="contextMenu = false"> <a-menu class="shadow !rounded !py-0" @click="contextMenu = false">
<a-menu-item v-if="contextMenuTarget" @click="deleteRow(contextMenuTarget.row)"> <a-menu-item v-if="contextMenuTarget" @click="deleteRow(contextMenuTarget.row)">
<div v-e="['a:row:delete']" class="nc-project-menu-item"> <div v-e="['a:row:delete']" class="nc-project-menu-item">

7
packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue

@ -43,8 +43,6 @@ const { api } = useApi()
const router = useRouter() const router = useRouter()
const route = useRoute()
/** Selected view(s) for menu */ /** Selected view(s) for menu */
const selected = ref<string[]>([]) const selected = ref<string[]>([])
@ -225,7 +223,7 @@ watch(views, (nextViews) => {
<template> <template>
<a-menu ref="menuRef" :class="{ dragging }" class="nc-views-menu flex-1" :selected-keys="selected"> <a-menu ref="menuRef" :class="{ dragging }" class="nc-views-menu flex-1" :selected-keys="selected">
<LazySmartsheetSidebarRenameableMenuItem <LazySmartsheetSidebarRenameableMenuItem
v-for="(view, index) of views" v-for="view of views"
:id="view.id" :id="view.id"
:key="view.id" :key="view.id"
:view="view" :view="view"
@ -233,8 +231,7 @@ watch(views, (nextViews) => {
class="transition-all ease-in duration-300" class="transition-all ease-in duration-300"
:class="{ :class="{
'bg-gray-100': isMarked === view.id, 'bg-gray-100': isMarked === view.id,
'active': 'active': activeView.id === view.id,
(route.params.viewTitle && route.params.viewTitle === view.title) || (route.params.viewTitle === '' && index === 0),
[`nc-view-item nc-${viewTypeAlias[view.type] || view.type}-view-item`]: true, [`nc-view-item nc-${viewTypeAlias[view.type] || view.type}-view-item`]: true,
}" }"
@change-view="changeView" @change-view="changeView"

2
packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

@ -142,7 +142,7 @@ const getIcon = (c: ColumnType) =>
<a-select <a-select
v-model:value="coverImageColumnId" v-model:value="coverImageColumnId"
class="w-full" class="w-full"
:options="coverOptions ?? []" :options="coverOptions"
dropdown-class-name="nc-dropdown-cover-image" dropdown-class-name="nc-dropdown-cover-image"
@click.stop @click.stop
/> />

12
packages/nc-gui/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue

@ -15,16 +15,10 @@ const activeTab = inject(
computed(() => ({} as TabItem)), computed(() => ({} as TabItem)),
) )
/** wait until table list loads since meta load requires table list **/
// until(tables)
// .toMatch((tables) => tables.length > 0)
// .then(() => {
// getMeta(route.params.title as string, true).finally(() => (loading.value = false))
// })
watch( watch(
() => route.params.title, () => route.params.title,
(tableTitle) => { (tableTitle) => {
/** wait until table list loads since meta load requires table list **/
until(tables) until(tables)
.toMatch((tables) => tables.length > 0) .toMatch((tables) => tables.length > 0)
.then(() => { .then(() => {
@ -37,10 +31,6 @@ watch(
<template> <template>
<div class="w-full h-full"> <div class="w-full h-full">
<!-- <div v-if="loading" class="flex items-center justify-center h-full w-full"> -->
<!-- <a-spin size="large" /> -->
<!-- </div> -->
<LazyTabsSmartsheet :active-tab="activeTab" /> <LazyTabsSmartsheet :active-tab="activeTab" />
</div> </div>
</template> </template>

1
packages/nc-gui/pages/[projectType]/form/[viewId]/index.vue

@ -14,7 +14,6 @@ const {
passwordDlg, passwordDlg,
password, password,
loadSharedView, loadSharedView,
isLoading,
} = useSharedFormStoreOrThrow() } = useSharedFormStoreOrThrow()
function isRequired(_columnObj: Record<string, any>, required = false) { function isRequired(_columnObj: Record<string, any>, required = false) {

Loading…
Cancel
Save