feature(web): add location saving to task groups on position change

This commit is contained in:
Jordan Knott 2020-04-10 21:53:03 -05:00
parent bd878c9c64
commit 063be79b89
3 changed files with 70 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import {
useCreateTaskMutation, useCreateTaskMutation,
useDeleteTaskMutation, useDeleteTaskMutation,
useUpdateTaskLocationMutation, useUpdateTaskLocationMutation,
useUpdateTaskGroupLocationMutation,
useCreateTaskGroupMutation, useCreateTaskGroupMutation,
} from 'shared/generated/graphql'; } from 'shared/generated/graphql';
@ -77,6 +78,7 @@ const Project = () => {
const [popupData, setPopupData] = useState(initialPopupState); const [popupData, setPopupData] = useState(initialPopupState);
const [quickCardEditor, setQuickCardEditor] = useState(initialQuickCardEditorState); const [quickCardEditor, setQuickCardEditor] = useState(initialQuickCardEditorState);
const [updateTaskLocation] = useUpdateTaskLocationMutation(); const [updateTaskLocation] = useUpdateTaskLocationMutation();
const [updateTaskGroupLocation] = useUpdateTaskGroupLocationMutation();
const [createTaskGroup] = useCreateTaskGroupMutation({ const [createTaskGroup] = useCreateTaskGroupMutation({
onCompleted: newTaskGroupData => { onCompleted: newTaskGroupData => {
const newListsData = { const newListsData = {
@ -179,6 +181,9 @@ const Project = () => {
setListsData(newState); setListsData(newState);
}; };
const onListDrop = (droppedColumn: any) => { const onListDrop = (droppedColumn: any) => {
updateTaskGroupLocation({
variables: { taskGroupID: droppedColumn.taskGroupID, position: droppedColumn.position },
});
const newState = { const newState = {
...listsData, ...listsData,
columns: { columns: {

View File

@ -175,6 +175,11 @@ export type UpdateTaskName = {
name: Scalars['String']; name: Scalars['String'];
}; };
export type NewTaskGroupLocation = {
taskGroupID: Scalars['UUID'];
position: Scalars['Float'];
};
export type Mutation = { export type Mutation = {
__typename?: 'Mutation'; __typename?: 'Mutation';
createRefreshToken: RefreshToken; createRefreshToken: RefreshToken;
@ -183,6 +188,7 @@ export type Mutation = {
createTeam: Team; createTeam: Team;
createProject: Project; createProject: Project;
createTaskGroup: TaskGroup; createTaskGroup: TaskGroup;
updateTaskGroupLocation: TaskGroup;
createTask: Task; createTask: Task;
updateTaskLocation: Task; updateTaskLocation: Task;
logoutUser: Scalars['Boolean']; logoutUser: Scalars['Boolean'];
@ -221,6 +227,11 @@ export type MutationCreateTaskGroupArgs = {
}; };
export type MutationUpdateTaskGroupLocationArgs = {
input: NewTaskGroupLocation;
};
export type MutationCreateTaskArgs = { export type MutationCreateTaskArgs = {
input: NewTask; 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<TaskGroup, 'taskGroupID' | 'position'>
) }
);
export type UpdateTaskLocationMutationVariables = { export type UpdateTaskLocationMutationVariables = {
taskID: Scalars['String']; taskID: Scalars['String'];
taskGroupID: Scalars['String']; taskGroupID: Scalars['String'];
@ -551,6 +576,40 @@ export function useGetProjectsLazyQuery(baseOptions?: ApolloReactHooks.LazyQuery
export type GetProjectsQueryHookResult = ReturnType<typeof useGetProjectsQuery>; export type GetProjectsQueryHookResult = ReturnType<typeof useGetProjectsQuery>;
export type GetProjectsLazyQueryHookResult = ReturnType<typeof useGetProjectsLazyQuery>; export type GetProjectsLazyQueryHookResult = ReturnType<typeof useGetProjectsLazyQuery>;
export type GetProjectsQueryResult = ApolloReactCommon.QueryResult<GetProjectsQuery, GetProjectsQueryVariables>; export type GetProjectsQueryResult = ApolloReactCommon.QueryResult<GetProjectsQuery, GetProjectsQueryVariables>;
export const UpdateTaskGroupLocationDocument = gql`
mutation updateTaskGroupLocation($taskGroupID: UUID!, $position: Float!) {
updateTaskGroupLocation(input: {taskGroupID: $taskGroupID, position: $position}) {
taskGroupID
position
}
}
`;
export type UpdateTaskGroupLocationMutationFn = ApolloReactCommon.MutationFunction<UpdateTaskGroupLocationMutation, UpdateTaskGroupLocationMutationVariables>;
/**
* __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<UpdateTaskGroupLocationMutation, UpdateTaskGroupLocationMutationVariables>) {
return ApolloReactHooks.useMutation<UpdateTaskGroupLocationMutation, UpdateTaskGroupLocationMutationVariables>(UpdateTaskGroupLocationDocument, baseOptions);
}
export type UpdateTaskGroupLocationMutationHookResult = ReturnType<typeof useUpdateTaskGroupLocationMutation>;
export type UpdateTaskGroupLocationMutationResult = ApolloReactCommon.MutationResult<UpdateTaskGroupLocationMutation>;
export type UpdateTaskGroupLocationMutationOptions = ApolloReactCommon.BaseMutationOptions<UpdateTaskGroupLocationMutation, UpdateTaskGroupLocationMutationVariables>;
export const UpdateTaskLocationDocument = gql` export const UpdateTaskLocationDocument = gql`
mutation updateTaskLocation($taskID: String!, $taskGroupID: String!, $position: Float!) { mutation updateTaskLocation($taskID: String!, $taskGroupID: String!, $position: Float!) {
updateTaskLocation(input: {taskID: $taskID, taskGroupID: $taskGroupID, position: $position}) { updateTaskLocation(input: {taskID: $taskID, taskGroupID: $taskGroupID, position: $position}) {

View File

@ -0,0 +1,6 @@
mutation updateTaskGroupLocation($taskGroupID: UUID!, $position: Float!) {
updateTaskGroupLocation(input:{taskGroupID:$taskGroupID, position: $position}) {
taskGroupID
position
}
}