client,server: Add first day of week option

This commit is contained in:
Elian Doran 2024-08-31 16:24:09 +03:00
parent dab97071c0
commit f5330cb915
No known key found for this signature in database
4 changed files with 28 additions and 2 deletions

View File

@ -206,4 +206,11 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
this.$monthSelect.val(this.date.getMonth());
this.$yearSelect.val(this.date.getFullYear());
}
async entitiesReloadedEvent({loadResults}) {
if (loadResults.getOptionNames().includes("firstDayOfWeek")) {
this.init();
}
}
}

View File

@ -12,6 +12,14 @@ const TPL = `
<label>${t("i18n.language")}</label>
<select class="locale-select form-control"></select>
</div>
<div class="col-6">
<label>First day of the week</label>
<select class="first-day-of-week-select form-control">
<option value="0">Sunday</option>
<option value="1">Monday</option>
</select>
</div>
</div>
</div>
`;
@ -19,12 +27,18 @@ const TPL = `
export default class LocalizationOptions extends OptionsWidget {
doRender() {
this.$widget = $(TPL);
this.$localeSelect = this.$widget.find(".locale-select");
this.$localeSelect.on("change", async() => {
const newLocale = this.$localeSelect.val();
await server.put(`options/locale/${newLocale}`);
utils.reloadFrontendApp("locale change");
});
this.$firstDayOfWeek = this.$widget.find(".first-day-of-week-select");
this.$firstDayOfWeek.on("change", () => {
this.updateOption("firstDayOfWeek", this.$firstDayOfWeek.val());
});
}
async optionsLoaded(options) {
@ -38,5 +52,6 @@ export default class LocalizationOptions extends OptionsWidget {
}
this.$localeSelect.val(options.locale);
this.$firstDayOfWeek.val(options.firstDayOfWeek);
}
}

View File

@ -59,7 +59,8 @@ const ALLOWED_OPTIONS = new Set([
'customSearchEngineUrl',
'promotedAttributesOpenInRibbon',
'editedNotesOpenInRibbon',
'locale'
'locale',
'firstDayOfWeek'
]);
function getOptions() {

View File

@ -95,7 +95,10 @@ const defaultOptions: DefaultOption[] = [
{ name: 'customSearchEngineUrl', value: 'https://duckduckgo.com/?q={keyword}', isSynced: true },
{ name: 'promotedAttributesOpenInRibbon', value: 'true', isSynced: true },
{ name: 'editedNotesOpenInRibbon', value: 'true', isSynced: true },
{ name: 'locale', value: 'en', isSynced: true }
// Internationalization
{ name: 'locale', value: 'en', isSynced: true },
{ name: 'firstDayOfWeek', value: '1', isSynced: true }
];
function initStartupOptions() {