Skip to content

Commit d1dbfb6

Browse files
authored
feat: gallery view (#1051)
* feat: gallery view * fix: lint type * chore: update i18n * fix: presort interaction * fix: the rendering for group by date field validation * fix: display tooltip when text ellipsis is activated * fix: rendering of card title
1 parent d59e99b commit d1dbfb6

File tree

72 files changed

+1169
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1169
-78
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ Visualize and interact with data in various ways best suited for their specific
7878
- Grid View: The default view of the table, which displays data in a spreadsheet-like format.
7979
- Form View: Input data in a form format, which is useful for collecting data.
8080
- Kanban View: Displays data in a Kanban board, which is a visual representation of data in columns and cards.
81+
- Gallery View: Displays data in a gallery format, which is useful for displaying images and other media.
8182
- Calendar View: Displays data in a calendar format, which is useful for tracking dates and events. (coming soon)
82-
- Gallery View: Displays data in a gallery format, which is useful for displaying images and other media. (coming soon)
8383
- Gantt View: Displays data in a Gantt chart, which is useful for tracking project schedules. (coming soon)
8484
- Timeline View: Displays data in a timeline format, which is useful for tracking events over time. (coming soon)
8585

apps/nestjs-backend/src/features/aggregation/aggregation.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export class AggregationService {
284284
where: {
285285
tableId,
286286
...(withView?.viewId ? { id: withView.viewId } : {}),
287-
type: { in: [ViewType.Grid, ViewType.Gantt, ViewType.Kanban] },
287+
type: { in: [ViewType.Grid, ViewType.Gantt, ViewType.Kanban, ViewType.Gallery] },
288288
deletedTime: null,
289289
},
290290
})

apps/nestjs-backend/src/features/share/share.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ export class ShareService {
351351
return this.getViewAllCollaborators(shareInfo);
352352
}
353353

354-
// only form and kanban view can get all records
354+
// only form, kanban and plugin view can get all collaborators
355355
if ([ViewType.Form, ViewType.Kanban, ViewType.Plugin].includes(view.type)) {
356356
return this.getViewAllCollaborators(shareInfo);
357357
}

apps/nestjs-backend/src/features/view/model/factory.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { assertNever, ViewType } from '@teable/core';
33
import type { View } from '@teable/db-main-prisma';
44
import { plainToInstance } from 'class-transformer';
55
import { FormViewDto } from './form-view.dto';
6+
import { GalleryViewDto } from './gallery-view.dto';
67
import { GridViewDto } from './grid-view.dto';
78
import { KanbanViewDto } from './kanban-view.dto';
89
import { PluginViewDto } from './plugin-view.dto';
@@ -15,11 +16,12 @@ export function createViewInstanceByRaw(viewRaw: View) {
1516
return plainToInstance(GridViewDto, viewVo);
1617
case ViewType.Kanban:
1718
return plainToInstance(KanbanViewDto, viewVo);
19+
case ViewType.Gallery:
20+
return plainToInstance(GalleryViewDto, viewVo);
1821
case ViewType.Form:
1922
return plainToInstance(FormViewDto, viewVo);
2023
case ViewType.Plugin:
2124
return plainToInstance(PluginViewDto, viewVo);
22-
case ViewType.Gallery:
2325
case ViewType.Gantt:
2426
case ViewType.Calendar:
2527
throw new Error('did not implement yet');
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { IShareViewMeta } from '@teable/core';
2+
import { GalleryViewCore } from '@teable/core';
3+
4+
export class GalleryViewDto extends GalleryViewCore {
5+
defaultShareMeta: IShareViewMeta = {
6+
includeRecords: true,
7+
};
8+
}

apps/nestjs-backend/src/features/view/view.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class ViewService implements IReadonlyAdapterService {
139139
// create view compensation data
140140
const innerViewRo = { ...viewRo };
141141
// primary field set visible default
142-
if (viewRo.type === ViewType.Kanban) {
142+
if ([ViewType.Kanban, ViewType.Gallery].includes(viewRo.type)) {
143143
const primaryField = await this.prismaService.txClient().field.findFirstOrThrow({
144144
where: { tableId, isPrimary: true, deletedTime: null },
145145
select: { id: true },

apps/nestjs-backend/src/utils/is-not-hidden-field.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { IKanbanViewOptions, IViewVo } from '@teable/core';
1+
import type { IGalleryViewOptions, IKanbanViewOptions, IViewVo } from '@teable/core';
22
import { ViewType } from '@teable/core';
33

44
export const isNotHiddenField = (
@@ -16,6 +16,13 @@ export const isNotHiddenField = (
1616
);
1717
}
1818

19+
if (viewType === ViewType.Gallery) {
20+
const { coverFieldId } = (options ?? {}) as IGalleryViewOptions;
21+
return (
22+
fieldId === coverFieldId || Boolean((columnMeta[fieldId] as { visible?: boolean })?.visible)
23+
);
24+
}
25+
1926
if ([ViewType.Form].includes(viewType)) {
2027
return Boolean((columnMeta[fieldId] as { visible?: boolean })?.visible);
2128
}

apps/nestjs-backend/test/data-helpers/caces/view-default-share-meta.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ export const VIEW_DEFAULT_SHARE_META: {
1919
includeRecords: true,
2020
},
2121
},
22+
{
23+
viewType: ViewType.Gallery,
24+
defaultShareMeta: {
25+
includeRecords: true,
26+
},
27+
},
2228
{
2329
viewType: ViewType.Grid,
2430
defaultShareMeta: {

apps/nextjs-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
"@tailwindcss/container-queries": "0.1.1",
116116
"@tanstack/react-query": "4.36.1",
117117
"@tanstack/react-table": "8.11.7",
118+
"@tanstack/react-virtual": "3.2.0",
118119
"@teable/common-i18n": "workspace:^",
119120
"@teable/core": "workspace:^",
120121
"@teable/icons": "workspace:^",

apps/nextjs-app/src/features/app/blocks/share/view/ShareView.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ViewType } from '@teable/core';
22
import { ShareViewContext } from '@teable/sdk/context';
33
import { useContext } from 'react';
44
import { FormView } from './component/form/FormView';
5+
import { GalleryView } from './component/gallery/GalleryView';
56
import { GridView } from './component/grid/GridView';
67
import { KanbanView } from './component/kanban/KanbanView';
78
import { PluginView } from './component/plugin/SharePluginView';
@@ -18,6 +19,8 @@ export const ShareView = () => {
1819
return <GridView />;
1920
case ViewType.Kanban:
2021
return <KanbanView />;
22+
case ViewType.Gallery:
23+
return <GalleryView />;
2124
case ViewType.Plugin:
2225
return <PluginView shareId={shareId} plugin={extra?.plugin} />;
2326
default:

0 commit comments

Comments
 (0)