From d6993596481757c904f8f908f03545b1aa71aefd Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Sun, 10 Mar 2013 22:18:59 -0500 Subject: [PATCH] Move the view logic back into the helper Staleness#days_stale only gives us the number of days that a Todo has been stale. Add the logic for choosing the CSS class to use back to the view helper. --- app/helpers/todos_helper.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 2898dbc4..2efdb27e 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -173,7 +173,18 @@ module TodosHelper # * l3: created more than 3 x staleness_starts # def staleness_class(item) - Staleness.days_stale(item, current_user) + days_stale = Staleness.days_stale(item, current_user) + start = current_user.prefs.staleness_starts + case days_stale + when 0...start + "" + when start...start*2 + " stale_l1" + when start*2...start*3 + " stale_l2" + else + " stale_l3" + end end def show_date_tag(date, the_class, text)