Skip to content
Snippets Groups Projects
Commit 097aaf8e authored by Ustjanzew's avatar Ustjanzew
Browse files

Interactive R session case catched.

parent 9cbf455f
No related branches found
No related tags found
No related merge requests found
......@@ -28,34 +28,41 @@ setMethod("add_page", "i2dashboard", function(object, page, title, layout = "sto
dir.create(object@workdir, showWarnings = FALSE)
dir.create(file.path(object@workdir, "envs"), recursive = T, showWarnings = FALSE)
if (name %in% names(object@pages)){
print("A page with this 'page'-argument already exists.")
answer1 <- menu(c("Yes", "No"), title="Do you want to overwrite this page? If 'No' you can input another 'page'-argument or cancel.")
switch (answer1,
"1"={
print("The page was overwritten.")
object@pages[[name]] <- list(title = title, layout = layout, menu = menu, components = list())
},
"2"={
answer2 <- menu(c("Yes", "Cancel"), title="Do you want to provide another 'page'-argument?")
switch (answer2,
"1"={
new_name <- readline("Please input a new 'page'-argument: ")
if (is.character(new_name)){
new_name <- .create_page_name(new_name)
print("Page with new 'page'-argument created.")
object@pages[[new_name]] <- list(title = title, layout = layout, menu = menu, components = list())
}
},
"2"={
print("Function 'add_page' canceled")
}
if (base::interactive()){
if (name %in% names(object@pages)){
print("A page with this 'page'-argument already exists.")
answer1 <- menu(c("Yes", "No"), title="Do you want to overwrite this page? If 'No' you can input another 'page'-argument or cancel.")
switch (answer1,
"1"={
print("The page was overwritten.")
object@pages[[name]] <- list(title = title, layout = layout, menu = menu, components = list())
},
"2"={
answer2 <- menu(c("Yes", "Cancel"), title="Do you want to provide another 'page'-argument?")
switch (answer2,
"1"={
new_name <- readline("Please input a new 'page'-argument: ")
if (is.character(new_name)){
new_name <- .create_page_name(new_name)
print("Page with new 'page'-argument created.")
object@pages[[new_name]] <- list(title = title, layout = layout, menu = menu, components = list())
}
},
"2"={
print("Function 'add_page' canceled")
}
)
}
)
} else {
object@pages[[name]] <- list(title = title, layout = layout, menu = menu, components = list())
}
)
} else {
warning("A page with this 'page'-argument already exists. The existing page will be overwritten.")
object@pages[[name]] <- list(title = title, layout = layout, menu = menu, components = list())
}
return(object)
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment