mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-18 00:52:21 +03:00
feat: add views and viewSorts tables (#1131)
* feat: add views table Closes #1120 * feat: add viewSorts table Closes #1120
This commit is contained in:
parent
428acf4a13
commit
0f364cc9e7
@ -846,6 +846,20 @@ export type EnumPipelineProgressableTypeFilter = {
|
||||
notIn?: InputMaybe<Array<PipelineProgressableType>>;
|
||||
};
|
||||
|
||||
export type EnumViewSortDirectionFilter = {
|
||||
equals?: InputMaybe<ViewSortDirection>;
|
||||
in?: InputMaybe<Array<ViewSortDirection>>;
|
||||
not?: InputMaybe<NestedEnumViewSortDirectionFilter>;
|
||||
notIn?: InputMaybe<Array<ViewSortDirection>>;
|
||||
};
|
||||
|
||||
export type EnumViewTypeFilter = {
|
||||
equals?: InputMaybe<ViewType>;
|
||||
in?: InputMaybe<Array<ViewType>>;
|
||||
not?: InputMaybe<NestedEnumViewTypeFilter>;
|
||||
notIn?: InputMaybe<Array<ViewType>>;
|
||||
};
|
||||
|
||||
export enum FileFolder {
|
||||
Attachment = 'Attachment',
|
||||
PersonPicture = 'PersonPicture',
|
||||
@ -1178,6 +1192,20 @@ export type NestedEnumPipelineProgressableTypeFilter = {
|
||||
notIn?: InputMaybe<Array<PipelineProgressableType>>;
|
||||
};
|
||||
|
||||
export type NestedEnumViewSortDirectionFilter = {
|
||||
equals?: InputMaybe<ViewSortDirection>;
|
||||
in?: InputMaybe<Array<ViewSortDirection>>;
|
||||
not?: InputMaybe<NestedEnumViewSortDirectionFilter>;
|
||||
notIn?: InputMaybe<Array<ViewSortDirection>>;
|
||||
};
|
||||
|
||||
export type NestedEnumViewTypeFilter = {
|
||||
equals?: InputMaybe<ViewType>;
|
||||
in?: InputMaybe<Array<ViewType>>;
|
||||
not?: InputMaybe<NestedEnumViewTypeFilter>;
|
||||
notIn?: InputMaybe<Array<ViewType>>;
|
||||
};
|
||||
|
||||
export type NestedIntFilter = {
|
||||
equals?: InputMaybe<Scalars['Int']>;
|
||||
gt?: InputMaybe<Scalars['Int']>;
|
||||
@ -2161,6 +2189,20 @@ export type Verify = {
|
||||
user: User;
|
||||
};
|
||||
|
||||
export type View = {
|
||||
__typename?: 'View';
|
||||
fields?: Maybe<Array<ViewField>>;
|
||||
id: Scalars['ID'];
|
||||
name: Scalars['String'];
|
||||
objectId: Scalars['String'];
|
||||
sorts?: Maybe<Array<ViewSort>>;
|
||||
type: ViewType;
|
||||
};
|
||||
|
||||
export type ViewCreateNestedOneWithoutFieldsInput = {
|
||||
connect?: InputMaybe<ViewWhereUniqueInput>;
|
||||
};
|
||||
|
||||
export type ViewField = {
|
||||
__typename?: 'ViewField';
|
||||
fieldName: Scalars['String'];
|
||||
@ -2169,6 +2211,8 @@ export type ViewField = {
|
||||
isVisible: Scalars['Boolean'];
|
||||
objectName: Scalars['String'];
|
||||
sizeInPx: Scalars['Int'];
|
||||
view?: Maybe<View>;
|
||||
viewId?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type ViewFieldCreateInput = {
|
||||
@ -2178,6 +2222,7 @@ export type ViewFieldCreateInput = {
|
||||
isVisible: Scalars['Boolean'];
|
||||
objectName: Scalars['String'];
|
||||
sizeInPx: Scalars['Int'];
|
||||
view?: InputMaybe<ViewCreateNestedOneWithoutFieldsInput>;
|
||||
};
|
||||
|
||||
export type ViewFieldCreateManyInput = {
|
||||
@ -2187,6 +2232,17 @@ export type ViewFieldCreateManyInput = {
|
||||
isVisible: Scalars['Boolean'];
|
||||
objectName: Scalars['String'];
|
||||
sizeInPx: Scalars['Int'];
|
||||
viewId?: InputMaybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type ViewFieldListRelationFilter = {
|
||||
every?: InputMaybe<ViewFieldWhereInput>;
|
||||
none?: InputMaybe<ViewFieldWhereInput>;
|
||||
some?: InputMaybe<ViewFieldWhereInput>;
|
||||
};
|
||||
|
||||
export type ViewFieldOrderByRelationAggregateInput = {
|
||||
_count?: InputMaybe<SortOrder>;
|
||||
};
|
||||
|
||||
export type ViewFieldOrderByWithRelationInput = {
|
||||
@ -2196,6 +2252,8 @@ export type ViewFieldOrderByWithRelationInput = {
|
||||
isVisible?: InputMaybe<SortOrder>;
|
||||
objectName?: InputMaybe<SortOrder>;
|
||||
sizeInPx?: InputMaybe<SortOrder>;
|
||||
view?: InputMaybe<ViewOrderByWithRelationInput>;
|
||||
viewId?: InputMaybe<SortOrder>;
|
||||
};
|
||||
|
||||
export enum ViewFieldScalarFieldEnum {
|
||||
@ -2205,6 +2263,7 @@ export enum ViewFieldScalarFieldEnum {
|
||||
IsVisible = 'isVisible',
|
||||
ObjectName = 'objectName',
|
||||
SizeInPx = 'sizeInPx',
|
||||
ViewId = 'viewId',
|
||||
WorkspaceId = 'workspaceId'
|
||||
}
|
||||
|
||||
@ -2215,6 +2274,7 @@ export type ViewFieldUpdateInput = {
|
||||
isVisible?: InputMaybe<Scalars['Boolean']>;
|
||||
objectName?: InputMaybe<Scalars['String']>;
|
||||
sizeInPx?: InputMaybe<Scalars['Int']>;
|
||||
view?: InputMaybe<ViewUpdateOneWithoutFieldsNestedInput>;
|
||||
};
|
||||
|
||||
export type ViewFieldUpdateManyWithoutWorkspaceNestedInput = {
|
||||
@ -2233,10 +2293,122 @@ export type ViewFieldWhereInput = {
|
||||
isVisible?: InputMaybe<BoolFilter>;
|
||||
objectName?: InputMaybe<StringFilter>;
|
||||
sizeInPx?: InputMaybe<IntFilter>;
|
||||
view?: InputMaybe<ViewRelationFilter>;
|
||||
viewId?: InputMaybe<StringNullableFilter>;
|
||||
};
|
||||
|
||||
export type ViewFieldWhereUniqueInput = {
|
||||
id?: InputMaybe<Scalars['String']>;
|
||||
workspaceId_viewId_objectName_fieldName?: InputMaybe<ViewFieldWorkspaceIdViewIdObjectNameFieldNameCompoundUniqueInput>;
|
||||
};
|
||||
|
||||
export type ViewFieldWorkspaceIdViewIdObjectNameFieldNameCompoundUniqueInput = {
|
||||
fieldName: Scalars['String'];
|
||||
objectName: Scalars['String'];
|
||||
viewId: Scalars['String'];
|
||||
};
|
||||
|
||||
export type ViewOrderByWithRelationInput = {
|
||||
fields?: InputMaybe<ViewFieldOrderByRelationAggregateInput>;
|
||||
id?: InputMaybe<SortOrder>;
|
||||
name?: InputMaybe<SortOrder>;
|
||||
objectId?: InputMaybe<SortOrder>;
|
||||
sorts?: InputMaybe<ViewSortOrderByRelationAggregateInput>;
|
||||
type?: InputMaybe<SortOrder>;
|
||||
};
|
||||
|
||||
export type ViewRelationFilter = {
|
||||
is?: InputMaybe<ViewWhereInput>;
|
||||
isNot?: InputMaybe<ViewWhereInput>;
|
||||
};
|
||||
|
||||
export type ViewSort = {
|
||||
__typename?: 'ViewSort';
|
||||
direction: ViewSortDirection;
|
||||
key: Scalars['String'];
|
||||
name: Scalars['String'];
|
||||
view: View;
|
||||
viewId: Scalars['String'];
|
||||
};
|
||||
|
||||
export enum ViewSortDirection {
|
||||
Asc = 'asc',
|
||||
Desc = 'desc'
|
||||
}
|
||||
|
||||
export type ViewSortListRelationFilter = {
|
||||
every?: InputMaybe<ViewSortWhereInput>;
|
||||
none?: InputMaybe<ViewSortWhereInput>;
|
||||
some?: InputMaybe<ViewSortWhereInput>;
|
||||
};
|
||||
|
||||
export type ViewSortOrderByRelationAggregateInput = {
|
||||
_count?: InputMaybe<SortOrder>;
|
||||
};
|
||||
|
||||
export type ViewSortUpdateManyWithoutWorkspaceNestedInput = {
|
||||
connect?: InputMaybe<Array<ViewSortWhereUniqueInput>>;
|
||||
disconnect?: InputMaybe<Array<ViewSortWhereUniqueInput>>;
|
||||
set?: InputMaybe<Array<ViewSortWhereUniqueInput>>;
|
||||
};
|
||||
|
||||
export type ViewSortViewIdKeyCompoundUniqueInput = {
|
||||
key: Scalars['String'];
|
||||
viewId: Scalars['String'];
|
||||
};
|
||||
|
||||
export type ViewSortWhereInput = {
|
||||
AND?: InputMaybe<Array<ViewSortWhereInput>>;
|
||||
NOT?: InputMaybe<Array<ViewSortWhereInput>>;
|
||||
OR?: InputMaybe<Array<ViewSortWhereInput>>;
|
||||
direction?: InputMaybe<EnumViewSortDirectionFilter>;
|
||||
key?: InputMaybe<StringFilter>;
|
||||
name?: InputMaybe<StringFilter>;
|
||||
view?: InputMaybe<ViewRelationFilter>;
|
||||
viewId?: InputMaybe<StringFilter>;
|
||||
};
|
||||
|
||||
export type ViewSortWhereUniqueInput = {
|
||||
viewId_key?: InputMaybe<ViewSortViewIdKeyCompoundUniqueInput>;
|
||||
};
|
||||
|
||||
export enum ViewType {
|
||||
Pipeline = 'Pipeline',
|
||||
Table = 'Table'
|
||||
}
|
||||
|
||||
export type ViewUpdateManyWithoutWorkspaceNestedInput = {
|
||||
connect?: InputMaybe<Array<ViewWhereUniqueInput>>;
|
||||
disconnect?: InputMaybe<Array<ViewWhereUniqueInput>>;
|
||||
set?: InputMaybe<Array<ViewWhereUniqueInput>>;
|
||||
};
|
||||
|
||||
export type ViewUpdateOneWithoutFieldsNestedInput = {
|
||||
connect?: InputMaybe<ViewWhereUniqueInput>;
|
||||
disconnect?: InputMaybe<Scalars['Boolean']>;
|
||||
};
|
||||
|
||||
export type ViewWhereInput = {
|
||||
AND?: InputMaybe<Array<ViewWhereInput>>;
|
||||
NOT?: InputMaybe<Array<ViewWhereInput>>;
|
||||
OR?: InputMaybe<Array<ViewWhereInput>>;
|
||||
fields?: InputMaybe<ViewFieldListRelationFilter>;
|
||||
id?: InputMaybe<StringFilter>;
|
||||
name?: InputMaybe<StringFilter>;
|
||||
objectId?: InputMaybe<StringFilter>;
|
||||
sorts?: InputMaybe<ViewSortListRelationFilter>;
|
||||
type?: InputMaybe<EnumViewTypeFilter>;
|
||||
};
|
||||
|
||||
export type ViewWhereUniqueInput = {
|
||||
id?: InputMaybe<Scalars['String']>;
|
||||
workspaceId_type_objectId_name?: InputMaybe<ViewWorkspaceIdTypeObjectIdNameCompoundUniqueInput>;
|
||||
};
|
||||
|
||||
export type ViewWorkspaceIdTypeObjectIdNameCompoundUniqueInput = {
|
||||
name: Scalars['String'];
|
||||
objectId: Scalars['String'];
|
||||
type: ViewType;
|
||||
};
|
||||
|
||||
export type Workspace = {
|
||||
@ -2258,6 +2430,8 @@ export type Workspace = {
|
||||
pipelines?: Maybe<Array<Pipeline>>;
|
||||
updatedAt: Scalars['DateTime'];
|
||||
viewFields?: Maybe<Array<ViewField>>;
|
||||
viewSorts?: Maybe<Array<ViewSort>>;
|
||||
views?: Maybe<Array<View>>;
|
||||
workspaceMember?: Maybe<Array<WorkspaceMember>>;
|
||||
};
|
||||
|
||||
@ -2337,6 +2511,8 @@ export type WorkspaceUpdateInput = {
|
||||
pipelines?: InputMaybe<PipelineUpdateManyWithoutWorkspaceNestedInput>;
|
||||
updatedAt?: InputMaybe<Scalars['DateTime']>;
|
||||
viewFields?: InputMaybe<ViewFieldUpdateManyWithoutWorkspaceNestedInput>;
|
||||
viewSorts?: InputMaybe<ViewSortUpdateManyWithoutWorkspaceNestedInput>;
|
||||
views?: InputMaybe<ViewUpdateManyWithoutWorkspaceNestedInput>;
|
||||
workspaceMember?: InputMaybe<WorkspaceMemberUpdateManyWithoutWorkspaceNestedInput>;
|
||||
};
|
||||
|
||||
|
@ -18,6 +18,8 @@ import {
|
||||
PipelineProgress,
|
||||
UserSettings,
|
||||
ViewField,
|
||||
View,
|
||||
ViewSort,
|
||||
} from '@prisma/client';
|
||||
|
||||
import { AbilityAction } from './ability.action';
|
||||
@ -37,7 +39,9 @@ type SubjectsAbility = Subjects<{
|
||||
PipelineProgress: PipelineProgress;
|
||||
Attachment: Attachment;
|
||||
UserSettings: UserSettings;
|
||||
View: View;
|
||||
ViewField: ViewField;
|
||||
ViewSort: ViewSort;
|
||||
}>;
|
||||
|
||||
export type AppAbility = PureAbility<
|
||||
|
@ -45,7 +45,7 @@ export class ViewFieldResolver {
|
||||
): Promise<Partial<ViewField>> {
|
||||
return this.viewFieldService.create({
|
||||
data: {
|
||||
...args.data,
|
||||
...(args.data as Prisma.ViewFieldCreateInput),
|
||||
workspace: { connect: { id: workspace.id } },
|
||||
},
|
||||
select: prismaSelect.value,
|
||||
|
@ -111,7 +111,9 @@ export class WorkspaceService {
|
||||
comment,
|
||||
activityTarget,
|
||||
activity,
|
||||
view,
|
||||
viewField,
|
||||
viewSort,
|
||||
} = this.prismaService.client;
|
||||
|
||||
const activitys = await activity.findMany({
|
||||
@ -151,9 +153,15 @@ export class WorkspaceService {
|
||||
activity.deleteMany({
|
||||
where,
|
||||
}),
|
||||
view.deleteMany({
|
||||
where,
|
||||
}),
|
||||
viewField.deleteMany({
|
||||
where,
|
||||
}),
|
||||
viewSort.deleteMany({
|
||||
where,
|
||||
}),
|
||||
refreshToken.deleteMany({
|
||||
where: { userId },
|
||||
}),
|
||||
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[workspaceId,viewId,objectName,fieldName]` on the table `viewFields` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateEnum
|
||||
CREATE TYPE "ViewType" AS ENUM ('Table', 'Pipeline');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "viewFields" ADD COLUMN "viewId" TEXT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "views" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"objectId" TEXT NOT NULL,
|
||||
"type" "ViewType" NOT NULL,
|
||||
"workspaceId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "views_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "views_workspaceId_type_objectId_name_key" ON "views"("workspaceId", "type", "objectId", "name");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "viewFields_workspaceId_viewId_objectName_fieldName_key" ON "viewFields"("workspaceId", "viewId", "objectName", "fieldName");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_personId_fkey" FOREIGN KEY ("personId") REFERENCES "people"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "views" ADD CONSTRAINT "views_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "viewFields" ADD CONSTRAINT "viewFields_viewId_fkey" FOREIGN KEY ("viewId") REFERENCES "views"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
@ -0,0 +1,19 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "ViewSortDirection" AS ENUM ('asc', 'desc');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "viewSorts" (
|
||||
"direction" "ViewSortDirection" NOT NULL,
|
||||
"key" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"viewId" TEXT NOT NULL,
|
||||
"workspaceId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "viewSorts_pkey" PRIMARY KEY ("viewId","key")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "viewSorts" ADD CONSTRAINT "viewSorts_viewId_fkey" FOREIGN KEY ("viewId") REFERENCES "views"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "viewSorts" ADD CONSTRAINT "viewSorts_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
@ -174,6 +174,8 @@ model Workspace {
|
||||
pipelineProgresses PipelineProgress[]
|
||||
activityTargets ActivityTarget[]
|
||||
viewFields ViewField[]
|
||||
views View[]
|
||||
viewSorts ViewSort[]
|
||||
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
deletedAt DateTime?
|
||||
@ -266,7 +268,7 @@ model Person {
|
||||
linkedinUrl String?
|
||||
/// @Validator.IsString()
|
||||
/// @Validator.IsOptional()
|
||||
xUrl String?
|
||||
xUrl String?
|
||||
/// @Validator.IsString()
|
||||
/// @Validator.IsOptional()
|
||||
jobTitle String?
|
||||
@ -557,6 +559,53 @@ model Attachment {
|
||||
@@map("attachments")
|
||||
}
|
||||
|
||||
enum ViewType {
|
||||
Table
|
||||
Pipeline
|
||||
}
|
||||
|
||||
model View {
|
||||
/// @Validator.IsString()
|
||||
/// @Validator.IsOptional()
|
||||
id String @id @default(uuid())
|
||||
|
||||
fields ViewField[]
|
||||
name String
|
||||
objectId String
|
||||
sorts ViewSort[]
|
||||
type ViewType
|
||||
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspaceId String
|
||||
|
||||
@@unique([workspaceId, type, objectId, name])
|
||||
@@map("views")
|
||||
}
|
||||
|
||||
enum ViewSortDirection {
|
||||
asc
|
||||
desc
|
||||
}
|
||||
|
||||
model ViewSort {
|
||||
direction ViewSortDirection
|
||||
key String
|
||||
name String
|
||||
|
||||
view View @relation(fields: [viewId], references: [id])
|
||||
viewId String
|
||||
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspaceId String
|
||||
|
||||
@@id([viewId, key])
|
||||
@@map("viewSorts")
|
||||
}
|
||||
|
||||
model ViewField {
|
||||
/// @Validator.IsString()
|
||||
/// @Validator.IsOptional()
|
||||
@ -568,10 +617,14 @@ model ViewField {
|
||||
objectName String
|
||||
sizeInPx Int
|
||||
|
||||
view View? @relation(fields: [viewId], references: [id])
|
||||
viewId String?
|
||||
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspaceId String
|
||||
|
||||
@@unique([workspaceId, viewId, objectName, fieldName])
|
||||
@@map("viewFields")
|
||||
}
|
||||
|
@ -16,5 +16,7 @@ export type ModelSelectMap = {
|
||||
PipelineStage: Prisma.PipelineStageSelect;
|
||||
PipelineProgress: Prisma.PipelineProgressSelect;
|
||||
Attachment: Prisma.AttachmentSelect;
|
||||
View: Prisma.ViewSelect;
|
||||
ViewSort: Prisma.ViewSortSelect;
|
||||
ViewField: Prisma.ViewFieldSelect;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user