Skip to content

Commit

Permalink
#887 - feedbacks (#1070)
Browse files Browse the repository at this point in the history
* first nation feedbacks
  - fixed issue with edit nation modal
  - fixed no data component import button click action
  - renamed List Management -> Indigenous Nations to First Nations
  - added functionality to disable import button if no first nations are available
  - fixed nation notes not refreshing when switching tabs issue
  - tab title now shows count of only active nations
  - fixed nation notes success notification frequency issue

* #887 - feedbacks
  - fixed issue where disabled first nation and staffs where visible in the add new form
  - removed right padding for `Resources` tab
  - moved hover effect to `Avatar` only
  - fixed the tooltip for import nations button

* linting fixes
  • Loading branch information
salabh-aot authored Oct 19, 2023
1 parent 79d06ec commit 8af63db
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 45 deletions.
4 changes: 1 addition & 3 deletions epictrack-api/src/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

from api import config
from api.config import _Config
from api.exceptions import (
PermissionDeniedError, ResourceExistsError, ResourceNotFoundError, UnprocessableEntityError)
from api.exceptions import PermissionDeniedError, ResourceExistsError, ResourceNotFoundError, UnprocessableEntityError
from api.models import db
from api.utils.auth import jwt
from api.utils.caching import AppCache
Expand All @@ -48,7 +47,6 @@ def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
db.init_app(app)

if run_mode != 'migration':

AppCache.configure_cache(run_mode, app)
# pylint: disable=import-outside-toplevel
from api.resources import API_BLUEPRINT, OPS_BLUEPRINT
Expand Down
7 changes: 5 additions & 2 deletions epictrack-api/src/api/models/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ def find_all_active_staff(cls):
return cls.query.filter_by(is_active=True, is_deleted=False)

@classmethod
def find_all_non_deleted_staff(cls):
def find_all_non_deleted_staff(cls, is_active=False):
"""Return all non-deleted staff"""
return cls.query.filter_by(is_deleted=False)
query = {"is_deleted": False}
if is_active:
query["is_active"] = is_active
return cls.query.filter_by(**query)

@classmethod
def check_existence(cls, email, staff_id):
Expand Down
4 changes: 3 additions & 1 deletion epictrack-api/src/api/resources/indigenous_nation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
"""Resource for indigenous nation endpoints."""
from http import HTTPStatus

from flask import jsonify, request
from flask_restx import Namespace, Resource, cors

Expand Down Expand Up @@ -99,7 +100,8 @@ class IndigenousNations(Resource):
@profiletime
def get():
"""Return all indigenous nations."""
indigenous_nations = IndigenousNationService.find_all_indigenous_nations()
args = req.BasicRequestQueryParameterSchema().load(request.args)
indigenous_nations = IndigenousNationService.find_all_indigenous_nations(args.get("is_active"))
return jsonify(res.IndigenousResponseNationSchema(many=True).dump(indigenous_nations)), HTTPStatus.OK

@staticmethod
Expand Down
3 changes: 2 additions & 1 deletion epictrack-api/src/api/resources/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def get():
current_app.logger.info('Getting staffs')
args = req.StaffByPositionsQueryParamSchema().load(request.args)
positions = args.get('positions')
is_active = args.get('is_active')
if not positions:
staffs = StaffService.find_all_non_deleted_staff()
staffs = StaffService.find_all_non_deleted_staff(is_active)
if positions:
current_app.logger.info(f'Position ids are {positions}')
staffs = StaffService.find_by_position_ids(positions)
Expand Down
6 changes: 4 additions & 2 deletions epictrack-api/src/api/schemas/request/staff_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

from api.schemas.validators import Phone

from .base import RequestBodyParameterSchema, RequestPathParameterSchema, RequestQueryParameterSchema
from .base import (
BasicRequestQueryParameterSchema, RequestBodyParameterSchema, RequestPathParameterSchema,
RequestQueryParameterSchema)
from .custom_fields import IntegerList


Expand Down Expand Up @@ -46,7 +48,7 @@ class StaffExistanceQueryParamSchema(RequestQueryParameterSchema):
)


class StaffByPositionsQueryParamSchema(RequestQueryParameterSchema):
class StaffByPositionsQueryParamSchema(BasicRequestQueryParameterSchema):
"""Staff by positions query parameter"""

positions = IntegerList(metadata={"description": "comma separated position ids"})
Expand Down
4 changes: 2 additions & 2 deletions epictrack-api/src/api/services/indigenous_nation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def check_existence(cls, name, indigenous_nation_id=None):
return IndigenousNation.check_existence(name, indigenous_nation_id)

@classmethod
def find_all_indigenous_nations(cls):
def find_all_indigenous_nations(cls, is_active):
"""Find all active indigenous nations"""
indigenous_nations = IndigenousNation.find_all(default_filters=False)
indigenous_nations = IndigenousNation.find_all(default_filters=is_active)
return indigenous_nations

@classmethod
Expand Down
6 changes: 3 additions & 3 deletions epictrack-api/src/api/services/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"""Service to manage Staffs."""

from flask import current_app
from api.exceptions import ResourceExistsError, ResourceNotFoundError

from api.exceptions import ResourceExistsError, ResourceNotFoundError
from api.models import Staff
from api.schemas.response import StaffResponseSchema

Expand Down Expand Up @@ -48,9 +48,9 @@ def find_all_active_staff(cls):
return response

@classmethod
def find_all_non_deleted_staff(cls):
def find_all_non_deleted_staff(cls, is_active=False):
"""Find all non-deleted staff"""
staffs = Staff.find_all_non_deleted_staff()
staffs = Staff.find_all_non_deleted_staff(is_active)
return staffs

@classmethod
Expand Down
1 change: 0 additions & 1 deletion epictrack-api/src/api/services/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ def import_first_nations(cls, work_id: int, indigenous_nation_ids: [int]):
)

# Mark removed entries as inactive
# TODO:CHECK THIS LOGIC
disabled_count = existing_first_nations_qry.filter(
IndigenousWork.is_active.is_(True),
IndigenousWork.indigenous_nation_id.notin_(indigenous_nation_ids),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const useStyle = makeStyles({
paddingBottom: "0.5rem",
},
tabPanel: {
padding: "1.5rem 1rem 1rem 1rem",
padding: "1.5rem 0px 1rem 1rem",
minHeight: "0px",
},
tab: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const FirstNationForm = ({ onSave, workNationId }: FirstNationFormProps) => {

const getAllFirstNations = async () => {
try {
const result = await indigenousNationService.getAll();
const result = await indigenousNationService.getAll(true);
if (result.status === 200) {
const firstNations = result.data as FirstNation[];
setFirstNations(sort(firstNations, "name"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ const FirstNationList = () => {
const [firstNationAvailable, setFirstNationAvailable] =
React.useState<boolean>(false);

const [menuRowIndex, setMenuRowIndex] = React.useState<number>(-1);

React.useEffect(() => {
if (workFirstNationId === undefined) {
setModalTitle("Add Nation");
Expand Down Expand Up @@ -213,16 +215,34 @@ const FirstNationList = () => {
const user = row.original.indigenous_nation.relationship_holder;
if (user === undefined || user === null) return <></>;
return (
<Box
className={classes.userProfileWrapper}
onMouseEnter={(event) => handleOpenUserMenu(event, row.original)}
onMouseLeave={handleCloseUserMenu}
sx={{ height: "100%" }}
>
<Avatar className={classes.avatar}>
<Box className={classes.userProfileWrapper} sx={{ height: "100%" }}>
<Avatar
className={classes.avatar}
onMouseEnter={(event) => {
event.stopPropagation();
event.preventDefault();
handleOpenUserMenu(event, row.original);
}}
onMouseLeave={handleCloseUserMenu}
>
<ETCaption2
bold
>{`${user?.first_name[0]}${user?.last_name[0]}`}</ETCaption2>
<UserMenu
anchorEl={userMenuAnchorEl}
email={relationshipHolder?.email || ""}
phone={relationshipHolder?.phone || ""}
position={relationshipHolder?.position?.name || ""}
firstName={relationshipHolder?.first_name || ""}
lastName={relationshipHolder?.last_name || ""}
onClose={handleCloseUserMenu}
origin={{ vertical: "top", horizontal: "left" }}
sx={{
marginTop: "2.1em",
pointerEvents: "none",
}}
id={`relationship_holder_${row.original.id}`}
/>
</Avatar>
<Typography
style={{
Expand All @@ -235,21 +255,6 @@ const FirstNationList = () => {
>
{user.full_name}
</Typography>
<UserMenu
anchorEl={userMenuAnchorEl}
email={relationshipHolder?.email || ""}
phone={relationshipHolder?.phone || ""}
position={relationshipHolder?.position?.name || ""}
firstName={relationshipHolder?.first_name || ""}
lastName={relationshipHolder?.last_name || ""}
onClose={handleCloseUserMenu}
origin={{ vertical: "top", horizontal: "left" }}
sx={{
marginTop: "2.1em",
pointerEvents: "none",
}}
id={`relationship_holder_${row.original.id}`}
/>
</Box>
);
},
Expand Down Expand Up @@ -425,7 +430,7 @@ const FirstNationList = () => {
gap: "0.5rem",
}}
>
<Tooltip title={"Import tasks from template"}>
<Tooltip title={"Import Nations from existing Works"}>
<IButton
onClick={() => setShowImportNationForm(true)}
disabled={!firstNationAvailable}
Expand All @@ -448,6 +453,9 @@ const FirstNationList = () => {
isLoading: loading,
showGlobalFilter: true,
}}
onHoveredRowChange={({ ...params }) => {
debugger;
}}
/>
</Grid>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion epictrack-web/src/components/workPlan/team/TeamForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const TeamForm = ({ onSave, workStaffId }: TeamFormProps) => {

const getAllStaff = async () => {
try {
const result = await staffService.getAll();
const result = await staffService.getAll(true);
if (result.status === 200) {
const staff = result.data as Staff[];
setStaff(sort(staff, "full_name"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import ServiceBase from "../common/serviceBase";
import { MasterBase } from "../../models/type";

class IndigenousNationService implements ServiceBase {
async getAll() {
async getAll(is_active = false) {
return await http.GetRequest(
Endpoints.IndigenousNations.INDIGENOUS_NATIONS
Endpoints.IndigenousNations.INDIGENOUS_NATIONS,
{ is_active }
);
}

Expand Down
4 changes: 2 additions & 2 deletions epictrack-web/src/services/staffService/staffService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { MasterBase } from "../../models/type";
import ServiceBase from "../common/serviceBase";

class StaffService implements ServiceBase {
async getAll() {
return await http.GetRequest(Endpoints.Staffs.STAFFS);
async getAll(is_active = false) {
return await http.GetRequest(Endpoints.Staffs.STAFFS, { is_active });
}

async getById(id: string) {
Expand Down

0 comments on commit 8af63db

Please sign in to comment.