This commit is contained in:
Lars Westermann 2019-06-08 22:39:22 +02:00
parent 70e1c2ec26
commit f417764695
Signed by: lars.westermann
GPG key ID: 9D417FA5BB9D5E1D
5 changed files with 34 additions and 34 deletions
src/jsMain/kotlin/de/kif/frontend/views/calendar

View file

@ -37,11 +37,11 @@ class CalendarEntry(private val calendar: CalendarBody, view: HTMLElement) : Vie
var error by classList.property("error")
private var nextScroll = 0.0
val editable: Boolean
private val editable: Boolean
get() = calendar.editable
var moveLookRoom: Long? = null
var moveLookTime: Int? = null
private var moveLockRoom: Long? = null
private var moveLockTime: Int? = null
private fun onMove(event: MouseEvent) {
val position = event.toPoint() - mouseDelta
@ -51,10 +51,10 @@ class CalendarEntry(private val calendar: CalendarBody, view: HTMLElement) : Vie
}
if (cell != null) {
if (moveLookRoom != null && cell.roomId != moveLookRoom) {
if (moveLockRoom != null && cell.roomId != moveLockRoom) {
return
}
if (moveLookTime != null && cell.time != moveLookTime) {
if (moveLockTime != null && cell.time != moveLockTime) {
return
}
@ -123,8 +123,8 @@ class CalendarEntry(private val calendar: CalendarBody, view: HTMLElement) : Vie
newRoom,
calendar.day,
newTime,
lookRoom = false,
lookTime = false
lockRoom = false,
lockTime = false
)
)
html.remove()
@ -175,8 +175,8 @@ class CalendarEntry(private val calendar: CalendarBody, view: HTMLElement) : Vie
mouseDelta = event.toPoint() - p
moveLookRoom = if (s.lookRoom) s.room.id else null
moveLookTime = if (s.lookTime) s.time else null
moveLockRoom = if (s.lockRoom) s.room.id else null
moveLockTime = if (s.lockTime) s.time else null
startDrag()
}

View file

@ -19,35 +19,35 @@ class CalendarTools(entry: CalendarEntry) : ViewCollection<View>() {
fun update(schedule: Schedule) {
this.schedule = schedule
setName(schedule.room, schedule.time)
lookRoomButton.classList["disabled"] = !schedule.lookRoom
lookTimeButton.classList["disabled"] = !schedule.lookTime
lockRoomButton.classList["disabled"] = !schedule.lockRoom
lockTimeButton.classList["disabled"] = !schedule.lockTime
}
private lateinit var nameView: TextView
private lateinit var lookRoomButton: IconView
private lateinit var lookTimeButton: IconView
private lateinit var lockRoomButton: IconView
private lateinit var lockTimeButton: IconView
init {
boxView {
nameView = textView { }
lookRoomButton = iconView(MaterialIcon.GPS_FIXED) {
title = "Look room"
lockRoomButton = iconView(MaterialIcon.GPS_FIXED) {
title = "Lock room"
onClick {
entry.pending = true
launch {
val s = entry.schedule.get()
ScheduleRepository.update(s.copy(lookRoom = "disabled" in this.classList))
ScheduleRepository.update(s.copy(lockRoom = "disabled" in this.classList))
}
}
}
lookTimeButton = iconView(MaterialIcon.ALARM) {
title = "Look time slot"
lockTimeButton = iconView(MaterialIcon.ALARM) {
title = "Lock time slot"
onClick {
entry.pending = true
launch {
val s = entry.schedule.get()
ScheduleRepository.update(s.copy(lookTime = "disabled" in this.classList))
ScheduleRepository.update(s.copy(lockTime = "disabled" in this.classList))
}
}
}
@ -56,7 +56,7 @@ class CalendarTools(entry: CalendarEntry) : ViewCollection<View>() {
textView("-10") {
title = "Schedule 10 minutes earlier"
onClick {
if (schedule.lookTime) return@onClick
if (schedule.lockTime) return@onClick
entry.pending = true
launch {
@ -68,7 +68,7 @@ class CalendarTools(entry: CalendarEntry) : ViewCollection<View>() {
textView("-5") {
title = "Schedule 5 minutes earlier"
onClick {
if (schedule.lookTime) return@onClick
if (schedule.lockTime) return@onClick
entry.pending = true
launch {
@ -80,7 +80,7 @@ class CalendarTools(entry: CalendarEntry) : ViewCollection<View>() {
textView("+5") {
title = "Schedule 5 minutes later"
onClick {
if (schedule.lookTime) return@onClick
if (schedule.lockTime) return@onClick
entry.pending = true
launch {
@ -92,7 +92,7 @@ class CalendarTools(entry: CalendarEntry) : ViewCollection<View>() {
textView("+10") {
title = "Schedule 10 minutes later"
onClick {
if (schedule.lookTime) return@onClick
if (schedule.lockTime) return@onClick
entry.pending = true
launch {