From 03a85ed449ffcb9fe8006c39c098d450ba55fb6e Mon Sep 17 00:00:00 2001 From: Danny Parsons Date: Tue, 24 Jan 2017 20:19:33 +0000 Subject: [PATCH] fixed bugs in link methods --- .../static/InstatObject/R/instat_object_R6.R | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 211b37d2ffb..bb57f2e66cf 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -706,20 +706,26 @@ instat_object$set("public", "delete_dataframe", function(data_name) { # TODO need a set or append private$.data_objects[[data_name]] <- NULL data_objects_changed <- TRUE - ind <- c() + link_name <- "" for(i in seq_along(private$.links)) { if(private$.links[[i]]$from_data_frame == data_name || private$.links[[i]]$to_data_frame == data_name) { - ind <- c(ind, i) + link_name <- names(private$.links)[i] + break } } - #TODO Should this be delete or disable? - if(length(ind) > 0) { - private$.links[ind] <- NULL - message(length(ind), " links removed") + if(link_name != "") { + #TODO Should this be delete or disable? + self$remove_link(link_name) } } ) +instat_object$set("public", "remove_link", function(link_name) { + if(!link_name %in% names(private$.links)) stop(link_name, " not found.") + private$.links[[link_name]] <- NULL +} +) + instat_object$set("public", "get_column_factor_levels", function(data_name,col_name = "") { self$get_data_objects(data_name)$get_column_factor_levels(col_name) }