gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit384d3d23384d3d23|||PR give calendar months their own addressAtlas384d3d23/components/calendar.hl

4.4 KB

  1. // components/calendar.hl — `/`: the month view under the app header, with the user's private events (ticket calendar#2).
  2. // The faces below are what the month view calls (`emit server …`, the trailing `session` is always the server's since
  3. // hybriel #16): thin wrappers — the session and the window are checked here, the events live in lib/events.hl (the
  4. // answer: calendarView / settingsView, the six weeks on screen), the default reminders in lib/settings.hl.
  5. // Signed out: no session user → nothing is read or written.
  6. parent './main.hl'
  7. import MonthView from './month-view/month-view.hl'
  8. import { userIdOfSession } from '../lib/users.hl'
  9. import { saveEvent, deleteEvent, calendarView, settingsView } from '../lib/events.hl'
  10. import { saveDefaults } from '../lib/settings.hl'
  11. import { savePush, dropPush, hasPush, testPush, pushedUntil } from '../lib/push.hl'
  12. import { validWindow } from '../lib/events-helpers.hl'
  13. __title = 'Calendar'
  14. // the request's headers (hybriel #105, names lowercase): the month view writes its names in the request's language on
  15. // the first render (calendar#6)
  16. route = null
  17. String monthAddress = route != null && route.query != null ? route.query.m : null
  18. headers = null
  19. String requestLanguage = headers != null && headers['accept-language'] != null ? headers['accept-language'] : ''
  20. View {
  21. calendarPage {
  22. MonthView { acceptLanguage = requestLanguage monthAddress = monthAddress }
  23. }
  24. }
  25. on server calLoad(first, last, session) {
  26. u = userIdOfSession(session)
  27. if (u == null) { return { error = 'log in with ident first' } }
  28. if (!validWindow(first, last)) { return { error = 'not a date' } }
  29. return calendarView(u, first, last)
  30. }
  31. on server calSave(fields, first, last, session) {
  32. u = userIdOfSession(session)
  33. if (u == null) { return { error = 'log in with ident first' } }
  34. if (!validWindow(first, last)) { return { error = 'not a date' } }
  35. if (fields == null || hlTypeName(fields) != 'Hybrid') { return { error = 'the event must be an object' } }
  36. r = saveEvent(u, fields)
  37. if (r.error != null) { return { error = r.error } }
  38. return calendarView(u, first, last)
  39. }
  40. on server calDelete(id, first, last, session) {
  41. u = userIdOfSession(session)
  42. if (u == null) { return { error = 'log in with ident first' } }
  43. if (!validWindow(first, last)) { return { error = 'not a date' } }
  44. r = deleteEvent(u, id)
  45. if (r.error != null) { return { error = r.error } }
  46. return calendarView(u, first, last)
  47. }
  48. // the calendar settings: the default reminders (rows)
  49. on server calSettingsLoad(session) {
  50. u = userIdOfSession(session)
  51. if (u == null) { return { error = 'log in with ident first' } }
  52. return settingsView(u)
  53. }
  54. on server calSettingsSave(rows, session) {
  55. u = userIdOfSession(session)
  56. if (u == null) { return { error = 'log in with ident first' } }
  57. r = saveDefaults(u, rows)
  58. if (r.error != null) { return { error = r.error } }
  59. return settingsView(u)
  60. }
  61. // the same save as calSave, sent while the server cannot be reached: a statement-form emit the offline layer queues and
  62. // replays (an event that is also emitted in value form is never queued — hence its own name)
  63. on server calSaveQueued(fields, first, last, session) {
  64. u = userIdOfSession(session)
  65. if (u == null) { return { error = 'log in with ident first' } }
  66. if (fields == null || hlTypeName(fields) != 'Hybrid') { return { error = 'the event must be an object' } }
  67. r = saveEvent(u, fields)
  68. if (r.error != null) { return { error = r.error } }
  69. return { ok = true }
  70. }
  71. // Web Push (calendar#9): this device's push subscription and zone — stored, so a reminder reaches it with the page closed
  72. on server calPushSave(sub, zone, session) {
  73. u = userIdOfSession(session)
  74. if (u == null) { return { error = 'log in with ident first' } }
  75. return savePush(u, sub, zone)
  76. }
  77. // "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)
  78. on server calPushTest(endpoint, session) {
  79. u = userIdOfSession(session)
  80. if (u == null) { return { error = 'log in with ident first' } }
  81. return testPush(u, endpoint)
  82. }
  83. // P1: up to when the server has pushed this device's reminders (the page does not show those again as missed)
  84. on server calPushedUntil(endpoint, session) {
  85. u = userIdOfSession(session)
  86. if (u == null) { return { since = 0 } }
  87. return pushedUntil(u, endpoint)
  88. }
  89. // this device stops getting pushes
  90. on server calPushOff(endpoint, session) {
  91. u = userIdOfSession(session)
  92. if (u == null) { return { error = 'log in with ident first' } }
  93. return dropPush(u, endpoint)
  94. }

Branches

Latest commits

  • 384d3d23|||PR give calendar months their own addressAtlas
  • 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
  • 79e49b4dMerge branch 'hl-standard' into mainAtlas