working on displaying data

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

@ -10,95 +10,104 @@
} }
} }
.indicator { .indicator-container {
padding-top: 6px; .indicator {
height: 90px; padding-top: 6px;
height: 90px;
.indicator-circle {
height: 100%;
position: relative;
.indicator-zones { .indicator-circle {
width: 100%;
height: 100%; height: 100%;
position: relative;
div { .indicator-zones {
width: 100%;
height: 100%; height: 100%;
width: 20%;
float: left;
}
.zone0 { div {
background-color: orange; height: 100%;
} width: 20%;
.zone1 { float: left;
background-color: yellow; }
}
.zone2 { .zone0 {
background-color: lightgreen; background-color: orange;
}
.zone1 {
background-color: yellow;
}
.zone2 {
background-color: lightgreen;
}
.zone3 {
background-color: green;
}
.zone4 {
background: repeating-linear-gradient(45deg, lightgray, green 15px);
}
} }
.zone3 {
background-color: green;
}
.zone4 {
background: repeating-linear-gradient(45deg, lightgray, green 15px);
}
}
.average {
position: absolute;
width: 10%;
height: 125%;
top: -3px;
border: 2px dashed black;
font-weight: bold;
font-size: 12px;
span { .average {
text-align: center;
position: absolute; position: absolute;
width: 7.75em; width: 10%;
} height: 107%;
} top: -3px;
} border: 2px dashed black;
} font-weight: bold;
font-size: 14px;
.indicator {
height: 30px; span {
text-align: center;
.indicator-circle { position: absolute;
width: 100%; width: 7.75em;
height: 100%; margin-top: -1.5em;
}
.average {
span {
top: -13px;
left: -2.5em;
font-size: 10px;
border: none;
line-height: 10px;
} }
} }
} }
&.small { &.short {
height: 90px; .indicator {
height: 30px;
.indicator-circle { .indicator-circle {
width: 90px; width: 100%;
overflow: hidden; height: 100%;
.indicator-zones { .average {
width: 900px; height: 120%;
}
.average { span {
border: none; left: -1.5em;
text-align: center; font-size: 10px;
width: 100%; border: none;
line-height: 90px; line-height: 10px;
}
}
} }
} }
} }
} }
// .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))
end items.uniq.compact.reverse
p.name.downcase.gsub(/\s/, '-') end
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 .row
%strong Parent Category: .col-12
&nbsp; %p
= render partial: 'categories/full_path', locals: {category: @category} = render 'categories/breadcrumbs', school_category: @school_category
- if @category.child_categories.present? .row
%p .col-12
%strong Child Categories: .school_category.p-2
- @category.child_categories.each do |child_category| %h3.title.text-center.pt-3
&nbsp; = @category.name
= link_to child_category.name, child_category
%p= @category.description
%p
%b Total Responses:
= number_with_delimiter(@school_category.response_count)
%p &nbsp; &nbsp; &nbsp;
%strong Questions
- @category.questions.each do |question| %b Average Response:
%p= link_to(question.text, question) = @school_category.answer_index_average.round(1)
(out of 5)
.indicator-container.py-3
= render 'school_categories/indicator', school_category: @school_category
- if @child_school_categories.present?
= link_to 'Edit', edit_category_path(@category) .row
| = render @child_school_categories
= link_to 'Back', categories_path

@ -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