Add reso check and room list
This commit is contained in:
parent
fface0e5ba
commit
94c35b9067
13 changed files with 193 additions and 90 deletions
|
@ -1,6 +1,7 @@
|
|||
package de.kif.frontend.views
|
||||
|
||||
import de.kif.frontend.launch
|
||||
import de.kif.frontend.repository.RoomRepository
|
||||
import de.kif.frontend.repository.WorkGroupRepository
|
||||
import de.westermann.kobserve.event.EventListener
|
||||
import de.westermann.kwebview.View
|
||||
|
@ -10,6 +11,7 @@ import de.westermann.kwebview.createHtmlView
|
|||
import de.westermann.kwebview.iterator
|
||||
import org.w3c.dom.*
|
||||
import kotlin.browser.document
|
||||
import kotlin.dom.clear
|
||||
|
||||
fun initWorkGroupConstraints() {
|
||||
var index = 10000
|
||||
|
@ -149,10 +151,15 @@ fun initWorkGroupConstraints() {
|
|||
launch {
|
||||
val all = WorkGroupRepository.all()
|
||||
|
||||
val id = (select.options[select.selectedIndex] as? HTMLOptionElement)?.value
|
||||
|
||||
for (wg in all) {
|
||||
val option = createHtmlView<HTMLOptionElement>()
|
||||
option.value = wg.id.toString()
|
||||
option.textContent = wg.name
|
||||
if (option.value == id) {
|
||||
option.selected = true
|
||||
}
|
||||
select.appendChild(option)
|
||||
}
|
||||
}
|
||||
|
@ -177,10 +184,49 @@ fun initWorkGroupConstraints() {
|
|||
launch {
|
||||
val all = WorkGroupRepository.all()
|
||||
|
||||
val id = (select.options[select.selectedIndex] as? HTMLOptionElement)?.value
|
||||
|
||||
for (wg in all) {
|
||||
val option = createHtmlView<HTMLOptionElement>()
|
||||
option.value = wg.id.toString()
|
||||
option.textContent = wg.name
|
||||
if (option.value == id) {
|
||||
option.selected = true
|
||||
}
|
||||
select.appendChild(option)
|
||||
}
|
||||
}
|
||||
|
||||
html.appendChild(select)
|
||||
}.html)
|
||||
}
|
||||
}
|
||||
addList.textView("In Raum x") {
|
||||
onClick {
|
||||
constraints.appendChild(View.wrap(createHtmlView<HTMLDivElement>()) {
|
||||
classList += "input-group"
|
||||
html.appendChild(TextView("Raum").apply {
|
||||
classList += "form-btn"
|
||||
onClick { this@wrap.html.remove() }
|
||||
}.html)
|
||||
|
||||
val select = createHtmlView<HTMLSelectElement>()
|
||||
select.classList.add("form-control")
|
||||
select.name = "constraint-room-${index++}"
|
||||
|
||||
val id = (select.options[select.selectedIndex] as? HTMLOptionElement)?.value
|
||||
|
||||
launch {
|
||||
val all = RoomRepository.all()
|
||||
select.clear()
|
||||
|
||||
for (room in all) {
|
||||
val option = createHtmlView<HTMLOptionElement>()
|
||||
option.value = room.id.toString()
|
||||
option.textContent = room.name
|
||||
if (option.value == id) {
|
||||
option.selected = true
|
||||
}
|
||||
select.appendChild(option)
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +241,6 @@ fun initWorkGroupConstraints() {
|
|||
val span = child.firstElementChild as HTMLElement
|
||||
|
||||
span.addEventListener("click", org.w3c.dom.events.EventListener {
|
||||
println("click")
|
||||
child.remove()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.kif.frontend.views.table
|
||||
|
||||
import de.kif.frontend.launch
|
||||
import de.kif.frontend.repository.TrackRepository
|
||||
import de.westermann.kwebview.components.InputView
|
||||
import de.westermann.kwebview.iterator
|
||||
import org.w3c.dom.HTMLFormElement
|
||||
|
@ -14,21 +16,25 @@ fun initTableLayout() {
|
|||
|
||||
val table = document.getElementsByClassName("table-layout-table")[0] as HTMLTableElement
|
||||
|
||||
val list = table.getElementsByTagName("tr").iterator().asSequence().filter {
|
||||
it.dataset["search"] != null
|
||||
}.map {
|
||||
when (it.dataset["edit"]) {
|
||||
"workgroup" -> WorkGroupTableLine(it)
|
||||
"room" -> RoomTableLine(it)
|
||||
else -> TableLine(it)
|
||||
}
|
||||
}.toList()
|
||||
launch {
|
||||
val tracks = TrackRepository.all()
|
||||
|
||||
val input = form.getElementsByTagName("input")[0] as HTMLInputElement
|
||||
val search = InputView.wrap(input)
|
||||
search.valueProperty.onChange {
|
||||
for (row in list) {
|
||||
row.search(search.value)
|
||||
val list = table.getElementsByTagName("tr").iterator().asSequence().filter {
|
||||
it.dataset["search"] != null
|
||||
}.map {
|
||||
when (it.dataset["edit"]) {
|
||||
"workgroup" -> WorkGroupTableLine(it, tracks)
|
||||
"room" -> RoomTableLine(it)
|
||||
else -> TableLine(it)
|
||||
}
|
||||
}.toList()
|
||||
|
||||
val input = form.getElementsByTagName("input")[0] as HTMLInputElement
|
||||
val search = InputView.wrap(input)
|
||||
search.valueProperty.onChange {
|
||||
for (row in list) {
|
||||
row.search(search.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.w3c.dom.HTMLElement
|
|||
import org.w3c.dom.HTMLSpanElement
|
||||
import org.w3c.dom.get
|
||||
|
||||
class WorkGroupTableLine(view: HTMLElement) : TableLine(view) {
|
||||
class WorkGroupTableLine(view: HTMLElement, tracks: List<Track>) : TableLine(view) {
|
||||
|
||||
private var lineId = dataset["id"]?.toLongOrNull() ?: -1
|
||||
|
||||
|
@ -24,9 +24,7 @@ class WorkGroupTableLine(view: HTMLElement) : TableLine(view) {
|
|||
private val spanWorkGroupLength: TextView
|
||||
private val spanWorkGroupInterested: TextView
|
||||
private val spanWorkGroupTrack: TextView
|
||||
private val spanWorkGroupProjector: TextView
|
||||
private val spanWorkGroupResolution: TextView
|
||||
private val spanWorkGroupLanguage: TextView
|
||||
|
||||
override var searchElement: SearchElement = super.searchElement
|
||||
|
||||
|
@ -41,12 +39,8 @@ class WorkGroupTableLine(view: HTMLElement) : TableLine(view) {
|
|||
TextView.wrap(spans.first { it.dataset["editType"] == "workgroup-interested" } as HTMLSpanElement)
|
||||
spanWorkGroupTrack =
|
||||
TextView.wrap(spans.first { it.dataset["editType"] == "workgroup-track" } as HTMLSpanElement)
|
||||
spanWorkGroupProjector =
|
||||
TextView.wrap(spans.first { it.dataset["editType"] == "workgroup-projector" } as HTMLSpanElement)
|
||||
spanWorkGroupResolution =
|
||||
TextView.wrap(spans.first { it.dataset["editType"] == "workgroup-resolution" } as HTMLSpanElement)
|
||||
spanWorkGroupLanguage =
|
||||
TextView.wrap(spans.first { it.dataset["editType"] == "workgroup-language" } as HTMLSpanElement)
|
||||
|
||||
setupEditable(spanWorkGroupName) {
|
||||
launch {
|
||||
|
@ -77,13 +71,6 @@ class WorkGroupTableLine(view: HTMLElement) : TableLine(view) {
|
|||
}
|
||||
}
|
||||
|
||||
setupBoolean(spanWorkGroupProjector) {
|
||||
launch {
|
||||
val wg = workGroup.get()
|
||||
WorkGroupRepository.update(wg.copy(projector = !wg.projector))
|
||||
}
|
||||
}
|
||||
|
||||
setupBoolean(spanWorkGroupResolution) {
|
||||
launch {
|
||||
val wg = workGroup.get()
|
||||
|
@ -91,19 +78,10 @@ class WorkGroupTableLine(view: HTMLElement) : TableLine(view) {
|
|||
}
|
||||
}
|
||||
|
||||
setupList(spanWorkGroupLanguage, Language.values().sortedBy { it.localeName }, { it.localeName }) {
|
||||
if (it == null) return@setupList
|
||||
launch {
|
||||
val wg = workGroup.get()
|
||||
if (wg.language == it) return@launch
|
||||
WorkGroupRepository.update(wg.copy(language = it))
|
||||
}
|
||||
}
|
||||
|
||||
launch {
|
||||
val tracks = listOf<Track?>(null) + TrackRepository.all()
|
||||
val list = listOf<Track?>(null) + tracks
|
||||
|
||||
setupList(spanWorkGroupTrack, tracks, { it.name }) {
|
||||
setupList(spanWorkGroupTrack, list, { it.name }) {
|
||||
launch x@{
|
||||
val wg = workGroup.get()
|
||||
if (wg.track == it) return@x
|
||||
|
@ -124,9 +102,7 @@ class WorkGroupTableLine(view: HTMLElement) : TableLine(view) {
|
|||
spanWorkGroupLength.text = wg.length.toString()
|
||||
spanWorkGroupInterested.text = wg.interested.toString()
|
||||
spanWorkGroupTrack.text = wg.track?.name ?: ""
|
||||
spanWorkGroupProjector.text = wg.projector.toString()
|
||||
spanWorkGroupResolution.text = wg.resolution.toString()
|
||||
spanWorkGroupLanguage.text = wg.language.localeName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue