Skip to content

Commit

Permalink
#1027 | Handle voided dashboard related entities
Browse files Browse the repository at this point in the history
  • Loading branch information
1t5j0y committed Feb 14, 2024
1 parent 4401474 commit ca8b0ed
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Input, IconButton, Typography, Tooltip, MenuItem } from "@material-ui/core";
import DeleteIcon from "@material-ui/icons/Delete";
import { isEmpty, map, size } from "lodash";
import { isEmpty, filter, map, size } from "lodash";
import Grid from "@material-ui/core/Grid";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import ExpandLessIcon from "@material-ui/icons/ExpandLess";
Expand Down Expand Up @@ -138,13 +138,24 @@ const CreateEditDashboardSections = props => {
toolTipKey={"APP_DESIGNER_DASHBOARD_SECTION_ADD_CARDS"}
/>
<SelectCardsView
dashboardCards={section.cards}
dashboardCards={filter(section.cards, card => card.voided === false)}
dispatch={props.dispatch}
addCards={cards => addCards(cards, section)}
/>
<CreateEditDashboardSectionCards
section={section}
cards={section.cards}
cards={filter(
section.cards,
card =>
card.voided === false &&
filter(
section.dashboardSectionCardMappings,
sectionCardMapping => sectionCardMapping.voided === false
)
.map(sectionCardMapping => sectionCardMapping.reportCardUUID)
.includes(card.uuid)
)}
// cards={section.cards}
dispatch={props.dispatch}
changeDisplayOrder={cards =>
props.dispatch({ type: "changeDisplayOrder", payload: { cards, section } })
Expand Down Expand Up @@ -185,7 +196,15 @@ const CreateEditDashboardSections = props => {
</Typography>
</Grid>
<Grid item sm={3}>
<Typography className={classes.questionCount}>{size(section.cards)} cards</Typography>
<Typography className={classes.questionCount}>
{size(
filter(
section.dashboardSectionCardMappings,
sectionCardMapping => sectionCardMapping.voided === false
)
)}{" "}
cards
</Typography>
</Grid>
<Grid item sm={2}>
<IconButton aria-label="delete" onClick={() => handleDelete(section)}>
Expand Down
22 changes: 19 additions & 3 deletions src/formDesigner/components/Dashboard/ShowDashboardSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Tooltip,
ExpansionPanelDetails
} from "@material-ui/core";
import { isEmpty, map, orderBy, size } from "lodash";
import { isEmpty, filter, map, orderBy, size } from "lodash";
import Grid from "@material-ui/core/Grid";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import ExpandLessIcon from "@material-ui/icons/ExpandLess";
Expand Down Expand Up @@ -134,7 +134,13 @@ const ShowDashboardSections = ({ sections, history }) => {
</Grid>
<Grid item sm={3}>
<Typography className={classes.questionCount}>
{size(section.cards)} cards
{size(
filter(
section.dashboardSectionCardMappings,
sectionCardMapping => sectionCardMapping.voided === false
)
)}{" "}
cards
</Typography>
</Grid>
</Grid>
Expand All @@ -151,7 +157,17 @@ const ShowDashboardSections = ({ sections, history }) => {
<Grid item xs={12}>
<ShowDashboardSectionCards
section={section}
cards={section.cards}
cards={filter(
section.cards,
card =>
card.voided === false &&
filter(
section.dashboardSectionCardMappings,
sectionCardMapping => sectionCardMapping.voided === false
)
.map(sectionCardMapping => sectionCardMapping.reportCardUUID)
.includes(card.uuid)
)}
history={history}
/>
</Grid>
Expand Down

0 comments on commit ca8b0ed

Please sign in to comment.