Skip to content

Commit e2677ff

Browse files
committed
feat: create ViewField model
- Created ViewField prisma model - Added ViewField server resolvers for findMany/updateOne - Added getViewFields/updateViewField graphql queries Closes #849
1 parent 03b619e commit e2677ff

File tree

15 files changed

+487
-1
lines changed

15 files changed

+487
-1
lines changed

front/src/generated/graphql.tsx

Lines changed: 195 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export type CommentThreadTarget = {
293293
createdAt: Scalars['DateTime'];
294294
id: Scalars['ID'];
295295
updatedAt: Scalars['DateTime'];
296-
workspace: Workspace;
296+
workspace?: Maybe<Workspace>;
297297
};
298298

299299
export type CommentThreadTargetCreateManyCommentThreadInput = {
@@ -712,6 +712,17 @@ export enum FileFolder {
712712
WorkspaceLogo = 'WorkspaceLogo'
713713
}
714714

715+
export type IntFilter = {
716+
equals?: InputMaybe<Scalars['Int']>;
717+
gt?: InputMaybe<Scalars['Int']>;
718+
gte?: InputMaybe<Scalars['Int']>;
719+
in?: InputMaybe<Array<Scalars['Int']>>;
720+
lt?: InputMaybe<Scalars['Int']>;
721+
lte?: InputMaybe<Scalars['Int']>;
722+
not?: InputMaybe<NestedIntFilter>;
723+
notIn?: InputMaybe<Array<Scalars['Int']>>;
724+
};
725+
715726
export type IntNullableFilter = {
716727
equals?: InputMaybe<Scalars['Int']>;
717728
gt?: InputMaybe<Scalars['Int']>;
@@ -765,6 +776,7 @@ export type Mutation = {
765776
updateOnePerson?: Maybe<Person>;
766777
updateOnePipelineProgress?: Maybe<PipelineProgress>;
767778
updateOnePipelineStage?: Maybe<PipelineStage>;
779+
updateOneViewField: ViewField;
768780
updateUser: User;
769781
updateWorkspace: Workspace;
770782
uploadAttachment: Scalars['String'];
@@ -880,6 +892,12 @@ export type MutationUpdateOnePipelineStageArgs = {
880892
};
881893

882894

895+
export type MutationUpdateOneViewFieldArgs = {
896+
data: ViewFieldUpdateInput;
897+
where: ViewFieldWhereUniqueInput;
898+
};
899+
900+
883901
export type MutationUpdateUserArgs = {
884902
data: UserUpdateInput;
885903
where: UserWhereUniqueInput;
@@ -985,6 +1003,17 @@ export type NestedEnumPipelineProgressableTypeFilter = {
9851003
notIn?: InputMaybe<Array<PipelineProgressableType>>;
9861004
};
9871005

1006+
export type NestedIntFilter = {
1007+
equals?: InputMaybe<Scalars['Int']>;
1008+
gt?: InputMaybe<Scalars['Int']>;
1009+
gte?: InputMaybe<Scalars['Int']>;
1010+
in?: InputMaybe<Array<Scalars['Int']>>;
1011+
lt?: InputMaybe<Scalars['Int']>;
1012+
lte?: InputMaybe<Scalars['Int']>;
1013+
not?: InputMaybe<NestedIntFilter>;
1014+
notIn?: InputMaybe<Array<Scalars['Int']>>;
1015+
};
1016+
9881017
export type NestedIntNullableFilter = {
9891018
equals?: InputMaybe<Scalars['Int']>;
9901019
gt?: InputMaybe<Scalars['Int']>;
@@ -1500,6 +1529,7 @@ export type Query = {
15001529
findManyPipelineProgress: Array<PipelineProgress>;
15011530
findManyPipelineStage: Array<PipelineStage>;
15021531
findManyUser: Array<User>;
1532+
findManyViewField: Array<ViewField>;
15031533
findManyWorkspaceMember: Array<WorkspaceMember>;
15041534
findUniqueCompany: Company;
15051535
findUniquePerson: Person;
@@ -1586,6 +1616,16 @@ export type QueryFindManyUserArgs = {
15861616
};
15871617

15881618

1619+
export type QueryFindManyViewFieldArgs = {
1620+
cursor?: InputMaybe<ViewFieldWhereUniqueInput>;
1621+
distinct?: InputMaybe<Array<ViewFieldScalarFieldEnum>>;
1622+
orderBy?: InputMaybe<Array<ViewFieldOrderByWithRelationInput>>;
1623+
skip?: InputMaybe<Scalars['Int']>;
1624+
take?: InputMaybe<Scalars['Int']>;
1625+
where?: InputMaybe<ViewFieldWhereInput>;
1626+
};
1627+
1628+
15891629
export type QueryFindManyWorkspaceMemberArgs = {
15901630
cursor?: InputMaybe<WorkspaceMemberWhereUniqueInput>;
15911631
distinct?: InputMaybe<Array<WorkspaceMemberScalarFieldEnum>>;
@@ -1867,6 +1907,66 @@ export type Verify = {
18671907
user: User;
18681908
};
18691909

1910+
export type ViewField = {
1911+
__typename?: 'ViewField';
1912+
fieldName: Scalars['String'];
1913+
id: Scalars['ID'];
1914+
index: Scalars['Int'];
1915+
isVisible: Scalars['Boolean'];
1916+
objectName: Scalars['String'];
1917+
sizeInPx: Scalars['Int'];
1918+
};
1919+
1920+
export type ViewFieldOrderByWithRelationInput = {
1921+
fieldName?: InputMaybe<SortOrder>;
1922+
id?: InputMaybe<SortOrder>;
1923+
index?: InputMaybe<SortOrder>;
1924+
isVisible?: InputMaybe<SortOrder>;
1925+
objectName?: InputMaybe<SortOrder>;
1926+
sizeInPx?: InputMaybe<SortOrder>;
1927+
};
1928+
1929+
export enum ViewFieldScalarFieldEnum {
1930+
FieldName = 'fieldName',
1931+
Id = 'id',
1932+
Index = 'index',
1933+
IsVisible = 'isVisible',
1934+
ObjectName = 'objectName',
1935+
SizeInPx = 'sizeInPx',
1936+
WorkspaceId = 'workspaceId'
1937+
}
1938+
1939+
export type ViewFieldUpdateInput = {
1940+
fieldName?: InputMaybe<Scalars['String']>;
1941+
id?: InputMaybe<Scalars['String']>;
1942+
index?: InputMaybe<Scalars['Int']>;
1943+
isVisible?: InputMaybe<Scalars['Boolean']>;
1944+
objectName?: InputMaybe<Scalars['String']>;
1945+
sizeInPx?: InputMaybe<Scalars['Int']>;
1946+
};
1947+
1948+
export type ViewFieldUpdateManyWithoutWorkspaceNestedInput = {
1949+
connect?: InputMaybe<Array<ViewFieldWhereUniqueInput>>;
1950+
disconnect?: InputMaybe<Array<ViewFieldWhereUniqueInput>>;
1951+
set?: InputMaybe<Array<ViewFieldWhereUniqueInput>>;
1952+
};
1953+
1954+
export type ViewFieldWhereInput = {
1955+
AND?: InputMaybe<Array<ViewFieldWhereInput>>;
1956+
NOT?: InputMaybe<Array<ViewFieldWhereInput>>;
1957+
OR?: InputMaybe<Array<ViewFieldWhereInput>>;
1958+
fieldName?: InputMaybe<StringFilter>;
1959+
id?: InputMaybe<StringFilter>;
1960+
index?: InputMaybe<IntFilter>;
1961+
isVisible?: InputMaybe<BoolFilter>;
1962+
objectName?: InputMaybe<StringFilter>;
1963+
sizeInPx?: InputMaybe<IntFilter>;
1964+
};
1965+
1966+
export type ViewFieldWhereUniqueInput = {
1967+
id?: InputMaybe<Scalars['String']>;
1968+
};
1969+
18701970
export type Workspace = {
18711971
__typename?: 'Workspace';
18721972
Attachment?: Maybe<Array<Attachment>>;
@@ -1885,6 +1985,7 @@ export type Workspace = {
18851985
pipelineStages?: Maybe<Array<PipelineStage>>;
18861986
pipelines?: Maybe<Array<Pipeline>>;
18871987
updatedAt: Scalars['DateTime'];
1988+
viewFields?: Maybe<Array<ViewField>>;
18881989
workspaceMember?: Maybe<Array<WorkspaceMember>>;
18891990
};
18901991

@@ -1959,6 +2060,7 @@ export type WorkspaceUpdateInput = {
19592060
pipelineStages?: InputMaybe<PipelineStageUpdateManyWithoutWorkspaceNestedInput>;
19602061
pipelines?: InputMaybe<PipelineUpdateManyWithoutWorkspaceNestedInput>;
19612062
updatedAt?: InputMaybe<Scalars['DateTime']>;
2063+
viewFields?: InputMaybe<ViewFieldUpdateManyWithoutWorkspaceNestedInput>;
19622064
workspaceMember?: InputMaybe<WorkspaceMemberUpdateManyWithoutWorkspaceNestedInput>;
19632065
};
19642066

@@ -2342,6 +2444,21 @@ export type RemoveProfilePictureMutationVariables = Exact<{
23422444

23432445
export type RemoveProfilePictureMutation = { __typename?: 'Mutation', updateUser: { __typename?: 'User', id: string, avatarUrl?: string | null } };
23442446

2447+
export type GetViewFieldsQueryVariables = Exact<{
2448+
where?: InputMaybe<ViewFieldWhereInput>;
2449+
}>;
2450+
2451+
2452+
export type GetViewFieldsQuery = { __typename?: 'Query', viewFields: Array<{ __typename?: 'ViewField', id: string, fieldName: string, isVisible: boolean, sizeInPx: number, index: number }> };
2453+
2454+
export type UpdateViewFieldMutationVariables = Exact<{
2455+
data: ViewFieldUpdateInput;
2456+
where: ViewFieldWhereUniqueInput;
2457+
}>;
2458+
2459+
2460+
export type UpdateViewFieldMutation = { __typename?: 'Mutation', updateOneViewField: { __typename?: 'ViewField', id: string, fieldName: string, isVisible: boolean, sizeInPx: number, index: number } };
2461+
23452462
export type GetWorkspaceMembersQueryVariables = Exact<{ [key: string]: never; }>;
23462463

23472464

@@ -4470,6 +4587,83 @@ export function useRemoveProfilePictureMutation(baseOptions?: Apollo.MutationHoo
44704587
export type RemoveProfilePictureMutationHookResult = ReturnType<typeof useRemoveProfilePictureMutation>;
44714588
export type RemoveProfilePictureMutationResult = Apollo.MutationResult<RemoveProfilePictureMutation>;
44724589
export type RemoveProfilePictureMutationOptions = Apollo.BaseMutationOptions<RemoveProfilePictureMutation, RemoveProfilePictureMutationVariables>;
4590+
export const GetViewFieldsDocument = gql`
4591+
query GetViewFields($where: ViewFieldWhereInput) {
4592+
viewFields: findManyViewField(where: $where) {
4593+
id
4594+
fieldName
4595+
isVisible
4596+
sizeInPx
4597+
index
4598+
}
4599+
}
4600+
`;
4601+
4602+
/**
4603+
* __useGetViewFieldsQuery__
4604+
*
4605+
* To run a query within a React component, call `useGetViewFieldsQuery` and pass it any options that fit your needs.
4606+
* When your component renders, `useGetViewFieldsQuery` returns an object from Apollo Client that contains loading, error, and data properties
4607+
* you can use to render your UI.
4608+
*
4609+
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
4610+
*
4611+
* @example
4612+
* const { data, loading, error } = useGetViewFieldsQuery({
4613+
* variables: {
4614+
* where: // value for 'where'
4615+
* },
4616+
* });
4617+
*/
4618+
export function useGetViewFieldsQuery(baseOptions?: Apollo.QueryHookOptions<GetViewFieldsQuery, GetViewFieldsQueryVariables>) {
4619+
const options = {...defaultOptions, ...baseOptions}
4620+
return Apollo.useQuery<GetViewFieldsQuery, GetViewFieldsQueryVariables>(GetViewFieldsDocument, options);
4621+
}
4622+
export function useGetViewFieldsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<GetViewFieldsQuery, GetViewFieldsQueryVariables>) {
4623+
const options = {...defaultOptions, ...baseOptions}
4624+
return Apollo.useLazyQuery<GetViewFieldsQuery, GetViewFieldsQueryVariables>(GetViewFieldsDocument, options);
4625+
}
4626+
export type GetViewFieldsQueryHookResult = ReturnType<typeof useGetViewFieldsQuery>;
4627+
export type GetViewFieldsLazyQueryHookResult = ReturnType<typeof useGetViewFieldsLazyQuery>;
4628+
export type GetViewFieldsQueryResult = Apollo.QueryResult<GetViewFieldsQuery, GetViewFieldsQueryVariables>;
4629+
export const UpdateViewFieldDocument = gql`
4630+
mutation UpdateViewField($data: ViewFieldUpdateInput!, $where: ViewFieldWhereUniqueInput!) {
4631+
updateOneViewField(data: $data, where: $where) {
4632+
id
4633+
fieldName
4634+
isVisible
4635+
sizeInPx
4636+
index
4637+
}
4638+
}
4639+
`;
4640+
export type UpdateViewFieldMutationFn = Apollo.MutationFunction<UpdateViewFieldMutation, UpdateViewFieldMutationVariables>;
4641+
4642+
/**
4643+
* __useUpdateViewFieldMutation__
4644+
*
4645+
* To run a mutation, you first call `useUpdateViewFieldMutation` within a React component and pass it any options that fit your needs.
4646+
* When your component renders, `useUpdateViewFieldMutation` returns a tuple that includes:
4647+
* - A mutate function that you can call at any time to execute the mutation
4648+
* - An object with fields that represent the current status of the mutation's execution
4649+
*
4650+
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
4651+
*
4652+
* @example
4653+
* const [updateViewFieldMutation, { data, loading, error }] = useUpdateViewFieldMutation({
4654+
* variables: {
4655+
* data: // value for 'data'
4656+
* where: // value for 'where'
4657+
* },
4658+
* });
4659+
*/
4660+
export function useUpdateViewFieldMutation(baseOptions?: Apollo.MutationHookOptions<UpdateViewFieldMutation, UpdateViewFieldMutationVariables>) {
4661+
const options = {...defaultOptions, ...baseOptions}
4662+
return Apollo.useMutation<UpdateViewFieldMutation, UpdateViewFieldMutationVariables>(UpdateViewFieldDocument, options);
4663+
}
4664+
export type UpdateViewFieldMutationHookResult = ReturnType<typeof useUpdateViewFieldMutation>;
4665+
export type UpdateViewFieldMutationResult = Apollo.MutationResult<UpdateViewFieldMutation>;
4666+
export type UpdateViewFieldMutationOptions = Apollo.BaseMutationOptions<UpdateViewFieldMutation, UpdateViewFieldMutationVariables>;
44734667
export const GetWorkspaceMembersDocument = gql`
44744668
query GetWorkspaceMembers {
44754669
workspaceMembers: findManyWorkspaceMember {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { gql } from '@apollo/client';
2+
3+
export const GET_VIEW_FIELDS = gql`
4+
query GetViewFields($where: ViewFieldWhereInput) {
5+
viewFields: findManyViewField(where: $where) {
6+
id
7+
fieldName
8+
isVisible
9+
sizeInPx
10+
index
11+
}
12+
}
13+
`;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { gql } from '@apollo/client';
2+
3+
export const UPDATE_VIEW_FIELD = gql`
4+
mutation UpdateViewField(
5+
$data: ViewFieldUpdateInput!
6+
$where: ViewFieldWhereUniqueInput!
7+
) {
8+
updateOneViewField(data: $data, where: $where) {
9+
id
10+
fieldName
11+
isVisible
12+
sizeInPx
13+
index
14+
}
15+
}
16+
`;

server/src/ability/ability.factory.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
PipelineProgress,
1818
Attachment,
1919
UserSettings,
20+
ViewField,
2021
} from '@prisma/client';
2122

2223
import { AbilityAction } from './ability.action';
@@ -36,6 +37,7 @@ type SubjectsAbility = Subjects<{
3637
PipelineProgress: PipelineProgress;
3738
Attachment: Attachment;
3839
UserSettings: UserSettings;
40+
ViewField: ViewField;
3941
}>;
4042

4143
export type AppAbility = PureAbility<
@@ -128,6 +130,10 @@ export class AbilityFactory {
128130
workspaceId: workspace.id,
129131
});
130132

133+
// ViewField
134+
can(AbilityAction.Read, 'ViewField', { workspaceId: workspace.id });
135+
can(AbilityAction.Update, 'ViewField', { workspaceId: workspace.id });
136+
131137
return build();
132138
}
133139
}

server/src/ability/ability.module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ import {
9494
ReadAttachmentAbilityHandler,
9595
UpdateAttachmentAbilityHandler,
9696
} from './handlers/attachment.ability-handler';
97+
import {
98+
ReadViewFieldAbilityHandler,
99+
UpdateViewFieldAbilityHandler,
100+
} from './handlers/view-field.ability-handler';
97101

98102
@Global()
99103
@Module({
@@ -178,6 +182,9 @@ import {
178182
CreatePipelineProgressAbilityHandler,
179183
UpdatePipelineProgressAbilityHandler,
180184
DeletePipelineProgressAbilityHandler,
185+
// ViewField
186+
ReadViewFieldAbilityHandler,
187+
UpdateViewFieldAbilityHandler,
181188
],
182189
exports: [
183190
AbilityFactory,
@@ -259,6 +266,9 @@ import {
259266
CreatePipelineProgressAbilityHandler,
260267
UpdatePipelineProgressAbilityHandler,
261268
DeletePipelineProgressAbilityHandler,
269+
// ViewField
270+
ReadViewFieldAbilityHandler,
271+
UpdateViewFieldAbilityHandler,
262272
],
263273
})
264274
export class AbilityModule {}

0 commit comments

Comments
 (0)