- Progress Commit

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-04-01 20:20:01 -04:00
parent 1343b68cc6
commit 282dbd0913
10 changed files with 148 additions and 60 deletions

View File

@@ -464,7 +464,12 @@ function Header({
{
key: 'mytasks',
icon: <FaTasks/>,
label: <Link to="/manage/tasks">{t('menus.header.my_tasks')}</Link>,
label: <Link to="/manage/tasks/mytasks">{t('menus.header.my_tasks')}</Link>,
},
{
key: 'all_tasks',
icon: <FaTasks/>,
label: <Link to="/manage/tasks/alltasks">{t('menus.header.all_tasks')}</Link>,
}
]
},

View File

@@ -1,46 +1,5 @@
import {gql} from "@apollo/client";
/**
* All tasks paginated query
* @type {DocumentNode}
*/
export const QUERY_ALL_TASKS_PAGINATED = gql`
query QUERY_ALL_TASKS_PAGINATED(
$offset: Int
$limit: Int
$order: [tasks_order_by!]!
) {
tasks(
offset: $offset
limit: $limit
order_by: $order
) {
id
created_at
updated_at
title
description
deleted
deleted_at
due_date
created_by
assigned_to
completed
completed_at
remind_at
priority
jobid
joblineid
partsorderid
billid
}
tasks_aggregate {
aggregate {
count
}
}
}
`;
const PARTIAL_TASK_FIELDS = gql`
fragment TaskFields on tasks {
@@ -87,6 +46,45 @@ const PARTIAL_TASK_FIELDS = gql`
}
`;
export const QUERY_ALL_TASKS_PAGINATED = gql`
${PARTIAL_TASK_FIELDS}
query QUERY_ALL_TASKS_PAGINATED(
$offset: Int
$limit: Int
$bodyshop: uuid!
$deleted: Boolean
$completed: Boolean
$assigned_to: String
$order: [tasks_order_by!]!
) {
tasks(
offset: $offset
limit: $limit
order_by: $order
where: {
bodyshopid: {_eq: $bodyshop},
deleted: {_eq: $deleted},
assigned_to: {_eq: $assigned_to},
completed: {_eq: $completed}
}
) {
...TaskFields
}
tasks_aggregate(
where: {
bodyshopid: {_eq: $bodyshop},
deleted: {_eq: $deleted},
assigned_to: {_eq: $assigned_to},
completed: {_eq: $completed}
}
) {
aggregate {
count
}
}
}
`;
// Query for joblineid
export const QUERY_JOBLINE_TASKS_PAGINATED = gql`
${PARTIAL_TASK_FIELDS}

View File

@@ -102,7 +102,9 @@ const Dms = lazy(() => import("../dms/dms.container"));
const DmsPayables = lazy(() => import("../dms-payables/dms-payables.container"));
const ManageRootPage = lazy(() => import("../manage-root/manage-root.page.container"));
const TtApprovals = lazy(() => import("../tt-approvals/tt-approvals.page.container"));
const TasksPage = lazy(() => import("../tasks/tasks.page.container"));
const MyTasksPage = lazy(() => import("../tasks/myTasksPageContainer.jsx"));
const AllTasksPage = lazy(() => import("../tasks/allTasksPageContainer.jsx"));
const TaskUpsertModalContainer = lazy(() => import("../../components/task-upsert-modal/task-upsert-modal.container"));
const { Content, Footer } = Layout;
@@ -259,12 +261,19 @@ export function Manage({ conflict, bodyshop, enableJoyRide, joyRideSteps, setJoy
}
/>
<Route
path='/tasks'
path='/tasks/mytasks'
element={
<Suspense fallback={<Spin/>}>
<TasksPage/>
<MyTasksPage/>
</Suspense>}
/>
<Route
path='/tasks/alltasks'
element={
<Suspense fallback={<Spin/>}>
<AllTasksPage/>
</Suspense>}
/>
<Route
path="/inventory/"
element={

View File

@@ -0,0 +1,48 @@
import React, {useEffect} from "react";
import {useTranslation} from "react-i18next";
import TasksPageComponent from "./tasks.page.component";
import {connect} from "react-redux";
import {createStructuredSelector} from "reselect";
import {setBreadcrumbs, setSelectedHeader} from "../../redux/application/application.actions";
import InstanceRenderManager from "../../utils/instanceRenderMgr.js";
import {selectBodyshop, selectCurrentUser} from "../../redux/user/user.selectors.js";
import TaskPageTypes from "./taskPageTypes.jsx";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
currentUser: selectCurrentUser,
});
const mapDispatchToProps = (dispatch) => ({
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
setSelectedHeader: (key) => dispatch(setSelectedHeader(key)),
});
export function MyTasksPageContainer({bodyshop, currentUser, setBreadcrumbs, setSelectedHeader, query}) {
const {t} = useTranslation();
useEffect(() => {
document.title = t("titles.all_tasks", {
app: InstanceRenderManager({
imex: '$t(titles.imexonline)',
rome: '$t(titles.romeonline)',
promanager: '$t(titles.promanager)'
})
});
setSelectedHeader("all_tasks");
setBreadcrumbs([
{
link: "/manage/alltasks",
label: t("titles.bc.all_tasks"),
},]);
}, [t, setBreadcrumbs, setSelectedHeader]);
return (
<TasksPageComponent type={TaskPageTypes.ALL_TASKS} currentUser={currentUser} bodyshop={bodyshop}/>
);
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(MyTasksPageContainer);

View File

@@ -7,6 +7,7 @@ import {createStructuredSelector} from "reselect";
import {setBreadcrumbs, setSelectedHeader} from "../../redux/application/application.actions";
import InstanceRenderManager from "../../utils/instanceRenderMgr.js";
import {selectBodyshop, selectCurrentUser} from "../../redux/user/user.selectors.js";
import TaskPageTypes from "./taskPageTypes.jsx";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -18,30 +19,30 @@ const mapDispatchToProps = (dispatch) => ({
setSelectedHeader: (key) => dispatch(setSelectedHeader(key)),
});
export function TasksPageContainer({bodyshop, currentUser, setBreadcrumbs, setSelectedHeader}) {
export function MyTasksPageContainer({bodyshop, currentUser, setBreadcrumbs, setSelectedHeader, query}) {
const {t} = useTranslation();
useEffect(() => {
document.title = t("titles.tasks", {
document.title = t("titles.my_tasks", {
app: InstanceRenderManager({
imex: '$t(titles.imexonline)',
rome: '$t(titles.romeonline)',
promanager: '$t(titles.promanager)'
})
});
setSelectedHeader("tasks");
setSelectedHeader("my_tasks");
setBreadcrumbs([
{
link: "/manage/tasks",
label: t("titles.bc.tasks"),
link: "/manage/mytasks",
label: t("titles.bc.my_tasks"),
},]);
}, [t, setBreadcrumbs, setSelectedHeader]);
return (
<TasksPageComponent currentUser={currentUser} bodyshop={bodyshop}/>
<TasksPageComponent type={TaskPageTypes.MY_TASKS} currentUser={currentUser} bodyshop={bodyshop}/>
);
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(TasksPageContainer);
)(MyTasksPageContainer);

View File

@@ -0,0 +1,6 @@
export const TaskPageTypes = {
MY_TASKS: 'myTasks',
ALL_TASKS: 'allTasks',
};
export default TaskPageTypes;

View File

@@ -1,13 +1,19 @@
import React from "react";
import TaskListContainer from "../../components/task-list/task-list.container.jsx";
import {QUERY_MY_TASKS_PAGINATED} from "../../graphql/tasks.queries.js";
import {QUERY_ALL_TASKS_PAGINATED, QUERY_MY_TASKS_PAGINATED} from "../../graphql/tasks.queries.js";
import taskPageTypes from "./taskPageTypes.jsx";
export default function TasksPageComponent({bodyshop, currentUser}) {
export default function TasksPageComponent({bodyshop, currentUser, type}) {
switch (type) {
case taskPageTypes.MY_TASKS:
return <TaskListContainer onlyMine={true} relationshipId={currentUser.email}
relationshipType={'user'} query={QUERY_MY_TASKS_PAGINATED}
bodyshop={bodyshop} titleTranslation={'tasks.titles.my_tasks'}
currentUser={currentUser}/>
case taskPageTypes.ALL_TASKS:
return <TaskListContainer query={QUERY_ALL_TASKS_PAGINATED} bodyshop={bodyshop}
titleTranslation={'tasks.titles.my_tasks'}
currentUser={currentUser}/>
}
return (
<div>
<TaskListContainer onlyMine={true} relationshipId={currentUser.email} relationshipType={'user'} query={QUERY_MY_TASKS_PAGINATED} bodyshop={bodyshop} titleTranslation={'tasks.titles.my_tasks'}
currentUser={currentUser}/>
</div>
);
}

View File

@@ -2177,6 +2177,7 @@
"create_task": "Create Task",
"tasks": "Tasks",
"my_tasks": "My Tasks",
"all_tasks": "All Tasks",
"accounting": "Accounting",
"accounting-payables": "Payables",
"accounting-payments": "Payments",
@@ -3134,12 +3135,16 @@
},
"titles": {
"tasks": "Tasks",
"all_tasks": "All Tasks",
"my_tasks": "My Tasks",
"accounting-payables": "Payables | {{app}}",
"accounting-payments": "Payments | {{app}}",
"accounting-receivables": "Receivables | {{app}}",
"app": "",
"bc": {
"tasks": "Tasks",
"all_tasks": "All Tasks",
"my_tasks": "My Tasks",
"accounting-payables": "Payables",
"accounting-payments": "Payments",
"accounting-receivables": "Receivables",

View File

@@ -2175,6 +2175,7 @@
"header": {
"create_task": "",
"tasks": "",
"all_tasks": "",
"my_tasks": "",
"accounting": "",
"accounting-payables": "",
@@ -3133,12 +3134,16 @@
},
"titles": {
"tasks": "",
"all_tasks": "",
"my_tasks": "",
"accounting-payables": "",
"accounting-payments": "",
"accounting-receivables": "",
"app": "",
"bc": {
"tasks": "",
"all_tasks": "",
"my_tasks": "",
"accounting-payables": "",
"accounting-payments": "",
"accounting-receivables": "",

View File

@@ -2176,6 +2176,7 @@
"create_task": "",
"tasks": "",
"my_tasks": "",
"all_tasks": "",
"accounting": "",
"accounting-payables": "",
"accounting-payments": "",
@@ -3137,8 +3138,12 @@
"accounting-receivables": "",
"app": "",
"tasks": "",
"all_tasks": "",
"my_tasks": "",
"bc": {
"tasks": "",
"all_tasks": "",
"my_tasks": "",
"accounting-payables": "",
"accounting-payments": "",
"accounting-receivables": "",