mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Show subcategory data when user selects different subcategory from
analyze dropdown. Finishes #182277850
This commit is contained in:
parent
61978eb45d
commit
6764024cd2
8 changed files with 38 additions and 8 deletions
|
|
@ -3,8 +3,9 @@ class AnalyzeController < SqmApplicationController
|
|||
@category ||= Category.find_by_category_id(params[:category])
|
||||
@categories = Category.all.order(:category_id)
|
||||
|
||||
@subcategory ||= @category.subcategories.order(:subcategory_id).first
|
||||
@subcategory ||= Subcategory.order(:subcategory_id).includes(%i[measures]).first
|
||||
@subcategories = @category.subcategories.order(:subcategory_id)
|
||||
@subcategory ||= Subcategory.find_by_subcategory_id(params[:subcategory])
|
||||
@subcategory ||= @subcategories.first
|
||||
|
||||
@measures = @subcategory.measures.order(:measure_id).includes(%i[scales admin_data_items])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -62,4 +62,8 @@ module AnalyzeHelper
|
|||
def analyze_category_link(district:, school:, academic_year:, category:)
|
||||
"/districts/#{district.slug}/schools/#{school.slug}/analyze?year=#{academic_year.range}&category=#{category.category_id}"
|
||||
end
|
||||
|
||||
def analyze_subcategory_link(district:, school:, academic_year:, category:, subcategory:)
|
||||
"/districts/#{district.slug}/schools/#{school.slug}/analyze?year=#{academic_year.range}&category=#{category.category_id}&subcategory=#{subcategory.subcategory_id}"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { Controller } from "@hotwired/stimulus"
|
|||
// Connects to data-controller="analyze"
|
||||
export default class extends Controller {
|
||||
connect() { }
|
||||
change_category(event) {
|
||||
refresh(event) {
|
||||
window.location = event.target.value
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,12 @@ class GroupedBarColumnPresenter
|
|||
end
|
||||
end
|
||||
|
||||
def basis
|
||||
return '' if type == :all
|
||||
|
||||
type
|
||||
end
|
||||
|
||||
def show_irrelevancy_message?
|
||||
return true if type == :student && !@measure.includes_student_survey_items?
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
<text x="<%= bar_label_x(presenter.position) %>%" y="<%= 20 %>%" text-anchor="middle">
|
||||
<tspan x="<%= bar_label_x(presenter.position) %>%" y="29%">measure not</tspan>
|
||||
<tspan x="<%= bar_label_x(presenter.position) %>%" y="34%">based on </tspan>
|
||||
<tspan x="<%= bar_label_x(presenter.position) %>%" y="39%"><%= presenter.type %> surveys </tspan>
|
||||
<tspan x="<%= bar_label_x(presenter.position) %>%" y="34%">based on</tspan>
|
||||
<tspan x="<%= bar_label_x(presenter.position) %>%" y="39%"><%= presenter.basis %> surveys </tspan>
|
||||
</text>
|
||||
<% elsif presenter.show_insufficient_data_message? %>
|
||||
<rect x="<%= bar_label_x(presenter.position) - 10 %>%" y="<%= 17 %>%" rx="15" ry="15" width="20%" height="<%= 34 %>%" fill="white" stroke="gray" />
|
||||
|
|
|
|||
|
|
@ -14,11 +14,16 @@
|
|||
<div class="d-flex flex-column flex-grow-6 bg-color-white col-3 px-5" data-controller="analyze">
|
||||
<h3 class="sub-header-4">Focus Area</h3>
|
||||
<p>Select a category & subcategory to analyze measure-level results</p>
|
||||
<select id="select-category" class="mx-3 form-select" data-id="category-dropdown" data-action="click->analyze#change_category">
|
||||
<select id="select-category" class="mx-3 form-select" data-id="category-dropdown" data-action="click->analyze#refresh">
|
||||
<% @categories.each do |category| %>
|
||||
<option value="<%= analyze_category_link(district: @district, school: @school, academic_year: @academic_year, category: category) %>" <%= @category.id == category.id ? "selected": "" %> ><%= "#{category.category_id}: #{category.name}" %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
<select id="select-subcategory" class="mx-3 form-select mt-3" data-id="subcategory-dropdown" data-action="click->analyze#refresh">
|
||||
<% @subcategories.each do |subcategory| %>
|
||||
<option value="<%= analyze_subcategory_link(district: @district, school: @school, academic_year: @academic_year, category: @category, subcategory: subcategory) %>" <%= @subcategory.subcategory_id == subcategory.subcategory_id ? "selected": "" %> ><%= "#{subcategory.subcategory_id}: #{subcategory.name}" %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ describe 'District Admin', js: true do
|
|||
let(:category) { Category.find_by_name('Teachers & Leadership') }
|
||||
let(:different_category) { Category.find_by_name('School Culture') }
|
||||
let(:subcategory) { Subcategory.find_by_name('Teachers & The Teaching Environment') }
|
||||
let(:different_subcategory) { Subcategory.find_by_name('Relationships') }
|
||||
let(:measures_for_subcategory) { Measure.where(subcategory:) }
|
||||
let(:scales_for_subcategory) { Scale.where(measure: measures_for_subcategory) }
|
||||
let(:survey_items_for_subcategory) { SurveyItem.where(scale: scales_for_subcategory) }
|
||||
|
|
@ -107,6 +108,9 @@ describe 'District Admin', js: true do
|
|||
go_to_different_category(different_category)
|
||||
district_admin_sees_category_change
|
||||
|
||||
go_to_different_subcategory(different_subcategory)
|
||||
district_admin_sees_subcategory_change
|
||||
|
||||
click_on 'Browse'
|
||||
district_admin_sees_browse_content
|
||||
|
||||
|
|
@ -199,10 +203,18 @@ def district_admin_sees_analyze_content
|
|||
expect(page).to have_text('1:Teachers & Leadership > 1A:Teachers & The Teaching Environment')
|
||||
end
|
||||
|
||||
def go_to_different_category(_category)
|
||||
select different_category.name, from: 'select-category'
|
||||
def go_to_different_category(category)
|
||||
select category.name, from: 'select-category'
|
||||
end
|
||||
|
||||
def district_admin_sees_category_change
|
||||
expect(page).to have_text '2A:Safety'
|
||||
end
|
||||
|
||||
def go_to_different_subcategory(subcategory)
|
||||
select subcategory.name, from: 'select-subcategory'
|
||||
end
|
||||
|
||||
def district_admin_sees_subcategory_change
|
||||
expect(page).to have_text('Relationships')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ describe 'analyze/index' do
|
|||
assign :category, category
|
||||
assign :categories, [category]
|
||||
assign :subcategory, subcategory
|
||||
assign :subcategories, category.subcategories
|
||||
assign :measures, [support_for_teaching, effective_leadership, professional_qualifications]
|
||||
|
||||
render
|
||||
|
|
@ -94,6 +95,7 @@ describe 'analyze/index' do
|
|||
it 'displays user interface controls' do
|
||||
expect(subject).to have_text 'Focus Area'
|
||||
expect(subject).to have_css '#select-category'
|
||||
expect(subject).to have_css '#select-subcategory'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue