Skip to content

Commit 43fa92f

Browse files
committed
feat: login module can use enter key to submit
1 parent 4871b52 commit 43fa92f

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.Ruserdata
55
CRAN-SUBMISSION
66
docs
7+
.DS_Store

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: lareshiny
22
Type: Package
33
Title: Lares 'shiny' Modules
4-
Version: 0.0.4.9000
4+
Version: 0.0.4.9001
55
Authors@R: person("Bernardo", "Lares", , "laresbernardo@gmail.com", c("cre","aut"))
66
Maintainer: Bernardo Lares <laresbernardo@gmail.com>
77
Description: Useful 'shiny' production-ready modules and helpers such as login window and visualization tools.

R/login.R

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
####################################################################
21
#' Login Module for Shiny
32
#'
43
#' Login Module for Shiny with local User and Password. This must be
@@ -76,9 +75,10 @@ module_login <- function(input, session,
7675

7776
# Rename values with custom texts
7877
if (length(change_text) > 0) {
79-
lares::check_opts(names(change_text), dic$term)
8078
for (term in names(change_text)) {
81-
dic$text[dic$term == term] <- change_text[[term]]
79+
if (term %in% dic$term) {
80+
dic$text[dic$term == term] <- change_text[[term]]
81+
}
8282
}
8383
}
8484

@@ -89,16 +89,30 @@ module_login <- function(input, session,
8989
"; background-color:", style$botton_bgd_colour,
9090
"; border-radius: 6px;"
9191
)
92-
modalDialog(if (!is.na(logo)) img(src = logo, height = logo_height, align = "center"),
92+
modalDialog(
93+
if (!is.na(logo)) img(src = logo, height = logo_height, align = "center"),
9394
title = dic$text[dic$term == "title"],
9495
textInput("username", paste0(dic$text[dic$term == "user"], ":"), width = "100%"),
9596
passwordInput("password", paste0(dic$text[dic$term == "pass"], ":"), width = "100%"),
96-
footer = tagList(actionButton("ok", HTML(paste0(
97-
"<span>", dic$text[dic$term == "enter"],
98-
'</span> <span class="fa fa-chevron-right"></span>'
99-
)),
100-
style = button_style
101-
)), size = "m"
97+
footer = tagList(
98+
actionButton("ok", HTML(paste0(
99+
"<span>", dic$text[dic$term == "enter"],
100+
'</span> <span class="fa fa-chevron-right"></span>'
101+
)),
102+
style = button_style
103+
),
104+
# Add JavaScript to handle Enter key
105+
tags$script(HTML("
106+
$(document).on('keypress', function(e) {
107+
if(e.which == 13) {
108+
if($('#password').is(':focus')) {
109+
$('#ok').click();
110+
}
111+
}
112+
});
113+
"))
114+
),
115+
size = "m"
102116
)
103117
}
104118

man/figures/.DS_Store

-6 KB
Binary file not shown.

0 commit comments

Comments
 (0)