Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37932 - Add asterisk to email address users form #10355

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<%= form_for @user do |f| %>
<%= base_errors_for @user %>

Expand Down Expand Up @@ -29,7 +28,7 @@
<%= text_f f, :login, :disabled => msg.present? , :label_help => msg %>
<%= text_f f, :firstname %>
<%= text_f f, :lastname %>
<%= text_f f, :mail %>
<%= text_f f, :mail, id: "mail", required: f.object.mail_enabled%>
<% unless @user == User.current %>
<%= checkbox_f f, :disabled %>
<% end %>
Expand Down Expand Up @@ -68,7 +67,7 @@
</div>
</br>
<%= field_set_tag _("General") do %>
<%= checkbox_f f, :mail_enabled %>
<%= checkbox_f f, :mail_enabled, onchange: 'toggleMailRequired(this)' %>
<div class='col-md-4'>
<%= link_to_function(_("Test email"), "tfm.users.testMail(this, '#{test_mail_user_url(f.object)}', {user_email: $('#user_mail').val()})",
:title => _("Send a test message to the user's email address to confirm the configuration is working."), :id => "test_mail_button", :class =>"btn btn-success") + hidden_spinner('', :id => 'test_indicator').html_safe if action_name == "edit" %>
Expand Down Expand Up @@ -139,6 +138,15 @@
</div>

<%= submit_or_cancel f %>

<script type="text/javascript">
function toggleMailRequired(checkbox) {
const emailLabel = document.querySelector('label[for="mail"]');
if (emailLabel) {
emailLabel.innerHTML = checkbox.checked ? _("Email Address *") : _("Email Address");
}
}
</script>
<% end %>

<% if @user.cached_usergroups.any? %>
Expand Down
Loading