-
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.
Merge pull request #2993 from bitzesty/year-filter-qa-2
Change award year switch to submit form on change
- Loading branch information
Showing
4 changed files
with
46 additions
and
30 deletions.
There are no files selected for viewing
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
54 changes: 32 additions & 22 deletions
54
app/views/shared/form_answers/_admin_award_year.html.slim
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,32 +1,42 @@ | ||
- current_year = AwardYear.current.year | ||
- selected_year = params[:year] ? params[:year].to_i : current_year | ||
- other_years = AwardYear.admin_switch.keys | ||
- other_years = AwardYear.admin_switch.keys.select{ |year| year <= current_year } | ||
|
||
fieldset.award-year-z-index.applications-filter.award-year-radios | ||
label.applications-filter__label | ||
' Award year | ||
.input__award-years | ||
input type="radio" id="current_year" name="year" value="#{current_year}" data-url="#{url_for(params.permit(:controller, :action).merge(year: current_year, search: params[:search]))}" checked=(current_year == params[:year].to_i || (namespace_name == :assessor && !params[:year])) | ||
label for="current_year" | ||
| Current year | ||
input type="radio" id="all_years" name="year" value="all_years" data-url="#{url_for(params.permit(:controller, :action).merge(year: :all_years, search: params[:search]))}" checked=(params[:year].to_s == 'all_years' || (namespace_name == :admin && !params[:year])) | ||
label for="all_years" | ||
| All years | ||
input type="radio" id="other" name="year" value="#{selected_year}" checked=(current_year != selected_year && other_years.include?(params[:year].to_i)) | ||
label for="other" | ||
| Other | ||
.if-no-js-hide | ||
input type="radio" id="current_year" name="award_year" value="#{current_year}" checked=(current_year == params[:year].to_i || (namespace_name == :assessor && other_years.exclude?(params[:year].to_i))) | ||
label for="current_year" | ||
| Current year | ||
input type="radio" id="all_years" name="award_year" value="all_years" checked=(params[:year].to_s == 'all_years' || (namespace_name == :admin && other_years.exclude?(params[:year].to_i))) | ||
label for="all_years" | ||
| All years | ||
input type="radio" id="other" name="award_year" value="#{selected_year}" checked=(current_year != selected_year && other_years.include?(params[:year].to_i)) | ||
label for="other" | ||
| Other | ||
|
||
.dropdown.other-years-dropdown class="#{(current_year != selected_year && other_years.include?(params[:year].to_i) ? '' : 'hide')}" | ||
a.dropdown-toggle.btn.btn-block.btn-default href="#" data-toggle="dropdown" role="button" aria-expanded="false" | ||
- current_year_text = params[:year].to_s == "all_years" || !params[:year] || !other_years.include?(params[:year].to_i) ? "All Years" : "#{selected_year - 1} - #{selected_year}" | ||
.dropdown.other-years-dropdown class="#{(current_year != selected_year && other_years.include?(params[:year].to_i) ? '' : 'hide')}" | ||
a.dropdown-toggle.btn.btn-block.btn-default href="#" data-toggle="dropdown" role="button" aria-expanded="false" | ||
- current_year_text = params[:year].to_s == "all_years" || !params[:year] || !other_years.include?(params[:year].to_i) ? "All Years" : "#{selected_year - 1} - #{selected_year}" | ||
|
||
= current_year_text | ||
span.caret-container | ||
span.caret | ||
ul.dropdown-menu.dropdown-menu-right | ||
li class="#{'active' if params[:year].to_s == 'all_years' || !params[:year]}" | ||
= link_to "All Years", url_for(params.permit(:controller, :action).merge(year: :all_years, search: params[:search])) | ||
= current_year_text | ||
span.caret-container | ||
span.caret | ||
ul.dropdown-menu.dropdown-menu-right | ||
li class="#{'active' if params[:year].to_s == 'all_years' || !params[:year]}" id="all_years" | ||
= link_to "All Years", "#" | ||
|
||
- AwardYear.admin_switch.each do |year, label| | ||
li class="#{'active' if label == current_year_text}" | ||
= link_to label, url_for(params.permit(:controller, :action).merge(year: year, search: params[:search])) | ||
- AwardYear.admin_switch.each do |year, label| | ||
- if year <= current_year | ||
li class="#{'active' if label == current_year_text}" id="#{year}" | ||
= link_to label, "#" | ||
|
||
select name="year" id="award_year" class="form-control if-js-hide" | ||
option value="all_years" selected=(params[:year].to_s == 'all_years' || (namespace_name == :admin && other_years.exclude?(params[:year].to_i))) | ||
| All years | ||
- AwardYear.admin_switch.each do |year, label| | ||
- if year <= current_year | ||
option value="#{year}" selected=(year == selected_year) | ||
= label |