Skip to content

Commit

Permalink
chore: code linting
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepanshKhurana committed May 3, 2024
1 parent 5e4ec04 commit 9c4f7f9
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 78 deletions.
14 changes: 5 additions & 9 deletions app/js/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
export function toggleIcon() {
$('.argus-icon').click((evt) => {
target = evt.currentTarget;

var target = evt.currentTarget;
const target = evt.currentTarget;

// This condition is reversed becuase if the eye has a class, that means
// it will be toggled. In other words, hasClass tells wasClass

var mode = $(target).hasClass('fa-eye') ? 'add' : 'view';

const mode = $(target).hasClass('fa-eye') ? 'add' : 'view';
$(target).toggleClass('fa-eye fa-eye-dropper');

Shiny.setInputValue(
'app-app_mode',
mode,
{ priority: 'event' }
);
{ priority: 'event' },
);
});
};
}

window.onload = toggleIcon;
2 changes: 1 addition & 1 deletion app/static/css/app.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/static/js/app.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions app/styles/_selector.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
width: fit-content;
}

.selectize-dropdown .selected {
background-color: #444;
}

.form-control,
.selectize-input,
.selectize-input > .item {
Expand Down
1 change: 0 additions & 1 deletion app/styles/main.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@import "selector";

.argus {

hr {
width: 60%;
}
Expand Down
41 changes: 13 additions & 28 deletions app/view/mod_add_selector.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
box::use(
shiny[
moduleServer,
NS,
div,
selectInput,
p,
observeEvent,
updateSelectInput,
eventReactive,
textOutput,
renderText,
numericInput,
updateNumericInput,
actionButton,
icon
],
shiny,
shinyvalidate[
InputValidator,
sv_lte
]
],
)

box::use(
Expand All @@ -35,36 +20,36 @@ choices <- get_table_list()

#' @export
ui <- function(id) {
ns <- NS(id)
div(
ns <- shiny$NS(id)
shiny$div(
class = "argus-filter-area",
p("Adding new entry to"),
selectInput(
shiny$p("Adding new entry to"),
shiny$selectInput(
inputId = ns("application"),
choices = sort(choices$applications, decreasing = TRUE),
label = NULL
),
p(""),
selectInput(
shiny$p(""),
shiny$selectInput(
inputId = ns("table"),
choices = choices$tables[["Test"]],
label = NULL
),
actionButton(
shiny$actionButton(
inputId = ns("go"),
label = NULL,
icon = icon("arrow-right"),
icon = shiny$icon("arrow-right"),
class = "go-button"
)
)
}

#' @export
server <- function(id, selected) {
moduleServer(id, function(input, output, session) {
shiny$moduleServer(id, function(input, output, session) {

observeEvent(input$application, {
updateSelectInput(
shiny$observeEvent(input$application, {
shiny$updateSelectInput(
session = session,
"table",
choices = choices$tables[[input$application]]
Expand Down
61 changes: 23 additions & 38 deletions app/view/mod_view_selector.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
box::use(
shiny[
moduleServer,
NS,
div,
selectInput,
p,
observeEvent,
updateSelectInput,
eventReactive,
textOutput,
renderText,
numericInput,
updateNumericInput,
actionButton,
icon
],
shiny,
shinyvalidate[
InputValidator,
sv_lte
]
],
)

box::use(
Expand All @@ -35,70 +20,70 @@ choices <- get_table_list()

#' @export
ui <- function(id) {
ns <- NS(id)
div(
ns <- shiny$NS(id)
shiny$div(
class = "argus-filter-area",
selectInput(
shiny$selectInput(
inputId = ns("operation"),
choices = c(
"Viewing" = "viewing",
"Editing" = "editing"
),
label = NULL
),
numericInput(
shiny$numericInput(
inputId = ns("row"),
min = 1,
max = 1,
value = 1,
label = NULL
),
p("of"),
textOutput(
shiny$p("of"),
shiny$textOutput(
ns("total_rows")
),
p("entries from"),
selectInput(
shiny$p("entries from"),
shiny$selectInput(
inputId = ns("application"),
choices = sort(choices$applications, decreasing = TRUE),
label = NULL
),
p(""),
selectInput(
shiny$p(""),
shiny$selectInput(
inputId = ns("table"),
choices = choices$tables[["Test"]],
label = NULL
),
actionButton(
shiny$actionButton(
inputId = ns("go"),
label = NULL,
icon = icon("arrow-right"),
icon = shiny$icon("arrow-right"),
class = "go-button"
)
)
}

#' @export
server <- function(id, selected) {
moduleServer(id, function(input, output, session) {
shiny$moduleServer(id, function(input, output, session) {

observeEvent(input$application, {
updateSelectInput(
shiny$observeEvent(input$application, {
shiny$updateSelectInput(
session = session,
"table",
choices = choices$tables[[input$application]]
)
})

table_data <- eventReactive(input$table, {
table_data <- shiny$eventReactive(input$table, {
process_table_data(
get_data(
input$table
)
)
})

observeEvent(input$row, {
shiny$observeEvent(input$row, {
if (is.na(input$row)) {
updateNumericInput(
session = session,
Expand All @@ -108,18 +93,18 @@ server <- function(id, selected) {
}
})

observeEvent(input$go, {
shiny$observeEvent(input$go, {
selected$table_name <- input$table
selected$row <- input$row
selected$operation <- input$operation
selected$table_data <- table_data
})

observeEvent(table_data(), {
shiny$observeEvent(table_data(), {

total <- nrow(table_data())

updateNumericInput(
shiny$updateNumericInput(
session = session,
"row",
max = total
Expand All @@ -129,7 +114,7 @@ server <- function(id, selected) {
iv$add_rule("row", sv_lte(total, message = ""))
iv$enable()

output$total_rows <- renderText({
output$total_rows <- shiny$renderText({
total
})

Expand Down

0 comments on commit 9c4f7f9

Please sign in to comment.