From 1ef01481fa9e70ef688b24ffd7957b97f020bb2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 10 Dec 2021 01:49:11 +0100 Subject: Major move from week to calendar meta-view. Also repairs month view. --- static/components/vevent-block.ts | 61 +++++++++++++++++++++------------------ static/style.scss | 11 +++++-- 2 files changed, 41 insertions(+), 31 deletions(-) (limited to 'static') diff --git a/static/components/vevent-block.ts b/static/components/vevent-block.ts index 6b3e7dec..95c72592 100644 --- a/static/components/vevent-block.ts +++ b/static/components/vevent-block.ts @@ -48,34 +48,36 @@ class ComponentBlock extends ComponentVEvent { /* -------------------------------------------------- */ - let p; - if ((p = data.getProperty('dtstart'))) { - let c = this.closest('.event-container') as HTMLElement - let start = parseDate(c.dataset.start!).getTime() - let end = parseDate(c.dataset.end!).getTime(); - // console.log(p); - let pp = to_local(p).getTime() - let result = 100 * (Math.min(end, Math.max(start, pp)) - start) / (end - start) + "%" - if (c.classList.contains('longevents')) { - this.style.left = result - } else { - this.style.top = result + if (window.VIEW === 'week') { + let p; + if ((p = data.getProperty('dtstart'))) { + let c = this.closest('.event-container') as HTMLElement + let start = parseDate(c.dataset.start!).getTime() + let end = parseDate(c.dataset.end!).getTime(); + // console.log(p); + let pp = to_local(p).getTime() + let result = 100 * (Math.min(end, Math.max(start, pp)) - start) / (end - start) + "%" + if (c.classList.contains('longevents')) { + this.style.left = result + } else { + this.style.top = result + } + // console.log('dtstart', p); } - // console.log('dtstart', p); - } - if ((p = data.getProperty('dtend'))) { - // console.log('dtend', p); - let c = this.closest('.event-container') as HTMLElement - let start = parseDate(c.dataset.start!).getTime() - let end = parseDate(c.dataset.end!).getTime(); - let pp = to_local(p).getTime() - let result = 100 - (100 * (Math.min(end, Math.max(start, pp)) - start) / (end - start)) + "%" - if (c.classList.contains('longevents')) { - this.style.width = 'unset'; - this.style.right = result; - } else { - this.style.height = 'unset'; - this.style.bottom = result; + if ((p = data.getProperty('dtend'))) { + // console.log('dtend', p); + let c = this.closest('.event-container') as HTMLElement + let start = parseDate(c.dataset.start!).getTime() + let end = parseDate(c.dataset.end!).getTime(); + let pp = to_local(p).getTime() + let result = 100 - (100 * (Math.min(end, Math.max(start, pp)) - start) / (end - start)) + "%" + if (c.classList.contains('longevents')) { + this.style.width = 'unset'; + this.style.right = result; + } else { + this.style.height = 'unset'; + this.style.bottom = result; + } } } @@ -84,7 +86,10 @@ class ComponentBlock extends ComponentVEvent { } if (data.getProperty('rrule') !== undefined) { - (this.getElementsByClassName('repeating')![0] as HTMLElement).innerText = '↺' + let rep = this.getElementsByClassName('repeating') + if (rep && rep.length !== 0) { + (rep[0] as HTMLElement).innerText = '↺' + } } } } diff --git a/static/style.scss b/static/style.scss index 92ab9441..2ae55a31 100644 --- a/static/style.scss +++ b/static/style.scss @@ -332,12 +332,15 @@ along with their colors. .cal-cell { overflow-y: auto; - .event { + .event, vevent-block { font-size: 8pt; border-radius: 5px; padding: 2px; - margin: 2px; + margin-top: 2px; + margin-bottom: 2px; font-family: arial; + + box-sizing: border-box; } } @@ -545,7 +548,9 @@ vevent-block, .event { background-color: var(--color); color: var(--complement); - position: absolute; + // position: absolute; + display: block; + width: 100%; min-height: 1em; border: 1px solid black; -- cgit v1.2.3