@@ -25,6 +25,7 @@ export interface WordFormData {
2525 translation : string ;
2626 romanization : string ;
2727 sentence : string ;
28+ notes : string ;
2829 status : number ;
2930 tags : string [ ] ;
3031}
@@ -36,6 +37,7 @@ export interface ValidationErrors {
3637 translation : string | null ;
3738 romanization : string | null ;
3839 sentence : string | null ;
40+ notes : string | null ;
3941 general : string | null ;
4042}
4143
@@ -103,6 +105,7 @@ function createEmptyFormData(): WordFormData {
103105 translation : '' ,
104106 romanization : '' ,
105107 sentence : '' ,
108+ notes : '' ,
106109 status : 1 ,
107110 tags : [ ]
108111 } ;
@@ -116,6 +119,7 @@ function createEmptyErrors(): ValidationErrors {
116119 translation : null ,
117120 romanization : null ,
118121 sentence : null ,
122+ notes : null ,
119123 general : null
120124 } ;
121125}
@@ -180,6 +184,7 @@ function createWordFormStore(): WordFormStoreState {
180184 this . formData . translation !== this . originalData . translation ||
181185 this . formData . romanization !== this . originalData . romanization ||
182186 this . formData . sentence !== this . originalData . sentence ||
187+ this . formData . notes !== this . originalData . notes ||
183188 this . formData . status !== this . originalData . status ||
184189 ! arraysEqual ( this . formData . tags , this . originalData . tags )
185190 ) ;
@@ -193,6 +198,7 @@ function createWordFormStore(): WordFormStoreState {
193198 this . errors . translation === null &&
194199 this . errors . romanization === null &&
195200 this . errors . sentence === null &&
201+ this . errors . notes === null &&
196202 this . errors . general === null
197203 ) ;
198204 } ,
@@ -247,6 +253,7 @@ function createWordFormStore(): WordFormStoreState {
247253 translation : data . term . translation === '*' ? '' : data . term . translation ,
248254 romanization : data . term . romanization ,
249255 sentence : data . term . sentence ,
256+ notes : data . term . notes || '' ,
250257 status : data . term . status ,
251258 tags : [ ...data . term . tags ]
252259 } ;
@@ -292,6 +299,7 @@ function createWordFormStore(): WordFormStoreState {
292299 this . validateField ( 'translation' ) ;
293300 this . validateField ( 'romanization' ) ;
294301 this . validateField ( 'sentence' ) ;
302+ this . validateField ( 'notes' ) ;
295303 return this . isValid ;
296304 } ,
297305
@@ -323,6 +331,14 @@ function createWordFormStore(): WordFormStoreState {
323331 this . errors . sentence = null ;
324332 }
325333 break ;
334+
335+ case 'notes' :
336+ if ( this . formData . notes . length > 1000 ) {
337+ this . errors . notes = 'Notes must be 1000 characters or less' ;
338+ } else {
339+ this . errors . notes = null ;
340+ }
341+ break ;
326342 }
327343 } ,
328344
@@ -349,6 +365,7 @@ function createWordFormStore(): WordFormStoreState {
349365 translation : this . formData . translation ,
350366 romanization : this . formData . romanization ,
351367 sentence : this . formData . sentence ,
368+ notes : this . formData . notes ,
352369 status : this . formData . status ,
353370 tags : this . formData . tags
354371 } ;
@@ -365,6 +382,7 @@ function createWordFormStore(): WordFormStoreState {
365382 translation : this . formData . translation ,
366383 romanization : this . formData . romanization ,
367384 sentence : this . formData . sentence ,
385+ notes : this . formData . notes ,
368386 status : this . formData . status ,
369387 tags : this . formData . tags
370388 } ;
0 commit comments