calendar
All repositories: gitoria
6.4 KB
import { editRow, addRow, removeRow } from '../lib/reminder-rows.hl'// Reminder settings: calendar defaults and the device's notification controls.import { withIndex } from '../lib/reminders.hl'Hybrid setRows = []String setError = ''Boolean settingsOpen = falseString askClass = 'hidden'String blockedClass = 'hidden'String plannedText = ''String pushText = ''String pushOffClass = 'hidden'Style {reminderBox {display = 'grid'gap = '.4rem'h3 {margin = '0'fontSize = '.85rem'fontWeight = '600'color = 'var(--color-text-muted, rgb(145, 150, 155))'}p {margin = '0'fontSize = '.85rem'color = 'var(--color-text-muted, rgb(145, 150, 155))'}}'#set-rows' {display = 'grid'gridTemplateColumns = 'minmax(0, 1fr)'gap = '.5rem'margin = '0'padding = '0'listStyle = 'none'}reminderRow {display = 'grid'gridTemplateColumns = '5rem minmax(0, 1fr) 2.75rem'alignItems = 'center'gap = '.4rem'input {minWidth = '0'width = '100%'}select {minWidth = '0'width = '100%'gridColumn = '2'}'input[type=time]' {gridColumn = '1 / 3'}button {gridColumn = '3'gridRow = '1'minWidth = '2.75rem'minHeight = '2.75rem'padding = '0'}}'reminder-row.other' {'input[type=time]' {display = 'none'}}formButtons {display = 'flex'flexWrap = 'wrap'gap = '.5rem''button.danger' {marginLeft = 'auto'}}eventEditor {position = 'fixed'inset = '0'zIndex = '40'display = 'grid'placeItems = 'center'padding = '1rem'background = 'color-mix(in srgb, var(--color-background-sunken) 82%, transparent)'form {display = 'grid'gap = '.7rem'width = '100%'maxWidth = '28rem'maxHeight = '100%'overflowY = 'auto'padding = '1rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'}h2 {margin = '0'}input {width = '100%'color = 'var(--color-text-strong)'}}'event-editor.closed' {display = 'none'}'event-editor[popover]' {width = '100%'height = '100%'maxWidth = 'none'maxHeight = 'none'margin = '0'border = '0'overflow = 'hidden'color = 'var(--color-text)'}'event-editor[popover]:not(:popover-open)' {display = 'none'}@media {minWidth = '60rem'reminderRow {gridTemplateColumns = '5rem minmax(0, 1fr) 7.5rem 2.75rem''input[type=time]' {gridColumn = '3'}button {gridColumn = '4'}}'reminder-row.other' {select {gridColumn = '2 / 4'}}}notifyBox {display = 'grid'gap = '.5rem'h3 {margin = '0'fontSize = '.85rem'fontWeight = '600'color = 'var(--color-text-muted, rgb(145, 150, 155))'}p {margin = '0'fontSize = '.85rem'color = 'var(--color-text-muted, rgb(145, 150, 155))'empty {display = 'none'}}button {width = '100%'}}'#notify-ask' {color = 'var(--color-accent-text)'background = 'var(--color-accent)'}'.hidden' {display = 'none'}}View {eventEditor { id = "settingseditor" popover = "manual" popoverOpen = settingsOpen on toggle(Hybrid e) { emit settingsToggled(e) } on keydown(Hybrid e) { emit settingsKey(e) }form { id = "settingsform" class = "timed"on submit(Hybrid e) {e.preventDefault()emit saveSettings(e)}h2 { "Reminder settings" }notifyBox {h3 { "Notifications on this device" }p { id = "notify-blocked" class = blockedClass "Notifications are blocked for this site in the browser settings." }p { id = "notify-planned" plannedText }p { id = "push-state" pushText }button { id = "notify-ask" type = "button" class = askClass "Turn on notifications" on click(Hybrid e) { $parent.askNotify(e) } }button { id = "push-test" type = "button" class = pushOffClass "Send a test notification" on click(Hybrid e) { $parent.pushTest(e) } }button { id = "push-off" type = "button" class = pushOffClass "Turn off on this device" on click(Hybrid e) { $parent.pushOff(e) } }}reminderBox {h3 { "Default reminders" }p { class = "muted" "Every event without reminders of its own is reminded like this:" }ol { id = "set-rows"for (r of setRows) {reminderRow { class = r.clsinput { type = "number" min = "0" value = r.n on change(Hybrid e) { emit setDefaultRow('set', r.i, 'n', e.target.value) } }select { value = r.unit on change(Hybrid e) { emit setDefaultRow('set', r.i, 'unit', e.target.value) }option { value = "minutes" "minutes before" }option { value = "hours" "hours before" }option { value = "days" "days before, at" }}input { type = "time" value = r.time on change(Hybrid e) { emit setDefaultRow('set', r.i, 'time', e.target.value) } }button { type = "button" class = "quiet" "×" on click(Hybrid e) { emit delDefaultRow('set', r.i) } }}}}button { id = "set-add" type = "button" class = "quiet" "Add reminder" on click(Hybrid e) { emit addDefaultRow('set') } }}p { id = "settingserror" class = "message" setError }formButtons {button { id = "set-save" type = "submit" "Save" }button { id = "set-cancel" type = "button" class = "quiet" popovertarget = "settingseditor" popovertargetaction = "hide" autofocus = "autofocus" "Cancel" }}}}}on setDefaultRow(String which, Number i, String field, String value) {setRows = editRow(setRows, i, field, value)}on addDefaultRow(String which) {setRows = addRow(setRows)}on delDefaultRow(String which, Number i) {setRows = removeRow(setRows, i)}on settingsToggled(Hybrid e) {settingsOpen = e.newState == 'open'if (e.newState != 'open') { return null }// no pointer event of the month view may have come yet, so the page's browser state is read now —// the notification section is right on the first look (and a device that allowed notifications is subscribed)$parent.refreshDevice()r = emit server calSettingsLoad()if (r == null || r.error != null) {setError = r == null ? 'the settings need the server: you are offline' : r.errorreturn null}setRows = withIndex(r.rows)setError = ''}on settingsKey(Hybrid e) {if (e.key == 'Escape') { settingsOpen = false }}on saveSettings(Hybrid e) {r = emit server calSettingsSave(setRows)if (r == null || r.error != null) {setError = r == null ? 'the settings could not be saved (offline?)' : r.errorreturn null}settingsOpen = false$parent.takeSoon(r)}
Branches
Latest commits
- 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
- add4b499|||PR Make calendar day actions keyboard accessibleAtlas