From 063be79b890af7039f8b07bd6cb6c7aade6094a9 Mon Sep 17 00:00:00 2001 From: Jordan Knott Date: Fri, 10 Apr 2020 21:53:03 -0500 Subject: [PATCH] feature(web): add location saving to task groups on position change --- web/src/Projects/Project/index.tsx | 5 ++ web/src/shared/generated/graphql.tsx | 59 +++++++++++++++++++ .../graphql/updateTaskGroupLocation.graphqls | 6 ++ 3 files changed, 70 insertions(+) create mode 100644 web/src/shared/graphql/updateTaskGroupLocation.graphqls diff --git a/web/src/Projects/Project/index.tsx b/web/src/Projects/Project/index.tsx index efc6182..14779e2 100644 --- a/web/src/Projects/Project/index.tsx +++ b/web/src/Projects/Project/index.tsx @@ -7,6 +7,7 @@ import { useCreateTaskMutation, useDeleteTaskMutation, useUpdateTaskLocationMutation, + useUpdateTaskGroupLocationMutation, useCreateTaskGroupMutation, } from 'shared/generated/graphql'; @@ -77,6 +78,7 @@ const Project = () => { const [popupData, setPopupData] = useState(initialPopupState); const [quickCardEditor, setQuickCardEditor] = useState(initialQuickCardEditorState); const [updateTaskLocation] = useUpdateTaskLocationMutation(); + const [updateTaskGroupLocation] = useUpdateTaskGroupLocationMutation(); const [createTaskGroup] = useCreateTaskGroupMutation({ onCompleted: newTaskGroupData => { const newListsData = { @@ -179,6 +181,9 @@ const Project = () => { setListsData(newState); }; const onListDrop = (droppedColumn: any) => { + updateTaskGroupLocation({ + variables: { taskGroupID: droppedColumn.taskGroupID, position: droppedColumn.position }, + }); const newState = { ...listsData, columns: { diff --git a/web/src/shared/generated/graphql.tsx b/web/src/shared/generated/graphql.tsx index 5884d35..cff588c 100644 --- a/web/src/shared/generated/graphql.tsx +++ b/web/src/shared/generated/graphql.tsx @@ -175,6 +175,11 @@ export type UpdateTaskName = { name: Scalars['String']; }; +export type NewTaskGroupLocation = { + taskGroupID: Scalars['UUID']; + position: Scalars['Float']; +}; + export type Mutation = { __typename?: 'Mutation'; createRefreshToken: RefreshToken; @@ -183,6 +188,7 @@ export type Mutation = { createTeam: Team; createProject: Project; createTaskGroup: TaskGroup; + updateTaskGroupLocation: TaskGroup; createTask: Task; updateTaskLocation: Task; logoutUser: Scalars['Boolean']; @@ -221,6 +227,11 @@ export type MutationCreateTaskGroupArgs = { }; +export type MutationUpdateTaskGroupLocationArgs = { + input: NewTaskGroupLocation; +}; + + export type MutationCreateTaskArgs = { input: NewTask; }; @@ -332,6 +343,20 @@ export type GetProjectsQuery = ( )> } ); +export type UpdateTaskGroupLocationMutationVariables = { + taskGroupID: Scalars['UUID']; + position: Scalars['Float']; +}; + + +export type UpdateTaskGroupLocationMutation = ( + { __typename?: 'Mutation' } + & { updateTaskGroupLocation: ( + { __typename?: 'TaskGroup' } + & Pick + ) } +); + export type UpdateTaskLocationMutationVariables = { taskID: Scalars['String']; taskGroupID: Scalars['String']; @@ -551,6 +576,40 @@ export function useGetProjectsLazyQuery(baseOptions?: ApolloReactHooks.LazyQuery export type GetProjectsQueryHookResult = ReturnType; export type GetProjectsLazyQueryHookResult = ReturnType; export type GetProjectsQueryResult = ApolloReactCommon.QueryResult; +export const UpdateTaskGroupLocationDocument = gql` + mutation updateTaskGroupLocation($taskGroupID: UUID!, $position: Float!) { + updateTaskGroupLocation(input: {taskGroupID: $taskGroupID, position: $position}) { + taskGroupID + position + } +} + `; +export type UpdateTaskGroupLocationMutationFn = ApolloReactCommon.MutationFunction; + +/** + * __useUpdateTaskGroupLocationMutation__ + * + * To run a mutation, you first call `useUpdateTaskGroupLocationMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useUpdateTaskGroupLocationMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @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; + * + * @example + * const [updateTaskGroupLocationMutation, { data, loading, error }] = useUpdateTaskGroupLocationMutation({ + * variables: { + * taskGroupID: // value for 'taskGroupID' + * position: // value for 'position' + * }, + * }); + */ +export function useUpdateTaskGroupLocationMutation(baseOptions?: ApolloReactHooks.MutationHookOptions) { + return ApolloReactHooks.useMutation(UpdateTaskGroupLocationDocument, baseOptions); + } +export type UpdateTaskGroupLocationMutationHookResult = ReturnType; +export type UpdateTaskGroupLocationMutationResult = ApolloReactCommon.MutationResult; +export type UpdateTaskGroupLocationMutationOptions = ApolloReactCommon.BaseMutationOptions; export const UpdateTaskLocationDocument = gql` mutation updateTaskLocation($taskID: String!, $taskGroupID: String!, $position: Float!) { updateTaskLocation(input: {taskID: $taskID, taskGroupID: $taskGroupID, position: $position}) { diff --git a/web/src/shared/graphql/updateTaskGroupLocation.graphqls b/web/src/shared/graphql/updateTaskGroupLocation.graphqls new file mode 100644 index 0000000..da36c58 --- /dev/null +++ b/web/src/shared/graphql/updateTaskGroupLocation.graphqls @@ -0,0 +1,6 @@ +mutation updateTaskGroupLocation($taskGroupID: UUID!, $position: Float!) { + updateTaskGroupLocation(input:{taskGroupID:$taskGroupID, position: $position}) { + taskGroupID + position + } +}