Bugfixes
This commit is contained in:
parent
6db71915b4
commit
f02124cbe8
|
@ -164,8 +164,8 @@ fun checkConstraints(
|
|||
if (
|
||||
s.workGroup.id == constraint.workGroup &&
|
||||
schedule.day == s.day &&
|
||||
start <= s.getAbsoluteEndTime() &&
|
||||
s.getAbsoluteStartTime() <= end
|
||||
start < s.getAbsoluteEndTime() &&
|
||||
s.getAbsoluteStartTime() < end
|
||||
) {
|
||||
errors += ConstraintError("Work group requires not same time with ${s.workGroup.name}!")
|
||||
}
|
||||
|
|
|
@ -26,11 +26,11 @@ 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
|
||||
val day = (calendarTable.dataset["day"]?.toIntOrNull() ?: -1).also { println(it) }
|
||||
val reloadOnFinish = (calendarTable.dataset["reload"]?.toBoolean() ?: false).also { println(it) }
|
||||
val referenceDate = (calendarTable.dataset["reference"]?.toLongOrNull() ?: -1L).also { println(it) }
|
||||
val nowDate = (calendarTable.dataset["now"]?.toLongOrNull() ?: -1L).also { println(it) }
|
||||
val timeDifference = (Date.now().toLong() - nowDate).also { println(it) }
|
||||
|
||||
fun scrollVerticalBy(pixel: Double, scrollBehavior: ScrollBehavior = ScrollBehavior.SMOOTH) {
|
||||
scrollAllVerticalBy(pixel, scrollBehavior)
|
||||
|
@ -226,4 +226,4 @@ class Calendar(calendar: HTMLElement) : View(calendar) {
|
|||
|
||||
fun initCalendar() {
|
||||
document.getElementsByClassName("calendar").iterator().forEach { Calendar(it) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,13 @@ import kotlin.js.Date
|
|||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
fun getYearOfDate(date: Date): Int {
|
||||
return ((Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) - Date.UTC(
|
||||
date.getFullYear(),
|
||||
0,
|
||||
0
|
||||
)) / 24 / 60 / 60 / 1000).toInt()
|
||||
}
|
||||
|
||||
class CalendarBody(val calendar: Calendar, view: HTMLElement) : ViewCollection<CalendarRow>(view) {
|
||||
|
||||
|
@ -26,6 +33,9 @@ class CalendarBody(val calendar: Calendar, view: HTMLElement) : ViewCollection<C
|
|||
val calendarCells: List<CalendarCell>
|
||||
get() = iterator().asSequence().flatten().toList()
|
||||
|
||||
var maxTime = 0
|
||||
var minTime = 0
|
||||
|
||||
private suspend fun updateRows(startTime: Int? = null, length: Int = 0) {
|
||||
if (calendarEntries.isEmpty() && startTime == null && !editable) {
|
||||
for (row in iterator().asSequence().toList()) {
|
||||
|
@ -64,6 +74,18 @@ class CalendarBody(val calendar: Calendar, view: HTMLElement) : ViewCollection<C
|
|||
min = (min / 60 - 1) * 60
|
||||
max = (max / 60 + 2) * 60
|
||||
|
||||
if (min == minTime && max == maxTime) return
|
||||
|
||||
minTime = min
|
||||
maxTime = max
|
||||
|
||||
min = calendarBodies.map { it.minTime }.min() ?: min
|
||||
max = calendarBodies.map { it.maxTime }.max() ?: max
|
||||
|
||||
calendarBodies.filter { it != this }.forEach {
|
||||
it.updateRows()
|
||||
}
|
||||
|
||||
while (isNotEmpty() && min > first().time) {
|
||||
remove(first())
|
||||
}
|
||||
|
@ -87,10 +109,11 @@ class CalendarBody(val calendar: Calendar, view: HTMLElement) : ViewCollection<C
|
|||
|
||||
fun update(scroll: ScrollBehavior) {
|
||||
val now = Date.now().toLong() - calendar.timeDifference
|
||||
val refDay = calendar.referenceDate / (1000 * 60 * 60 * 24)
|
||||
val nowDay = now / (1000 * 60 * 60 * 24)
|
||||
val refDay = getYearOfDate(Date(calendar.referenceDate))
|
||||
val nowDay = getYearOfDate(Date(now))
|
||||
val d = nowDay - refDay
|
||||
val diff = (day - d).toInt()
|
||||
val diff = (day - d)
|
||||
|
||||
val date = Date(now)
|
||||
val currentTime = date.getHours() * 60 + date.getMinutes() + (diff * 60 * 24)
|
||||
|
||||
|
@ -140,6 +163,8 @@ class CalendarBody(val calendar: Calendar, view: HTMLElement) : ViewCollection<C
|
|||
}
|
||||
|
||||
init {
|
||||
calendarBodies += this
|
||||
|
||||
calendarEntries = view.getElementsByClassName("calendar-entry")
|
||||
.iterator().asSequence().map { CalendarEntry(this, it) }.toList()
|
||||
|
||||
|
@ -198,4 +223,8 @@ class CalendarBody(val calendar: Calendar, view: HTMLElement) : ViewCollection<C
|
|||
update(ScrollBehavior.SMOOTH)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val calendarBodies: MutableList<CalendarBody> = mutableListOf()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,10 +51,11 @@ fun Route.board() {
|
|||
val referenceTime = Configuration.Schedule.referenceDate.time
|
||||
|
||||
val refDate = Configuration.Schedule.referenceDate
|
||||
val todayDate = now
|
||||
|
||||
val refDay = refDate.time / (1000 * 60 * 60 * 24)
|
||||
val todayDay = now.time / (1000 * 60 * 60 * 24)
|
||||
val day = (todayDay - refDay).toInt()
|
||||
val refDay = Calendar.getInstance().also { it.time = todayDate }.get(Calendar.DAY_OF_YEAR)
|
||||
val todayDay = Calendar.getInstance().also { it.time = refDate }.get(Calendar.DAY_OF_YEAR)
|
||||
val day = todayDay - refDay
|
||||
|
||||
val list = ScheduleRepository.getByDay(day)
|
||||
val rooms = RoomRepository.all()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.kif.backend.route
|
||||
|
||||
import com.soywiz.klock.*
|
||||
import com.soywiz.klock.jvm.toDateTime
|
||||
import com.soywiz.klock.DateTime
|
||||
import com.soywiz.klock.days
|
||||
import de.kif.backend.Configuration
|
||||
import de.kif.backend.isAuthenticated
|
||||
import de.kif.backend.prefix
|
||||
|
@ -77,10 +77,13 @@ fun DIV.renderCalendar(
|
|||
val gridLabelWidth = 60
|
||||
val minutesOfDay = to - from
|
||||
|
||||
val refDate = Configuration.Schedule.referenceDate
|
||||
val todayDate = Date()
|
||||
val now = Calendar.getInstance()
|
||||
val d = (now.timeInMillis / (1000 * 60 * 60 * 24) -
|
||||
Configuration.Schedule.referenceDate.time / (1000 * 60 * 60 * 24)).toInt()
|
||||
val diff = day - d
|
||||
val refDay = Calendar.getInstance().also { it.time = todayDate }.get(Calendar.DAY_OF_YEAR)
|
||||
val todayDay = Calendar.getInstance().also { it.time = refDate }.get(Calendar.DAY_OF_YEAR)
|
||||
val diff = day - (todayDay - refDay)
|
||||
|
||||
val currentTime = now.get(Calendar.HOUR_OF_DAY) * 60 + now.get(Calendar.MINUTE) + (diff * 60 * 24)
|
||||
|
||||
div("calendar-table") {
|
||||
|
@ -188,8 +191,8 @@ fun Route.calendar() {
|
|||
val refDate = Configuration.Schedule.referenceDate
|
||||
val todayDate = Date()
|
||||
|
||||
val refDay = refDate.time / (1000 * 60 * 60 * 24)
|
||||
val todayDay = todayDate.time / (1000 * 60 * 60 * 24)
|
||||
val refDay = Calendar.getInstance().also { it.time = todayDate }.get(Calendar.DAY_OF_YEAR)
|
||||
val todayDay = Calendar.getInstance().also { it.time = refDate }.get(Calendar.DAY_OF_YEAR)
|
||||
val day = todayDay - refDay
|
||||
|
||||
call.respondRedirect("$prefix/calendar/$day", false)
|
||||
|
|
Loading…
Reference in a new issue