
# ui --------------------------------------------------------------------------
navbar_df_info_ui <- function(id) {
  ns <- NS(id)
  tagList(
    uiOutput(ns('navbar_df_info')),
    fluidRow(
      column(3, mini_btn(ns('df_btn_overview'), '', icon('magnifying-glass'))),
      column(3, mini_btn(ns('df_btn_meta'), '', bs_icon('info-circle'))),
      column(3, mini_btn(ns('df_btn_change'), '', icon('shuffle'))),
      column(3, mini_btn(ns('df_btn_edit'), '', icon('screwdriver-wrench')))
    ),
      tags$br(),
    fluidRow(
      column(3, mini_btn(ns('df_btn_import'), '', icon('upload'))),
      column(3, mini_btn(ns('df_btn_export'), '', icon('download'))),
      column(3, mini_btn(ns('df_btn_output'), '', icon('tablet-screen-button'))),
      column(3, mini_btn(ns('df_btn_explore'), '', icon('chart-simple')))
    )
  )
}

# server ----------------------------------------------------------------------
navbar_df_info_server <- function(id, app_session) {
  moduleServer(id, function(input, output, session) {
	  ns <- session$ns

    output$navbar_df_info <- renderUI({
      req(session$userData$dt$act_mini_meta())

      mini_meta <- session$userData$dt$act_mini_meta()
      tagList(
        div(class = 'spada-navbar-df-info-header',
            h2(session$userData$dt$act_name)),
        p('Rows/Columns:', mini_meta[['row_col']]),
        p("Columns with NA's:", mini_meta[['col_nas']])
      )
    })

    # buttons --------
    observe({
      nav_select('navbar', selected = 'Data', session = app_session)
      nav_select('navset_card_pill_data', selected = 'Overview', session = app_session)
    }) |> bindEvent(input$df_btn_overview)

    observe({
      nav_select('navbar', selected = 'Data', session = app_session)
      nav_select('navset_card_pill_data', selected = 'Metadata', session = app_session)
    }) |> bindEvent(input$df_btn_meta)

    observe({
      nav_select('navbar', selected = 'Data', session = app_session)
      nav_select('navset_card_pill_data', selected = 'Data', session = app_session)
    }) |> bindEvent(input$df_btn_change)

    observe({
      nav_select('navbar', selected = 'Exploratory', session = app_session)
    }) |> bindEvent(input$df_btn_explore)

    observe({
      nav_select('navbar', selected = 'Data', session = app_session)
      nav_select('navset_card_pill_data', selected = 'Import', session = app_session)
    }) |> bindEvent(input$df_btn_import)

    observe({
      nav_select('navbar', selected = 'Data', session = app_session)
      nav_select('navset_card_pill_data', selected = 'Export', session = app_session)
    }) |> bindEvent(input$df_btn_export)

    observe({
      nav_select('navbar', selected = 'Output', session = app_session)
    }) |> bindEvent(input$df_btn_output)

    observe({
      nav_select('navbar', selected = 'Edit', session = app_session)
    }) |> bindEvent(input$df_btn_edit)

  })
}
