This commit is contained in:
Lars Westermann 2019-06-12 22:20:13 +02:00
parent 06e73365a9
commit 36bdad8036
Signed by: lars.westermann
GPG key ID: 9D417FA5BB9D5E1D
5 changed files with 29 additions and 2 deletions

View file

@ -24,6 +24,7 @@ class Calendar(calendar: HTMLElement) : View(calendar) {
private val htmlBody = document.body ?: createHtmlView()
val day = calendarTable.dataset["day"]?.toIntOrNull() ?: -1
val reloadOnFinish = calendarTable.dataset["reload"]?.toBoolean() ?: false
val referenceDate = calendarTable.dataset["reference"]?.toLongOrNull() ?: -1L
val nowDate = calendarTable.dataset["now"]?.toLongOrNull() ?: -1L
val timeDifference = Date.now().toLong() - nowDate

View file

@ -10,6 +10,7 @@ import org.w3c.dom.HTMLElement
import org.w3c.dom.INSTANT
import org.w3c.dom.SMOOTH
import org.w3c.dom.ScrollBehavior
import kotlin.browser.window
import kotlin.js.Date
import kotlin.math.max
import kotlin.math.min
@ -97,7 +98,10 @@ class CalendarBody(val calendar: Calendar, view: HTMLElement) : ViewCollection<C
var activeRow: CalendarRow? = null
var largestRowTime = Int.MIN_VALUE
for (row in this) {
largestRowTime = max(largestRowTime, row.time)
if (row.time == rowTime) {
row.classList.clear()
for (str in row.classList) {
@ -118,6 +122,10 @@ class CalendarBody(val calendar: Calendar, view: HTMLElement) : ViewCollection<C
}
}
if (largestRowTime < currentTime && calendar.reloadOnFinish) {
window.location.reload()
}
if (calendar.autoScroll && activeRow != null) {
if (calendar.orientation == Calendar.Orientation.ROOM_TO_TIME) {
calendar.scrollVerticalTo((activeRow.offsetTop - 150).toDouble(), scroll)

View file

@ -119,6 +119,21 @@
border-bottom: none;
}
& > div {
flex-grow: 0;
flex-shrink: 0;
}
.board-schedule-name {
flex-grow: 1 !important;
flex-shrink: 1 !important;
}
.board-schedule-room {
flex-grow: 1 !important;
flex-shrink: 1 !important;
}
.board-schedule-clock {
position: absolute;
left: 1rem;

View file

@ -174,7 +174,8 @@ fun Route.board() {
min,
max,
rooms,
schedules
schedules,
reloadAfterFinish = true
)
}
div("board-twitter") {

View file

@ -70,7 +70,8 @@ fun DIV.renderCalendar(
from: Int,
to: Int,
rooms: List<Room>,
schedules: Map<Room, Map<Int, List<Schedule>>>
schedules: Map<Room, Map<Int, List<Schedule>>>,
reloadAfterFinish: Boolean = false
) {
val gridLabelWidth = 60
val minutesOfDay = to - from
@ -85,6 +86,7 @@ fun DIV.renderCalendar(
attributes["data-day"] = day.toString()
attributes["data-reference"] = Configuration.Schedule.referenceDate.time.toString()
attributes["data-now"] = now.timeInMillis.toString()
attributes["data-reload"] = reloadAfterFinish.toString()
div("calendar-table-box ${orientation.name.toLowerCase().replace("_", "-")}") {
div("calendar-header") {