Skip to content

Your favorite shift management application!

fix(ui): disable view settings a calendar's own view overrides

panteLx427f6eb67409
diff --git a/components/view-settings-sheet.tsx b/components/view-settings-sheet.tsx
index aba9508..4e109b8 100644
--- a/components/view-settings-sheet.tsx
+++ b/components/view-settings-sheet.tsx
@@ -122,167 +122,180 @@ function ViewFields({
{ day: 0, label: t("view.sunday") },
];
const days = value.highlightedWeekdays;
+ // Neither is part of CalendarViewSettings, so a calendar's own view can never take them over
+ const hasPersonalSection = !!stampBar || !!onlyMyShifts;
return (
- <div className={cn("flex flex-col gap-6", disabled && LOCKED_FIELDS)}>
- <section className="flex flex-col gap-3">
- <SectionLabel className="mb-0">{t("view.density")}</SectionLabel>
- <div className="flex items-center justify-between gap-4">
- <div className="min-w-0">
- <div className="text-[14px] font-semibold text-fg-strong">{t("view.shiftsPerDay")}</div>
- <div className="text-[12.5px] text-fg-secondary">{t("view.shiftsPerDayHint")}</div>
- </div>
- <LimitControl
- label={t("view.shiftsPerDay")}
- value={value.shiftsPerDay}
- onChange={(shiftsPerDay) => onChange({ shiftsPerDay })}
- disabled={disabled}
- />
- </div>
- <div className="flex items-center justify-between gap-4">
- <div className="min-w-0">
- <div className="text-[14px] font-semibold text-fg-strong">
- {t("view.externalShiftsPerDay")}
+ <div className="flex flex-col gap-6">
+ {hasPersonalSection && (
+ <section className="flex flex-col gap-3">
+ <SectionLabel className="mb-0">{t("view.personalSection")}</SectionLabel>
+ {stampBar && (
+ <ToggleRow
+ id={`${id}-dock`}
+ title={t("view.showPresetBar")}
+ description={t("view.showPresetBarHint")}
+ checked={stampBar.checked}
+ onCheckedChange={stampBar.onChange}
+ />
+ )}
+ {onlyMyShifts && (
+ <>
+ <ToggleRow
+ id={`${id}-only-mine`}
+ title={t("view.onlyMyShifts")}
+ description={t("view.onlyMyShiftsHint")}
+ checked={onlyMyShifts.checked}
+ onCheckedChange={onlyMyShifts.onChange}
+ />
+ {onlyMyShifts.checked && onlyMyShifts.signupsDisabled && (
+ <InfoNote icon={Info}>{t("view.onlyMyShiftsSignupsDisabledHint")}</InfoNote>
+ )}
+ </>
+ )}
+ </section>
+ )}
+
+ <div className={cn("flex flex-col gap-6", disabled && LOCKED_FIELDS)}>
+ <section
+ className={cn(
+ "flex flex-col gap-3",
+ hasPersonalSection && "border-t border-line pt-5"
+ )}
+ >
+ <SectionLabel className="mb-0">{t("view.density")}</SectionLabel>
+ <div className="flex items-center justify-between gap-4">
+ <div className="min-w-0">
+ <div className="text-[14px] font-semibold text-fg-strong">{t("view.shiftsPerDay")}</div>
+ <div className="text-[12.5px] text-fg-secondary">{t("view.shiftsPerDayHint")}</div>
</div>
- <div className="text-[12.5px] text-fg-secondary">
- {t("view.externalShiftsPerDayHint")}
+ <LimitControl
+ label={t("view.shiftsPerDay")}
+ value={value.shiftsPerDay}
+ onChange={(shiftsPerDay) => onChange({ shiftsPerDay })}
+ disabled={disabled}
+ />
+ </div>
+ <div className="flex items-center justify-between gap-4">
+ <div className="min-w-0">
+ <div className="text-[14px] font-semibold text-fg-strong">
+ {t("view.externalShiftsPerDay")}
+ </div>
+ <div className="text-[12.5px] text-fg-secondary">
+ {t("view.externalShiftsPerDayHint")}
+ </div>
</div>
+ <LimitControl
+ label={t("view.externalShiftsPerDay")}
+ value={value.externalShiftsPerDay}
+ onChange={(externalShiftsPerDay) => onChange({ externalShiftsPerDay })}
+ disabled={disabled}
+ />
</div>
- <LimitControl
- label={t("view.externalShiftsPerDay")}
- value={value.externalShiftsPerDay}
- onChange={(externalShiftsPerDay) => onChange({ externalShiftsPerDay })}
- disabled={disabled}
- />
- </div>
- {/* Phone cells have no room for a second line, so the toggle would do nothing there */}
- {desktop && (
- <ToggleRow
- id={`${id}-notes`}
- title={t("view.showNotes")}
- description={t("view.showNotesHint")}
- checked={value.showShiftNotes}
- onCheckedChange={(showShiftNotes) => onChange({ showShiftNotes })}
- disabled={disabled}
- />
- )}
- {stampBar && (
- <ToggleRow
- id={`${id}-dock`}
- title={t("view.showPresetBar")}
- description={t("view.showPresetBarHint")}
- checked={stampBar.checked}
- onCheckedChange={stampBar.onChange}
- disabled={disabled}
- />
- )}
- {onlyMyShifts && (
- <>
+ {/* Phone cells have no room for a second line, so the toggle would do nothing there */}
+ {desktop && (
<ToggleRow
- id={`${id}-only-mine`}
- title={t("view.onlyMyShifts")}
- description={t("view.onlyMyShiftsHint")}
- checked={onlyMyShifts.checked}
- onCheckedChange={onlyMyShifts.onChange}
+ id={`${id}-notes`}
+ title={t("view.showNotes")}
+ description={t("view.showNotesHint")}
+ checked={value.showShiftNotes}
+ onCheckedChange={(showShiftNotes) => onChange({ showShiftNotes })}
disabled={disabled}
/>
- {onlyMyShifts.checked && onlyMyShifts.signupsDisabled && (
- <InfoNote icon={Info}>{t("view.onlyMyShiftsSignupsDisabledHint")}</InfoNote>
- )}
- </>
- )}
- </section>
+ )}
+ </section>
- <section className="flex flex-col gap-3 border-t border-line pt-5">
- <SectionLabel className="mb-0">{t("view.sortOptions")}</SectionLabel>
- <Field label={t("view.sortBy")}>
- <ChoiceChips
- value={value.sortType}
- onChange={(sortType) => onChange({ sortType })}
- disabled={disabled}
- options={[
- { value: "startTime", label: t("view.sortByStartTime") },
- { value: "createdAt", label: t("view.sortByCreatedAt") },
- { value: "title", label: t("view.sortByTitle") },
- ]}
- />
- </Field>
- <Field label={t("view.sortOrder")}>
- <ChoiceChips
- value={value.sortOrder}
- onChange={(sortOrder) => onChange({ sortOrder })}
+ <section className="flex flex-col gap-3 border-t border-line pt-5">
+ <SectionLabel className="mb-0">{t("view.sortOptions")}</SectionLabel>
+ <Field label={t("view.sortBy")}>
+ <ChoiceChips
+ value={value.sortType}
+ onChange={(sortType) => onChange({ sortType })}
+ disabled={disabled}
+ options={[
+ { value: "startTime", label: t("view.sortByStartTime") },
+ { value: "createdAt", label: t("view.sortByCreatedAt") },
+ { value: "title", label: t("view.sortByTitle") },
+ ]}
+ />
+ </Field>
+ <Field label={t("view.sortOrder")}>
+ <ChoiceChips
+ value={value.sortOrder}
+ onChange={(sortOrder) => onChange({ sortOrder })}
+ disabled={disabled}
+ options={[
+ { value: "asc", label: t("view.sortOrderAsc") },
+ { value: "desc", label: t("view.sortOrderDesc") },
+ ]}
+ />
+ </Field>
+ <ToggleRow
+ id={`${id}-combined`}
+ title={t("view.combinedSort")}
+ description={t("view.combinedSortHint")}
+ checked={value.combinedSort}
+ onCheckedChange={(combinedSort) => onChange({ combinedSort })}
disabled={disabled}
- options={[
- { value: "asc", label: t("view.sortOrderAsc") },
- { value: "desc", label: t("view.sortOrderDesc") },
- ]}
/>
- </Field>
- <ToggleRow
- id={`${id}-combined`}
- title={t("view.combinedSort")}
- description={t("view.combinedSortHint")}
- checked={value.combinedSort}
- onCheckedChange={(combinedSort) => onChange({ combinedSort })}
- disabled={disabled}
- />
- </section>
+ </section>
- <section className="flex flex-col gap-3 border-t border-line pt-5">
- <SectionLabel className="mb-0">{t("view.dayHighlighting")}</SectionLabel>
- <ToggleRow
- id={`${id}-weekends`}
- title={t("view.highlightWeekends")}
- description={t("view.highlightWeekendsHint")}
- checked={days.includes(0) && days.includes(6)}
- onCheckedChange={(checked) =>
- onChange({
- highlightedWeekdays: checked
- ? Array.from(new Set([...days, 0, 6]))
- : days.filter((d) => d !== 0 && d !== 6),
- })
- }
- disabled={disabled}
- />
- <Field label={t("view.customWeekdays")} hint={t("view.customWeekdaysHint")}>
- <div className="grid grid-cols-7 gap-1.5">
- {weekdays.map(({ day, label }) => {
- const selected = days.includes(day);
- return (
- <button
- key={day}
- type="button"
- aria-pressed={selected}
- title={label}
- disabled={disabled}
- onClick={() =>
- onChange({
- highlightedWeekdays: selected
- ? days.filter((d) => d !== day)
- : [...days, day],
- })
- }
- className={cn(
- "h-9 rounded-lg border text-[12.5px] font-semibold",
- selected ? "border-brand text-brand-ink" : "border-line text-fg-secondary",
- !disabled && (selected ? "bg-brand-soft" : "bg-surface-card")
- )}
- >
- {label.slice(0, 2)}
- </button>
- );
- })}
- </div>
- </Field>
- <Field label={t("view.highlightColor")}>
- <ColorSwatches
- size="sm"
- value={value.highlightColor}
- onChange={(highlightColor) => onChange({ highlightColor })}
+ <section className="flex flex-col gap-3 border-t border-line pt-5">
+ <SectionLabel className="mb-0">{t("view.dayHighlighting")}</SectionLabel>
+ <ToggleRow
+ id={`${id}-weekends`}
+ title={t("view.highlightWeekends")}
+ description={t("view.highlightWeekendsHint")}
+ checked={days.includes(0) && days.includes(6)}
+ onCheckedChange={(checked) =>
+ onChange({
+ highlightedWeekdays: checked
+ ? Array.from(new Set([...days, 0, 6]))
+ : days.filter((d) => d !== 0 && d !== 6),
+ })
+ }
disabled={disabled}
/>
- </Field>
- </section>
+ <Field label={t("view.customWeekdays")} hint={t("view.customWeekdaysHint")}>
+ <div className="grid grid-cols-7 gap-1.5">
+ {weekdays.map(({ day, label }) => {
+ const selected = days.includes(day);
+ return (
+ <button
+ key={day}
+ type="button"
+ aria-pressed={selected}
+ title={label}
+ disabled={disabled}
+ onClick={() =>
+ onChange({
+ highlightedWeekdays: selected
+ ? days.filter((d) => d !== day)
+ : [...days, day],
+ })
+ }
+ className={cn(
+ "h-9 rounded-lg border text-[12.5px] font-semibold",
+ selected ? "border-brand text-brand-ink" : "border-line text-fg-secondary",
+ !disabled && (selected ? "bg-brand-soft" : "bg-surface-card")
+ )}
+ >
+ {label.slice(0, 2)}
+ </button>
+ );
+ })}
+ </div>
+ </Field>
+ <Field label={t("view.highlightColor")}>
+ <ColorSwatches
+ size="sm"
+ value={value.highlightColor}
+ onChange={(highlightColor) => onChange({ highlightColor })}
+ disabled={disabled}
+ />
+ </Field>
+ </section>
+ </div>
</div>
);
}
@@ -434,18 +447,22 @@ export function PersonalViewPanel({
const { calendars } = useCalendars();
const calendar = calendarId ? calendars.find((c) => c.id === calendarId) : undefined;
const { personal, updatePersonal, storedInAccount } = settings;
+ // The calendar's own view replaces these fields as a whole; the stamp bar and
+ // the own-shifts filter never come from it (see resolveViewSettings), so they stay editable
+ const overridden = !!calendar?.viewSettings;
return (
<PanelBody>
<div className="flex flex-col gap-5">
- {calendar?.viewSettings && (
+ {overridden && (
<InfoNote icon={Info}>
- {t("view.overriddenByCalendar", { calendar: calendar.name })}
+ {t("view.overriddenByCalendar", { calendar: calendar!.name })}
</InfoNote>
)}
<ViewFields
value={personal}
onChange={updatePersonal}
+ disabled={overridden}
stampBar={{
checked: personal.showStampBar,
onChange: (showStampBar) => updatePersonal({ showStampBar }),
diff --git a/messages/cs.json b/messages/cs.json
index c644662..7bdb061 100644
--- a/messages/cs.json
+++ b/messages/cs.json
@@ -250,7 +250,8 @@
"onlyMyShiftsHint": "V kalendáři a denním zobrazení ukáže jen směny, na které jste přiřazeni",
"onlyMyShiftsSignupsDisabledHint": "Přiřazení jsou pro tento kalendář vypnutá, proto zůstane prázdný.",
"settingsDescriptionLocal": "Vaše osobní zobrazení na tomto zařízení. Platí pro všechny kalendáře bez vlastního zobrazení.",
- "overriddenByCalendar": "„{calendar}“ má vlastní zobrazení. Vaše osobní zobrazení tam neplatí.",
+ "overriddenByCalendar": "„{calendar}“ má vlastní zobrazení. Níže vyšedlá nastavení tam neplatí; nahoře zůstávají vždy osobní.",
+ "personalSection": "Vždy osobní",
"calendarOwn": "Vlastní zobrazení pro tento kalendář",
"calendarOwnHint": "Platí pro všechny, kdo mají k tomuto kalendáři přístup.",
"calendarOffNote": "Každý tu vidí své osobní zobrazení. To vaše nastavíte v „Moje zobrazení“.",
diff --git a/messages/de.json b/messages/de.json
index d61c88a..e258094 100644
--- a/messages/de.json
+++ b/messages/de.json
@@ -250,7 +250,8 @@
"onlyMyShiftsHint": "Zeigt im Kalender und in der Tagesansicht nur Schichten, denen du zugewiesen bist",
"onlyMyShiftsSignupsDisabledHint": "Für diesen Kalender sind Zuweisungen deaktiviert, daher bleibt der Kalender leer.",
"settingsDescriptionLocal": "Deine persönliche Ansicht auf diesem Gerät. Gilt für alle Kalender ohne eigene Ansicht.",
- "overriddenByCalendar": "„{calendar}“ hat eine eigene Ansicht. Dort gilt deine persönliche Ansicht nicht.",
+ "overriddenByCalendar": "„{calendar}“ hat eine eigene Ansicht. Die ausgegrauten Einstellungen unten gelten dort nicht; nur die Einstellungen oben bleiben immer persönlich.",
+ "personalSection": "Immer persönlich",
"calendarOwn": "Eigene Ansicht für diesen Kalender",
"calendarOwnHint": "Gilt für alle mit Zugriff auf diesen Kalender.",
"calendarOffNote": "Alle sehen hier ihre persönliche Ansicht. Deine stellst du unter „Meine Ansicht“ ein.",
diff --git a/messages/en.json b/messages/en.json
index 9caba43..971e862 100644
--- a/messages/en.json
+++ b/messages/en.json
@@ -250,7 +250,8 @@
"onlyMyShiftsHint": "Shows only shifts you're assigned to in the calendar and day view",
"onlyMyShiftsSignupsDisabledHint": "Assignments are turned off for this calendar, so the calendar stays empty.",
"settingsDescriptionLocal": "Your personal view on this device. Applies to all calendars without their own view.",
- "overriddenByCalendar": "“{calendar}” has its own view. Your personal view does not apply there.",
+ "overriddenByCalendar": "“{calendar}” has its own view. The grayed-out settings below don't apply there; only the settings above always stay personal.",
+ "personalSection": "Always personal",
"calendarOwn": "Own view for this calendar",
"calendarOwnHint": "Applies to everyone with access to this calendar.",
"calendarOffNote": "Everyone sees their personal view here. You set yours under “My view”.",
diff --git a/messages/es.json b/messages/es.json
index 5463f45..1a4153a 100644
--- a/messages/es.json
+++ b/messages/es.json
@@ -250,7 +250,8 @@
"onlyMyShiftsHint": "Muestra en el calendario y la vista diaria solo los turnos asignados a ti",
"onlyMyShiftsSignupsDisabledHint": "Las asignaciones están desactivadas para este calendario, por lo que quedará vacío.",
"settingsDescriptionLocal": "Tu vista personal en este dispositivo. Se aplica a todos los calendarios sin vista propia.",
- "overriddenByCalendar": "«{calendar}» tiene su propia vista. Allí no se aplica tu vista personal.",
+ "overriddenByCalendar": "«{calendar}» tiene su propia vista. Los ajustes en gris de abajo no se aplican allí; solo los de arriba siguen siendo siempre personales.",
+ "personalSection": "Siempre personal",
"calendarOwn": "Vista propia para este calendario",
"calendarOwnHint": "Se aplica a todas las personas con acceso a este calendario.",
"calendarOffNote": "Aquí cada persona ve su vista personal. La tuya se ajusta en «Mi vista».",
diff --git a/messages/fr.json b/messages/fr.json
index 873835d..3486f55 100755
--- a/messages/fr.json
+++ b/messages/fr.json
@@ -250,7 +250,8 @@
"onlyMyShiftsHint": "N'affiche dans le calendrier et la vue journalière que les créneaux qui vous sont attribués",
"onlyMyShiftsSignupsDisabledHint": "Les attributions sont désactivées pour ce calendrier, il restera donc vide.",
"settingsDescriptionLocal": "Votre affichage personnel sur cet appareil. Il s’applique à tous les calendriers sans affichage propre.",
- "overriddenByCalendar": "« {calendar} » a son propre affichage. Votre affichage personnel ne s’y applique pas.",
+ "overriddenByCalendar": "« {calendar} » a son propre affichage. Les réglages grisés ci-dessous ne s’y appliquent pas ; seuls ceux du haut restent toujours personnels.",
+ "personalSection": "Toujours personnel",
"calendarOwn": "Affichage propre à ce calendrier",
"calendarOwnHint": "S’applique à toutes les personnes ayant accès à ce calendrier.",
"calendarOffNote": "Chacun voit ici son affichage personnel. Le vôtre se règle dans « Mon affichage ».",
diff --git a/messages/it.json b/messages/it.json
index 2e2ce19..31382f7 100644
--- a/messages/it.json
+++ b/messages/it.json
@@ -250,7 +250,8 @@
"onlyMyShiftsHint": "Mostra nel calendario e nella vista giornaliera solo i turni a te assegnati",
"onlyMyShiftsSignupsDisabledHint": "Le assegnazioni sono disattivate per questo calendario, quindi rimarrà vuoto.",
"settingsDescriptionLocal": "La tua vista personale su questo dispositivo. Vale per tutti i calendari senza una vista propria.",
- "overriddenByCalendar": "«{calendar}» ha una vista propria. Lì la tua vista personale non vale.",
+ "overriddenByCalendar": "«{calendar}» ha una vista propria. Le impostazioni in grigio qui sotto non valgono lì; solo quelle sopra restano sempre personali.",
+ "personalSection": "Sempre personale",
"calendarOwn": "Vista propria per questo calendario",
"calendarOwnHint": "Vale per tutte le persone con accesso a questo calendario.",
"calendarOffNote": "Qui ognuno vede la propria vista personale. La tua si imposta in «La mia vista».",