This commit is contained in:
Lars Westermann 2019-06-13 01:58:58 +02:00
parent 0cb890de07
commit 99bfacbaf0
Signed by: lars.westermann
GPG key ID: 9D417FA5BB9D5E1D
8 changed files with 100 additions and 83 deletions

View file

@ -71,7 +71,7 @@ fun initRoomConstraints() {
for (e in child.children.iterator()) { for (e in child.children.iterator()) {
if (e is HTMLInputElement && e.name.contains("-day-")) { if (e is HTMLInputElement && e.name.contains("-day-")) {
val input = InputView.wrap(e) val input = InputView.wrap(InputType.NUMBER, e)
updateDateView(child, input.value.toIntOrNull() ?: 0) updateDateView(child, input.value.toIntOrNull() ?: 0)
input.valueProperty.onChange { input.valueProperty.onChange {

View file

@ -100,11 +100,14 @@ fun initWorkGroupConstraints() {
classList += "form-btn" classList += "form-btn"
onClick { this@wrap.html.remove() } onClick { this@wrap.html.remove() }
}.html) }.html)
html.appendChild(InputView(InputType.TEXT).apply { html.appendChild(InputView(InputType.NUMBER).apply {
classList += "form-control" classList += "form-control"
html.name = "constraint-only-before-time-day-${index}" html.name = "constraint-only-before-time-day-${index}"
placeholder = "Tag (optional)" placeholder = "Tag (optional)"
min = -1337.0
max = 1337.0
updateDateView(this@wrap.html, value.toIntOrNull() ?: 0) updateDateView(this@wrap.html, value.toIntOrNull() ?: 0)
valueProperty.onChange { valueProperty.onChange {
updateDateView(this@wrap.html, value.toIntOrNull() ?: 0) updateDateView(this@wrap.html, value.toIntOrNull() ?: 0)
@ -126,11 +129,14 @@ fun initWorkGroupConstraints() {
classList += "form-btn" classList += "form-btn"
onClick { this@wrap.html.remove() } onClick { this@wrap.html.remove() }
}.html) }.html)
html.appendChild(InputView(InputType.TEXT).apply { html.appendChild(InputView(InputType.NUMBER).apply {
classList += "form-control" classList += "form-control"
html.name = "constraint-only-after-time-day-${index}" html.name = "constraint-only-after-time-day-${index}"
placeholder = "Tag (optional)" placeholder = "Tag (optional)"
min = -1337.0
max = 1337.0
updateDateView(this@wrap.html, value.toIntOrNull() ?: 0) updateDateView(this@wrap.html, value.toIntOrNull() ?: 0)
valueProperty.onChange { valueProperty.onChange {
updateDateView(this@wrap.html, value.toIntOrNull() ?: 0) updateDateView(this@wrap.html, value.toIntOrNull() ?: 0)
@ -152,11 +158,14 @@ fun initWorkGroupConstraints() {
classList += "form-btn" classList += "form-btn"
onClick { this@wrap.html.remove() } onClick { this@wrap.html.remove() }
}.html) }.html)
html.appendChild(InputView(InputType.TEXT).apply { html.appendChild(InputView(InputType.NUMBER).apply {
classList += "form-control" classList += "form-control"
html.name = "constraint-exact-time-day-${index}" html.name = "constraint-exact-time-day-${index}"
placeholder = "Tag (optional)" placeholder = "Tag (optional)"
min = -1337.0
max = 1337.0
updateDateView(this@wrap.html, value.toIntOrNull() ?: 0) updateDateView(this@wrap.html, value.toIntOrNull() ?: 0)
valueProperty.onChange { valueProperty.onChange {
updateDateView(this@wrap.html, value.toIntOrNull() ?: 0) updateDateView(this@wrap.html, value.toIntOrNull() ?: 0)
@ -281,7 +290,7 @@ fun initWorkGroupConstraints() {
for (e in child.children.iterator()) { for (e in child.children.iterator()) {
if (e is HTMLInputElement && e.name.contains("-day-")) { if (e is HTMLInputElement && e.name.contains("-day-")) {
val input = InputView.wrap(e) val input = InputView.wrap(InputType.NUMBER, e)
updateDateView(child, input.value.toIntOrNull() ?: 0) updateDateView(child, input.value.toIntOrNull() ?: 0)
input.valueProperty.onChange { input.valueProperty.onChange {

View file

@ -8,6 +8,7 @@ import de.westermann.kobserve.list.observableListOf
import de.westermann.kobserve.list.sortObservable import de.westermann.kobserve.list.sortObservable
import de.westermann.kwebview.View import de.westermann.kwebview.View
import de.westermann.kwebview.components.Button import de.westermann.kwebview.components.Button
import de.westermann.kwebview.components.InputType
import de.westermann.kwebview.components.InputView import de.westermann.kwebview.components.InputView
import de.westermann.kwebview.components.ListView import de.westermann.kwebview.components.ListView
import de.westermann.kwebview.extra.listFactory import de.westermann.kwebview.extra.listFactory
@ -24,7 +25,7 @@ class CalendarEdit(
Button.wrap(document.getElementById("calendar-edit-button") as HTMLButtonElement) Button.wrap(document.getElementById("calendar-edit-button") as HTMLButtonElement)
val search = val search =
InputView.wrap(view.querySelector(".calendar-edit-search input") as HTMLInputElement) InputView.wrap(InputType.SEARCH, view.querySelector(".calendar-edit-search input") as HTMLInputElement)
val listView = ListView.wrap<CalendarWorkGroup>( val listView = ListView.wrap<CalendarWorkGroup>(
view.querySelector(".calendar-edit-list") as HTMLElement view.querySelector(".calendar-edit-list") as HTMLElement

View file

@ -2,6 +2,7 @@ package de.kif.frontend.views.table
import de.kif.frontend.launch import de.kif.frontend.launch
import de.kif.frontend.repository.TrackRepository import de.kif.frontend.repository.TrackRepository
import de.westermann.kwebview.components.InputType
import de.westermann.kwebview.components.InputView import de.westermann.kwebview.components.InputView
import de.westermann.kwebview.iterator import de.westermann.kwebview.iterator
import org.w3c.dom.HTMLFormElement import org.w3c.dom.HTMLFormElement
@ -30,7 +31,7 @@ fun initTableLayout() {
}.toList() }.toList()
val input = form.getElementsByTagName("input")[0] as HTMLInputElement val input = form.getElementsByTagName("input")[0] as HTMLInputElement
val search = InputView.wrap(input) val search = InputView.wrap(InputType.SEARCH, input)
search.valueProperty.onChange { search.valueProperty.onChange {
for (row in list) { for (row in list) {
row.search(search.value) row.search(search.value)

View file

@ -111,7 +111,7 @@ class InputView(
} }
companion object { companion object {
fun wrap(view: HTMLInputElement) = InputView(InputType.SEARCH, view.value, view) fun wrap(type: InputType, view: HTMLInputElement) = InputView(type, view.value, view)
} }
} }

View file

@ -176,6 +176,7 @@ form {
.input-group { .input-group {
display: flex; display: flex;
position: relative;
.form-btn { .form-btn {
height: 2.5rem; height: 2.5rem;
@ -215,6 +216,6 @@ form {
line-height: 2.5rem; line-height: 2.5rem;
margin-left: 1rem; margin-left: 1rem;
width: 100%; width: 100%;
top: 2.3rem; top: 0;
} }
} }

View file

@ -51,7 +51,7 @@ fun Route.account() {
+"Sicherung" +"Sicherung"
} }
if (user.checkPermission(Permission.ADMIN)) { if (user.checkPermission(Permission.SCHEDULE)) {
a(href = "$prefix/account/import", classes = "form-btn") { a(href = "$prefix/account/import", classes = "form-btn") {
+"Aus Wiki importieren" +"Aus Wiki importieren"
} }
@ -185,16 +185,11 @@ fun Route.account() {
+"Arbeitskreise löschen" +"Arbeitskreise löschen"
} }
} }
if ( if (user.checkPermission(Permission.SCHEDULE)) {
user.checkPermission(Permission.WORK_GROUP) &&
user.checkPermission(Permission.ROOM) &&
user.checkPermission(Permission.SCHEDULE)
) {
a("$prefix/account/backup/delete/schedules", classes = "form-btn btn-danger") { a("$prefix/account/backup/delete/schedules", classes = "form-btn btn-danger") {
+"Zeitplan löschen" +"Zeitplan löschen"
} }
} }
if (user.checkPermission(Permission.ADMIN)) { if (user.checkPermission(Permission.ADMIN)) {
a("$prefix/account/backup/delete/all", classes = "form-btn btn-danger") { a("$prefix/account/backup/delete/all", classes = "form-btn btn-danger") {
+"Alles löschen" +"Alles löschen"
@ -207,7 +202,7 @@ fun Route.account() {
} }
get("/account/import") { get("/account/import") {
authenticateOrRedirect(Permission.ADMIN) { user -> authenticateOrRedirect(Permission.SCHEDULE) { user ->
val tracks = TrackRepository.all() val tracks = TrackRepository.all()
val wikiSections = WikiImporter.loadSections() val wikiSections = WikiImporter.loadSections()
@ -215,80 +210,78 @@ fun Route.account() {
content { content {
h1 { +"Aus Wiki importieren" } h1 { +"Aus Wiki importieren" }
if (user.checkPermission(Permission.ADMIN)) { div("account-import-wiki") {
div("account-import-wiki") { span { +"Arbeitskreise aus dem KIF-Wiki importieren" }
span { +"Arbeitskreise aus dem KIF-Wiki importieren" }
form(action = "$prefix/account/import", method = FormMethod.post) { form(action = "$prefix/account/import", method = FormMethod.post) {
for ((index, section) in wikiSections.withIndex()) { for ((index, section) in wikiSections.withIndex()) {
div("form-group") { div("form-group") {
label { label {
htmlFor = "section-$index-track" htmlFor = "section-$index-track"
+section +section
}
select(
classes = "form-control"
) {
name = "section-$index-track"
option {
selected = false
value = "-1"
+"Nicht importieren"
} }
select( option {
classes = "form-control" selected = true
) { value = "null"
name = "section-$index-track" +"Importieren"
}
for (track in tracks) {
option { option {
selected = false selected = false
value = "-1" value = track.id.toString()
+"Nicht importieren" +track.name
} }
option {
selected = true
value = "null"
+"Importieren"
}
for (track in tracks) {
option {
selected = false
value = track.id.toString()
+track.name
}
}
}
input(type = InputType.hidden, name = "section-$index-name") {
value = section
} }
} }
input(type = InputType.hidden, name = "section-$index-name") {
value = section
}
} }
}
div("form-switch-group") { div("form-switch-group") {
div("form-group form-switch") { div("form-group form-switch") {
input( input(
name = "skip-existing", name = "skip-existing",
classes = "form-control", classes = "form-control",
type = InputType.checkBox type = InputType.checkBox
) { ) {
id = "skip-existing" id = "skip-existing"
checked = false checked = false
}
label {
htmlFor = "skip-existing"
+"Existierende Arbeitskreise überspringen"
}
} }
div("form-group form-switch") { label {
input( htmlFor = "skip-existing"
name = "delete-existing", +"Existierende Arbeitskreise überspringen"
classes = "form-control",
type = InputType.checkBox
) {
id = "delete-existing"
checked = false
}
label {
htmlFor = "delete-existing"
+"Existierende Arbeitskreise löschen"
}
} }
} }
div("form-group form-switch") {
input(
name = "delete-existing",
classes = "form-control",
type = InputType.checkBox
) {
id = "delete-existing"
checked = false
}
label {
htmlFor = "delete-existing"
+"Existierende Arbeitskreise löschen"
}
}
}
button(type = ButtonType.submit, classes = "form-btn btn-primary") { button(type = ButtonType.submit, classes = "form-btn btn-primary") {
+"Importieren" +"Importieren"
}
} }
} }
} }
@ -377,7 +370,7 @@ fun Route.account() {
} }
post("/account/import") { post("/account/import") {
authenticate(Permission.ADMIN) { authenticate(Permission.SCHEDULE) {
val params = call.receiveParameters().toMap().mapValues { (_, list) -> val params = call.receiveParameters().toMap().mapValues { (_, list) ->
list.firstOrNull() list.firstOrNull()
} }
@ -488,7 +481,7 @@ fun Route.account() {
} }
get("/account/backup/delete/schedules") { get("/account/backup/delete/schedules") {
authenticate(Permission.ROOM, Permission.WORK_GROUP, Permission.SCHEDULE) { authenticate(Permission.SCHEDULE) {
ScheduleRepository.all().forEach { ScheduleRepository.all().forEach {
if (it.id != null) ScheduleRepository.delete(it.id) if (it.id != null) ScheduleRepository.delete(it.id)
} }

View file

@ -418,10 +418,14 @@ fun Route.workGroup() {
} }
input( input(
name = "constraint-only-before-time-day-$index", name = "constraint-only-before-time-day-$index",
classes = "form-control" classes = "form-control",
type = InputType.number
) { ) {
value = constraint.day?.toString() ?: "" value = constraint.day?.toString() ?: ""
min = "-1337"
max = "1337"
placeholder = "Tag (optional)" placeholder = "Tag (optional)"
} }
input( input(
@ -447,10 +451,14 @@ fun Route.workGroup() {
} }
input( input(
name = "constraint-only-after-time-day-$index", name = "constraint-only-after-time-day-$index",
classes = "form-control" classes = "form-control",
type = InputType.number
) { ) {
value = constraint.day?.toString() ?: "" value = constraint.day?.toString() ?: ""
min = "-1337"
max = "1337"
placeholder = "Tag (optional)" placeholder = "Tag (optional)"
} }
input( input(
@ -476,10 +484,14 @@ fun Route.workGroup() {
} }
input( input(
name = "constraint-exact-time-day-$index", name = "constraint-exact-time-day-$index",
classes = "form-control" classes = "form-control",
type = InputType.number
) { ) {
value = constraint.day?.toString() ?: "" value = constraint.day?.toString() ?: ""
min = "-1337"
max = "1337"
placeholder = "Tag (optional)" placeholder = "Tag (optional)"
} }
input( input(