forked from consuldemocracy/consuldemocracy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request consuldemocracy#5744 from consuldemocracy/select_name
Associate all select fields with labels
- Loading branch information
Showing
37 changed files
with
188 additions
and
208 deletions.
There are no files selected for viewing
10 changes: 5 additions & 5 deletions
10
app/assets/javascripts/polls_admin.js → ...ets/javascripts/admin/poll/shifts/form.js
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
class Admin::Poll::Shifts::FormComponent < ApplicationComponent | ||
attr_reader :shift, :booth, :officer | ||
|
||
def initialize(shift, booth:, officer:) | ||
@shift = shift | ||
@booth = booth | ||
@officer = officer | ||
end | ||
|
||
private | ||
|
||
def voting_polls | ||
booth.polls.current | ||
end | ||
|
||
def recount_polls | ||
booth.polls.current_or_recounting | ||
end | ||
|
||
def shift_vote_collection_dates | ||
return [] if voting_polls.blank? | ||
|
||
date_options((voting_start_date..voting_end_date), Poll::Shift.tasks[:vote_collection]) | ||
end | ||
|
||
def shift_recount_scrutiny_dates | ||
return [] if recount_polls.blank? | ||
|
||
dates = recount_polls.map(&:ends_at).map(&:to_date).sort.reduce([]) do |total, date| | ||
initial_date = [date, Date.current].max | ||
total << (initial_date..date + Poll::RECOUNT_DURATION).to_a | ||
end | ||
date_options(dates.flatten.uniq, Poll::Shift.tasks[:recount_scrutiny]) | ||
end | ||
|
||
def date_options(dates, task_id) | ||
valid_dates(dates, task_id).map { |date| [l(date, format: :long), l(date)] } | ||
end | ||
|
||
def valid_dates(dates, task_id) | ||
dates.reject { |date| officer_shifts(task_id).include?(date) } | ||
end | ||
|
||
def voting_start_date | ||
start_date = voting_polls.minimum(:starts_at).to_date | ||
[start_date, Date.current].max | ||
end | ||
|
||
def voting_end_date | ||
voting_polls.maximum(:ends_at).to_date | ||
end | ||
|
||
def officer_shifts(task_id) | ||
officer.shifts.where(task: task_id, booth: booth).map(&:date) | ||
end | ||
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 @@ | ||
<%= form.date_field :date_of_birth, **field_options %> |
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,25 @@ | ||
class Shared::DateOfBirthFieldComponent < ApplicationComponent | ||
attr_reader :form, :options | ||
|
||
def initialize(form, **options) | ||
@form = form | ||
@options = options | ||
end | ||
|
||
private | ||
|
||
def default_options | ||
{ | ||
min: "1900-01-01", | ||
max: minimum_required_age.years.ago | ||
} | ||
end | ||
|
||
def field_options | ||
default_options.merge(options) | ||
end | ||
|
||
def minimum_required_age | ||
User.minimum_required_age | ||
end | ||
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
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
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
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
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
Oops, something went wrong.