fix(calendar): en tom kalender skal sige hvorfor, ikke bare være tom
At vælge en kalender er nogen, der siger "vis mig den her". At gemme valget og lade gitteret stå tomt, til fejeren kommer forbi et kvarter senere, er en kalender, der påstår, at fjorten dage er fri — og personen står på siden med knappen under hånden. Gemningen henter nu selv. Og er der forbundet en konto uden at der er valgt nogen kalendere, siger visningen dét. "Der er ikke valgt en kalender" og "der er ikke booket noget" ser ens ud, og kun den ene er noget at gøre noget ved.
This commit is contained in:
@@ -197,8 +197,19 @@
|
||||
calendarsSaved = false;
|
||||
try {
|
||||
await api.setCalendars(shownCalendars);
|
||||
await loadCalendar();
|
||||
calendarsSaved = true;
|
||||
// And fetch, without being asked again.
|
||||
//
|
||||
// Ticking a calendar is somebody saying "show me this one". Saving the
|
||||
// choice and leaving the grid empty until the sweep comes round a quarter
|
||||
// of an hour later is a calendar that says a fortnight is clear — and the
|
||||
// person is on this page, watching, with the button under their hand.
|
||||
// Also what refreshes the panel: syncCalendarNow reloads it when it is done.
|
||||
if (shownCalendars.length) {
|
||||
await syncCalendarNow();
|
||||
} else {
|
||||
await loadCalendar();
|
||||
}
|
||||
} catch (e) {
|
||||
app.toast(humanMessage(e));
|
||||
} finally {
|
||||
|
||||
@@ -22,13 +22,18 @@
|
||||
/** Null until the first answer, so nothing flashes before it is known. */
|
||||
let window_ = $state(null);
|
||||
let connected = $state(null);
|
||||
/** Whether any calendar in the connected account is ticked. */
|
||||
let anyShown = $state(false);
|
||||
/** The dates the grid is showing, so the notice below can compare against them. */
|
||||
let showing = $state(null);
|
||||
|
||||
$effect(() => {
|
||||
api
|
||||
.getCalendar()
|
||||
.then((status) => (connected = status.connected))
|
||||
.then((status) => {
|
||||
connected = status.connected;
|
||||
anyShown = (status.calendars ?? []).some((c) => c.shown);
|
||||
})
|
||||
.catch(() => {
|
||||
// A calendar that could not be asked about is not a reason to withhold
|
||||
// the grid: the tasks in it are verdande's own and do not depend on
|
||||
@@ -101,6 +106,16 @@
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<!-- Connected, and nothing ticked. Worth its own sentence rather than an empty
|
||||
grid: "no calendar is chosen" and "nothing is booked" look identical, and
|
||||
only one of them is something to do about. -->
|
||||
{#if connected && !anyShown}
|
||||
<p class="hint">
|
||||
{t('cal.noneChosen')}
|
||||
<a href="/indstillinger/integrationer">{t('cal.settings')}</a>
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
{#if beyond}
|
||||
<p class="hint">{t('cal.beyondWindow', { from: window_.from, to: window_.to })}</p>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user