feat(oxibadge): add settings screen for shifts, rounding and language
Check, format and test / build (push) Successful in 10m22s
Check, format and test / build (push) Successful in 10m22s
Add a settings screen (gear button on the month-confirmation screen) to configure the expected shift times, the rounding step, the interface language, and the time clock address — replacing the old onboarding-only connection flow. Settings persist to the same preferences.toml as the reader address, under a single load_settings/ save_settings command pair. The review screen's "fix shifts" action now redistributes stacked punches by nearest configured shift time instead of blind position, and a stacked cell manually cleared down to one entry no longer leaves a dangling empty input. Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,24 +9,41 @@
|
||||
import ConfirmMonth from '$lib/components/ConfirmMonth.svelte';
|
||||
import LoadingScreen from '$lib/components/LoadingScreen.svelte';
|
||||
import TimesheetReview from '$lib/components/TimesheetReview.svelte';
|
||||
import SettingsButton from '$lib/components/SettingsButton.svelte';
|
||||
import Settings from '$lib/components/Settings.svelte';
|
||||
import { buildEmployees, type AttendanceRecord } from '$lib/components/review/fromRecords';
|
||||
import type { Shifts } from '$lib/shifts';
|
||||
import type { Settings as SettingsData } from '$lib/settings';
|
||||
|
||||
type Step = 'loading' | 'setup' | 'confirm-month' | 'loading-records' | 'loading-employees' | 'review';
|
||||
type Step = 'loading' | 'setup' | 'confirm-month' | 'loading-records' | 'loading-employees' | 'review' | 'settings';
|
||||
|
||||
let step = $state<Step>('loading');
|
||||
let selectedYear = $state(0);
|
||||
let selectedMonth = $state(0);
|
||||
let records = $state<AttendanceRecord[]>([]);
|
||||
let employeeNames = $state<Record<string, string>>({});
|
||||
// Placeholder: sovrascritti da load_settings prima che la revisione sia raggiungibile.
|
||||
let shifts = $state<Shifts>({ in1: '', out1: '', in2: '', out2: '', round_step_min: 0 });
|
||||
|
||||
const period = $derived(`${monthName($locale, selectedMonth)} ${selectedYear}`);
|
||||
const reviewEmployees = $derived(buildEmployees(selectedYear, selectedMonth, records, employeeNames));
|
||||
|
||||
onMount(async () => {
|
||||
const preferences = await invoke<{ host: string; port: number } | null>('load_preferences');
|
||||
step = preferences ? 'confirm-month' : 'setup';
|
||||
const settings = await invoke<SettingsData>('load_settings');
|
||||
shifts = settings.shifts;
|
||||
step = settings.reader.host ? 'confirm-month' : 'setup';
|
||||
});
|
||||
|
||||
function openSettings() {
|
||||
clearError();
|
||||
step = 'settings';
|
||||
}
|
||||
|
||||
function closeSettings() {
|
||||
clearError();
|
||||
step = 'confirm-month';
|
||||
}
|
||||
|
||||
async function loadMonth(selection: { year: number; month: number }) {
|
||||
selectedYear = selection.year;
|
||||
selectedMonth = selection.month;
|
||||
@@ -49,9 +66,17 @@
|
||||
year={selectedYear}
|
||||
month={selectedMonth}
|
||||
employees={reviewEmployees}
|
||||
shift={shifts}
|
||||
onback={() => (step = 'confirm-month')}
|
||||
onexport={(payload) => invoke('export_timesheet', { payload })}
|
||||
/>
|
||||
{:else if step === 'settings'}
|
||||
<Settings
|
||||
onback={closeSettings}
|
||||
onsettingschange={(s: SettingsData) => {
|
||||
shifts = s.shifts;
|
||||
}}
|
||||
/>
|
||||
{:else}
|
||||
<Screen>
|
||||
{#if step === 'loading'}
|
||||
@@ -59,6 +84,7 @@
|
||||
{:else if step === 'setup'}
|
||||
<Onboarding onconnected={() => (step = 'confirm-month')} />
|
||||
{:else if step === 'confirm-month'}
|
||||
<SettingsButton ariaLabel={$_('settings.title')} onclick={openSettings} />
|
||||
<ConfirmMonth onstart={loadMonth} />
|
||||
{:else if step === 'loading-records'}
|
||||
<LoadingScreen
|
||||
|
||||
Reference in New Issue
Block a user