Skip to content
Snippets Groups Projects
Unverified Commit 055dec64 authored by tribut's avatar tribut :man_dancing:
Browse files

Warn user when they sign up for a talk in a different language

parent aa6d5f39
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ module ApplicationHelper
attributes = {}
attributes[:loggedin_uid] = current_user.id if user_signed_in?
attributes[:is_shiftcoordinator] = 1 if current_user&.shiftcoordinator?
attributes[:languages_from] = current_user.languages_from unless current_user&.languages_from.blank?
{ data: attributes }
end
end
......@@ -33,6 +33,23 @@ export default class extends Controller {
});
}
verifyLanguages(event) {
const languagesFrom = document.body.dataset.languagesFrom;
const languageSession = this.element.dataset.language;
if (!languagesFrom) {
return;
}
if (!languagesFrom.split(',').includes(languageSession)) {
const response = confirm("You are signing up for a talk with language " + languageSession + ", which you claim not to understand!");
if (response) {
return;
} else {
event.preventDefault();
event.stopImmediatePropagation(); // don't continue with further actions on the same element
}
}
}
submitWithPrompt(event) {
event.preventDefault();
......
......@@ -14,8 +14,11 @@
</span>
<% if !user.languages_from.blank? || !user.languages_to.blank? %>
<small class="text-2xs uppercase font-light bg-black/10 rounded-sm p-1 ml-1">
<% if !user.languages_from.blank? && !user.languages_from.split(',').include?(session.language) %>
<span aria-help="User doesn't understand the language of the talk" title="User doesn't understand the language of the talk">⚠️</span>
<% end %>
<%= user.languages_from %>
<% if user.languages_from && user.languages_to %><% end %>
<span aria-label="to"></span>
<%= user.languages_to %>
</small>
<% end %>
......
<% unassigned_users = User.all - session.assignments.collect(&:user) %>
<%= turbo_frame_tag dom_id(session), method: "morph", class: "w-full", data: { controller: "session" } do %>
<%= turbo_frame_tag dom_id(session), method: "morph", class: "w-full", data: { controller: "session", language: session.language } do %>
<div class="session shadow hover:shadow-lg overflow-scroll text-sm w-full !h-full min-h-full hover:!min-h-max <%= session.translators_needed? ? "translators-needed" : "no-translators-needed" %> <%= session.backup_needed? ? "backup-needed" : "no-backup-needed" %> <%= session.assignees? ? "has-assignees" : "no-assignees" %> <%= (session.ends_at < Time.now ? "past" : "") %>">
<h4>
<small class="text-2xs uppercase font-light bg-black/10 rounded-sm p-1 mr-1 lang-<%= session.language %>"><%= session.language %></small>
......@@ -24,11 +24,11 @@
<%= link_to conference_session_candidates_path(session.conference, session), class: "pr-1 only-candidate hidden", title: "Withdraw", aria_label: "Withdraw", data: { turbo_method: :delete, turbo_frame: dom_id(session) }, method: :delete do %>
🙅
<% end %>
<%= link_to conference_session_candidates_path(session.conference, session), class: "pr-1 only-no-candidate hidden", title: "Volunteer Myself", aria_label: "Volunteer Myself", data: { turbo_method: :post, turbo_frame: dom_id(session) } do %>
<%= link_to conference_session_candidates_path(session.conference, session), class: "pr-1 only-no-candidate hidden", title: "Volunteer Myself", aria_label: "Volunteer Myself", data: { action: "session#verifyLanguages", turbo_method: :post, turbo_frame: dom_id(session) } do %>
🙋
<% end %>
<%= form_with url: conference_session_candidates_path(session.conference, session), method: :post, class: "inline", data: { turbo_frame: dom_id(session) } do |form| %>
<%= link_to conference_session_candidates_path(session.conference, session), class: "pr-1 only-no-candidate hidden", title: "Volunteer (with special skills)", aria_label: "Volunteer (with special skills)", data: { action: "session#submitWithPrompt", prompt: "Why are you especially qualified? (Please keep it short, thanks)", turbo_prefetch:"false" } do %>
<%= link_to conference_session_candidates_path(session.conference, session), class: "pr-1 only-no-candidate hidden", title: "Volunteer (with special skills)", aria_label: "Volunteer (with special skills)", data: { action: "session#verifyLanguages session#submitWithPrompt", prompt: "Why are you especially qualified? (Please keep it short, thanks)", turbo_prefetch:"false" } do %>
🙌
<% end %>
<% end %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment