Skip to content

Commit c8fec48

Browse files
authored
Merge pull request #119 from djedi/feature/monday-first-day-of-week
feat: add week start on Monday setting
2 parents 63e0faa + 41a29b0 commit c8fec48

File tree

10 files changed

+79
-7
lines changed

10 files changed

+79
-7
lines changed

app/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ class User(Base):
220220
calendar_token = Column(String(64), unique=True, nullable=True)
221221
kanban_enabled = Column(Boolean, nullable=True, default=False)
222222
kanban_columns = Column(String(512), nullable=True, default='["todo", "done"]')
223+
week_start_monday = Column(Boolean, nullable=True, default=False)
223224
notes = relationship("Note", lazy="dynamic", cascade="all, delete, delete-orphan")
224225
meta = relationship("Meta", lazy="dynamic", cascade="all, delete, delete-orphan")
225226
external_calendars = relationship(

app/routes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,8 @@ async def sidebar_data():
12801280
except (json.JSONDecodeError, TypeError):
12811281
kanban_columns = ["todo", "done"]
12821282

1283+
week_start_monday = user.week_start_monday or False
1284+
12831285
return (
12841286
jsonify(
12851287
tags=tags,
@@ -1290,6 +1292,7 @@ async def sidebar_data():
12901292
vim_mode=vim_mode,
12911293
kanban_enabled=kanban_enabled,
12921294
kanban_columns=kanban_columns,
1295+
week_start_monday=week_start_monday,
12931296
),
12941297
200,
12951298
)
@@ -1373,6 +1376,7 @@ async def get_settings():
13731376
vim_mode=user.vim_mode or False,
13741377
kanban_enabled=user.kanban_enabled or False,
13751378
kanban_columns=kanban_columns,
1379+
week_start_monday=user.week_start_monday or False,
13761380
),
13771381
200,
13781382
)
@@ -1414,6 +1418,9 @@ async def update_settings():
14141418
if valid_columns:
14151419
user.kanban_columns = json.dumps(valid_columns)
14161420

1421+
if "week_start_monday" in req:
1422+
user.week_start_monday = req["week_start_monday"]
1423+
14171424
db.session.add(user)
14181425
db.session.flush()
14191426
db.session.commit()
@@ -1432,6 +1439,7 @@ async def update_settings():
14321439
vim_mode=user.vim_mode or False,
14331440
kanban_enabled=user.kanban_enabled or False,
14341441
kanban_columns=kanban_columns,
1442+
week_start_monday=user.week_start_monday or False,
14351443
),
14361444
200,
14371445
)

client/src/components/Calendar.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
:nearby-month-days="true"
99
:nearby-selectable-month-days="true"
1010
:focusable="false"
11+
:first-day-of-week="sidebar.weekStartMonday ? 1 : 0"
1112
@update:model-value="changeDate"
1213
>
1314
</b-datepicker>

client/src/components/NestedTags.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
</template>
7676

7777
<script setup lang="ts">
78-
import { ref, computed, watch } from 'vue';
78+
import { computed, ref, watch } from 'vue';
7979
import type { ITagNode } from '../interfaces';
8080
import { getExpandedTags, saveExpandedTags } from '../services/localstorage';
8181

client/src/components/Settings.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
Enable Auto-Save
1717
</b-switch>
1818
</div>
19+
<div class="setting-row">
20+
<b-switch v-model="localWeekStartMonday" @update:modelValue="onWeekStartMondayChange">
21+
Start week on Monday
22+
</b-switch>
23+
<p class="setting-hint">
24+
Display the calendar with Monday as the first day of the week (European style).
25+
</p>
26+
</div>
1927
</div>
2028

2129
<div class="settings-card">
@@ -207,10 +215,10 @@
207215
import { computed, getCurrentInstance, onMounted, ref } from 'vue';
208216
import type { IExternalCalendar } from '../interfaces';
209217
import { CalendarService } from '../services/calendars';
218+
import directionService, { type DirectionPreference } from '../services/direction';
210219
import { Requests } from '../services/requests';
211220
import type { BuefyInstance } from '../services/sharedBuefy';
212221
import sidebar from '../services/sidebar';
213-
import directionService, { type DirectionPreference } from '../services/direction';
214222
import themeService, { type ThemePreference } from '../services/theme';
215223
216224
const emit = defineEmits<{
@@ -226,6 +234,7 @@ const localTheme = ref<ThemePreference>('system');
226234
const localDirection = ref<DirectionPreference>('ltr');
227235
const localKanbanEnabled = ref(false);
228236
const localKanbanColumns = ref<string[]>(['todo', 'done']);
237+
const localWeekStartMonday = ref(false);
229238
230239
const themeOptions = [
231240
{ value: 'light', label: 'Light', icon: 'fas fa-sun' },
@@ -257,6 +266,7 @@ onMounted(() => {
257266
localDirection.value = directionService.preference;
258267
localKanbanEnabled.value = sidebar.kanbanEnabled;
259268
localKanbanColumns.value = [...sidebar.kanbanColumns];
269+
localWeekStartMonday.value = sidebar.weekStartMonday;
260270
261271
fetchCalendarUrl();
262272
fetchExternalCalendars();
@@ -274,6 +284,18 @@ const onAutoSaveChange = (value: boolean) => {
274284
});
275285
};
276286
287+
const onWeekStartMondayChange = (value: boolean) => {
288+
// Update the setting immediately
289+
sidebar.toggleWeekStartMonday(value);
290+
291+
// Show success toast
292+
buefy?.toast.open({
293+
message: `Week now starts on ${value ? 'Monday' : 'Sunday'}`,
294+
type: 'is-success',
295+
duration: 2000,
296+
});
297+
};
298+
277299
const onVimModeChange = (value: boolean) => {
278300
// Update the setting immediately
279301
sidebar.toggleVimMode(value);

client/src/interfaces.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ export interface IExternalEvent {
6161
}
6262

6363
export interface ITagNode {
64-
name: string; // Display name (e.g., "family" for "home/family")
65-
fullPath: string; // Full tag path (e.g., "home/family")
64+
name: string; // Display name (e.g., "family" for "home/family")
65+
fullPath: string; // Full tag path (e.g., "home/family")
6666
children: ITagNode[];
67-
isLeaf: boolean; // True if this is an actual tag, not just a parent folder
67+
isLeaf: boolean; // True if this is an actual tag, not just a parent folder
6868
}

client/src/services/sidebar.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class SidebarSerivce {
7575
public vimMode: boolean = false;
7676
public kanbanEnabled: boolean = false;
7777
public kanbanColumns: string[] = ['todo', 'done'];
78+
public weekStartMonday: boolean = false;
7879
public currentNoteId: string | null = null;
7980
public date: Date | null = null;
8081
public sidebarLoading: boolean = false;
@@ -195,6 +196,7 @@ class SidebarSerivce {
195196
this.vimMode = res.data.vim_mode;
196197
this.kanbanEnabled = res.data.kanban_enabled || false;
197198
this.kanbanColumns = res.data.kanban_columns || ['todo', 'done'];
199+
this.weekStartMonday = res.data.week_start_monday || false;
198200
}
199201

200202
if (this.selectedSearch.length && this.searchString.length) {
@@ -272,6 +274,13 @@ class SidebarSerivce {
272274
} catch (_e) {}
273275
}
274276

277+
public async toggleWeekStartMonday(enabled: boolean) {
278+
try {
279+
await Requests.put('/settings', { week_start_monday: enabled });
280+
this.weekStartMonday = enabled;
281+
} catch (_e) {}
282+
}
283+
275284
public async updateKanbanColumns(columns: string[]) {
276285
try {
277286
await Requests.put('/settings', { kanban_columns: columns });

client/src/views/Day.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
watch,
4242
} from 'vue';
4343
import { onBeforeRouteLeave, onBeforeRouteUpdate, useRoute, useRouter } from 'vue-router';
44-
import Editor from '@/components/Editor.vue';
44+
import type Editor from '@/components/Editor.vue';
4545
import Header from '@/components/Header.vue';
4646
import MarkdownPreview from '@/components/MarkdownPreview.vue';
4747
import UnsavedForm from '@/components/UnsavedForm.vue';

client/src/views/Note.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
ref,
3838
} from 'vue';
3939
import { onBeforeRouteLeave, onBeforeRouteUpdate, useRoute, useRouter } from 'vue-router';
40-
import Editor from '@/components/Editor.vue';
40+
import type Editor from '@/components/Editor.vue';
4141
import Header from '@/components/Header.vue';
4242
import MarkdownPreview from '@/components/MarkdownPreview.vue';
4343
import type { IHeaderOptions, INote } from '../interfaces';
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Add week_start_monday column to User table
2+
3+
Revision ID: week_start_monday_001
4+
Revises: f1803e0263f1
5+
Create Date: 2025-12-12 00:00:00.000000
6+
7+
"""
8+
9+
from alembic import op
10+
import sqlalchemy as sa
11+
12+
13+
# revision identifiers, used by Alembic.
14+
revision = "week_start_monday_001"
15+
down_revision = "f1803e0263f1"
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
with op.batch_alter_table("user", schema=None) as batch_op:
22+
batch_op.add_column(
23+
sa.Column(
24+
"week_start_monday", sa.Boolean(), nullable=True, server_default="0"
25+
)
26+
)
27+
28+
29+
def downgrade():
30+
with op.batch_alter_table("user", schema=None) as batch_op:
31+
batch_op.drop_column("week_start_monday")

0 commit comments

Comments
 (0)