Skip to content

Commit 7fe227e

Browse files
authored
Merge pull request #2804 from objectcomputing/feature-2802/pageable-pulse-responses
Moved the pulse responses up to the pie chart card, made them…
2 parents 244fc81 + a0b3aa5 commit 7fe227e

File tree

1 file changed

+50
-61
lines changed

1 file changed

+50
-61
lines changed

web-ui/src/pages/PulseReportPage.jsx

Lines changed: 50 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import {
2222
SentimentSatisfied,
2323
SentimentVerySatisfied,
2424
} from '@mui/icons-material';
25+
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
26+
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
2527
import {
2628
Avatar,
2729
Card,
@@ -33,7 +35,8 @@ import {
3335
MenuItem,
3436
Modal,
3537
TextField,
36-
Typography
38+
Typography,
39+
Link,
3740
} from '@mui/material';
3841
import ToggleButton from '@mui/material/ToggleButton';
3942
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
@@ -79,6 +82,8 @@ const ScoreOptionLabel = {
7982
'Combined': 'Both',
8083
};
8184

85+
const pulsesPerPage = 15;
86+
8287
/*
8388
// Returns a random, integer score between 1 and 5.
8489
// We may want to uncomment this later for testing.
@@ -117,6 +122,7 @@ const PulseReportPage = () => {
117122
const [expanded, setExpanded] = useState(false);
118123
const [scoreChartData, setScoreChartData] = useState([]);
119124
const [pulses, setPulses] = useState([]);
125+
const [pulsesPageNumber, setPulsesPageNumber] = useState(0);
120126
const [scope, setScope] = useState('Individual');
121127
const [scoreType, setScoreType] = useState(ScoreOption.COMBINED);
122128
const [selectedPulse, setSelectedPulse] = useState(null);
@@ -329,6 +335,7 @@ const PulseReportPage = () => {
329335
return compare;
330336
});
331337
setPulses(pulses);
338+
setPulsesPageNumber(0);
332339
};
333340

334341
useEffect(() => {
@@ -389,63 +396,6 @@ const PulseReportPage = () => {
389396
</Card>
390397
);
391398

392-
const scoreDistributionChart = () => (
393-
<Card>
394-
<CardHeader
395-
title="Distribution of pulse scores for selected team members"
396-
titleTypographyProps={{ variant: 'h5', component: 'h2' }}
397-
/>
398-
<CardContent>
399-
<BarChart
400-
width={500}
401-
height={300}
402-
data={barChartData}
403-
margin={{
404-
top: 5,
405-
right: 30,
406-
left: 20,
407-
bottom: 5
408-
}}
409-
>
410-
<CartesianGrid strokeDasharray="3 3" />
411-
<XAxis dataKey="score" />
412-
<YAxis />
413-
<Tooltip />
414-
<Legend />
415-
{(scoreType == ScoreOption.COMBINED || scoreType == ScoreOption.INTERNAL) &&
416-
<Bar
417-
dataKey="internal"
418-
fill={ociDarkBlue}
419-
name={ScoreOptionLabel[ScoreOption.INTERNAL]}
420-
/>
421-
}
422-
{(scoreType == ScoreOption.COMBINED || scoreType == ScoreOption.EXTERNAL) &&
423-
<Bar
424-
dataKey="external"
425-
fill={ociOrange}
426-
name={ScoreOptionLabel[ScoreOption.EXTERNAL]}
427-
/>
428-
}
429-
</BarChart>
430-
<ExpandMore
431-
expand={expanded}
432-
onClick={() => setExpanded(!expanded)}
433-
aria-expanded={expanded}
434-
aria-label={expanded ? 'show less' : 'show more'}
435-
size="large"
436-
/>
437-
<Collapse
438-
className="bottom-row"
439-
in={expanded}
440-
timeout="auto"
441-
unmountOnExit
442-
>
443-
{responseSummary()}
444-
</Collapse>
445-
</CardContent>
446-
</Card>
447-
);
448-
449399
const handleCommentClick = pulse => {
450400
setSelectedPulse(pulse);
451401
setShowComments(true);
@@ -725,16 +675,36 @@ const PulseReportPage = () => {
725675
</div>
726676
}
727677
</div>
678+
<ExpandMore
679+
expand={expanded}
680+
onClick={() => setExpanded(!expanded)}
681+
aria-expanded={expanded}
682+
aria-label={expanded ? 'show less' : 'show more'}
683+
size="large"
684+
/>
685+
<Collapse
686+
className="bottom-row"
687+
in={expanded}
688+
timeout="auto"
689+
unmountOnExit
690+
>
691+
{responseSummary()}
692+
</Collapse>
728693
</CardContent>
729694
</Card>
730695
</>
731696
);
732697

733698
const responseSummary = () => {
734-
let filteredPulses = pulses;
699+
const leftDisabled = (pulsesPageNumber <= 0);
700+
const rightDisabled = (((pulsesPageNumber + 1) * pulsesPerPage) >= pulses.length);
701+
const start = pulsesPageNumber * pulsesPerPage;
702+
const pulsesSlice = pulses.slice(start, start + pulsesPerPage);
703+
704+
let filteredPulses = pulsesSlice;
735705
const teamMemberIds = teamMembers.map(member => member.id);
736706
if (teamMemberIds.length) {
737-
filteredPulses = pulses.filter(pulse =>
707+
filteredPulses = pulsesSlice.filter(pulse =>
738708
teamMemberIds.includes(pulse.teamMemberId)
739709
);
740710
}
@@ -773,6 +743,26 @@ const PulseReportPage = () => {
773743
</div>
774744
);
775745
})}
746+
<Link to="#"
747+
style={leftDisabled ? { cursor: 'auto' } : { cursor: 'pointer' }}
748+
onClick={(event) => {
749+
event.preventDefault();
750+
if (!leftDisabled) {
751+
setPulsesPageNumber(pulsesPageNumber - 1);
752+
}
753+
}}>
754+
<ArrowBackIcon/>
755+
</Link>
756+
<Link to="#"
757+
style={rightDisabled ? { cursor: 'auto' } : { cursor: 'pointer' }}
758+
onClick={(event) => {
759+
event.preventDefault();
760+
if (!rightDisabled) {
761+
setPulsesPageNumber(pulsesPageNumber + 1);
762+
}
763+
}}>
764+
<ArrowForwardIcon/>
765+
</Link>
776766
</>
777767
);
778768
};
@@ -840,7 +830,6 @@ const PulseReportPage = () => {
840830
/>
841831
{pulseScoresChart()}
842832
{averageScores()}
843-
{scoreDistributionChart()}
844833
<Modal open={showComments} onClose={() => setShowComments(false)}>
845834
<Card className="feedback-request-enable-edits-modal">
846835
<CardHeader

0 commit comments

Comments
 (0)