Skip to content

Commit b217883

Browse files
author
HugoFara
committed
fix(api): broken text reading, notes were not displaying and romanization was displaying.
1 parent b5de604 commit b217883

File tree

7 files changed

+44
-4
lines changed

7 files changed

+44
-4
lines changed

src/backend/Core/Repository/LanguageRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function mapToEntity(array $row): Language
8181
(bool) ($row['LgSplitEachChar'] ?? false),
8282
(bool) ($row['LgRightToLeft'] ?? false),
8383
(string) ($row['LgTTSVoiceAPI'] ?? ''),
84-
(bool) ($row['LgShowRomanization'] ?? true)
84+
(bool) ($row['LgShowRomanization'] ?? false)
8585
);
8686
}
8787

src/backend/Services/LanguageService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ private function normalizeLanguageData(array $data): array
943943
'LgSplitEachChar' => !empty($data['splitEachChar']),
944944
'LgRightToLeft' => !empty($data['rightToLeft']),
945945
'LgTTSVoiceAPI' => $data['ttsVoiceApi'] ?? '',
946-
'LgShowRomanization' => $data['showRomanization'] ?? true,
946+
'LgShowRomanization' => $data['showRomanization'] ?? false,
947947
];
948948
}
949949

src/backend/Views/Text/word_modal.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,24 @@ class="textarea"
232232
<p class="help">Use {curly braces} around the term</p>
233233
</div>
234234

235+
<!-- Notes -->
236+
<div class="field">
237+
<label class="label is-small">Notes</label>
238+
<div class="control">
239+
<textarea
240+
class="textarea"
241+
:class="{ 'is-danger': formStore.errors.notes }"
242+
x-model="formStore.formData.notes"
243+
@blur="validateField('notes')"
244+
rows="2"
245+
placeholder="Personal notes about this term..."
246+
></textarea>
247+
</div>
248+
<template x-if="formStore.errors.notes">
249+
<p class="help is-danger" x-text="formStore.errors.notes"></p>
250+
</template>
251+
</div>
252+
235253
<!-- Status -->
236254
<div class="field">
237255
<label class="label is-small">Status</label>

src/frontend/js/api/terms.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export interface TermCreateFullRequest {
150150
translation: string;
151151
romanization?: string;
152152
sentence?: string;
153+
notes?: string;
153154
status: number;
154155
tags?: string[];
155156
}
@@ -161,6 +162,7 @@ export interface TermUpdateFullRequest {
161162
translation: string;
162163
romanization?: string;
163164
sentence?: string;
165+
notes?: string;
164166
status: number;
165167
tags?: string[];
166168
}
@@ -215,6 +217,7 @@ export interface TermForEdit {
215217
translation: string;
216218
romanization: string;
217219
sentence: string;
220+
notes: string;
218221
status: number;
219222
tags: string[];
220223
}

src/frontend/js/core/api_client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface ApiClientConfig {
2525
}
2626

2727
const defaultConfig: ApiClientConfig = {
28-
baseUrl: '/api.php/v1',
28+
baseUrl: '/api/v1',
2929
defaultHeaders: {
3030
'Content-Type': 'application/json',
3131
Accept: 'application/json'

src/frontend/js/reading/stores/word_form_store.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
};

src/frontend/js/reading/text_renderer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ function buildWordDataAttributes(word: WordData): Record<string, string> {
7979
'data_pos': String(word.position),
8080
'data_order': String(word.position),
8181
'data_status': String(word.status),
82-
'data_wid': word.wordId ? String(word.wordId) : ''
82+
'data_wid': word.wordId ? String(word.wordId) : '',
83+
'data_hex': word.hex
8384
};
8485

8586
if (word.translation) {

0 commit comments

Comments
 (0)