- additional cleanup and validation / fixes
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -33,7 +33,8 @@ export function TaskListContainer({
|
||||
currentUser,
|
||||
onlyMine,
|
||||
parentJobId,
|
||||
showRo = true
|
||||
showRo = true,
|
||||
disableJobRefetch = false
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const searchParams = queryString.parse(useLocation().search);
|
||||
@@ -73,14 +74,20 @@ export function TaskListContainer({
|
||||
const completed_at = !currentStatus ? dayjs().toISOString() : null;
|
||||
|
||||
try {
|
||||
const toggledTask = await toggleTaskCompleted({
|
||||
const toggledTaskObject = {
|
||||
variables: {
|
||||
id: id,
|
||||
completed: !currentStatus,
|
||||
completed_at: completed_at
|
||||
},
|
||||
refetchQueries: [Object.keys(query)[0], "GET_JOB_BY_PK"]
|
||||
});
|
||||
refetchQueries: [Object.keys(query)[0]]
|
||||
};
|
||||
|
||||
if (!disableJobRefetch) {
|
||||
toggledTaskObject.refetchQueries.push("GET_JOB_BY_PK");
|
||||
}
|
||||
|
||||
const toggledTask = await toggleTaskCompleted(toggledTaskObject);
|
||||
|
||||
if (!toggledTask.errors) {
|
||||
dispatch(
|
||||
@@ -119,14 +126,21 @@ export function TaskListContainer({
|
||||
const toggleDeletedStatus = async (id, currentStatus) => {
|
||||
const deleted_at = !currentStatus ? dayjs().toISOString() : null;
|
||||
try {
|
||||
const toggledTask = await toggleTaskDeleted({
|
||||
const toggledTaskObject = {
|
||||
variables: {
|
||||
id: id,
|
||||
deleted: !currentStatus,
|
||||
deleted_at: deleted_at
|
||||
},
|
||||
refetchQueries: [Object.keys(query)[0], "GET_JOB_BY_PK"]
|
||||
});
|
||||
refetchQueries: [Object.keys(query)[0]]
|
||||
};
|
||||
|
||||
if (!disableJobRefetch) {
|
||||
toggledTaskObject.refetchQueries.push("GET_JOB_BY_PK");
|
||||
}
|
||||
|
||||
const toggledTask = await toggleTaskDeleted(toggledTaskObject);
|
||||
|
||||
if (!toggledTask.errors) {
|
||||
dispatch(
|
||||
insertAuditTrail({
|
||||
|
||||
@@ -16,7 +16,7 @@ const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({});
|
||||
const mapDispatchToProps = () => ({});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(TaskUpsertModalComponent);
|
||||
|
||||
|
||||
@@ -119,9 +119,15 @@ export function TaskUpsertModalContainer({ bodyshop, currentUser, taskUpsert, to
|
||||
taskId: existingTask.id,
|
||||
task: replaceUndefinedWithNull(values)
|
||||
},
|
||||
refetchQueries: ["GET_JOB_BY_PK"]
|
||||
refetchQueries: []
|
||||
};
|
||||
|
||||
// We have relationship IDS, so we need to refetch the job
|
||||
if (jobid || joblineid || billid || partsorderid) {
|
||||
taskObject.refetchQueries.push("GET_JOB_BY_PK");
|
||||
}
|
||||
|
||||
// We have a relationship query, so we need to refetch the query
|
||||
if (query && Object.keys(query).length) {
|
||||
taskObject.refetchQueries.push(Object.keys(query)[0]);
|
||||
}
|
||||
@@ -180,9 +186,15 @@ export function TaskUpsertModalContainer({ bodyshop, currentUser, taskUpsert, to
|
||||
}
|
||||
]
|
||||
},
|
||||
refetchQueries: ["GET_JOB_BY_PK"]
|
||||
refetchQueries: []
|
||||
};
|
||||
|
||||
// We have relationship IDS, so we need to refetch the job
|
||||
if (jobid || joblineid || billid || partsorderid) {
|
||||
newTaskObject.refetchQueries.push("GET_JOB_BY_PK");
|
||||
}
|
||||
|
||||
// We have a relationship query, so we need to refetch the query
|
||||
if (query && Object.keys(query).length) {
|
||||
newTaskObject.refetchQueries.push(Object.keys(query)[0]);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { QUERY_ALL_TASKS_PAGINATED, QUERY_MY_TASKS_PAGINATED } from "../../graph
|
||||
import taskPageTypes from "./taskPageTypes.jsx";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectCurrentUser } from "../../redux/user/user.selectors.js";
|
||||
import {connect} from "react-redux";
|
||||
import { connect } from "react-redux";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser
|
||||
@@ -13,7 +13,7 @@ const mapDispatchToProps = (dispatch) => ({});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(TasksPageComponent);
|
||||
|
||||
export function TasksPageComponent({ currentUser, type }) {
|
||||
export function TasksPageComponent({ currentUser, type }) {
|
||||
switch (type) {
|
||||
case taskPageTypes.MY_TASKS:
|
||||
return (
|
||||
@@ -23,10 +23,17 @@ export function TasksPageComponent({ currentUser, type }) {
|
||||
relationshipType={"user"}
|
||||
query={{ QUERY_MY_TASKS_PAGINATED }}
|
||||
titleTranslation={"tasks.titles.my_tasks"}
|
||||
disableJobRefetch={true}
|
||||
/>
|
||||
);
|
||||
case taskPageTypes.ALL_TASKS:
|
||||
return <TaskListContainer query={{ QUERY_ALL_TASKS_PAGINATED }} titleTranslation={"tasks.titles.all_tasks"} />;
|
||||
return (
|
||||
<TaskListContainer
|
||||
query={{ QUERY_ALL_TASKS_PAGINATED }}
|
||||
titleTranslation={"tasks.titles.all_tasks"}
|
||||
disableJobRefetch={true}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return <></>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user