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
src
jsMain/kotlin/de/kif/frontend/views/calendar
jvmMain/kotlin/de/kif/backend/route

View file

@ -21,6 +21,9 @@ class Calendar(calendar: HTMLElement) : View(calendar) {
val calendarTable = calendar.getElementsByClassName("calendar-table")[0] as HTMLElement val calendarTable = calendar.getElementsByClassName("calendar-table")[0] as HTMLElement
private val calendarTableHeader = calendar.getElementsByClassName("calendar-header")[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() private val htmlBody = document.body ?: createHtmlView()
val day = calendarTable.dataset["day"]?.toIntOrNull() ?: -1 val day = calendarTable.dataset["day"]?.toIntOrNull() ?: -1

View file

@ -58,12 +58,18 @@ class CalendarEdit(
for (workGroup in WorkGroupRepository.all()) { for (workGroup in WorkGroupRepository.all()) {
workGroupList += CalendarWorkGroup(calendar, this, workGroup).also { 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 { init {
toggleEditButton.onClick { toggleEditButton.onClick {
calendar.classList.toggle("edit") 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 { onWheel {
it.stopPropagation() it.stopPropagation()
} }
@ -95,9 +107,9 @@ class CalendarEdit(
val schedules = scheduled[schedule.workGroup] ?: emptyList() val schedules = scheduled[schedule.workGroup] ?: emptyList()
scheduled += schedule.workGroup to schedules + schedule scheduled += schedule.workGroup to schedules + schedule
workGroupList.firstOrNull { it.workGroup.id == schedule.workGroup.id }?.isScheduled =
workGroupList.firstOrNull { it.workGroup.id == schedule.workGroup.id }?.isScheduled = true !showAll && schedule.workGroup in scheduled
} }
} }
@ -105,9 +117,15 @@ class CalendarEdit(
val schedule = scheduled.values.flatten().firstOrNull { it.id == id } ?: return@onDelete val schedule = scheduled.values.flatten().firstOrNull { it.id == id } ?: return@onDelete
val schedules = scheduled[schedule.workGroup] ?: emptyList() val schedules = scheduled[schedule.workGroup] ?: emptyList()
scheduled += schedule.workGroup to schedules - schedule
workGroupList.firstOrNull { it.workGroup.id == schedule.workGroup.id }?.isScheduled = true 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 =
!showAll && schedule.workGroup in scheduled
} }
listView.listFactory(sortedList) listView.listFactory(sortedList)

View file

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

View file

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