11class GradeListPane extends Pane {
22 id = 'cl' ;
3- icon = ' ' ;
3+ icon = ' ' ;
44
55 #div1;
66 #div2;
@@ -22,8 +22,8 @@ class GradeListPane extends Pane {
2222 } ,
2323 {
2424 id : 'result_desc' , label : i18n ( 'cl.sortByResultDesc' ) , comparator : ( a , b ) => {
25- const resultA = Number ( a . CijferStr ) ;
26- const resultB = Number ( b . CijferStr ) ;
25+ const resultA = Number ( a . CijferStr ?. replace ( ',' , '.' ) ) ;
26+ const resultB = Number ( b . CijferStr ?. replace ( ',' , '.' ) ) ;
2727 if ( isNaN ( resultA ) && isNaN ( resultB ) ) return a . CijferStr . localeCompare ( b . CijferStr ) ;
2828 if ( isNaN ( resultA ) ) return 1 ;
2929 if ( isNaN ( resultB ) ) return - 1 ;
@@ -32,8 +32,8 @@ class GradeListPane extends Pane {
3232 } ,
3333 {
3434 id : 'result_asc' , label : i18n ( 'cl.sortByResultAsc' ) , comparator : ( a , b ) => {
35- const resultA = Number ( a . CijferStr ) ;
36- const resultB = Number ( b . CijferStr ) ;
35+ const resultA = Number ( a . CijferStr ?. replace ( ',' , '.' ) ) ;
36+ const resultB = Number ( b . CijferStr ?. replace ( ',' , '.' ) ) ;
3737 if ( isNaN ( resultA ) && isNaN ( resultB ) ) return a . CijferStr . localeCompare ( b . CijferStr ) ;
3838 if ( isNaN ( resultA ) ) return 1 ;
3939 if ( isNaN ( resultB ) ) return - 1 ;
@@ -42,28 +42,16 @@ class GradeListPane extends Pane {
4242 } ,
4343 ] ;
4444 sortingOption = this . sortingOptions [ 0 ] ;
45+ sortingShown = false ;
4546
4647 constructor ( parentElement ) {
4748 super ( parentElement ) ;
4849
4950 this . element . id = 'st-grade-recents-pane' ;
50- this . #div1 = this . element . createChildElement ( 'div' , { class : 'st-div' } ) ;
51- this . #div1. createChildElement ( 'h3' , { class : 'st-section-heading' , innerText : i18n ( 'cl.title' ) } ) ;
52- const select = this . #div1. createChildElement ( 'select' , { class : 'st-select' } ) ;
53- for ( const option of this . sortingOptions ) {
54- const optionElement = select . createChildElement ( 'option' , { value : option . id , innerText : option . label } ) ;
55- if ( option === this . sortingOption ) {
56- optionElement . selected = true ;
57- }
58- }
59- select . addEventListener ( 'change' , ( ) => {
60- const selectedOption = this . sortingOptions . find ( option => option . id === select . value ) ;
61- if ( selectedOption && selectedOption !== this . sortingOption ) {
62- this . sortingOption = selectedOption ;
63- this . redraw ( ) ;
64- }
65- } ) ;
51+ this . element . classList . remove ( 'st-hidden' ) ;
6652
53+ this . #div1 = this . element . createChildElement ( 'div' , { class : 'st-div' , style : 'margin-bottom: 16px' } ) ;
54+ this . #div1. createChildElement ( 'h3' , { class : 'st-section-heading' , innerText : i18n ( 'cl.title' ) } ) ;
6755 this . element . createChildElement ( 'hr' ) ;
6856 this . #div2 = this . element . createChildElement ( 'div' , { class : 'st-div' } ) ;
6957 }
@@ -73,11 +61,40 @@ class GradeListPane extends Pane {
7361 super . show ( ) ;
7462 }
7563
76- redraw ( ) {
64+ async redraw ( ) {
7765 this . progressBar . dataset . visible = 'true' ;
7866
67+ this . #div1. innerHTML = '' ;
7968 this . #div2. innerHTML = '' ;
8069
70+ if ( this . sortingShown ) {
71+ this . #div1. createChildElement ( 'h3' , { class : 'st-section-heading' , innerText : i18n ( 'cl.title' ) } ) ;
72+ const select = this . #div1. createChildElement ( 'select' , { class : 'st-select' , style : 'width: 100%' } ) ;
73+ for ( const option of this . sortingOptions ) {
74+ const optionElement = select . createChildElement ( 'option' , { value : option . id , innerText : option . label } ) ;
75+ if ( option === this . sortingOption ) {
76+ optionElement . selected = true ;
77+ }
78+ }
79+ select . addEventListener ( 'change' , ( ) => {
80+ const selectedOption = this . sortingOptions . find ( option => option . id === select . value ) ;
81+ if ( selectedOption && selectedOption !== this . sortingOption ) {
82+ this . sortingOption = selectedOption ;
83+ this . redraw ( ) ;
84+ }
85+ } ) ;
86+ } else {
87+ this . #div1. createChildElement ( 'h3' , { class : 'st-section-heading' , innerText : i18n ( 'cl.recents' ) } ) ;
88+ this . #div1. createChildElement ( 'button' , { class : 'st-button icon' , 'data-icon' : '' , title : i18n ( 'cl.sort' ) , style : { position : 'absolute' , top : '12px' , right : '12px' } } )
89+ . addEventListener ( 'click' , ( ) => {
90+ this . sortingShown = true ;
91+ this . redraw ( ) ;
92+ } ) ;
93+ }
94+ this . element . querySelector ( 'hr' ) . style . display = this . sortingShown ? 'block' : 'none' ;
95+
96+ const recentGrades = await magisterApi . gradesRecent ( currentGradeTable . grades . length ) ;
97+
8198 const grades = currentGradeTable . grades . filter ( grade => grade . CijferStr ?. length > 0 && grade . CijferKolom ?. KolomSoort !== 2 ) ;
8299 grades . sort ( this . sortingOption . comparator ) ;
83100
@@ -93,11 +110,28 @@ class GradeListPane extends Pane {
93110
94111 const list = this . #div2. createChildElement ( 'ul' , { class : 'st-grade-list' } ) ;
95112 for ( const grade of grades ) {
96- const listItem = list . createChildElement ( 'li' , { class : 'st-grade-list-item' } ) ;
97- listItem . createChildElement ( 'span' , { class : 'st-grade-list-item-result' , innerText : grade . CijferStr } ) ;
98- listItem . createChildElement ( 'span' , { class : 'st-grade-list-item-course' , innerText : grade . VakNaam } ) ;
99- listItem . createChildElement ( 'span' , { class : 'st-grade-list-item-date' , innerText : new Date ( grade . DatumIngevoerd ) . toLocaleDateString ( locale ) } ) ;
100- listItem . createChildElement ( 'span' , { class : 'st-grade-list-item-description' , innerText : grade . CijferKolom . WerkInformatieOmschrijving || grade . CijferKolom . KolomOmschrijving || '-' } ) ;
113+ const recentGrade = recentGrades . find ( rg => rg . kolomId === grade . CijferKolom . Id ) ;
114+ if ( ! recentGrade && ! this . sortingShown ) {
115+ this . sortingShown = true ;
116+ this . redraw ( ) ;
117+ return ;
118+ }
119+ const gradeItem = list . createChildElement ( 'li' , { class : 'st-grade-item' } ) ;
120+
121+ const col1 = gradeItem . createChildElement ( 'div' )
122+ col1 . createChildElement ( 'div' , { innerText : grade . Vak ?. Omschrijving || '-' } )
123+ if ( grade . CijferKolom . WerkInformatieOmschrijving || grade . CijferKolom . KolomOmschrijving || recentGrade ?. omschrijving ) col1 . createChildElement ( 'div' , { innerText : grade . CijferKolom . WerkInformatieOmschrijving || grade . CijferKolom . KolomOmschrijving || recentGrade ?. omschrijving || '-' } )
124+ col1 . createChildElement ( 'div' , { innerText : new Date ( grade . DatumIngevoerd ) . toLocaleDateString ( locale ) } ) ;
125+
126+ const col2 = gradeItem . createChildElement ( 'div' )
127+ col2 . createChildElement ( 'div' , { innerText : grade . CijferStr , classList : grade . IsVoldoende === false ? [ 'st-insufficient' ] : [ ] } )
128+ if ( grade . CijferKolom ?. Weging ?? recentGrade ) col2 . createChildElement ( 'div' , { innerText : ( grade . CijferKolom ?. Weging ?? recentGrade ?. weegfactor ?? '?' ) + 'x' } ) ;
129+
130+ gradeItem . style . cursor = 'pointer' ;
131+ gradeItem . addEventListener ( 'click' , ( ) => {
132+ const dialog = new GradeDetailDialog ( grade , currentGradeTable . identifier . year ) ;
133+ dialog . show ( ) ;
134+ } ) ;
101135 }
102136
103137 this . progressBar . dataset . visible = 'false' ;
0 commit comments