diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2dd6bf2df1723d243ba95ee622f7f32684f046eb..d1a9e8a08ab63ba1097e3821ff486f6da2e11829 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/javascript/controllers/session_controller.js b/app/javascript/controllers/session_controller.js index a3a9872c73276cc8d2b999da8e492599108d1f46..ffc5dfdde1cc32f720e39f404467f8a66e20a379 100644 --- a/app/javascript/controllers/session_controller.js +++ b/app/javascript/controllers/session_controller.js @@ -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(); diff --git a/app/views/candidates/_user_avatar.html.erb b/app/views/candidates/_user_avatar.html.erb index d83033073a194fbc34e6f8d3ee8523a8c9ce6e4b..10274ba2270972aef2b5edad27a6739395628c82 100644 --- a/app/views/candidates/_user_avatar.html.erb +++ b/app/views/candidates/_user_avatar.html.erb @@ -14,9 +14,12 @@ </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"> - <%= user.languages_from %> - <% if user.languages_from && user.languages_to %>→<% end %> - <%= user.languages_to %> + <% 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 %> + <span aria-label="to">→</span> + <%= user.languages_to %> </small> <% end %> <% if candidate.note %> diff --git a/app/views/sessions/_session.html.erb b/app/views/sessions/_session.html.erb index c4df7dad0fb4947a7aa17b43d6e10a522f8e19d3..5d0c016151f36e45376834769a6ba43b46e3cd63 100644 --- a/app/views/sessions/_session.html.erb +++ b/app/views/sessions/_session.html.erb @@ -1,5 +1,5 @@ <% 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 %>