From 5dba14c36809207d89bf7ae287f2c032aa938363 Mon Sep 17 00:00:00 2001 From: Lars Westermann Date: Sat, 15 Jun 2019 22:19:20 +0200 Subject: [PATCH] Change things --- src/jsMain/kotlin/de/kif/frontend/main.kt | 5 ++--- .../de/kif/frontend/views/calendar/Calendar.kt | 8 +++++++- .../kif/frontend/views/calendar/CalendarBody.kt | 17 +++++++---------- .../kif/frontend/views/calendar/CalendarCell.kt | 6 ++++++ .../kif/frontend/views/calendar/CalendarRow.kt | 7 +++---- .../de/westermann/kwebview/ViewCollection.kt | 8 +++++--- 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/jsMain/kotlin/de/kif/frontend/main.kt b/src/jsMain/kotlin/de/kif/frontend/main.kt index 2e59890..d01ee93 100644 --- a/src/jsMain/kotlin/de/kif/frontend/main.kt +++ b/src/jsMain/kotlin/de/kif/frontend/main.kt @@ -1,8 +1,5 @@ package de.kif.frontend -import de.kif.frontend.repository.RoomRepository -import de.kif.frontend.repository.ScheduleRepository -import de.kif.frontend.repository.WorkGroupRepository import de.kif.frontend.views.board.initBoard import de.kif.frontend.views.calendar.initCalendar import de.kif.frontend.views.initAnnouncement @@ -65,6 +62,7 @@ fun main() = init { } } + /* val url = window.location.pathname if ("brett" in url || "wand" in url) { ScheduleRepository.onCreate { @@ -95,4 +93,5 @@ fun main() = init { window.location.reload() } } + */ } diff --git a/src/jsMain/kotlin/de/kif/frontend/views/calendar/Calendar.kt b/src/jsMain/kotlin/de/kif/frontend/views/calendar/Calendar.kt index 09e20f0..276cc56 100644 --- a/src/jsMain/kotlin/de/kif/frontend/views/calendar/Calendar.kt +++ b/src/jsMain/kotlin/de/kif/frontend/views/calendar/Calendar.kt @@ -30,7 +30,7 @@ class Calendar(calendar: HTMLElement) : View(calendar) { val day = (calendarTable.dataset["day"]?.toIntOrNull() ?: -1) val reloadOnFinish = (calendarTable.dataset["reload"]?.toBoolean() ?: false) - val hideEmpty = (calendarTable.dataset["hide-empty"]?.toBoolean() ?: false) + val hideEmpty = (calendarTable.dataset["hideEmpty"]?.toBoolean() ?: false) val referenceDate = (calendarTable.dataset["reference"]?.toLongOrNull() ?: -1L) val nowDate = (calendarTable.dataset["now"]?.toLongOrNull() ?: -1L) val timeDifference = (Date.now().toLong() - nowDate) @@ -128,6 +128,12 @@ class Calendar(calendar: HTMLElement) : View(calendar) { fun updateVisibility() { visibleRooms = body.calendarCells.asSequence().filter { it.isNotEmpty() }.map { it.roomId }.toSet() + body.updateVisibility() + + for (element in calendarTableHeader.children) { + val id = element.dataset["room"]?.toLongOrNull() ?: continue + element.dataset["hidden"] = isRoomHidden(id).toString() + } } init { diff --git a/src/jsMain/kotlin/de/kif/frontend/views/calendar/CalendarBody.kt b/src/jsMain/kotlin/de/kif/frontend/views/calendar/CalendarBody.kt index b7327b2..37a0766 100644 --- a/src/jsMain/kotlin/de/kif/frontend/views/calendar/CalendarBody.kt +++ b/src/jsMain/kotlin/de/kif/frontend/views/calendar/CalendarBody.kt @@ -28,11 +28,12 @@ class CalendarBody(val calendar: Calendar, view: HTMLElement) : ViewCollection = emptyList() - val calendarCells: List get() = iterator().asSequence().flatten().toList() + val calendarEntries: List + get() = calendarCells.asSequence().flatten().toList() + var maxTime = 0 var minTime = 0 @@ -167,20 +168,17 @@ class CalendarBody(val calendar: Calendar, view: HTMLElement) : ViewCollection