Skip to content

Commit

Permalink
dep v bump
Browse files Browse the repository at this point in the history
  • Loading branch information
mvysny committed Oct 19, 2024
1 parent c632a2f commit 6ae05e4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ local.properties
out
target
src/main/frontend/generated
.kotlin
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[versions]
vaadin = "24.4.11"
vaadin = "24.5.0"
# https://repo1.maven.org/maven2/org/slf4j/slf4j-api/
slf4j = "2.0.13"
vok = "0.17.1"
vok = "0.18"

[libraries]
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
Expand Down
33 changes: 28 additions & 5 deletions src/main/kotlin/com/vaadin/securitydemo/admin/AdminRoute.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.vaadin.securitydemo.admin

import com.github.mvysny.karibudsl.v10.*
import com.github.vokorm.exp
import com.gitlab.mvysny.jdbiorm.condition.Condition
import com.gitlab.mvysny.jdbiorm.vaadin.filter.FilterTextField
import com.gitlab.mvysny.jdbiorm.vaadin.filter.NumberRangePopup
import com.vaadin.flow.component.textfield.TextField
Expand All @@ -20,29 +21,51 @@ import jakarta.annotation.security.RolesAllowed
@PageTitle("Administration")
@RolesAllowed("ROLE_ADMIN")
class AdminRoute : KComposite() {
private val dataProvider = User.dataProvider
private val idFilter = NumberRangePopup()
private val usernameFilter = FilterTextField()
private val rolesFilter = FilterTextField()

private val root = ui {
verticalLayout {
h1("Administration pages")
grid<User>(User.dataProvider) {
grid<User>(dataProvider) {
isExpand = true

appendHeaderRow() // workaround for https://github.com/vaadin/vaadin-grid-flow/issues/912
val filterBar: FilterBar<User> = appendHeaderRow().asFilterBar(this)
val filterBar = appendHeaderRow()

columnFor(User::id) {
setSortProperty(User::id.exp)
filterBar.forField(NumberRangePopup(), this).inRange()
idFilter.addValueChangeListener { updateFilter() }
filterBar.getCell(this).component = idFilter
}
columnFor(User::username) {
setSortProperty(User::username.exp)
filterBar.forField(FilterTextField(), this).istartsWith()
usernameFilter.addValueChangeListener { updateFilter() }
filterBar.getCell(this).component = usernameFilter
}
columnFor(User::roles) {
setSortProperty(User::roles.exp)
filterBar.forField(FilterTextField(), this).istartsWith()
rolesFilter.addValueChangeListener { updateFilter() }
filterBar.getCell(this).component = rolesFilter
}
addColumn { it.hashedPassword } .setHeader("Hashed Password")
}
}
}

private fun updateFilter() {
var c: Condition = Condition.NO_CONDITION
if (!idFilter.isEmpty) {
c = c.and(idFilter.value.asLongInterval().contains(User::id.exp))
}
if (usernameFilter.value.isNotBlank()) {
c = c.and(User::username.exp.startsWithIgnoreCase(usernameFilter.value))
}
if (rolesFilter.value.isNotBlank()) {
c = c.and(User::roles.exp.startsWithIgnoreCase(rolesFilter.value))
}
dataProvider.filter = c
}
}

0 comments on commit 6ae05e4

Please sign in to comment.