Skip to content

Commit 2dc1a4f

Browse files
committed
3.15.0-beta.9
1 parent cf8a5ea commit 2dc1a4f

8 files changed

Lines changed: 135 additions & 66 deletions

File tree

manifest-firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "__MSG_appName__",
44
"description": "__MSG_appDesc__",
5-
"version": "3.15.0.8",
5+
"version": "3.15.0.9",
66
"default_locale": "nl",
77
"icons": {
88
"16": "icons/icon@16px.png",

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "__MSG_appName__",
44
"description": "__MSG_appDesc__",
5-
"version": "3.15.0.8",
5+
"version": "3.15.0.9",
66
"default_locale": "nl",
77
"icons": {
88
"16": "icons/icon@16px.png",

src/scripts/api.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ class MagisterApi {
111111
return new MagisterApiRequestKwtRegistration(id).delete();
112112
}
113113

114-
gradesRecent() {
115-
return new MagisterApiRequestGradesRecent().get();
114+
gradesRecent(size = 25) {
115+
return new MagisterApiRequestGradesRecent(size).get();
116116
}
117117

118118
gradesForYear(year) {
@@ -408,10 +408,10 @@ class MagisterApiRequestKwtRegistration extends MagisterApiRequest {
408408
}
409409

410410
class MagisterApiRequestGradesRecent extends MagisterApiRequest {
411-
constructor() {
411+
constructor(size = 25) {
412412
super();
413413
this.identifier = 'gradesRecent';
414-
this.path = `api/personen/$USERID/cijfers/laatste?top=20&skip=0`;
414+
this.path = `api/personen/$USERID/cijfers/laatste?top=${size}&skip=0`;
415415
}
416416
outputFormat = (res) => res.items;
417417
sample = [{ omschrijving: "Voorbeeld", ingevoerdOp: new Date(now.getTime() - 172800000), vak: { code: "netl", omschrijving: "Nederlandse taal" }, waarde: "6,9", weegfactor: 0, isVoldoende: true }, { omschrijving: "Baguette", ingevoerdOp: new Date(now.getTime() - 691200000), vak: { code: "fatl", omschrijving: "Franse taal" }, waarde: "U", weegfactor: 0, isVoldoende: true }, { omschrijving: "Grade mockery", ingevoerdOp: new Date(now.getTime() - 6891200000), vak: { code: "entl", omschrijving: "Engelse taal" }, waarde: "5,4", weegfactor: 0 }];

src/scripts/grades/grades.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function gradeOverview() {
3030

3131
const gradesContainer = contentContainer.createChildElement('div', { id: 'st-grades-container' });
3232

33-
const panesContainer = contentContainer.createChildElement('div', { class: 'st-panes-container st-hidden' });
33+
const panesContainer = contentContainer.createChildElement('div', { class: 'st-panes-container' });
3434

3535
listPane = new GradeListPane(panesContainer);
3636
backupPane = new GradeBackupPane(panesContainer);
@@ -56,8 +56,9 @@ async function gradeOverview() {
5656
const input = label.createChildElement('input', {
5757
id: `st-grade-${config.instance.id}-input`,
5858
class: 'st-checkbox-input',
59-
type: 'checkbox',
59+
type: 'checkbox'
6060
});
61+
if (config.instance.isVisible) input.checked = true;
6162
config.input = input;
6263
input.addEventListener('change', () => {
6364
config.instance.toggle(input.checked);
@@ -250,7 +251,7 @@ class GradeTable {
250251
id: grade.CijferId,
251252
innerText: grade.CijferStr,
252253
classList: [
253-
['insufficient', grade.IsVoldoende === false],
254+
['st-insufficient', grade.IsVoldoende === false],
254255
['inh', grade.Inhalen],
255256
['vr', grade.Vrijstelling],
256257
['not-counted', grade.TeltMee === false],
@@ -346,12 +347,16 @@ class GradeDetailDialog extends Dialog {
346347
const column1 = createElement('div', this.body, { class: 'st-grade-detail-dialog-column' });
347348
createElement('h3', column1, { class: 'st-section-heading', innerText: this.grade.CijferKolom.KolomOmschrijving || i18n('details') });
348349

349-
const metricsStrip = createElement('div', column1, { style: 'display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;' });
350+
const gradeItem = column1.createChildElement('div', { class: 'st-grade-item', style: 'font-size: 12.5px;' });
350351

351-
if (this.grade.CijferStr.length < 5)
352-
createElement('div', metricsStrip, { class: 'st-metric', innerText: this.grade.CijferStr || '-', dataset: { description: i18n('assessment') }, style: syncedStorage['insufficient'] !== 'off' && this.grade.IsVoldoende === false ? 'color: var(--st-accent-warn)' : '' });
353-
if (this.grade.CijferKolom?.Weging >= 0)
354-
createElement('div', metricsStrip, { class: 'st-metric', innerText: `${this.grade.CijferKolom.Weging}x`, dataset: { description: i18n('weight') } });
352+
const col1 = gradeItem.createChildElement('div')
353+
col1.createChildElement('div', { innerText: this.grade.Vak?.Omschrijving || '-' })
354+
col1.createChildElement('div', { innerText: this.grade.CijferKolom.WerkInformatieOmschrijving || this.grade.CijferKolom.KolomOmschrijving || '-' })
355+
col1.createChildElement('div', { innerText: new Date(this.grade.DatumIngevoerd).toLocaleDateString(locale) });
356+
357+
const col2 = gradeItem.createChildElement('div')
358+
col2.createChildElement('div', { innerText: this.grade.CijferStr, classList: this.grade.IsVoldoende === false ? ['st-insufficient'] : [] })
359+
col2.createChildElement('div', { innerText: (this.grade.CijferKolom?.Weging ?? '?') + 'x' });
355360

356361
let table1 = createElement('table', column1, { class: 'st' });
357362

src/scripts/grades/list.js

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class 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';

src/scripts/style.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ table.table-grid-layout>tbody>tr.selected {
19791979
switch (syncedStorage['insufficient']) {
19801980
case 'underline':
19811981
createStyle(`
1982-
.st-grade-table tr:nth-child(n+3) td:not(:first-child).insufficient {
1982+
.st-insufficient {
19831983
font-weight: bold;
19841984
text-decoration: underline var(--st-accent-warn) 2px;
19851985
text-underline-offset: 2px;
@@ -1988,7 +1988,7 @@ table.table-grid-layout>tbody>tr.selected {
19881988

19891989
case 'background':
19901990
createStyle(`
1991-
.st-grade-table tr:nth-child(n+3) td:not(:first-child).insufficient {
1991+
.st-insufficient {
19921992
font-weight: bold;
19931993
background-color: var(--st-highlight-warn);
19941994
@@ -2004,7 +2004,7 @@ table.table-grid-layout>tbody>tr.selected {
20042004

20052005
case 'textcolor':
20062006
createStyle(`
2007-
.st-grade-table tr:nth-child(n+3) td:not(:first-child).insufficient {
2007+
.st-insufficient {
20082008
font-weight: bold;
20092009
color: var(--st-accent-warn);
20102010
}`, 'study-tools-insufficient')

src/strings/nl.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
"title": "Lijstweergave",
210210
"recents": "Laatste cijfers",
211211
"emptyDesc": "Er zijn geen cijfers in deze cijferlijst.",
212-
"sortBy": "Sorteren op",
212+
"sort": "Sorteren",
213213
"sortByDateDesc": "Datum (nieuwste eerst)",
214214
"sortByDateAsc": "Datum (oudste eerst)",
215215
"sortByResultDesc": "Resultaat (hoogste eerst)",

src/styles/grades.css

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@
300300
#st-grades-toolbar {
301301
display: flex;
302302
justify-content: space-between;
303-
background-color: var(--st-background-secondary);
303+
background-color: var(--st-background-tertiary);
304304
border-bottom: var(--st-border);
305305
border-top-left-radius: var(--st-border-radius);
306306
border-top-right-radius: var(--st-border-radius);
@@ -324,7 +324,7 @@
324324
height: 32px;
325325
padding: 0;
326326
margin: 0;
327-
background-color: var(--st-background-tertiary);
327+
background-color: var(--st-background-secondary);
328328
border: var(--st-border);
329329
border-radius: calc(var(--st-border-radius) * 0.75);
330330
font-weight: 600;
@@ -360,6 +360,54 @@
360360
border-bottom-right-radius: 0;
361361
}
362362

363+
.st-grade-item {
364+
display: grid;
365+
grid-template-columns: 1fr 2.8em;
366+
align-items: center;
367+
gap: 4px;
368+
padding: 6px 10px;
369+
margin-bottom: 6px;
370+
font-size: 11px;
371+
372+
font-family: var(--st-font-family-secondary);
373+
background-color: var(--st-background-secondary);
374+
border: var(--st-border);
375+
border-radius: var(--st-border-radius);
376+
377+
& * {
378+
text-overflow: ellipsis;
379+
overflow-x: hidden;
380+
white-space: nowrap;
381+
}
382+
383+
&>div:first-child {
384+
&>div {
385+
font-size: .9em;
386+
}
387+
388+
&>div:first-child {
389+
font-size: 1.25em;
390+
font-weight: 500;
391+
font-family: var(--st-font-family-primary);
392+
}
393+
}
394+
395+
&>div:last-child {
396+
display: flex;
397+
flex-direction: column;
398+
align-items: center;
399+
400+
&>div:first-child {
401+
font-size: 1.45em;
402+
font-weight: 500;
403+
font-family: var(--st-font-family-primary);
404+
padding: 4px;
405+
margin: -4px;
406+
margin-bottom: -2px;
407+
}
408+
}
409+
}
410+
363411
#st-grades-container {
364412
overflow: auto;
365413
}
@@ -427,19 +475,7 @@
427475
#st-grade-recents-pane {
428476
max-width: 300px;
429477

430-
.st-grade-list {
431-
432-
.st-grade-list-item {
433-
font-family: var(--st-font-family-secondary);
434-
435-
.st-grade-list-item-result {
436-
font-size: 16px;
437-
font-weight: 500;
438-
font-family: var(--st-font-family-primary);
439-
display: block;
440-
}
441-
}
442-
}
478+
.st-grade-list {}
443479
}
444480

445481
#st-grade-backup-pane {
@@ -541,12 +577,6 @@
541577
}
542578
}
543579

544-
/* TODO: use */
545-
#st-cs-central-tendencies[data-great=true] {
546-
background-image: linear-gradient(35deg, var(--st-accent-primary), var(--st-accent-primary-dark));
547-
color: var(--st-contrast-accent);
548-
}
549-
550580
#st-cs-suf-insuf {
551581
padding-bottom: 8px;
552582
display: grid;

0 commit comments

Comments
 (0)