Skip to content

Commit

Permalink
Merge branch 'qa'
Browse files Browse the repository at this point in the history
  • Loading branch information
smeeks committed Dec 5, 2022
2 parents 84a606a + 08d0b81 commit 68460ee
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
7 changes: 6 additions & 1 deletion app/controllers/scenarios_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ class ScenariosController < OrganizationAwareController
#-----------------------------------------------------------------------------
def index
@fy_year = allowed_params[:fy_year] || current_planning_year_year
@status = allowed_params[:status]
@scenarios = Scenario.where(fy_year: @fy_year, organization: current_user.viewable_organizations).order(created_at: :desc)

if @status
@scenarios = @scenarios.where(state: @status)
end

respond_to do |format|
format.html
end
Expand Down Expand Up @@ -187,7 +192,7 @@ def form_params
end

def allowed_params
params.permit(:fy_year)
params.permit(:fy_year, :status)
end

def set_scenario
Expand Down
43 changes: 37 additions & 6 deletions app/views/scenarios/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@
%i.fa.fa-plus
%h5
.row
.col-md-1
.col-md-4
%form
%select#yearSelector
-(2020..2050).each do |year|
%option{value: "#{year}", selected: (year.to_s==@fy_year.to_s)}
=format_as_fiscal_year year
%label{style: "margin-left: 5px;"} Filter by Status
%select#statusFilter
%option{value: "", selected: @status == nil}
- Scenario.all.map{|s| s.state}.uniq.each do |state|
%option{value: state, selected: state == @status}
= state == "cancelled" ? "Closed" : state.titleize
-if current_user.organization.try(:organization_type).try(:name) == "Grantor"
.col-md-10
.col-md-7
.col-md-1
=link_to export_to_csv_draft_projects_path(fy_year: @fy_year) do
%i.fa.fa-file-excel-o
Expand All @@ -21,26 +27,51 @@
.row
.col-md-12
=column_chart Scenario.peaks_and_valleys_chart_data(nil, @fy_year), prefix: "$", stacked: true
=column_chart Scenario.peaks_and_valleys_chart_data(nil, @fy_year), prefix: "$", library: {scales: {yAxes: [{id: 'y-axis', type: 'logarithmic'},]}}
:javascript
$(document).ready(function () {
// Pre-populate filters used for the scenarios table
var scenarioFilters = {fy_year: #{@fy_year}, status: "#{@status}"};

// This controls the year dropdown in each asset table
$("#yearSelector").change(function(){
var year = $(this).val();
goToYear(year);
scenarioFilters["fy_year"] = year;
applyFilters(scenarioFilters);
});

// Filter the table by scenario status
$("#statusFilter").change(function(){
var scenarioStatus = $(this).val();
scenarioFilters["status"] = scenarioStatus;
applyFilters(scenarioFilters);
});
});


function goToYear(year){
window.location.replace("/scenarios?fy_year=" + year);
// function goToYear(year){
// window.location.replace("/scenarios?fy_year=" + year);
// }
function applyFilters(filters){
// Construct params string using filter values
var filtersParamString = "?";
Object.keys(filters).forEach(function(filter) {
if (filters[filter] != "") {
filtersParamString += filter + "=" + filters[filter] + "&";
}
});
filtersParamString = filtersParamString.slice(0, -1);

window.location.replace("/scenarios" + filtersParamString);
}

// function filterByStatus(status){
// window.location.replace("/scenarios?status=" + status);
// }
:ruby
table_dom_id = SecureRandom.hex
Expand Down
2 changes: 1 addition & 1 deletion app/views/scenarios/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
.row
.col-md-12
=column_chart Scenario.peaks_and_valleys_chart_data(@scenario), prefix: "$", stacked: true, label: "Value"
=column_chart Scenario.peaks_and_valleys_chart_data(@scenario), prefix: "$", label: "Value", library: {scales: {yAxes: [{id: 'y-axis', type: 'logarithmic'},]}}
.row
[email protected]_slice(6) do |budgets|
Expand Down
2 changes: 1 addition & 1 deletion lib/transam_cpt/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TransamCpt
VERSION = "2.23.0"
VERSION = "2.26.0"
end

0 comments on commit 68460ee

Please sign in to comment.