diff options
-rw-r--r-- | module/calp/html/vcomponent.scm | 7 | ||||
-rw-r--r-- | static/components/vevent-edit.ts | 25 | ||||
-rw-r--r-- | static/globals.ts | 15 |
3 files changed, 24 insertions, 23 deletions
diff --git a/module/calp/html/vcomponent.scm b/module/calp/html/vcomponent.scm index b2959df5..23884b58 100644 --- a/module/calp/html/vcomponent.scm +++ b/module/calp/html/vcomponent.scm @@ -222,7 +222,7 @@ (h3 (input (@ (type "text") (placeholder "Sammanfattning") (name "summary") (required) - (class "interactive") (data-property "summary") + (data-property "summary") ; (value ,(prop ev 'SUMMARY)) ))) @@ -231,14 +231,12 @@ ,@(with-label "Starttid" '(date-time-input (@ (name "dtstart") - (class "interactive") (data-property "dtstart") ))) ,@(with-label "Sluttid" '(date-time-input (@ (name "dtend") - (class "interactive") (data-property "dtend")))) (div @@ -246,7 +244,6 @@ "Heldag?" `(input (@ (type "checkbox") (name "wholeday") - (onclick "wholeday_checkbox(this)") )))) ) @@ -256,7 +253,6 @@ `(input (@ (placeholder "Plats") (name "location") (type "text") - (class "interactive") (data-property "location") ; (value ,(or (prop ev 'LOCATION) "")) ))) @@ -264,7 +260,6 @@ ,@(with-label "Beskrivning" `(textarea (@ (placeholder "Beskrivning") - (class "interactive") (data-property "description") (name "description")) ; ,(prop ev 'DESCRIPTION) diff --git a/static/components/vevent-edit.ts b/static/components/vevent-edit.ts index b9c76dd3..e393b1ce 100644 --- a/static/components/vevent-edit.ts +++ b/static/components/vevent-edit.ts @@ -52,7 +52,8 @@ class ComponentEdit extends ComponentVEvent { this.redraw(data); - for (let el of this.getElementsByClassName("interactive")) { + // for (let el of this.getElementsByClassName("interactive")) { + for (let el of this.querySelectorAll("[data-property]")) { // console.log(el); el.addEventListener('input', () => { let obj = vcal_objects.get(this.uid) @@ -70,6 +71,25 @@ class ComponentEdit extends ComponentVEvent { }); } + let wholeday_ = this.querySelector('[name="wholeday"]') + if (wholeday_) { + let wholeday = wholeday_ as HTMLInputElement + + if (data.getProperty('dtstart')?.dateonly) { + wholeday.checked = true; + } + + wholeday.addEventListener('click', () => { + let chk = wholeday.checked + let start = data!.getProperty('dtstart') + let end = data!.getProperty('dtend') + start.dateonly = chk + end.dateonly = chk + data!.setProperty('dtstart', start); + data!.setProperty('dtend', end); + }); + } + let submit = this.querySelector('form') as HTMLFormElement submit.addEventListener('submit', (e) => { console.log(submit, e); @@ -84,7 +104,8 @@ class ComponentEdit extends ComponentVEvent { /* We only update our fields, instead of reinstansiating ourselves from the template, in hope that it's faster */ - for (let el of this.getElementsByClassName("interactive")) { + + for (let el of this.querySelectorAll("[data-property]")) { if (!(el instanceof HTMLElement)) continue; let p = el.dataset.property!; let d: any; diff --git a/static/globals.ts b/static/globals.ts index 6b689697..cb65d953 100644 --- a/static/globals.ts +++ b/static/globals.ts @@ -33,18 +33,3 @@ function find_block(uid: uid): ComponentBlock | null { // throw 'Popup not fonud'; return null; } - - - - - - - - -/* -function wholeday_checkbox(box: HTMLInputElement) { - box.closest('.timeinput')! - .querySelectorAll('input[is="date-time"]') - .forEach((el) => { (el as DateTimeInput).dateonly = box.checked }); -} -*/ |