R/shouldShowChangedColsTab.R

Defines functions shouldShowChangedColsTab

Documented in shouldShowChangedColsTab

## Copyright(c) 2017-2026 R. Mark Sharp
## This file is part of nprcgenekeepr

#' Determine if Changed Columns tab should be displayed
#'
#' Checks the changedCols list to determine if the Changed Columns tab should
#' be inserted into the application navigation. The tab is shown when column
#' names were modified during QC processing.
#'
#' @param changedCols list containing information about changed column names.
#'   Expected fields include: \code{caseChange}, \code{spaceRemoved},
#'   \code{periodRemoved}, \code{underScoreRemoved}, \code{egoToId},
#'   \code{egoidToId}, \code{sireIdToSire}, \code{damIdToDam},
#'   \code{birthdateToBirth}, \code{deathdateToDeath},
#'   \code{recordstatusToRecordStatus}, \code{fromcenterToFromCenter}.
#'
#' @return Logical. TRUE if columns were changed and tab should be shown,
#'   FALSE otherwise.
#'
#' @seealso \code{\link{checkChangedColsLst}} for the original implementation
#' @export
#' @examples
#' library(nprcgenekeepr)
#' ## No column changes recorded: the tab stays hidden.
#' shouldShowChangedColsTab(list())
#' ## A recorded case change: the tab should be shown.
#' shouldShowChangedColsTab(list(caseChange = c(Id = "id")))
shouldShowChangedColsTab <- function(changedCols) {
  if (is.null(changedCols)) {
    return(FALSE)
  }

  if (!is.list(changedCols)) {
    return(FALSE)
  }

  if (length(changedCols) == 0L) {
    return(FALSE)
  }

  # Check each possible changed column field
  fields <- c(
    "caseChange", "spaceRemoved", "periodRemoved", "underScoreRemoved",
    "egoToId", "egoidToId", "sireIdToSire", "damIdToDam",
    "birthdateToBirth", "deathdateToDeath",
    "recordstatusToRecordStatus", "fromcenterToFromCenter"
  )

  for (field in fields) {
    if (field %in% names(changedCols) && length(changedCols[[field]]) > 0L) {
        return(TRUE)
    }
  }

  FALSE
}

Try the nprcgenekeepr package in your browser

Any scripts or data that you put into this service are public.

nprcgenekeepr documentation built on July 26, 2026, 5:06 p.m.