Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/dinesh-aot/EPIC-FLOW int…
Browse files Browse the repository at this point in the history
…o 1356
  • Loading branch information
dinesh-aot committed Dec 1, 2023
2 parents 9f4492c + db5ddb0 commit e5b3254
Show file tree
Hide file tree
Showing 21 changed files with 362 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""project lead to team lead
Revision ID: 7a42d4f57279
Revises: 1e1a2af1605b
Create Date: 2023-11-24 13:39:01.142953
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '7a42d4f57279'
down_revision = '1e1a2af1605b'
branch_labels = None
depends_on = None


def upgrade():
op.execute("Update roles set name='Team Lead' where name='Project Lead'")


def downgrade():
pass
4 changes: 2 additions & 2 deletions epictrack-api/src/api/actions/set_phases_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def run(self, source_event: Event, params):
db.session.query(WorkPhase)
.filter(
WorkPhase.sort_order
> source_event.event_configuration.work_phase.sort_order
and WorkPhase.work_id == source_event.work_id
> source_event.event_configuration.work_phase.sort_order,
WorkPhase.work_id == source_event.work_id,
)
.all()
)
Expand Down
2 changes: 1 addition & 1 deletion epictrack-api/src/api/resources/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def get(work_id):
@auth.require
@profiletime
def post(work_id):
"""Get all the active staff allocated to the work"""
"""Add staff member to a work"""
req.WorkIdPathParameterSchema().load(request.view_args)
request_json = req.StaffWorkBodyParamSchema().load(API.payload)
staff = WorkService.create_work_staff(work_id, request_json)
Expand Down
1 change: 0 additions & 1 deletion epictrack-api/src/api/services/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class StaffService:
def find_by_position_id(cls, position_id):
"""Find staff by position."""
current_app.logger.debug(f"Find staff by position : {position_id}")
staffs_schema = StaffResponseSchema(many=True)
staffs = Staff.find_active_staff_by_position(position_id)
return staffs

Expand Down
14 changes: 14 additions & 0 deletions epictrack-api/src/api/services/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from api.services.event_template import EventTemplateService
from api.services.outcome_template import OutcomeTemplateService
from api.services.phaseservice import PhaseService
from api.services.code import CodeService


class WorkService: # pylint: disable=too-many-public-methods
Expand Down Expand Up @@ -148,6 +149,19 @@ def create_work(cls, payload, commit: bool = True):
if sort_order == 1:
work.current_work_phase_id = work_phase_id
sort_order = sort_order + 1
role_id = CodeService.find_code_values_by_type(
"roles",
{
"name": "Team Lead"
}
).get("codes")[0].get("id")
WorkService.create_work_staff(
work.id,
{
"staff_id": payload["work_lead_id"],
"role_id": role_id, "is_active": True
}
)
if commit:
db.session.commit()
return work
Expand Down
Binary file not shown.
39 changes: 34 additions & 5 deletions epictrack-web/src/components/layout/SideNav/SideNav.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useMemo } from "react";
import {
ListItemButton,
List,
Expand All @@ -14,14 +14,15 @@ import { styled } from "@mui/system";
import ExpandLess from "@mui/icons-material/ExpandLess";
import ExpandMore from "@mui/icons-material/ExpandMore";
import Collapse from "@mui/material/Collapse";
import { Routes } from "./SideNavElements";
import { RouteType, Routes } from "./SideNavElements";
import { Palette } from "../../../styles/theme";
import { SideNavProps } from "./types";
import { useAppSelector } from "../../../hooks";
import Icons from "../../icons";
import { groupBy } from "../../../utils";
import { IconProps } from "../../icons/type";
import { ETSubhead } from "../../shared";
import { hasPermission } from "../../shared/restricted";

const ListItemStyled = styled(ListItem)({
padding: "0px 0px 0px 0px",
Expand Down Expand Up @@ -57,6 +58,7 @@ const DrawerBox = () => {
const [open, setOpen] = React.useState<{ [x: string]: boolean }>({});
const uiState = useAppSelector((state) => state.uiState);
const location = useLocation();
const { roles } = useAppSelector((state) => state.user.userDetail);
const handleClick = (route: any) => {
if (route.routes && route.routes.length > 0) {
setOpen((prevState: any) => ({
Expand All @@ -72,9 +74,36 @@ const DrawerBox = () => {
return <Icon className={`sidebar-item ${active ? "active" : ""}`} />;
}, []);

const groupedRoutes = React.useMemo(
() => groupBy(Routes, (p) => p.group),
[]
const isRouteAllowed = (route: RouteType, roles: Array<any>) => {
const allowed = route["allowedRoles"] ?? [];
return hasPermission({ roles, allowed }) || !route["isAuthenticated"];
};

const filterRoutes = (routes: RouteType[], roles: Array<any>) => {
return routes.reduce((allowedRoutes: any, route) => {
if (isRouteAllowed(route, roles)) {
const newRoute: RouteType = { ...route };
if (newRoute["routes"]) {
newRoute["routes"] = filterRoutes(newRoute["routes"], roles);
}

const addRoute =
(newRoute["routes"] && newRoute["routes"].length > 0) ||
!newRoute["routes"];

if (addRoute) {
allowedRoutes.push(newRoute);
}
}
return allowedRoutes;
}, []);
};

const allowedRoutes: RouteType[] = filterRoutes(Routes, roles);

const groupedRoutes = useMemo(
() => groupBy(allowedRoutes, (p) => p.group),
[allowedRoutes]
);

return (
Expand Down
31 changes: 31 additions & 0 deletions epictrack-web/src/components/layout/SideNav/SideNavElements.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ROLES } from "../../../constants/application-constant";
import { Icon } from "../../icons/type";

export const Routes: RouteType[] = [
Expand All @@ -6,12 +7,16 @@ export const Routes: RouteType[] = [
icon: "DashboardIcon",
path: "/",
group: "Group1",
allowedRoles: [],
isAuthenticated: false,
},
{
name: "All Works",
icon: "AllIcon",
path: "/works",
group: "Group1",
allowedRoles: [],
isAuthenticated: false,
},
{
name: "Reports",
Expand All @@ -22,18 +27,26 @@ export const Routes: RouteType[] = [
{
name: "Referral Schedule",
path: "/reports/referral-schedule",
allowedRoles: [],
isAuthenticated: false,
},
{
name: "Resource Forecast",
path: "/reports/resource-forecast",
allowedRoles: [],
isAuthenticated: false,
},
{
name: "30-60-90",
path: "/reports/30-60-90",
allowedRoles: [],
isAuthenticated: false,
},
{
name: "Event Calendar",
path: "/reports/event-calendar",
allowedRoles: [],
isAuthenticated: false,
},
],
},
Expand All @@ -42,12 +55,16 @@ export const Routes: RouteType[] = [
icon: "InsightIcon",
path: "/insights",
group: "Group2",
allowedRoles: [],
isAuthenticated: false,
},
{
name: "Task Templates",
path: "/templates",
group: "Group3",
icon: "PenIcon",
allowedRoles: [],
isAuthenticated: false,
},
{
name: "List Management",
Expand All @@ -58,22 +75,32 @@ export const Routes: RouteType[] = [
{
name: "Staff",
path: "/list-management/staffs",
allowedRoles: [],
isAuthenticated: false,
},
{
name: "First Nations",
path: "/list-management/first-nations",
allowedRoles: [],
isAuthenticated: false,
},
{
name: "Proponents",
path: "/list-management/proponents",
allowedRoles: [],
isAuthenticated: false,
},
{
name: "Projects",
path: "/list-management/projects",
allowedRoles: [],
isAuthenticated: false,
},
{
name: "Work Staff",
path: "/list-management/work-staff",
allowedRoles: [],
isAuthenticated: false,
},
],
},
Expand All @@ -86,6 +113,8 @@ export const Routes: RouteType[] = [
{
name: "Users",
path: "/admin/users",
allowedRoles: [ROLES.CREATE],
isAuthenticated: true,
},
],
},
Expand All @@ -97,4 +126,6 @@ export interface RouteType {
group?: string;
icon?: Icon;
routes?: RouteType[];
allowedRoles?: string[];
isAuthenticated?: boolean;
}
2 changes: 1 addition & 1 deletion epictrack-web/src/components/myWorkplans/CardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { Box } from "@mui/material";

const CardList = () => {
return <Box></Box>;
return <Box>This is a card list</Box>;
};

export default CardList;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import { FormControlLabel, Stack, Switch } from "@mui/material";
import { useAppSelector } from "../../../hooks";
import { ETCaption2 } from "../../shared";
import { Palette } from "../../../styles/theme";
import { CustomSwitch } from "../../shared/CustomSwitch";

export const AssigneeToggle = () => {
const user = useAppSelector((state) => state.user.userDetail);

const [isUsersWorkPlans, setIsUsersWorkPlans] = React.useState(false);
return (
<Stack direction="row" spacing={1} alignItems={"center"}>
<>
<ETCaption2 bold color={Palette.neutral.dark}>
{user.firstName}'s{" "}
</ETCaption2>
<ETCaption2 color={Palette.neutral.dark}>Workplans</ETCaption2>
</>
<CustomSwitch
color="primary"
checked={isUsersWorkPlans}
onChange={() => setIsUsersWorkPlans(!isUsersWorkPlans)}
/>
</Stack>
);
};
12 changes: 12 additions & 0 deletions epictrack-web/src/components/myWorkplans/Filters/NameFilter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";
import { TextField } from "@mui/material";

export const NameFilter = () => {
return (
<TextField
placeholder="Search for a Project"
variant="outlined"
fullWidth
/>
);
};
Loading

0 comments on commit e5b3254

Please sign in to comment.