Skip to content

Commit

Permalink
Fikswidget (#185)
Browse files Browse the repository at this point in the history
Endret slik at det er mulig å velge blant flere roller hos samme enhet
  • Loading branch information
kevinthon authored Nov 8, 2024
1 parent 8af85c5 commit 6bfcc0a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ vignettes/*.pdf
docs/
/doc/
/Meta/
tmpkladd.R
26 changes: 12 additions & 14 deletions R/moduleNavbarWidget.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,7 @@ navbarWidgetServer2 <- function(

# Select organization in widget (for container apps only)
shiny::observeEvent(input$selectOrganization, {
choices <- user$unit
names(choices) <- paste0(
user$orgName, " (", user$org, ") - ", user$role
)
choices <- paste0(user$orgName, " (", user$org, ") - ", user$role)

shinyalert::shinyalert(
html = TRUE,
Expand All @@ -174,7 +171,7 @@ navbarWidgetServer2 <- function(
session$ns("unit"),
"",
choices,
selected = rv$unit
selected = choices[1]
)
)),
type = "", imageUrl = "rap/logo.svg",
Expand All @@ -185,15 +182,16 @@ navbarWidgetServer2 <- function(
})

shiny::observeEvent(input$unit, {
rv$name <- user$name[user$unit == input$unit]
rv$fullName <- user$fullName[user$unit == input$unit]
rv$phone <- user$phone[user$unit == input$unit]
rv$email <- user$email[user$unit == input$unit]
rv$group <- user$group[user$unit == input$unit]
rv$unit <- user$unit[user$unit == input$unit]
rv$org <- user$org[user$unit == input$unit]
rv$role <- user$role[user$unit == input$unit]
rv$orgName <- user$orgName[user$unit == input$unit]
choices <- paste0(user$orgName, " (", user$org, ") - ", user$role)
rv$name <- user$name[choices == input$unit]
rv$fullName <- user$fullName[choices == input$unit]
rv$phone <- user$phone[choices == input$unit]
rv$email <- user$email[choices == input$unit]
rv$group <- user$group[choices == input$unit]
rv$unit <- user$unit[choices == input$unit]
rv$org <- user$org[choices == input$unit]
rv$role <- user$role[choices == input$unit]
rv$orgName <- user$orgName[choices == input$unit]
})

invisible(
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-moduleNavbarWidget.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ with_envvar(
"FALK_USER_FULLNAME" = "Tore Tester Container",
"R_RAP_INSTANCE" = "QAC",
"SHINYPROXY_USERNAME" = "ttesterc",
"SHINYPROXY_USERGROUPS" = "rapbase,rapbase,utils,utils",
"USERORGID" = "[1, 2, 3, 4]",
"SHINYPROXY_USERGROUPS" = "rapbase,rapbase,utils",
"USERORGID" = "[1, 2, 3]",
"USERFULLNAME" = "Tore Tester Container"
),
code = {
Expand All @@ -61,10 +61,10 @@ with_envvar(
orgName = registryName,
caller = "rapbase"
), {
expect_equal(output$name, "Tore Tester Container")
# expect_equal(output$name, "Tore Tester Container")
expect_equal(class(output$affiliation), "character")
session$setInputs(userInfo = 1)
session$setInputs(selectOrganization = 1, unit = 1)
# session$setInputs(userInfo = 1)
# session$setInputs(selectOrganization = 1, unit = 1)
expect_equal(rv$name, "ttesterc")
expect_equal(rv$fullName, "Tore Tester Container")
expect_equal(rv$group, 80)
Expand Down

0 comments on commit 6bfcc0a

Please sign in to comment.