Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter is minimised to a single button in active filters #599

Merged
merged 7 commits into from
Jul 15, 2024

Conversation

vedhav
Copy link
Contributor

@vedhav vedhav commented Jul 4, 2024

Closes #592

Please checkout to these branches before testing:

  1. teal - 669_insertUI@main
  2. teal.slice - remove_add_filters_ui@669_insertUI@main

Example shiny app to test:

pkgload::load_all("teal.slice")
library(shinyjs)


# create a FilteredData object
data(miniACC, package = "MultiAssayExperiment")
datasets <- init_filtered_data(list(iris = iris, mtcars = mtcars, MAE = miniACC))

# setting initial state
set_filter_state(
  datasets = datasets,
  filter = teal_slices(
    teal_slice(dataname = "iris", varname = "Species", selected = "virginica", keep_na = FALSE),
    teal_slice(dataname = "mtcars", id = "4 cyl", title = "4 Cylinders", expr = "cyl == 4"),
    teal_slice(dataname = "mtcars", varname = "mpg", selected = c(20.0, 25.0), keep_na = FALSE, keep_inf = FALSE),
    teal_slice(
      dataname = "MAE", varname = "years_to_birth", selected = c(30, 50), keep_na = TRUE
    ),
    teal_slice(
      dataname = "MAE", varname = "vital_status", selected = "1", keep_na = FALSE
    ),
    teal_slice(
      dataname = "MAE", varname = "gender", selected = "female", keep_na = TRUE
    ),
    teal_slice(
      dataname = "MAE", varname = "ARRAY_TYPE", selected = "", keep_na = TRUE
    )
  )
)

ui <- fluidPage(
  shinyjs::useShinyjs(),
  fluidRow(
    column(
      width = 9,
      tabsetPanel(
        tabPanel(title = "iris", dataTableOutput("iris_table")),
        tabPanel(title = "mtcars", dataTableOutput("mtcars_table"))
      )
    ),
    # ui for the filter panel
    column(width = 3, datasets$ui_filter_panel("filter_panel"))
  )
)

server <- function(input, output, session) {
  # this is the shiny server function for the filter panel and the datasets
  # object can now be used inside the application
  datasets$srv_filter_panel("filter_panel")

  # get the filtered datasets and put them inside reactives for analysis
  iris_filtered_data <- reactive(datasets$get_data(dataname = "iris", filtered = TRUE))
  mtcars_filtered_data <- reactive(datasets$get_data(dataname = "mtcars", filtered = TRUE))

  output$iris_table <- renderDataTable(iris_filtered_data())
  output$mtcars_table <- renderDataTable(mtcars_filtered_data())
}

shinyApp(ui, server)

Example teal app to test

pkgload::load_all("teal.slice")
pkgload::load_all("teal")
library(teal.modules.general)


# create a FilteredData object
data(miniACC, package = "MultiAssayExperiment")

data <- teal_data(
  iris = iris,
  mtcars = mtcars,
  MAE = miniACC
)

app <- init(
  data = data,
  modules = tm_variable_browser()
)

shinyApp(app$ui, app$server)

@vedhav vedhav requested a review from gogonzo July 4, 2024 12:47
@vedhav vedhav added the core label Jul 4, 2024
@vedhav vedhav marked this pull request as draft July 4, 2024 12:55
@vedhav vedhav removed the request for review from gogonzo July 4, 2024 12:55
@vedhav
Copy link
Contributor Author

vedhav commented Jul 4, 2024

I see that the teal app fails. I'm looking into this now.

@vedhav
Copy link
Contributor Author

vedhav commented Jul 4, 2024

Nevermind, It works fine. I was in the wrong teal branch 🤦🏽

@vedhav vedhav marked this pull request as ready for review July 4, 2024 13:00
@vedhav vedhav requested a review from gogonzo July 4, 2024 13:00
@gogonzo gogonzo linked an issue Jul 8, 2024 that may be closed by this pull request
3 tasks
Copy link
Contributor

@gogonzo gogonzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow_add is ignored.

@vedhav vedhav requested a review from gogonzo July 15, 2024 11:39
Copy link
Contributor

@gogonzo gogonzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I think we can simplify even further (see all the comments below)
  • If we remove add_ui/srv it should be in the NEWS as it is a public method of the exported class.

@vedhav vedhav requested a review from gogonzo July 15, 2024 13:45
Copy link
Contributor

@gogonzo gogonzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@gogonzo gogonzo merged commit 41b2a27 into 669_insertUI@main Jul 15, 2024
1 check passed
@gogonzo gogonzo deleted the remove_add_filters_ui@669_insertUI@main branch July 15, 2024 15:22
@github-actions github-actions bot locked and limited conversation to collaborators Jul 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: UI to add filter should be minimalized to a single button
2 participants