Mark old schedules as finished
This commit is contained in:
parent
6d243f2903
commit
90b4a990af
|
@ -126,6 +126,10 @@ class CalendarBody(val calendar: Calendar, view: HTMLElement) : ViewCollection<C
|
||||||
calendar.scrollHorizontalTo((activeRow.offsetLeft - 100).toDouble(), scroll)
|
calendar.scrollHorizontalTo((activeRow.offsetLeft - 100).toDouble(), scroll)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (entry in calendarEntries) {
|
||||||
|
entry.updateTime(diff, currentTime)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
|
@ -35,6 +35,13 @@ class CalendarEntry(private val calendar: CalendarBody, view: HTMLElement) : Vie
|
||||||
var startTime = dataset["time"]?.toIntOrNull() ?: 0
|
var startTime = dataset["time"]?.toIntOrNull() ?: 0
|
||||||
var length = dataset["length"]?.toIntOrNull() ?: 0
|
var length = dataset["length"]?.toIntOrNull() ?: 0
|
||||||
|
|
||||||
|
private val finishedProperty = dataset.property("finished")
|
||||||
|
var finished: Boolean
|
||||||
|
get() = finishedProperty.value == "true"
|
||||||
|
set(value) {
|
||||||
|
finishedProperty.value = value.toString()
|
||||||
|
}
|
||||||
|
|
||||||
var pending by classList.property("pending")
|
var pending by classList.property("pending")
|
||||||
private var error by classList.property("error")
|
private var error by classList.property("error")
|
||||||
private var nextScroll = 0.0
|
private var nextScroll = 0.0
|
||||||
|
@ -218,6 +225,7 @@ class CalendarEntry(private val calendar: CalendarBody, view: HTMLElement) : Vie
|
||||||
if (schedule.id != null) scheduleId = schedule.id
|
if (schedule.id != null) scheduleId = schedule.id
|
||||||
this.schedule.set(schedule)
|
this.schedule.set(schedule)
|
||||||
|
|
||||||
|
html.removeAttribute("style")
|
||||||
style {
|
style {
|
||||||
val pos = (schedule.time % CALENDAR_GRID_WIDTH) / CALENDAR_GRID_WIDTH.toDouble()
|
val pos = (schedule.time % CALENDAR_GRID_WIDTH) / CALENDAR_GRID_WIDTH.toDouble()
|
||||||
|
|
||||||
|
@ -251,7 +259,6 @@ class CalendarEntry(private val calendar: CalendarBody, view: HTMLElement) : Vie
|
||||||
language = workGroup.language.code
|
language = workGroup.language.code
|
||||||
this.workGroup = workGroup
|
this.workGroup = workGroup
|
||||||
|
|
||||||
html.removeAttribute("style")
|
|
||||||
style {
|
style {
|
||||||
val size = workGroup.length / CALENDAR_GRID_WIDTH.toDouble()
|
val size = workGroup.length / CALENDAR_GRID_WIDTH.toDouble()
|
||||||
|
|
||||||
|
@ -274,6 +281,10 @@ class CalendarEntry(private val calendar: CalendarBody, view: HTMLElement) : Vie
|
||||||
calendarErrors?.setErrors(errors)
|
calendarErrors?.setErrors(errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateTime(diff: Int, currentTime: Int) {
|
||||||
|
finished = (diff < 0 || diff == 0 && startTime + length < currentTime)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun create(calendar: CalendarBody, schedule: Schedule): CalendarEntry {
|
fun create(calendar: CalendarBody, schedule: Schedule): CalendarEntry {
|
||||||
val entry = CalendarEntry(calendar, createHtmlView())
|
val entry = CalendarEntry(calendar, createHtmlView())
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 100%;
|
left: 100%;
|
||||||
margin-left: 1rem;
|
margin-left: 1rem;
|
||||||
border-right: solid 1px var(--input-border-color);
|
border-right: solid 1px var(--table-border-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,6 +302,18 @@
|
||||||
outline: solid 0.4rem var(--error-color);
|
outline: solid 0.4rem var(--error-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&[data-finished = "true"]::before {
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: var(--background-primary-color);
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
@include no-select()
|
@include no-select()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,7 @@ import kotlin.math.min
|
||||||
|
|
||||||
const val MINUTES_OF_DAY = 24 * 60
|
const val MINUTES_OF_DAY = 24 * 60
|
||||||
|
|
||||||
private fun DIV.calendarCell(schedule: Schedule?) {
|
private fun DIV.calendarEntry(schedule: Schedule, diff: Int, currentTime: Int) {
|
||||||
if (schedule != null) {
|
|
||||||
span("calendar-entry") {
|
span("calendar-entry") {
|
||||||
attributes["style"] = CSSBuilder().apply {
|
attributes["style"] = CSSBuilder().apply {
|
||||||
val size = schedule.workGroup.length / CALENDAR_GRID_WIDTH.toDouble()
|
val size = schedule.workGroup.length / CALENDAR_GRID_WIDTH.toDouble()
|
||||||
|
@ -56,12 +55,14 @@ private fun DIV.calendarCell(schedule: Schedule?) {
|
||||||
attributes["data-time"] = schedule.time.toString()
|
attributes["data-time"] = schedule.time.toString()
|
||||||
attributes["data-length"] = schedule.workGroup.length.toString()
|
attributes["data-length"] = schedule.workGroup.length.toString()
|
||||||
|
|
||||||
|
val finished = (diff < 0 || diff == 0 && schedule.time + schedule.workGroup.length < currentTime)
|
||||||
|
attributes["data-finished"] = finished.toString()
|
||||||
|
|
||||||
span("calendar-entry-name") {
|
span("calendar-entry-name") {
|
||||||
+schedule.workGroup.name
|
+schedule.workGroup.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun DIV.renderCalendar(
|
fun DIV.renderCalendar(
|
||||||
orientation: CalendarOrientation,
|
orientation: CalendarOrientation,
|
||||||
|
@ -145,7 +146,9 @@ fun DIV.renderCalendar(
|
||||||
|
|
||||||
val schedule = (start..end).mapNotNull { schedules[room]?.get(it) }.firstOrNull()
|
val schedule = (start..end).mapNotNull { schedules[room]?.get(it) }.firstOrNull()
|
||||||
|
|
||||||
calendarCell(schedule)
|
if (schedule != null) {
|
||||||
|
calendarEntry(schedule, diff, currentTime)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue