- 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,
|
currentUser,
|
||||||
onlyMine,
|
onlyMine,
|
||||||
parentJobId,
|
parentJobId,
|
||||||
showRo = true
|
showRo = true,
|
||||||
|
disableJobRefetch = false
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const searchParams = queryString.parse(useLocation().search);
|
const searchParams = queryString.parse(useLocation().search);
|
||||||
@@ -73,14 +74,20 @@ export function TaskListContainer({
|
|||||||
const completed_at = !currentStatus ? dayjs().toISOString() : null;
|
const completed_at = !currentStatus ? dayjs().toISOString() : null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const toggledTask = await toggleTaskCompleted({
|
const toggledTaskObject = {
|
||||||
variables: {
|
variables: {
|
||||||
id: id,
|
id: id,
|
||||||
completed: !currentStatus,
|
completed: !currentStatus,
|
||||||
completed_at: completed_at
|
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) {
|
if (!toggledTask.errors) {
|
||||||
dispatch(
|
dispatch(
|
||||||
@@ -119,14 +126,21 @@ export function TaskListContainer({
|
|||||||
const toggleDeletedStatus = async (id, currentStatus) => {
|
const toggleDeletedStatus = async (id, currentStatus) => {
|
||||||
const deleted_at = !currentStatus ? dayjs().toISOString() : null;
|
const deleted_at = !currentStatus ? dayjs().toISOString() : null;
|
||||||
try {
|
try {
|
||||||
const toggledTask = await toggleTaskDeleted({
|
const toggledTaskObject = {
|
||||||
variables: {
|
variables: {
|
||||||
id: id,
|
id: id,
|
||||||
deleted: !currentStatus,
|
deleted: !currentStatus,
|
||||||
deleted_at: deleted_at
|
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) {
|
if (!toggledTask.errors) {
|
||||||
dispatch(
|
dispatch(
|
||||||
insertAuditTrail({
|
insertAuditTrail({
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
currentUser: selectCurrentUser
|
currentUser: selectCurrentUser
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({});
|
const mapDispatchToProps = () => ({});
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(TaskUpsertModalComponent);
|
export default connect(mapStateToProps, mapDispatchToProps)(TaskUpsertModalComponent);
|
||||||
|
|
||||||
|
|||||||
@@ -119,9 +119,15 @@ export function TaskUpsertModalContainer({ bodyshop, currentUser, taskUpsert, to
|
|||||||
taskId: existingTask.id,
|
taskId: existingTask.id,
|
||||||
task: replaceUndefinedWithNull(values)
|
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) {
|
if (query && Object.keys(query).length) {
|
||||||
taskObject.refetchQueries.push(Object.keys(query)[0]);
|
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) {
|
if (query && Object.keys(query).length) {
|
||||||
newTaskObject.refetchQueries.push(Object.keys(query)[0]);
|
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 taskPageTypes from "./taskPageTypes.jsx";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { selectCurrentUser } from "../../redux/user/user.selectors.js";
|
import { selectCurrentUser } from "../../redux/user/user.selectors.js";
|
||||||
import {connect} from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentUser: selectCurrentUser
|
currentUser: selectCurrentUser
|
||||||
@@ -13,7 +13,7 @@ const mapDispatchToProps = (dispatch) => ({});
|
|||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(TasksPageComponent);
|
export default connect(mapStateToProps, mapDispatchToProps)(TasksPageComponent);
|
||||||
|
|
||||||
export function TasksPageComponent({ currentUser, type }) {
|
export function TasksPageComponent({ currentUser, type }) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case taskPageTypes.MY_TASKS:
|
case taskPageTypes.MY_TASKS:
|
||||||
return (
|
return (
|
||||||
@@ -23,10 +23,17 @@ export function TasksPageComponent({ currentUser, type }) {
|
|||||||
relationshipType={"user"}
|
relationshipType={"user"}
|
||||||
query={{ QUERY_MY_TASKS_PAGINATED }}
|
query={{ QUERY_MY_TASKS_PAGINATED }}
|
||||||
titleTranslation={"tasks.titles.my_tasks"}
|
titleTranslation={"tasks.titles.my_tasks"}
|
||||||
|
disableJobRefetch={true}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case taskPageTypes.ALL_TASKS:
|
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:
|
default:
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user