Skip to content

Commit

Permalink
Refactor comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mikmart committed Jan 21, 2024
1 parent f1c1e84 commit 9f807d5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/searchbuilder.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# server-side processing for the SearchBuilder extension
# https://datatables.net/extensions/searchbuilder/

# returns NULL if the search doesn't contain any valid conditions
# returns NULL if none of the search criteria are valid
sbEvaluateSearch = function(search, data) {
# https://datatables.net/reference/option/searchBuilder.preDefined
stopifnot(search$logic %in% c('AND', 'OR'))
Expand All @@ -24,10 +24,11 @@ sbEvaluateCriteria = function(criteria, data) {
v = sbParseValue(sbExtractValue(criteria), type)
sbEvaluateCondition(cond, type, x, v)
} else {
# skip evaluating invalid conditions
# just return NULL for criteria with an invalid condition
}
}

# check that condition is present and values are non-empty
sbHasValidCondition = function(criteria) {
'condition' %in% names(criteria) && all(sapply(criteria, nzchar))
}
Expand Down

0 comments on commit 9f807d5

Please sign in to comment.