-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
641a09d
commit 600e9bd
Showing
9 changed files
with
105 additions
and
42 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function focusField(event, key, field) { | ||
const tag = event.target.tagName; | ||
if (field === null || event.defaultPrevented || | ||
event.key !== key || tag === 'INPUT' || tag === 'TEXTAREA') { | ||
return; // Do nothing if the event was already processed or key was not s | ||
} | ||
|
||
field.focus(); | ||
event.preventDefault(); | ||
} | ||
|
||
function searchKeydown(event) { | ||
focusField(event, 's', document.getElementById('search-card')) | ||
} | ||
|
||
function adjustKey(event) { | ||
focusField(event, 'a', document.getElementById('adjust')) | ||
} | ||
|
||
function setupShortcuts() { | ||
document.addEventListener('keydown', adjustKey, true); | ||
document.addEventListener('keydown', searchKeydown, true); | ||
} | ||
|
||
function removeShortcuts() { | ||
document.addEventListener('keydown', adjustKey, true); | ||
document.removeEventListener('keydown', searchKeydown, true); | ||
} | ||
|
||
document.addEventListener('turbolinks:load', setupShortcuts); | ||
document.addEventListener('turbolinks:before-cache', removeShortcuts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
var table = document.getElementById('vote-users-table') | ||
table.innerHTML = "<%= j render('admin/vote_users/table', vote_users: @vote_users) %>" | ||
var user = document.getElementById('vote-user') | ||
var statusDisplay = document.getElementById('status-display'); | ||
<% if @vote_users.any? %> | ||
statusDisplay.innerHTML = ""; | ||
<% if @vote_user.present? %> | ||
user.innerHTML = "<%= j render('admin/vote_users/user', vote_user: @vote_user) %>" | ||
statusDisplay.classList.replace('d-flex', 'd-none'); | ||
statusDisplay.innerHTML = ""; | ||
var link = document.querySelector('#vote-user > div > a') | ||
link.focus() | ||
<% else %> | ||
user.innerHTML = ""; | ||
statusDisplay.classList.replace('d-none', 'd-flex'); | ||
statusDisplay.innerHTML = "<%= j t('admin.searches.no_results') %>"; | ||
statusDisplay.innerHTML = "<%= t('admin.searches.no_results') %>"; | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<div class="bg-info rounded p-3"> | ||
<h3> | ||
<%= vote_user.to_s %> | ||
</h3> | ||
<div class="mb-2"> | ||
<%= vote_user.card_number %> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<% if vote_user.presence %> | ||
<%= link_to(t('model.vote_user.make_not_present'), | ||
admin_attendance_path(vote_user), | ||
method: :delete, remote: true, | ||
class: 'btn btn-primary', | ||
id: 'adjust') %> | ||
<% else %> | ||
<%= link_to(t('model.vote_user.make_present'), | ||
admin_attendance_path(vote_user), | ||
method: :patch, remote: true, | ||
class: 'btn btn-primary', | ||
id: 'adjust') %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters