From d240e8cdc2ee66f29ee63e69ae185703761c6162 Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Mon, 5 Aug 2019 09:29:57 -0400 Subject: [PATCH] inline list of years --- app/controllers/categories_controller.rb | 1 - app/controllers/schools_controller.rb | 1 - app/views/layouts/_school_header.html.haml | 13 ++++++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index f979a5cc..4900a994 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -17,7 +17,6 @@ class CategoriesController < ApplicationController school_categories = SchoolCategory.for(@school, @category) @years = school_categories.map(&:year).map(&:to_i).sort @year = (params[:year] || @years.last || "2019").to_i - @years.delete(@year) if school_categories.empty? school_categories = [SchoolCategory.new(school: @school, category: @category, year: @year)] diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index e09f769f..e8249545 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -20,7 +20,6 @@ class SchoolsController < ApplicationController @years = @school_categories.map(&:year).map(&:to_i).sort.uniq @year = (params[:year] || @years.last || "2019").to_i - @years.delete(@year) missing_categories = @categories - @school_categories.map(&:category) missing_categories.each do |category| diff --git a/app/views/layouts/_school_header.html.haml b/app/views/layouts/_school_header.html.haml index 4e7f5e72..ba9bc5dc 100644 --- a/app/views/layouts/_school_header.html.haml +++ b/app/views/layouts/_school_header.html.haml @@ -5,17 +5,16 @@ = simple_format(@school.description) - if @year.present? %p - Data from - = "#{@year - 1}-#{@year}" - school year. + - if @years.present? %p - Show year: - - @years.each do |year| + %b Data from: + - @years.sort.reverse.each do |year| +     - if @school_category.present? - = link_to("#{year - 1}-#{year}", school_category_path(@school_category.school, @school_category.category, year: year)) + = link_to_unless(year == @year, "#{year - 1}-#{year}", school_category_path(@school_category.school, @school_category.category, year: year)) - else - = link_to("#{year - 1}-#{year}", school_path(@school, year: year)) + = link_to_unless(year == @year, "#{year - 1}-#{year}", school_path(@school, year: year)) - if @school.district.present? %p %strong District: