TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.
TypeScript graphviewkanban-boardnodejsproductivityproject-managementself-hostedtasktask-managementtask-managertodoapp
feat: calendar settings
Nikolai Giman02b9f8cd30f2
diff --git a/api/src/tv-modules/ui-preferences/types.ts b/api/src/tv-modules/ui-preferences/types.tsindex ddfb4fd..61789d9 100644--- a/api/src/tv-modules/ui-preferences/types.ts+++ b/api/src/tv-modules/ui-preferences/types.ts@@ -36,8 +36,22 @@ const UiPreferencesSectionArkType = UiPreferencesItemArkType.array().narrow((arrreturn true})+export const UI_SETTINGS_KEY = '__settings__'++const firstDayOfWeekArkType = type('number.integer').narrow((v, ctx) =>+ v >= 0 && v <= 6 ? true : ctx.mustBe('an integer 0..6 (0=Sunday)'),+)++export const UiSettingsArkType = type({+ 'firstDayOfWeek?': firstDayOfWeekArkType,+})++export type UiSettings = typeof UiSettingsArkType.infer++const SectionOrSettingsArkType = UiPreferencesSectionArkType.or(UiSettingsArkType)+export const UiPreferencesArkType = type({- '[string]': UiPreferencesSectionArkType,+ '[string]': SectionOrSettingsArkType,}).narrow((obj, ctx) => {const keys = Object.keys(obj)if (keys.length > MAX_SECTIONS) {@@ -50,6 +64,14 @@ export const UiPreferencesArkType = type({if (!ID_PATTERN.test(key)) {return ctx.mustBe(`section key matching [a-zA-Z0-9_.\\-:]+ (got "${key}")`)}+ const value = (obj as Record<string, unknown>)[key]+ if (key === UI_SETTINGS_KEY) {+ if (Array.isArray(value)) {+ return ctx.mustBe(`"${UI_SETTINGS_KEY}" to be a settings object, not an array`)+ }+ } else if (!Array.isArray(value)) {+ return ctx.mustBe(`section "${key}" to be an array of items`)+ }}return true})diff --git a/taskview-packages/taskview-api/src/api/ui-preferences.types.ts b/taskview-packages/taskview-api/src/api/ui-preferences.types.tsindex 0f99526..b982f1e 100644--- a/taskview-packages/taskview-api/src/api/ui-preferences.types.ts+++ b/taskview-packages/taskview-api/src/api/ui-preferences.types.ts@@ -5,4 +5,12 @@ export type UiPreferencesItem = {width?: 'narrow' | 'wide'}-export type UiPreferences = Record<string, UiPreferencesItem[]>+export type FirstDayOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6++export type UiSettings = {+ firstDayOfWeek?: FirstDayOfWeek+}++export const UI_SETTINGS_KEY = '__settings__'++export type UiPreferences = Record<string, UiPreferencesItem[] | UiSettings>diff --git a/web/src/components/features/main/screen-main/parts/MainScreenAddTaskDialog.vue b/web/src/components/features/main/screen-main/parts/MainScreenAddTaskDialog.vueindex 89bc78b..f97087b 100644--- a/web/src/components/features/main/screen-main/parts/MainScreenAddTaskDialog.vue+++ b/web/src/components/features/main/screen-main/parts/MainScreenAddTaskDialog.vue@@ -58,6 +58,7 @@<template #content><UCalendarv-model="(deadline as any)"+ :week-starts-on="weekStart"class="p-2"/></template>@@ -104,6 +105,9 @@ import { useGoalsStore } from '@/stores/goals.store'import { useBaseScreenStore } from '@/stores/base-screen.store'import { $ls, $tvApi } from '@/plugins/axios'import { useTaskView } from '@/composables/useTaskView'+import { useWeekStart } from '@/composables/useWeekStart'++const weekStart = useWeekStart()const LAST_SELECTED_PROJECT_KEY = 'lastSelectedProjectId'diff --git a/web/src/components/features/sprints/parts/SprintCadenceDialog.vue b/web/src/components/features/sprints/parts/SprintCadenceDialog.vueindex c8650c9..7626f56 100644--- a/web/src/components/features/sprints/parts/SprintCadenceDialog.vue+++ b/web/src/components/features/sprints/parts/SprintCadenceDialog.vue@@ -53,6 +53,7 @@<template #content><UCalendarv-model="startDateModel"+ :week-starts-on="weekStart"class="p-2"/></template>@@ -112,8 +113,11 @@ import { useDateFormat } from '@vueuse/core'import { CalendarDate } from '@internationalized/date'import { useTaskView } from '@/composables/useTaskView'import { useSprintsStore } from '@/stores/sprints.store'+import { useWeekStart } from '@/composables/useWeekStart'import type { SprintCadenceFormValue } from '@/types/sprints.types'+const weekStart = useWeekStart()+const open = defineModel<boolean>('open', { default: false })const props = defineProps<{diff --git a/web/src/components/features/sprints/parts/SprintForm.vue b/web/src/components/features/sprints/parts/SprintForm.vueindex 7ad3077..d6887ec 100644--- a/web/src/components/features/sprints/parts/SprintForm.vue+++ b/web/src/components/features/sprints/parts/SprintForm.vue@@ -35,6 +35,7 @@<UCalendarv-model="startDateModel":max-value="endDateModel"+ :week-starts-on="weekStart"class="p-2"/></template>@@ -57,6 +58,7 @@<UCalendarv-model="endDateModel":min-value="startDateModel"+ :week-starts-on="weekStart"class="p-2"/></template>@@ -102,8 +104,11 @@ import { useI18n } from 'vue-i18n'import { useDateFormat } from '@vueuse/core'import { CalendarDate } from '@internationalized/date'import { useSprintFormat, type EstimateUnit } from '../composables/useSprintFormat'+import { useWeekStart } from '@/composables/useWeekStart'import type { SprintFormValue } from '@/types/sprints.types'+const weekStart = useWeekStart()+const model = defineModel<SprintFormValue>({ required: true })const props = withDefaults(diff --git a/web/src/components/features/tasks/parts/TaskDeadline.vue b/web/src/components/features/tasks/parts/TaskDeadline.vueindex 20bdc48..1008d9e 100644--- a/web/src/components/features/tasks/parts/TaskDeadline.vue+++ b/web/src/components/features/tasks/parts/TaskDeadline.vue@@ -22,6 +22,7 @@v-model="startDateModel":placeholder="startCalendarDefaultValue":max-value="endDateModel"+ :week-starts-on="weekStart"/><UCheckboxv-model="showStartTime"@@ -69,6 +70,7 @@v-model="endDateModel":placeholder="endCalendarDefaultValue":min-value="startDateModel"+ :week-starts-on="weekStart"/><UCheckboxv-model="showEndTime"@@ -168,6 +170,9 @@ import { CalendarDate, Time } from '@internationalized/date'import { useTasksStore } from '@/stores/tasks.store'import { useColor } from '@/composables/useColotMode'import { useGoalPermissions } from '@/composables/useGoalPermissions'+import { useWeekStart } from '@/composables/useWeekStart'++const weekStart = useWeekStart()type QuickAction = 'today' | 'tomorrow' | 'yesterday' | 'week' | 'month' | 'clear' | nulldiff --git a/web/src/components/features/tasks/parts/TaskTimeTrackingForm.vue b/web/src/components/features/tasks/parts/TaskTimeTrackingForm.vueindex a609d3f..2cec8bc 100644--- a/web/src/components/features/tasks/parts/TaskTimeTrackingForm.vue+++ b/web/src/components/features/tasks/parts/TaskTimeTrackingForm.vue@@ -15,6 +15,7 @@<UCalendarv-model="startDate":max-value="endDate"+ :week-starts-on="weekStart"/><UInputTimev-model="startTime"@@ -38,6 +39,7 @@<UCalendarv-model="endDate":min-value="startDate"+ :week-starts-on="weekStart"/><UInputTimev-model="endTime"@@ -85,6 +87,9 @@ import { computed, ref, shallowRef } from 'vue'import { useI18n } from 'vue-i18n'import { useDateFormat } from '@vueuse/core'import { CalendarDate, Time } from '@internationalized/date'+import { useWeekStart } from '@/composables/useWeekStart'++const weekStart = useWeekStart()export type TimeEntryFormPayload = {startedAt: stringdiff --git a/web/src/components/features/time-reports/TimeReportsFilters.vue b/web/src/components/features/time-reports/TimeReportsFilters.vueindex 14de64b..118a40e 100644--- a/web/src/components/features/time-reports/TimeReportsFilters.vue+++ b/web/src/components/features/time-reports/TimeReportsFilters.vue@@ -15,6 +15,7 @@<UCalendarv-model="fromDate":max-value="toDate"+ :week-starts-on="weekStart"/></div></template>@@ -37,6 +38,7 @@<UCalendarv-model="toDate":min-value="fromDate"+ :week-starts-on="weekStart"/></div></template>@@ -90,6 +92,9 @@ import { useDateFormat } from '@vueuse/core'import { CalendarDate } from '@internationalized/date'import type { GoalItem } from 'taskview-api'import { useTimeReportsStore } from '@/stores/time-reports.store'+import { useWeekStart } from '@/composables/useWeekStart'++const weekStart = useWeekStart()const props = defineProps<{availableProjects: GoalItem[]diff --git a/web/src/components/features/ui-customization/UiCustomizationOthers.vue b/web/src/components/features/ui-customization/UiCustomizationOthers.vuenew file mode 100644index 0000000..2957ced--- /dev/null+++ b/web/src/components/features/ui-customization/UiCustomizationOthers.vue@@ -0,0 +1,41 @@+<template>+ <div class="flex flex-col gap-4">+ <UFormField :label="t('uiCustomization.others.weekStart')"+ :description="t('uiCustomization.others.weekStartHint')">+ <USelectMenu v-model="weekStart"+ :items="weekStartItems"+ value-key="value"+ class="w-full lg:w-72" />+ </UFormField>+ </div>+</template>++<script setup lang="ts">+import { computed } from 'vue'+import { useI18n } from 'vue-i18n'+import type { FirstDayOfWeek } from 'taskview-api'+import { useUiPreferencesStore } from '@/stores/uiPreferences.store'++const { t } = useI18n()+const store = useUiPreferencesStore()++const DEFAULT = -1++const weekStart = computed<number>({+ get: () => store.settings.firstDayOfWeek ?? DEFAULT,+ set: (value) => {+ store.setSetting('firstDayOfWeek', value === DEFAULT ? undefined : (value as FirstDayOfWeek))+ },+})++const weekStartItems = computed(() => [+ { value: DEFAULT, label: t('uiCustomization.others.weekStartDefault') },+ { value: 1, label: t('uiCustomization.others.monday') },+ { value: 2, label: t('uiCustomization.others.tuesday') },+ { value: 3, label: t('uiCustomization.others.wednesday') },+ { value: 4, label: t('uiCustomization.others.thursday') },+ { value: 5, label: t('uiCustomization.others.friday') },+ { value: 6, label: t('uiCustomization.others.saturday') },+ { value: 0, label: t('uiCustomization.others.sunday') },+])+</script>diff --git a/web/src/composables/useWeekStart.ts b/web/src/composables/useWeekStart.tsnew file mode 100644index 0000000..300ae1a--- /dev/null+++ b/web/src/composables/useWeekStart.ts@@ -0,0 +1,8 @@+import { computed, type ComputedRef } from 'vue'+import type { FirstDayOfWeek } from 'taskview-api'+import { useUiPreferencesStore } from '@/stores/uiPreferences.store'++export function useWeekStart(): ComputedRef<FirstDayOfWeek | undefined> {+ const store = useUiPreferencesStore()+ return computed(() => store.settings.firstDayOfWeek)+}diff --git a/web/src/locales/en.ts b/web/src/locales/en.tsindex d1bcac2..09e82ae 100644--- a/web/src/locales/en.ts+++ b/web/src/locales/en.ts@@ -587,6 +587,19 @@ export default {analyticsIndicators: 'Analytics — Indicators',analyticsCharts: 'Analytics — Charts',tasks: 'Tasks',+ others: 'Others',+ },+ others: {+ weekStart: 'First day of week',+ weekStartHint: 'Applies to all calendar date pickers.',+ weekStartDefault: 'Default',+ monday: 'Monday',+ tuesday: 'Tuesday',+ wednesday: 'Wednesday',+ thursday: 'Thursday',+ friday: 'Friday',+ saturday: 'Saturday',+ sunday: 'Sunday',},taskFields: {subtasks: 'Subtasks',diff --git a/web/src/locales/ru.ts b/web/src/locales/ru.tsindex 9900b08..592cfa1 100644--- a/web/src/locales/ru.ts+++ b/web/src/locales/ru.ts@@ -560,6 +560,19 @@ export default {analyticsIndicators: 'Аналитика — показатели',analyticsCharts: 'Аналитика — графики',tasks: 'Задачи',+ others: 'Прочее',+ },+ others: {+ weekStart: 'Первый день недели',+ weekStartHint: 'Применяется во всех календарях выбора даты.',+ weekStartDefault: 'По умолчанию',+ monday: 'Понедельник',+ tuesday: 'Вторник',+ wednesday: 'Среда',+ thursday: 'Четверг',+ friday: 'Пятница',+ saturday: 'Суббота',+ sunday: 'Воскресенье',},taskFields: {subtasks: 'Подзадачи',diff --git a/web/src/pages/user/ui-customization.vue b/web/src/pages/user/ui-customization.vueindex 8e9cda4..fa036fa 100644--- a/web/src/pages/user/ui-customization.vue+++ b/web/src/pages/user/ui-customization.vue@@ -25,7 +25,12 @@:key="s.id"#[s.id]>+ <component+ :is="s.component"+ v-if="s.component"+ /><UiCustomizationSection+ v-else:title="t(s.labelKey)":resolved="s.resolved"@change="items => prefsStore.setSection(s.id, items)"@@ -55,14 +60,12 @@ const router = useRouter()const sections = reactive(uiCustomizationSections.map((def) => {- const used = def.useSection()- const prefs = useUiPreferences(def.id, () => used.catalogue.value)- return {- id: def.id,- labelKey: def.labelKey,- resolved: prefs.resolved,- init: used.init,+ if (def.kind === 'custom') {+ return { id: def.id, labelKey: def.labelKey, resolved: undefined, init: undefined, component: def.component }}+ const used = def.useSection()+ const { resolved } = useUiPreferences(def.id, () => used.catalogue.value)+ return { id: def.id, labelKey: def.labelKey, resolved, init: used.init, component: undefined }}),)diff --git a/web/src/stores/uiPreferences.store.ts b/web/src/stores/uiPreferences.store.tsindex b159721..9cd2603 100644--- a/web/src/stores/uiPreferences.store.ts+++ b/web/src/stores/uiPreferences.store.ts@@ -1,23 +1,36 @@import { defineStore } from 'pinia'import { ref } from 'vue'import { useDebounceFn } from '@vueuse/core'-import type { UiPreferences, UiPreferencesItem } from 'taskview-api'+import { UI_SETTINGS_KEY, type UiPreferences, type UiPreferencesItem, type UiSettings } from 'taskview-api'import { $tvApi } from '@/plugins/axios'const SAVE_DEBOUNCE_MS = 250+type Sections = Record<string, UiPreferencesItem[]>+export const useUiPreferencesStore = defineStore('uiPreferences', () => {- const prefs = ref<UiPreferences>({})+ const prefs = ref<Sections>({})+ const settings = ref<UiSettings>({})const loaded = ref(false)const loading = ref(false)const saving = ref(false)+ function split(blob: UiPreferences): { sections: Sections; settings: UiSettings } {+ const { [UI_SETTINGS_KEY]: settingsEntry, ...sections } = blob+ return {+ sections: sections as Sections,+ settings: (settingsEntry as UiSettings | undefined) ?? {},+ }+ }+async function fetch() {if (loading.value) returnloading.value = truetry {const result = await $tvApi.uiPreferences.fetch()- prefs.value = result ?? {}+ const { sections, settings: s } = split(result ?? {})+ prefs.value = sections+ settings.value = sloaded.value = true} finally {loading.value = false@@ -27,8 +40,16 @@ export const useUiPreferencesStore = defineStore('uiPreferences', () => {const flush = useDebounceFn(async () => {saving.value = truetry {- const result = await $tvApi.uiPreferences.update(prefs.value)- if (result) prefs.value = result+ const payload: UiPreferences = { ...prefs.value }+ if (Object.keys(settings.value).length > 0) {+ payload[UI_SETTINGS_KEY] = settings.value+ }+ const result = await $tvApi.uiPreferences.update(payload)+ if (result) {+ const { sections, settings: s } = split(result)+ prefs.value = sections+ settings.value = s+ }} finally {saving.value = false}@@ -43,13 +64,20 @@ export const useUiPreferencesStore = defineStore('uiPreferences', () => {return prefs.value[section] ?? []}+ function setSetting<K extends keyof UiSettings>(key: K, value: UiSettings[K]) {+ settings.value = { ...settings.value, [key]: value }+ flush()+ }+return {prefs,+ settings,loaded,loading,saving,fetch,setSection,getSection,+ setSetting,}})diff --git a/web/src/uiCustomization/registry.ts b/web/src/uiCustomization/registry.tsindex 291c1cc..7c0808c 100644--- a/web/src/uiCustomization/registry.ts+++ b/web/src/uiCustomization/registry.ts@@ -1,9 +1,11 @@import { analyticsIndicatorsSection, analyticsChartsSection } from './sections/analytics'import { tasksSection } from './sections/tasks'+import { othersSection } from './sections/others'import type { UiCustomizationSectionDef } from './types'export const uiCustomizationSections: UiCustomizationSectionDef[] = [analyticsIndicatorsSection,analyticsChartsSection,tasksSection,+ othersSection,]diff --git a/web/src/uiCustomization/sections/analytics.ts b/web/src/uiCustomization/sections/analytics.tsindex 0a687d5..1418e0d 100644--- a/web/src/uiCustomization/sections/analytics.ts+++ b/web/src/uiCustomization/sections/analytics.ts@@ -12,6 +12,7 @@ type AnalyticsSubsectionArgs = {function buildAnalyticsSection(args: AnalyticsSubsectionArgs): UiCustomizationSectionDef {const { id, labelKey, payloadKind } = argsreturn {+ kind: 'list',id,labelKey,useSection() {diff --git a/web/src/uiCustomization/sections/others.ts b/web/src/uiCustomization/sections/others.tsnew file mode 100644index 0000000..976e063--- /dev/null+++ b/web/src/uiCustomization/sections/others.ts@@ -0,0 +1,9 @@+import UiCustomizationOthers from '@/components/features/ui-customization/UiCustomizationOthers.vue'+import type { UiCustomizationSectionDef } from '../types'++export const othersSection: UiCustomizationSectionDef = {+ kind: 'custom',+ id: 'others',+ labelKey: 'uiCustomization.sections.others',+ component: UiCustomizationOthers,+}diff --git a/web/src/uiCustomization/sections/tasks.ts b/web/src/uiCustomization/sections/tasks.tsindex 00373db..c15da2d 100644--- a/web/src/uiCustomization/sections/tasks.ts+++ b/web/src/uiCustomization/sections/tasks.ts@@ -1,9 +1,12 @@import { computed } from 'vue'import { useI18n } from 'vue-i18n'-import type { UiCustomizationSectionDef } from '../types'+import type { UiCustomizationListTabDef } from '../types'import { TASK_DETAIL_FIELDS } from './tasks.types'-export const tasksSection: UiCustomizationSectionDef = {+// Typed as the list variant (not the union) so consumers like TaskDetailPanel+// can call `tasksSection.useSection()` directly without narrowing.+export const tasksSection: UiCustomizationListTabDef = {+ kind: 'list',id: 'tasks',labelKey: 'uiCustomization.sections.tasks',useSection() {diff --git a/web/src/uiCustomization/types.ts b/web/src/uiCustomization/types.tsindex 2375dc0..8b1f58e 100644--- a/web/src/uiCustomization/types.ts+++ b/web/src/uiCustomization/types.ts@@ -1,4 +1,4 @@-import type { ComputedRef } from 'vue'+import type { Component, ComputedRef } from 'vue'import type { CatalogueEntry } from '@/composables/useUiPreferences'export type UiCustomizationSectionUseReturn = {@@ -6,8 +6,27 @@ export type UiCustomizationSectionUseReturn = {init?: () => Promise<void> | void}-export type UiCustomizationSectionDef = {+type UiCustomizationTabBase = {id: stringlabelKey: string+}++/**+ * A reorder/hide list tab driven by a catalogue of items (analytics sections,+ * task fields, …) — rendered via UiCustomizationSection.+ */+export type UiCustomizationListTabDef = UiCustomizationTabBase & {+ kind: 'list'useSection: () => UiCustomizationSectionUseReturn}++/**+ * A tab that renders an arbitrary settings component (e.g. scalar preferences+ * like "first day of week"). Not a reorderable list.+ */+export type UiCustomizationCustomTabDef = UiCustomizationTabBase & {+ kind: 'custom'+ component: Component+}++export type UiCustomizationSectionDef = UiCustomizationListTabDef | UiCustomizationCustomTabDef