refactor: improve filtering logic and map initialization
Co-authored-by: aider (deepseek/deepseek-chat) <aider@aider.chat>
This commit is contained in:
28
app.R
28
app.R
@@ -362,9 +362,8 @@ server <- function(input, output, session) {
|
||||
# Initialize filteredOwners with all owners
|
||||
filteredOwners <- reactiveVal(owners)
|
||||
|
||||
# Update filtered owners when filter button is clicked
|
||||
observeEvent(input$filterButton, {
|
||||
# Start with all owners
|
||||
# Function to filter owners based on inputs
|
||||
filterOwners <- function() {
|
||||
filtered <- owners
|
||||
|
||||
# Filter by subdivision if specified
|
||||
@@ -392,13 +391,28 @@ server <- function(input, output, session) {
|
||||
filter(grepl(input$location, location, ignore.case = TRUE))
|
||||
}
|
||||
|
||||
filteredOwners(filtered)
|
||||
return(filtered)
|
||||
}
|
||||
|
||||
# Update filtered owners when filter button is clicked
|
||||
observeEvent(input$filterButton, {
|
||||
filteredOwners(filterOwners())
|
||||
})
|
||||
|
||||
# Also update when the app starts
|
||||
# Also update when any of the filter inputs change
|
||||
observe({
|
||||
# Trigger initial update
|
||||
filteredOwners(owners)
|
||||
# Track dependencies
|
||||
input$name
|
||||
input$location
|
||||
input$sub_name
|
||||
|
||||
# Update filtered owners, but only if the filter button has been clicked at least once
|
||||
# To prevent immediate filtering on app start
|
||||
if (!is.null(input$filterButton)) {
|
||||
if (input$filterButton > 0) {
|
||||
filteredOwners(filterOwners())
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
mean_lat <- reactive({
|
||||
|
||||
Reference in New Issue
Block a user