working on displaying data

pull/1/head
Jared Cosulich 9 years ago
parent 74ff33d74e
commit a8862d1734

@ -10,6 +10,7 @@
} }
} }
.indicator-container {
.indicator { .indicator {
padding-top: 6px; padding-top: 6px;
height: 90px; height: 90px;
@ -48,21 +49,23 @@
.average { .average {
position: absolute; position: absolute;
width: 10%; width: 10%;
height: 125%; height: 107%;
top: -3px; top: -3px;
border: 2px dashed black; border: 2px dashed black;
font-weight: bold; font-weight: bold;
font-size: 12px; font-size: 14px;
span { span {
text-align: center; text-align: center;
position: absolute; position: absolute;
width: 7.75em; width: 7.75em;
margin-top: -1.5em;
} }
} }
} }
} }
&.short {
.indicator { .indicator {
height: 30px; height: 30px;
@ -71,34 +74,40 @@
height: 100%; height: 100%;
.average { .average {
height: 120%;
span { span {
top: -13px; left: -1.5em;
left: -2.5em;
font-size: 10px; font-size: 10px;
border: none; border: none;
line-height: 10px; line-height: 10px;
} }
} }
} }
&.small {
height: 90px;
.indicator-circle {
width: 90px;
overflow: hidden;
.indicator-zones {
width: 900px;
}
.average {
border: none;
text-align: center;
width: 100%;
line-height: 90px;
} }
} }
} }
} // .indicator {
//
// &.small {
// height: 90px;
//
// .indicator-circle {
// width: 90px;
// overflow: hidden;
//
// .indicator-zones {
// width: 900px;
// }
//
// .average {
// border: none;
// text-align: center;
// width: 100%;
// line-height: 90px;
// }
// }
// }
//
// }

@ -11,6 +11,8 @@ class CategoriesController < ApplicationController
# GET /categories/1 # GET /categories/1
# GET /categories/1.json # GET /categories/1.json
def show def show
@school_category = SchoolCategory.for(@school, @category).first
@child_school_categories = SchoolCategory.for_parent_category(@school, @category)
end end
# GET /categories/new # GET /categories/new

@ -10,7 +10,7 @@ class SchoolsController < ApplicationController
# GET /schools/1 # GET /schools/1
# GET /schools/1.json # GET /schools/1.json
def show def show
@school_categories = @school.school_categories.for_parent_category(nil).sort @school_categories = @school.school_categories.for_parent_category(@school, nil).sort
end end
# GET /schools/new # GET /schools/new

@ -9,12 +9,15 @@ class Category < ApplicationRecord
scope :for_parent, -> (category=nil) { where(parent_category_id: category.try(:id)) } scope :for_parent, -> (category=nil) { where(parent_category_id: category.try(:id)) }
def root_identifier def path
p = self p = self
while p.parent_category.present? items = [p]
p = p.parent_category items << p while (p = p.try(:parent_category))
items.uniq.compact.reverse
end end
p.name.downcase.gsub(/\s/, '-')
def root_identifier
path.first.name.downcase.gsub(/\s/, '-')
end end
def root_index def root_index

@ -7,7 +7,7 @@ class SchoolCategory < ApplicationRecord
validates_associated :category validates_associated :category
scope :for, -> (school, category) { where(school: school).where(category: category) } scope :for, -> (school, category) { where(school: school).where(category: category) }
scope :for_parent_category, -> (category=nil) { joins(:category).merge(Category.for_parent(category)) } scope :for_parent_category, -> (school, category=nil) { where(school: school).joins(:category).merge(Category.for_parent(category)) }
def answer_index_average def answer_index_average
answer_index_total.to_f / response_count.to_f answer_index_total.to_f / response_count.to_f

@ -0,0 +1,2 @@
%p
= school_category.category.path.map { |c| link_to(c.name, [school_category.school, c]) }.join(' > ').html_safe

@ -1,38 +1,30 @@
%p#notice= notice = render 'layouts/school_header'
%p
%strong Name:
= @category.name
%p
%strong Blurb:
= @category.blurb
%p
%strong Description:
= @category.description
%p
%strong External:
= @category.external_id
%p
%strong Parent Category:
&nbsp;
= render partial: 'categories/full_path', locals: {category: @category}
- if @category.child_categories.present? .row
.col-12
%p %p
%strong Child Categories: = render 'categories/breadcrumbs', school_category: @school_category
- @category.child_categories.each do |child_category|
&nbsp;
= link_to child_category.name, child_category
.row
.col-12
.school_category.p-2
%h3.title.text-center.pt-3
= @category.name
%p= @category.description
%p %p
%strong Questions %b Total Responses:
= number_with_delimiter(@school_category.response_count)
- @category.questions.each do |question| &nbsp; &nbsp; &nbsp;
%p= link_to(question.text, question)
%b Average Response:
= @school_category.answer_index_average.round(1)
(out of 5)
.indicator-container.py-3
= render 'school_categories/indicator', school_category: @school_category
= link_to 'Edit', edit_category_path(@category) - if @child_school_categories.present?
| .row
= link_to 'Back', categories_path = render @child_school_categories

@ -0,0 +1,10 @@
.row
.col
=# link_to(image_tag(@district.logo), @district) if @district.present?
%h2= link_to @school.name, @school
= simple_format(@school.description)
%p Data for 2015-2016 school year.
- if @school.district.present?
%p
%strong District:
= link_to @school.district.name, @school.district

@ -1,12 +1,12 @@
.col-4.py-3 .col-6.py-3
.school_category.p-2 .school_category.short.p-2
%h4.title.text-center.pt-3 %h4.title.text-center.pt-3
= link_to(school_category.category.name, [school_category.school, school_category.category]) = link_to(school_category.category.name, [school_category.school, school_category.category])
.indicator-container .indicator-container.short
= render 'school_categories/indicator', school_category: school_category = render 'school_categories/indicator', school_category: school_category
.description.px-2.pt-3.pb-2 .description.px-2.pt-3.pb-2.mt-2
- if false #(measurements = school_category.questions.measurements.for_school(school_measure.school)).present? - if false #(measurements = school_category.questions.measurements.for_school(school_measure.school)).present?
= render 'measurements/nonlikert', measurement: measurements.first, description: school_measure.measure.description = render 'measurements/nonlikert', measurement: measurements.first, description: school_measure.measure.description
- else - else

@ -1,12 +1,4 @@
.row = render 'layouts/school_header'
.col
%p
%strong Name:
= @school.name
- if @school.district.present?
%p
%strong District:
= link_to @school.district.name, @school.district
.row .row
= render @school_categories = render @school_categories

Loading…
Cancel
Save