Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client,server: Add first day of week option
Elian Doranf5330cb91597
diff --git a/src/public/app/widgets/buttons/calendar.js b/src/public/app/widgets/buttons/calendar.jsindex 21792fc252..19822a2280 100644--- a/src/public/app/widgets/buttons/calendar.js+++ b/src/public/app/widgets/buttons/calendar.js@@ -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();+ }+ }+}diff --git a/src/public/app/widgets/type_widgets/options/appearance/i18n.js b/src/public/app/widgets/type_widgets/options/appearance/i18n.jsindex 0c79ac94c7..2137cd26a7 100644--- a/src/public/app/widgets/type_widgets/options/appearance/i18n.js+++ b/src/public/app/widgets/type_widgets/options/appearance/i18n.js@@ -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);}}\ No newline at end of filediff --git a/src/routes/api/options.ts b/src/routes/api/options.tsindex 9655404328..05e7355fa6 100644--- a/src/routes/api/options.ts+++ b/src/routes/api/options.ts@@ -59,7 +59,8 @@ const ALLOWED_OPTIONS = new Set(['customSearchEngineUrl','promotedAttributesOpenInRibbon','editedNotesOpenInRibbon',- 'locale'+ 'locale',+ 'firstDayOfWeek']);function getOptions() {diff --git a/src/services/options_init.ts b/src/services/options_init.tsindex 111e78cd49..2adbadd2be 100644--- a/src/services/options_init.ts+++ b/src/services/options_init.ts@@ -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() {