Skip to content

Commit 4f2abff

Browse files
committed
Fix linting issues
1 parent 7ced94c commit 4f2abff

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

sess/R/handlers.R

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ dataview_to_state <- function(data) {
206206
}
207207
row_index <- rownames(data)
208208
rownames(data) <- NULL
209-
cols <- c(list(if (is.null(row_index)) seq_len(n) else trimws(row_index)), lapply(seq_len(ncol(data)), function(i) data[, i]))
209+
cols <- c(
210+
list(if (is.null(row_index)) seq_len(n) else trimws(row_index)),
211+
lapply(seq_len(ncol(data)), function(i) data[, i])
212+
)
210213
headers <- c(" ", colnames)
211214
matrix_type <- dataview_data_type(data)
212215
types <- c(if (is.null(row_index)) "num" else "string", rep(matrix_type, ncol(data)))
@@ -238,22 +241,22 @@ dataview_columns <- function(state) {
238241
} else {
239242
""
240243
}
241-
244+
242245
col_def <- list(
243246
headerName = jsonlite::unbox(title),
244247
field = jsonlite::unbox(as.character(index - 1L)),
245248
cellClass = jsonlite::unbox(class),
246249
type = jsonlite::unbox(ag_type)
247250
)
248-
251+
249252
# For set filters, include unique values so ag-grid can show all options
250253
if (type %in% c("logical", "factor")) {
251254
unique_vals <- sort(unique(as.character(col_data)))
252255
unique_vals <- unique_vals[!is.na(unique_vals)]
253256
# Keep as vector, not list, so JSON serialization is [val1, val2, ...]
254257
col_def$filterParams <- list(values = I(unique_vals))
255258
}
256-
259+
257260
col_def
258261
}, list(state$headers, state$types, seq_along(state$headers), state$columns), NULL)
259262
}
@@ -294,13 +297,19 @@ dataview_match_condition <- function(values, cond, type_hint) {
294297
}
295298

296299
# Determine filter type from cond or use hint
297-
filter_type <- as.character(cond$filterType %||%
298-
if (type_hint == "date") "date"
299-
else if (type_hint == "datetime") "datetime"
300-
else if (type_hint %in% c("num", "num-fmt")) "number"
301-
else if (type_hint %in% c("logical", "factor")) "set"
302-
else "text"
303-
)
300+
filter_type <- if (!is.null(cond$filterType)) {
301+
as.character(cond$filterType)
302+
} else if (type_hint == "date") {
303+
"date"
304+
} else if (type_hint == "datetime") {
305+
"datetime"
306+
} else if (type_hint %in% c("num", "num-fmt")) {
307+
"number"
308+
} else if (type_hint %in% c("logical", "factor")) {
309+
"set"
310+
} else {
311+
"text"
312+
}
304313

305314
if (filter_type == "number") {
306315
nums <- suppressWarnings(as.numeric(values))
@@ -405,7 +414,9 @@ dataview_apply_filter_model <- function(state, filter_model, row_idx) {
405414
type_hint <- state$types[[col_pos]]
406415
column_match <- rep(TRUE, length(values))
407416

408-
if (!is.null(col_model$operator) && !is.null(col_model$condition1) && !is.null(col_model$condition2)) {
417+
if (!is.null(col_model$operator) &&
418+
!is.null(col_model$condition1) &&
419+
!is.null(col_model$condition2)) {
409420
left <- dataview_match_condition(values, col_model$condition1, type_hint)
410421
right <- dataview_match_condition(values, col_model$condition2, type_hint)
411422
op <- toupper(as.character(col_model$operator))
@@ -440,7 +451,8 @@ dataview_apply_sort_model <- function(state, sort_model, row_idx) {
440451
if (type_hint %in% c("num", "num-fmt")) {
441452
sort_vectors[[length(sort_vectors) + 1L]] <- suppressWarnings(as.numeric(raw_values))
442453
} else if (type_hint == "date") {
443-
sort_vectors[[length(sort_vectors) + 1L]] <- suppressWarnings(as.Date(as.character(raw_values)))
454+
sort_vectors[[length(sort_vectors) + 1L]] <-
455+
suppressWarnings(as.Date(as.character(raw_values)))
444456
} else {
445457
sort_vectors[[length(sort_vectors) + 1L]] <- tolower(as.character(raw_values))
446458
}

0 commit comments

Comments
 (0)