1
- import { isText } from "@ /utility" ;
2
- import { UnknownSubject } from "@ " ;
1
+ import { isText } from ".. /utility" ;
2
+ import { UnknownSubject } from "../ " ;
3
3
4
4
export class Entry {
5
5
public readonly date : Date ;
6
+ public readonly subjectShorts = new Map < string , string > ( [
7
+ [ "D" , "Deutsch" ] ,
8
+ [ "E" , "Englisch" ] ,
9
+ [ "WI" , "Wirtschaft" ] ,
10
+ [ "GGK" , "Geschichte und Gemeinschaftskunde" ] ,
11
+ [ "CH" , "Chemie" ] ,
12
+ [ "S" , "Sport" ] ,
13
+ [ "M" , "Mathe" ] ,
14
+ [ "BK" , "Bildende Kunst" ] ,
15
+ [ "BK1" , "Bildende Kunst" ] ,
16
+ [ "BK2" , "Bildende Kunst" ] ,
17
+ [ "GS" , "Global Studies" ] ,
18
+ [ "PH" , "Physik" ] ,
19
+ [ "IT" , "Informatik" ] ,
20
+ [ "INF" , "Informationstechnik" ] ,
21
+ [ "ITÜS" , "IT Softwareentwicklung" ] ,
22
+ [ "ITÜH" , "IT Hardware" ] ,
23
+ [ "EVR" , "Religion" ] ,
24
+ [ "ETH" , "Ethik" ] ,
25
+ [ "SP" , "Zweitsprache" ] ,
26
+ [ "IFÖM" , "Mathe Förderunterricht" ] ,
27
+ [ "IFÖE" , "Englisch Förderunterricht" ] ,
28
+ [ "IFÖD" , "Deutsch Förderunterricht" ] ,
29
+ ] ) ;
6
30
7
31
constructor (
8
32
date : Date | string ,
@@ -97,6 +121,22 @@ export class Entry {
97
121
return this . longSubjectName ( this . oldSubject ) ;
98
122
}
99
123
124
+ /**
125
+ * Update the subject shorts with a map
126
+ * @param subjectShorts
127
+ *
128
+ * @example
129
+ * ```js
130
+ * entry.updateSubjectShorts(new Map([["D", "Deutsch"]]))
131
+ * ```
132
+ */
133
+ public registerSubjectShorts ( subjectShorts : Map < string , string > ) {
134
+ // Update the subjectShorts map with the parameter map
135
+ for ( const [ k , v ] of subjectShorts ) {
136
+ this . subjectShorts . set ( k , v ) ;
137
+ }
138
+ }
139
+
100
140
private longSubjectName ( subjectShort : string ) : string {
101
141
const validReg = / [ a - b A - b ] / ;
102
142
if ( ! validReg . test ( subjectShort ) ) {
@@ -106,32 +146,7 @@ export class Entry {
106
146
const replaceReg = / ( [ 0 - 9 ] | \/ ) .* $ / ;
107
147
subjectShort = subjectShort . replace ( replaceReg , "" ) ;
108
148
109
- const subjectShorts = {
110
- D : "Deutsch" ,
111
- E : "Englisch" ,
112
- WI : "Wirtschaft" ,
113
- GGK : "Geschichte und Gemeinschaftskunde" ,
114
- CH : "Chemie" ,
115
- S : "Sport" ,
116
- M : "Mathe" ,
117
- BK : "Bildende Kunst" ,
118
- BK1 : "Bildende Kunst" ,
119
- BK2 : "Bildende Kunst" ,
120
- GS : "Global Studies" ,
121
- PH : "Physik" ,
122
- IT : "Informatik" ,
123
- INF : "Informationstechnik" ,
124
- ITÜS : "IT Softwareentwicklung" ,
125
- ITÜH : "IT Hardware" ,
126
- EVR : "Religion" ,
127
- ETH : "Ethik" ,
128
- SP : "Zweitsprache" ,
129
- IFÖM : "Mathe Förderunterricht" ,
130
- IFÖE : "Englisch Förderunterricht" ,
131
- IFÖD : "Deutsch Förderunterricht" ,
132
- } ;
133
-
134
- const subjectLong = subjectShorts [ subjectShort ] ;
149
+ const subjectLong = this . subjectShorts . get ( subjectShort ) ;
135
150
136
151
if ( subjectLong === undefined ) {
137
152
throw new UnknownSubject ( subjectShort ) ;
0 commit comments