calendar
All repositories: gitoria
4.3 KB
// components/calendar.hl — `/`: the month view under the app header, with the user's private events (ticket calendar#2).// The faces below are what the month view calls (`emit server …`, the trailing `session` is always the server's since// hybriel #16): thin wrappers — the session and the window are checked here, the events live in lib/events.hl (the// answer: calendarView / settingsView, the six weeks on screen), the default reminders in lib/settings.hl.// Signed out: no session user → nothing is read or written.parent './main.hl'import MonthView from './month-view/month-view.hl'import { userIdOfSession } from '../lib/users.hl'import { saveEvent, deleteEvent, calendarView, settingsView } from '../lib/events.hl'import { saveDefaults } from '../lib/settings.hl'import { savePush, dropPush, hasPush, testPush, pushedUntil } from '../lib/push.hl'import { validWindow } from '../lib/events-helpers.hl'__title = 'Calendar'// the request's headers (hybriel #105, names lowercase): the month view writes its names in the request's language on// the first render (calendar#6)headers = nullString requestLanguage = headers != null && headers['accept-language'] != null ? headers['accept-language'] : ''View {calendarPage {MonthView { acceptLanguage = requestLanguage }}}on server calLoad(first, last, session) {u = userIdOfSession(session)if (u == null) { return { error = 'log in with ident first' } }if (!validWindow(first, last)) { return { error = 'not a date' } }return calendarView(u, first, last)}on server calSave(fields, first, last, session) {u = userIdOfSession(session)if (u == null) { return { error = 'log in with ident first' } }if (!validWindow(first, last)) { return { error = 'not a date' } }if (fields == null || hlTypeName(fields) != 'Hybrid') { return { error = 'the event must be an object' } }r = saveEvent(u, fields)if (r.error != null) { return { error = r.error } }return calendarView(u, first, last)}on server calDelete(id, first, last, session) {u = userIdOfSession(session)if (u == null) { return { error = 'log in with ident first' } }if (!validWindow(first, last)) { return { error = 'not a date' } }r = deleteEvent(u, id)if (r.error != null) { return { error = r.error } }return calendarView(u, first, last)}// the calendar settings: the default reminders (rows)on server calSettingsLoad(session) {u = userIdOfSession(session)if (u == null) { return { error = 'log in with ident first' } }return settingsView(u)}on server calSettingsSave(rows, session) {u = userIdOfSession(session)if (u == null) { return { error = 'log in with ident first' } }r = saveDefaults(u, rows)if (r.error != null) { return { error = r.error } }return settingsView(u)}// the same save as calSave, sent while the server cannot be reached: a statement-form emit the offline layer queues and// replays (an event that is also emitted in value form is never queued — hence its own name)on server calSaveQueued(fields, first, last, session) {u = userIdOfSession(session)if (u == null) { return { error = 'log in with ident first' } }if (fields == null || hlTypeName(fields) != 'Hybrid') { return { error = 'the event must be an object' } }r = saveEvent(u, fields)if (r.error != null) { return { error = r.error } }return { ok = true }}// Web Push (calendar#9): this device's push subscription and zone — stored, so a reminder reaches it with the page closedon server calPushSave(sub, zone, session) {u = userIdOfSession(session)if (u == null) { return { error = 'log in with ident first' } }return savePush(u, sub, zone)}// "Send a test notification": one test push to this device in a few seconds (calendar#12: a phone owner can see that push reaches it)on server calPushTest(endpoint, session) {u = userIdOfSession(session)if (u == null) { return { error = 'log in with ident first' } }return testPush(u, endpoint)}// P1: up to when the server has pushed this device's reminders (the page does not show those again as missed)on server calPushedUntil(endpoint, session) {u = userIdOfSession(session)if (u == null) { return { since = 0 } }return pushedUntil(u, endpoint)}// this device stops getting pusheson server calPushOff(endpoint, session) {u = userIdOfSession(session)if (u == null) { return { error = 'log in with ident first' } }return dropPush(u, endpoint)}
Branches
Latest commits
- bc2d7776|||PR WIP calendar28: preserve toggle focus and chip specificityAtlas
- 189c4c8c|||PR WIP calendar28: replace visual class state with View conditionsAtlas
- fff2f537Merge branch 'calendar31-lib' into mainAtlas
- 07cde3dc|||PR keep worker records out of the repo; README vendor is day72Atlas
- a753b0ab|||PR move shared calendar logic to libAtlas
- b32a921dMerge branch 'vendor-day72' into mainAtlas
- 60a0dd19|||PR Hybriel day72 (00c9dbb8) instead of the withdrawn day73Atlas
- 53f5464dMerge branch 'calendar26-day73' into mainAtlas
- 338499ec|||PR Keep reminder settings open during editing and rejected savesAtlas
- ad9e8d59|||PR Use framework page and popover state, Hybriel day73Atlas
- cab224a1Re-vendor calendar to verified Hybriel day73Atlas
- f9b8f918Merge branch 'calendar-vendor-day61' into mainAtlas
- 66341793|||PR Vendor Hybriel day61Atlas
- 36fc596bMerge branch 'vendor-day59' into mainAtlas
- b37cc1da|||PR Vendor Hybriel day59Atlas
- 05665102Merge branch 'vendor-day56' into mainAtlas
- 687296fb|||PR Vendor Hybriel day56Atlas
- a6166d4eMerge branch 'hl-standard-3' into mainAtlas
- 6d0eb3b0|||PR Calendar day add buttons only when signed in (Kunibert minor)Atlas
- add4b499|||PR Make calendar day actions keyboard accessibleAtlas