gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit651752c0651752c0|||PR run the browser gate once per deployAtlas651752c0/components/reminder-settings.hl

6.4 KB

  1. import { editRow, addRow, removeRow } from '../lib/reminder-rows.hl'
  2. // Reminder settings: calendar defaults and the device's notification controls.
  3. import { withIndex } from '../lib/reminders.hl'
  4. Hybrid setRows = []
  5. String setError = ''
  6. Boolean settingsOpen = false
  7. String askClass = 'hidden'
  8. String blockedClass = 'hidden'
  9. String plannedText = ''
  10. String pushText = ''
  11. String pushOffClass = 'hidden'
  12. Style {
  13. reminderBox {
  14. display = 'grid'
  15. gap = '.4rem'
  16. h3 {
  17. margin = '0'
  18. fontSize = '.85rem'
  19. fontWeight = '600'
  20. color = 'var(--color-text-muted, rgb(145, 150, 155))'
  21. }
  22. p {
  23. margin = '0'
  24. fontSize = '.85rem'
  25. color = 'var(--color-text-muted, rgb(145, 150, 155))'
  26. }
  27. }
  28. '#set-rows' {
  29. display = 'grid'
  30. gridTemplateColumns = 'minmax(0, 1fr)'
  31. gap = '.5rem'
  32. margin = '0'
  33. padding = '0'
  34. listStyle = 'none'
  35. }
  36. reminderRow {
  37. display = 'grid'
  38. gridTemplateColumns = '5rem minmax(0, 1fr) 2.75rem'
  39. alignItems = 'center'
  40. gap = '.4rem'
  41. input {
  42. minWidth = '0'
  43. width = '100%'
  44. }
  45. select {
  46. minWidth = '0'
  47. width = '100%'
  48. gridColumn = '2'
  49. }
  50. 'input[type=time]' {
  51. gridColumn = '1 / 3'
  52. }
  53. button {
  54. gridColumn = '3'
  55. gridRow = '1'
  56. minWidth = '2.75rem'
  57. minHeight = '2.75rem'
  58. padding = '0'
  59. }
  60. }
  61. 'reminder-row.other' {
  62. 'input[type=time]' {
  63. display = 'none'
  64. }
  65. }
  66. formButtons {
  67. display = 'flex'
  68. flexWrap = 'wrap'
  69. gap = '.5rem'
  70. 'button.danger' {
  71. marginLeft = 'auto'
  72. }
  73. }
  74. eventEditor {
  75. position = 'fixed'
  76. inset = '0'
  77. zIndex = '40'
  78. display = 'grid'
  79. placeItems = 'center'
  80. padding = '1rem'
  81. background = 'color-mix(in srgb, var(--color-background-sunken) 82%, transparent)'
  82. form {
  83. display = 'grid'
  84. gap = '.7rem'
  85. width = '100%'
  86. maxWidth = '28rem'
  87. maxHeight = '100%'
  88. overflowY = 'auto'
  89. padding = '1rem'
  90. background = 'var(--color-surface)'
  91. borderRadius = 'var(--radius-large)'
  92. }
  93. h2 {
  94. margin = '0'
  95. }
  96. input {
  97. width = '100%'
  98. color = 'var(--color-text-strong)'
  99. }
  100. }
  101. 'event-editor.closed' {
  102. display = 'none'
  103. }
  104. 'event-editor[popover]' {
  105. width = '100%'
  106. height = '100%'
  107. maxWidth = 'none'
  108. maxHeight = 'none'
  109. margin = '0'
  110. border = '0'
  111. overflow = 'hidden'
  112. color = 'var(--color-text)'
  113. }
  114. 'event-editor[popover]:not(:popover-open)' {
  115. display = 'none'
  116. }
  117. @media {
  118. minWidth = '60rem'
  119. reminderRow {
  120. gridTemplateColumns = '5rem minmax(0, 1fr) 7.5rem 2.75rem'
  121. 'input[type=time]' {
  122. gridColumn = '3'
  123. }
  124. button {
  125. gridColumn = '4'
  126. }
  127. }
  128. 'reminder-row.other' {
  129. select {
  130. gridColumn = '2 / 4'
  131. }
  132. }
  133. }
  134. notifyBox {
  135. display = 'grid'
  136. gap = '.5rem'
  137. h3 {
  138. margin = '0'
  139. fontSize = '.85rem'
  140. fontWeight = '600'
  141. color = 'var(--color-text-muted, rgb(145, 150, 155))'
  142. }
  143. p {
  144. margin = '0'
  145. fontSize = '.85rem'
  146. color = 'var(--color-text-muted, rgb(145, 150, 155))'
  147. empty {
  148. display = 'none'
  149. }
  150. }
  151. button {
  152. width = '100%'
  153. }
  154. }
  155. '#notify-ask' {
  156. color = 'var(--color-accent-text)'
  157. background = 'var(--color-accent)'
  158. }
  159. '.hidden' {
  160. display = 'none'
  161. }
  162. }
  163. View {
  164. eventEditor { id = "settingseditor" popover = "manual" popoverOpen = settingsOpen on toggle(Hybrid e) { emit settingsToggled(e) } on keydown(Hybrid e) { emit settingsKey(e) }
  165. form { id = "settingsform" class = "timed"
  166. on submit(Hybrid e) {
  167. e.preventDefault()
  168. emit saveSettings(e)
  169. }
  170. h2 { "Reminder settings" }
  171. notifyBox {
  172. h3 { "Notifications on this device" }
  173. p { id = "notify-blocked" class = blockedClass "Notifications are blocked for this site in the browser settings." }
  174. p { id = "notify-planned" plannedText }
  175. p { id = "push-state" pushText }
  176. button { id = "notify-ask" type = "button" class = askClass "Turn on notifications" on click(Hybrid e) { $parent.askNotify(e) } }
  177. button { id = "push-test" type = "button" class = pushOffClass "Send a test notification" on click(Hybrid e) { $parent.pushTest(e) } }
  178. button { id = "push-off" type = "button" class = pushOffClass "Turn off on this device" on click(Hybrid e) { $parent.pushOff(e) } }
  179. }
  180. reminderBox {
  181. h3 { "Default reminders" }
  182. p { class = "muted" "Every event without reminders of its own is reminded like this:" }
  183. ol { id = "set-rows"
  184. for (r of setRows) {
  185. reminderRow { class = r.cls
  186. input { type = "number" min = "0" value = r.n on change(Hybrid e) { emit setDefaultRow('set', r.i, 'n', e.target.value) } }
  187. select { value = r.unit on change(Hybrid e) { emit setDefaultRow('set', r.i, 'unit', e.target.value) }
  188. option { value = "minutes" "minutes before" }
  189. option { value = "hours" "hours before" }
  190. option { value = "days" "days before, at" }
  191. }
  192. input { type = "time" value = r.time on change(Hybrid e) { emit setDefaultRow('set', r.i, 'time', e.target.value) } }
  193. button { type = "button" class = "quiet" "×" on click(Hybrid e) { emit delDefaultRow('set', r.i) } }
  194. }
  195. }
  196. }
  197. button { id = "set-add" type = "button" class = "quiet" "Add reminder" on click(Hybrid e) { emit addDefaultRow('set') } }
  198. }
  199. p { id = "settingserror" class = "message" setError }
  200. formButtons {
  201. button { id = "set-save" type = "submit" "Save" }
  202. button { id = "set-cancel" type = "button" class = "quiet" popovertarget = "settingseditor" popovertargetaction = "hide" autofocus = "autofocus" "Cancel" }
  203. }
  204. }
  205. }
  206. }
  207. on setDefaultRow(String which, Number i, String field, String value) {
  208. setRows = editRow(setRows, i, field, value)
  209. }
  210. on addDefaultRow(String which) {
  211. setRows = addRow(setRows)
  212. }
  213. on delDefaultRow(String which, Number i) {
  214. setRows = removeRow(setRows, i)
  215. }
  216. on settingsToggled(Hybrid e) {
  217. settingsOpen = e.newState == 'open'
  218. if (e.newState != 'open') { return null }
  219. // no pointer event of the month view may have come yet, so the page's browser state is read now —
  220. // the notification section is right on the first look (and a device that allowed notifications is subscribed)
  221. $parent.refreshDevice()
  222. r = emit server calSettingsLoad()
  223. if (r == null || r.error != null) {
  224. setError = r == null ? 'the settings need the server: you are offline' : r.error
  225. return null
  226. }
  227. setRows = withIndex(r.rows)
  228. setError = ''
  229. }
  230. on settingsKey(Hybrid e) {
  231. if (e.key == 'Escape') { settingsOpen = false }
  232. }
  233. on saveSettings(Hybrid e) {
  234. r = emit server calSettingsSave(setRows)
  235. if (r == null || r.error != null) {
  236. setError = r == null ? 'the settings could not be saved (offline?)' : r.error
  237. return null
  238. }
  239. settingsOpen = false
  240. $parent.takeSoon(r)
  241. }

Branches

Latest commits

  • 651752c0|||PR run the browser gate once per deployAtlas
  • e24e28a1|||PR preserve calendar state across month addresses and split dialogsAtlas
  • 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