This commit is contained in:
Lars Westermann 2019-06-13 02:35:06 +02:00
parent b473221f92
commit 4596a78697
Signed by: lars.westermann
GPG key ID: 9D417FA5BB9D5E1D
4 changed files with 32 additions and 7 deletions

View file

@ -21,6 +21,9 @@ class Calendar(calendar: HTMLElement) : View(calendar) {
val calendarTable = calendar.getElementsByClassName("calendar-table")[0] as HTMLElement
private val calendarTableHeader = calendar.getElementsByClassName("calendar-header")[0] as HTMLElement
val showAllWorkGroupsBtn =
(document.getElementById("calendar-all-work-groups") as? HTMLElement)?.let { wrap(it) }
private val htmlBody = document.body ?: createHtmlView()
val day = calendarTable.dataset["day"]?.toIntOrNull() ?: -1

View file

@ -58,12 +58,18 @@ class CalendarEdit(
for (workGroup in WorkGroupRepository.all()) {
workGroupList += CalendarWorkGroup(calendar, this, workGroup).also {
it.isScheduled = workGroup in scheduled
it.isScheduled = !showAll && workGroup in scheduled
}
}
}
}
fun update() {
for (wk in workGroupList) {
wk.isScheduled = !showAll && wk.workGroup in scheduled
}
}
init {
toggleEditButton.onClick {
calendar.classList.toggle("edit")
@ -73,6 +79,12 @@ class CalendarEdit(
}
}
calendar.showAllWorkGroupsBtn?.onClick?.addListener {
showAll = !showAll
calendar.showAllWorkGroupsBtn.classList.toggle("btn-primary", showAll)
update()
}
onWheel {
it.stopPropagation()
}
@ -96,8 +108,8 @@ class CalendarEdit(
val schedules = scheduled[schedule.workGroup] ?: emptyList()
scheduled += schedule.workGroup to schedules + schedule
workGroupList.firstOrNull { it.workGroup.id == schedule.workGroup.id }?.isScheduled = true
workGroupList.firstOrNull { it.workGroup.id == schedule.workGroup.id }?.isScheduled =
!showAll && schedule.workGroup in scheduled
}
}
@ -105,9 +117,15 @@ class CalendarEdit(
val schedule = scheduled.values.flatten().firstOrNull { it.id == id } ?: return@onDelete
val schedules = scheduled[schedule.workGroup] ?: emptyList()
val new = schedules - schedule
if (new.isEmpty())
scheduled -= schedule.workGroup
else
scheduled += schedule.workGroup to schedules - schedule
workGroupList.firstOrNull { it.workGroup.id == schedule.workGroup.id }?.isScheduled = true
workGroupList.firstOrNull { it.workGroup.id == schedule.workGroup.id }?.isScheduled =
!showAll && schedule.workGroup in scheduled
}
listView.listFactory(sortedList)

View file

@ -202,7 +202,7 @@ fun Route.account() {
}
get("/account/import") {
authenticateOrRedirect(Permission.SCHEDULE) { user ->
authenticateOrRedirect(Permission.SCHEDULE) {
val tracks = TrackRepository.all()
val wikiSections = WikiImporter.loadSections()

View file

@ -308,6 +308,10 @@ fun Route.calendar() {
id = "calendar-auto-check-constraints"
+"Auto check"
}
button(classes = "form-btn") {
id = "calendar-all-work-groups"
+"Alle AKs"
}
}
}
}