Skip to content

Commit 39a29e2

Browse files
authored
Merge pull request #4 from PSIAIMS/update-from-feedback
Update from feedback
2 parents 6b05476 + 548cf8b commit 39a29e2

File tree

9 files changed

+317
-145
lines changed

9 files changed

+317
-145
lines changed

mods/mod-branchq1.R

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ branchq1_ui <- function(id){
1616
)
1717
),
1818
div(class = "graph", id = ns("graph"),
19-
div(class = "slice",
20-
div(class = c("branch")),
19+
div(class = "slice", id = ns("slice1"),
2120
div(
2221
class = c("branch", "main"), id = ns("b0"),
2322
"Main",
@@ -37,15 +36,14 @@ branchq1_ui <- function(id){
3736
style = "z-index: 3;"
3837
)),
3938
div(class = "slice",
40-
id = ns("commit_ls"),
41-
div(class = "branch", id = ns("b1")),
42-
div(class = "branch", id = ns("b2"))
39+
id = ns("commit_ls")
4340
),
4441
),
4542
conditionalPanel(
4643
condition = "input.branch_btn > 0",
4744
h3("Add Commits"),
4845
p("Now let's add two additional commits to each branch.
46+
First, let's put two commits to 'New Branch'. Then, let's add a commit to main.
4947
The commit will always be added to the branch you are currently on"),
5048
fluidRow(
5149
column(width = 6, textInput(ns("input_text"), "Enter Commit Message:")),
@@ -66,12 +64,20 @@ branchq1_server <- function(id){
6664
# Make a new branch
6765
observeEvent(input$branch_btn, {
6866
disable("branch_btn")
69-
shinyjs::runjs(
70-
str_glue(
71-
"$('#{ns('b1')}').addClass('topbranch');
72-
"
73-
)
67+
insertUI(
68+
selector = paste0("#", ns("slice1")),
69+
where = "afterBegin",
70+
ui = div(class = c("branch"))
71+
)
72+
73+
74+
insertUI(
75+
selector = paste0("#", ns("commit_ls")),
76+
where = "beforeEnd",
77+
ui = tagList(div(class = c("branch", "topbranch"), id = ns("b1")),
78+
div(class = "branch", id = ns("b2")))
7479
)
80+
7581
})
7682

7783
observeEvent(input$commit_btn, {

mods/mod-commitq1.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ commitq1_server <- function(id){
8282
disable("undo_btn")
8383
} else if(num_dots() == 3){
8484
disable("commit_btn")
85-
test <- setequal(messages(), c("My first commit",
85+
test <- setequal(str_to_lower(messages()),
86+
str_to_lower(c("My first commit",
8687
"Next commit",
87-
"Final commit"))
88+
"Final commit")))
8889
if(test){
8990
showModal(
9091
modalDialog(

mods/mod-commitq2.R

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,68 @@
11
init <- 'print("hello [My Name]")'
22

3-
commitq2_ui <- function(id){
3+
commitq2_ui <- function(id) {
44
ns <- NS(id)
5-
splitLayout(
6-
cellWidths = c("50%", "50%"),
7-
aceEditor(ns("code_box"), "Code Box", value = init),
8-
column(
9-
width = 12,
10-
div(style = "margin-left: 0.4rem;",
11-
textInput(ns("commit_msg"), "Commit Message", "")),
12-
actionButton(ns("commit_btn"), "Commit", width = "100%"),
13-
div(id = ns("commit_ls"), class = "branch",
14-
div(
15-
class = "dot",
16-
message = "My first commit"
17-
)
5+
tagList(
6+
h3("Let's make our first commit"),
7+
p(
8+
"In order to make a commit, first we will need to change the code.
9+
So update your name, then write a commit message into the box.
10+
Finally save the commit by pressing the commit button."
11+
),
12+
splitLayout(
13+
cellWidths = c("50%", "50%"),
14+
aceEditor(ns("code_box"), "Code Box", value = init),
15+
column(
16+
width = 12,
17+
div(style = "margin-left: 0.4rem;",
18+
textInput(ns("commit_msg"), "Commit Message", "")),
19+
actionButton(ns("commit_btn"), "Commit", width = "100%"),
20+
div(
21+
id = ns("commit_ls"),
22+
class = "branch",
23+
div(class = "dot",
24+
message = "My first commit")
1825

26+
)
1927
)
2028
)
2129
)
2230
}
2331

24-
commitq2_server <- function(id){
25-
moduleServer(
26-
id,
27-
function(input, output, session){
28-
ns <- session$ns
29-
30-
observeEvent(input$code_box, {
31-
if(input$code_box != init){
32-
shinyjs::enable("commit_msg")
33-
} else {
34-
shinyjs::disable("commit_msg")
35-
shinyjs::disable("commit_btn")
36-
}
37-
})
38-
39-
40-
observeEvent(input$commit_msg, {
41-
if (input$commit_msg != "") {
42-
shinyjs::enable("commit_btn")
43-
} else {
44-
shinyjs::disable("commit_btn")
45-
}
46-
})
47-
48-
observeEvent(input$commit_btn, {
49-
insertUI(
50-
selector = paste0("#", ns("commit_ls")),
51-
where = "beforeEnd",
52-
ui = div(
53-
class = "dot",
54-
message = input$commit_msg
55-
)
56-
)
57-
58-
updateTextInput(session, "commit_msg", value = "")
59-
})
60-
61-
62-
}
63-
)
32+
commitq2_server <- function(id) {
33+
moduleServer(id,
34+
function(input, output, session) {
35+
ns <- session$ns
36+
37+
observeEvent(input$code_box, {
38+
if (input$code_box != init) {
39+
shinyjs::enable("commit_msg")
40+
} else {
41+
shinyjs::disable("commit_msg")
42+
shinyjs::disable("commit_btn")
43+
}
44+
})
45+
46+
47+
observeEvent(input$commit_msg, {
48+
if (input$commit_msg != "") {
49+
shinyjs::enable("commit_btn")
50+
} else {
51+
shinyjs::disable("commit_btn")
52+
}
53+
})
54+
55+
observeEvent(input$commit_btn, {
56+
insertUI(
57+
selector = paste0("#", ns("commit_ls")),
58+
where = "beforeEnd",
59+
ui = div(class = "dot",
60+
message = input$commit_msg)
61+
)
62+
63+
updateTextInput(session, "commit_msg", value = "")
64+
})
65+
66+
67+
})
6468
}

mods/mod-commitq3.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ commitq3_ui <- function(id){
22
ns <- NS(id)
33
tagList(
44
h3("Can you find the version of code Camille needs for journal A?"),
5-
p('Using your mouse click to checkout each version Camille saved.
5+
p('Using your mouse click to "checkout" each version Camille saved.
66
Once you find the right one, make sure to tag it so we can find it in the future.'),
7-
7+
88
div(id = ns("graph"),
99
div(
1010
class = "dot",

0 commit comments

Comments
 (0)