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

View file

@ -10,8 +10,8 @@ data class Schedule(
val room: Room, val room: Room,
val day: Int, val day: Int,
val time: Int, val time: Int,
val lookRoom: Boolean, val lockRoom: Boolean,
val lookTime: Boolean, val lockTime: Boolean,
override val createdAt: Long = 0, override val createdAt: Long = 0,
override val updateAt: Long = 0 override val updateAt: Long = 0
) : Model { ) : Model {

View file

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

View file

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

View file

@ -60,8 +60,8 @@ object DbSchedule : Table() {
val roomId = long("room_id").index() val roomId = long("room_id").index()
val day = integer("day").index() val day = integer("day").index()
val time = integer("time_slot") val time = integer("time_slot")
val lookRoom = bool("look_room").default(false) val lockRoom = bool("lock_room").default(false)
val lookTime = bool("look_time").default(false) val lockTime = bool("lock_time").default(false)
val createdAt = long("createdAt") val createdAt = long("createdAt")
val updatedAt = long("updatedAt") val updatedAt = long("updatedAt")

View file

@ -24,8 +24,8 @@ object ScheduleRepository : Repository<Schedule> {
val roomId = row[DbSchedule.roomId] val roomId = row[DbSchedule.roomId]
val day = row[DbSchedule.day] val day = row[DbSchedule.day]
val time = row[DbSchedule.time] val time = row[DbSchedule.time]
val lookRoom = row[DbSchedule.lookRoom] val lockRoom = row[DbSchedule.lockRoom]
val lookTime = row[DbSchedule.lookTime] val lockTime = row[DbSchedule.lockTime]
val createdAt = row[DbSchedule.createdAt] val createdAt = row[DbSchedule.createdAt]
val updatedAt = row[DbSchedule.updatedAt] val updatedAt = row[DbSchedule.updatedAt]
@ -35,7 +35,7 @@ object ScheduleRepository : Repository<Schedule> {
val room = RoomRepository.get(roomId) val room = RoomRepository.get(roomId)
?: throw IllegalStateException("Room for schedule does not exist!") ?: throw IllegalStateException("Room for schedule does not exist!")
return Schedule(id, workGroup, room, day, time, lookRoom, lookTime, createdAt, updatedAt) return Schedule(id, workGroup, room, day, time, lockRoom, lockTime, createdAt, updatedAt)
} }
override suspend fun get(id: Long): Schedule? { override suspend fun get(id: Long): Schedule? {
@ -57,8 +57,8 @@ object ScheduleRepository : Repository<Schedule> {
it[roomId] = model.room.id ?: throw IllegalArgumentException("Room does not exist!") it[roomId] = model.room.id ?: throw IllegalArgumentException("Room does not exist!")
it[day] = model.day it[day] = model.day
it[time] = model.time it[time] = model.time
it[lookRoom] = model.lookRoom it[lockRoom] = model.lockRoom
it[lookTime] = model.lookTime it[lockTime] = model.lockTime
it[createdAt] = now it[createdAt] = now
it[updatedAt] = now it[updatedAt] = now
@ -81,8 +81,8 @@ object ScheduleRepository : Repository<Schedule> {
it[roomId] = model.room.id ?: throw IllegalArgumentException("Room does not exist!") it[roomId] = model.room.id ?: throw IllegalArgumentException("Room does not exist!")
it[day] = model.day it[day] = model.day
it[time] = model.time it[time] = model.time
it[lookRoom] = model.lookRoom it[lockRoom] = model.lockRoom
it[lookTime] = model.lookTime it[lockTime] = model.lockTime
it[updatedAt] = now it[updatedAt] = now
} }