feat(vocab): add SRS schedule date formatting and update close button text
This commit is contained in:
@@ -16,6 +16,7 @@ import { Op } from 'sequelize';
|
||||
import { BISAYA_PHASE1_DIDACTICS, BISAYA_DIDACTICS_FRAGMENTS } from '../scripts/bisaya-course-phase1.js';
|
||||
|
||||
const DAILY_SRS_LIMIT = 50;
|
||||
const SRS_SCHEDULE_TIME_ZONE = 'Europe/Berlin';
|
||||
|
||||
export default class VocabService {
|
||||
_stripGermanNumberSeparators(value) {
|
||||
@@ -317,6 +318,21 @@ export default class VocabService {
|
||||
return date.toISOString();
|
||||
}
|
||||
|
||||
_getSrsScheduleDateKey(value) {
|
||||
const date = value instanceof Date ? value : new Date(value);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return '';
|
||||
}
|
||||
const parts = new Intl.DateTimeFormat('en-US', {
|
||||
timeZone: SRS_SCHEDULE_TIME_ZONE,
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit'
|
||||
}).formatToParts(date);
|
||||
const byType = new Map(parts.map((part) => [part.type, part.value]));
|
||||
return `${byType.get('year')}-${byType.get('month')}-${byType.get('day')}`;
|
||||
}
|
||||
|
||||
_clampInteger(value, { min = 0, max = 100000, fallback = 0 } = {}) {
|
||||
const numeric = Number(value);
|
||||
if (!Number.isFinite(numeric)) {
|
||||
@@ -2043,8 +2059,10 @@ export default class VocabService {
|
||||
&& new Date(item.nextDueAt).getTime() > now.getTime()
|
||||
))
|
||||
.forEach((item) => {
|
||||
const date = new Date(item.nextDueAt).toISOString().slice(0, 10);
|
||||
upcomingByDate.set(date, (upcomingByDate.get(date) || 0) + 1);
|
||||
const date = this._getSrsScheduleDateKey(item.nextDueAt);
|
||||
if (date) {
|
||||
upcomingByDate.set(date, (upcomingByDate.get(date) || 0) + 1);
|
||||
}
|
||||
});
|
||||
const rows = validDueRows.slice(0, limit);
|
||||
const totalDueCount = validDueRows.length;
|
||||
|
||||
@@ -327,7 +327,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<div class="form-actions">
|
||||
<button type="button" class="button-secondary" @click="showIntensiveStatusDialog = false">{{ $t('general.close') }}</button>
|
||||
<button type="button" class="button-secondary" @click="showIntensiveStatusDialog = false">{{ $t('message.close') }}</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user