Skip to content

Commit

Permalink
Graph for region and district as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenyeargin committed Feb 4, 2024
1 parent a84f043 commit bb1ed4d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
11 changes: 10 additions & 1 deletion app/controllers/admin/districts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ def index
end

# GET /districts/1 or /districts/1.json
def show; end
def show
@manpower_survey = []
@district.chapters.each do |c|
record = { name: c.name, data: {} }
c.manpower_surveys.each do |s|
record[:data][s.survey_date] = s.manpower
end
@manpower_survey << record
end
end

# GET /districts/new
def new
Expand Down
11 changes: 10 additions & 1 deletion app/controllers/admin/regions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ def index
end

# GET /regions/1 or /regions/1.json
def show; end
def show
@manpower_survey = []
@region.chapters.each do |c|
record = { name: c.name, data: {} }
c.manpower_surveys.each do |s|
record[:data][s.survey_date] = s.manpower
end
@manpower_survey << record
end
end

# GET /regions/new
def new
Expand Down
3 changes: 2 additions & 1 deletion app/views/admin/chapters/_chapter.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
</div>

<hr />

<% unless current_page?(admin_chapters_url) %>
<div id="manpower_chart">
<%= line_chart @manpower_survey, title: 'Daily Reported Manpower' %>
</div>

<% unless current_page?(admin_chapters_url) %>
<hr />
<div id="map" class="map-box-form" data-controller="map" data-map-url-value="<%= admin_chapter_path(chapter, format: :json) %>"></div>
<% end %>
5 changes: 5 additions & 0 deletions app/views/admin/districts/_district.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
</div>

<% unless current_page?(admin_districts_url) %>
<hr />
<div id="manpower_chart">
<%= line_chart @manpower_survey, title: 'Daily Reported Manpower' %>
</div>

<hr />
<div data-controller="map" data-map-url-value="<%= map_data_path(format: :json, district_id: district.id) %>">
<div class="row">
Expand Down
5 changes: 5 additions & 0 deletions app/views/admin/regions/_region.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
</div>

<% unless current_page?(admin_regions_url) %>
<hr />
<div id="manpower_chart">
<%= line_chart @manpower_survey, title: 'Daily Reported Manpower' %>
</div>

<hr />
<div data-controller="map" data-map-url-value="<%= map_data_path(format: :json, region_id: region.id) %>">
<div class="row">
Expand Down

0 comments on commit bb1ed4d

Please sign in to comment.