@@ -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' ;
2527import {
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' ;
3841import ToggleButton from '@mui/material/ToggleButton' ;
3942import 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 ) ;
@@ -191,7 +197,9 @@ const PulseReportPage = () => {
191197 }
192198
193199 frequencies [ internalScore - 1 ] . internal ++ ;
194- frequencies [ externalScore - 1 ] . external ++ ;
200+ if ( externalScore != null ) {
201+ frequencies [ externalScore - 1 ] . external ++ ;
202+ }
195203
196204 let memberIdToUse ;
197205 if ( memberId ) {
@@ -250,7 +258,9 @@ const PulseReportPage = () => {
250258 ] ;
251259 for ( let day of scoreChartDataPoints ) {
252260 day . datapoints . forEach ( datapoint => {
253- externalPieCounts [ datapoint . externalScore - 1 ] . value ++ ;
261+ if ( datapoint . externalScore != null ) {
262+ externalPieCounts [ datapoint . externalScore - 1 ] . value ++ ;
263+ }
254264 } ) ;
255265 }
256266 // Filter out data with a zero value so that the pie chart does not attempt
@@ -329,6 +339,7 @@ const PulseReportPage = () => {
329339 return compare ;
330340 } ) ;
331341 setPulses ( pulses ) ;
342+ setPulsesPageNumber ( 0 ) ;
332343 } ;
333344
334345 useEffect ( ( ) => {
@@ -389,63 +400,6 @@ const PulseReportPage = () => {
389400 </ Card >
390401 ) ;
391402
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-
449403 const handleCommentClick = pulse => {
450404 setSelectedPulse ( pulse ) ;
451405 setShowComments ( true ) ;
@@ -725,16 +679,36 @@ const PulseReportPage = () => {
725679 </ div >
726680 }
727681 </ div >
682+ < ExpandMore
683+ expand = { expanded }
684+ onClick = { ( ) => setExpanded ( ! expanded ) }
685+ aria-expanded = { expanded }
686+ aria-label = { expanded ? 'show less' : 'show more' }
687+ size = "large"
688+ />
689+ < Collapse
690+ className = "bottom-row"
691+ in = { expanded }
692+ timeout = "auto"
693+ unmountOnExit
694+ >
695+ { responseSummary ( ) }
696+ </ Collapse >
728697 </ CardContent >
729698 </ Card >
730699 </ >
731700 ) ;
732701
733702 const responseSummary = ( ) => {
734- let filteredPulses = pulses ;
703+ const leftDisabled = ( pulsesPageNumber <= 0 ) ;
704+ const rightDisabled = ( ( ( pulsesPageNumber + 1 ) * pulsesPerPage ) >= pulses . length ) ;
705+ const start = pulsesPageNumber * pulsesPerPage ;
706+ const pulsesSlice = pulses . slice ( start , start + pulsesPerPage ) ;
707+
708+ let filteredPulses = pulsesSlice ;
735709 const teamMemberIds = teamMembers . map ( member => member . id ) ;
736710 if ( teamMemberIds . length ) {
737- filteredPulses = pulses . filter ( pulse =>
711+ filteredPulses = pulsesSlice . filter ( pulse =>
738712 teamMemberIds . includes ( pulse . teamMemberId )
739713 ) ;
740714 }
@@ -773,6 +747,26 @@ const PulseReportPage = () => {
773747 </ div >
774748 ) ;
775749 } ) }
750+ < Link to = "#"
751+ style = { leftDisabled ? { cursor : 'auto' } : { cursor : 'pointer' } }
752+ onClick = { ( event ) => {
753+ event . preventDefault ( ) ;
754+ if ( ! leftDisabled ) {
755+ setPulsesPageNumber ( pulsesPageNumber - 1 ) ;
756+ }
757+ } } >
758+ < ArrowBackIcon />
759+ </ Link >
760+ < Link to = "#"
761+ style = { rightDisabled ? { cursor : 'auto' } : { cursor : 'pointer' } }
762+ onClick = { ( event ) => {
763+ event . preventDefault ( ) ;
764+ if ( ! rightDisabled ) {
765+ setPulsesPageNumber ( pulsesPageNumber + 1 ) ;
766+ }
767+ } } >
768+ < ArrowForwardIcon />
769+ </ Link >
776770 </ >
777771 ) ;
778772 } ;
@@ -840,7 +834,6 @@ const PulseReportPage = () => {
840834 />
841835 { pulseScoresChart ( ) }
842836 { averageScores ( ) }
843- { scoreDistributionChart ( ) }
844837 < Modal open = { showComments } onClose = { ( ) => setShowComments ( false ) } >
845838 < Card className = "feedback-request-enable-edits-modal" >
846839 < CardHeader
0 commit comments