Skip to content

Commit

Permalink
Feat: Added Effort value sum to team member efforts table
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fborges committed Oct 3, 2023
1 parent bf02cde commit c2c8cc8
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 6 deletions.
6 changes: 4 additions & 2 deletions app/graphql/types/demand_efforts_list_type.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Types
class DemandEffortsListType < BaseObject
field :demand_efforts, [Types::DemandEffortType], null: true
field :demand_efforts, [Types::DemandEffortType], null: true
field :efforts_value_sum, Float, null: true
field :demand_efforts_count, Int, null: true
end
end
end

2 changes: 1 addition & 1 deletion app/graphql/types/teams/team_member_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def demands(status: 'ALL', type: 'ALL', limit: nil)
def demand_efforts_list(from_date: nil, until_date: nil, page_number: nil)
efforts = object.demand_efforts.to_dates(from_date, until_date).order(start_time_to_computation: :desc)
efforts_paginated = efforts.page(page_number).per(10)
{ 'demand_efforts_count' => efforts.count, 'demand_efforts' => efforts_paginated }
{ 'demand_efforts_count' => efforts.count, 'demand_efforts' => efforts_paginated, 'efforts_value_sum' => efforts.sum(&:effort_value).round(2) }
end

def projects_list(order_field:, sort_direction: 'ASC', per_page: 10, page_number: 1)
Expand Down
1 change: 1 addition & 0 deletions app/spa/src/components/TeamMemberDashboardTables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ const TeamMemberDashboardTables = ({
{searchParams && (
<Table
title={t("dashboard.latestEfforts.title")}
subtitle={`${t("dashboard.latestEfforts.effortsValueSum")} ${teamMember?.demandEffortsList?.effortsValueSum || 0}`}
headerCells={latestEffortsHeader}
rows={latestEffortsRows || []}
pagination={{
Expand Down
18 changes: 18 additions & 0 deletions app/spa/src/components/ui/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type RowWithCollapse = {
type TableProps = {
rows: Row[] | RowWithCollapse[]
title?: string | ReactElement
subtitle?: string | ReactElement
headerCells?: Cell[]
footerCells?: Cell[]
pagination?: TablePaginationProps
Expand Down Expand Up @@ -110,6 +111,7 @@ const TableRowWithCollapse = ({ row, index }: TableRowWithCollapseProps) => {

const Table = ({
title,
subtitle,
headerCells,
rows,
withCollapse = false,
Expand All @@ -133,6 +135,22 @@ const Table = ({
{title}
</Typography>
)}
{subtitle && (
<Typography
color="primary"
variant="h6"
component="h6"
sx={{
paddingLeft: 2,
display: "flex",
justifyContent: "space-between",
fontSize: "18px",
fontWeight: 400,
}}
>
{subtitle}
</Typography>
)}
<MUITable>
{headerCells && (
<TableHead>
Expand Down
3 changes: 2 additions & 1 deletion app/spa/src/locales/coca/teamMembers.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
"demands": "Demands",
"effortValue": "Effort Value",
"untilDate": "End Date",
"fromDate": "Start Date"
"fromDate": "Start Date",
"effortsValueSum": "Total Effort:"
},
"teams": {
"title": "Teams"
Expand Down
3 changes: 2 additions & 1 deletion app/spa/src/locales/en/teamMembers.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
"demands": "Demands",
"effortValue": "Effort Value",
"untilDate": "End Date",
"fromDate": "Start Date"
"fromDate": "Start Date",
"effortsValueSum": "Total Effort:"
},
"teams": {
"title": "Teams"
Expand Down
3 changes: 2 additions & 1 deletion app/spa/src/locales/pt/teamMembers.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
"demands": "Demandas",
"effortValue": "Valor do esforço",
"untilDate": "Data final",
"fromDate": "Data inicial"
"fromDate": "Data inicial",
"effortsValueSum": "Total dos esforços:"
},
"teams": {
"title": "Times"
Expand Down
1 change: 1 addition & 0 deletions app/spa/src/modules/teamMember/teamMember.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ export type TeamMember = {
demandEffortsList?: {
demandEfforts?: DemandEffort[]
demandEffortsCount?: number
effortsValueSum?: number
}
}
1 change: 1 addition & 0 deletions app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const TEAM_MEMBER_QUERY = gql`
membershipEffortPercentage
}
demandEffortsCount
effortsValueSum
}
}
}
Expand Down

0 comments on commit c2c8cc8

Please sign in to comment.