From abc35b774d94597c7a8ca2b7fe481e6ec653fda2 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Thu, 20 Jun 2013 23:07:24 +0200 Subject: [PATCH] Show unbilled items in timeline by default; add dropdown This reduces the need for pagination in the timeline (refs: #a9faa0). --- stoptime.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/stoptime.rb b/stoptime.rb index 98d2ef4..c4f8a26 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1182,7 +1182,11 @@ module StopTime::Controllers # Retrieves all registered time in descending order to present # the timeline using Views#time_entries def get - @time_entries = TimeEntry.all(:order => "start DESC") + if @input["show"] == "all" + @time_entries = TimeEntry.all(:order => "start DESC") + else + @time_entries = TimeEntry.joins(:task).where("stoptime_tasks.invoice_id" => nil) + end @time_entries.each do |te| @input["bill_#{te.id}"] = true if te.bill? end @@ -1518,6 +1522,16 @@ module StopTime::Views h1 do text! "Timeline" small "#{@time_entries.count} time entries" + div.btn_group.pull_right do + a.btn.btn_small.dropdown_toggle :href => "#", "data-toggle" => "dropdown" do + text! @input["show"] == "all" ? "All" : "Unbilled" + span.caret + end + ul.dropdown_menu :role => "menu", :aria_labelledby => "dLabel" do + li { a "All", :href => R(Timeline, :show => "all") } + li { a "Unbilled", :href => R(Timeline, :show => "unbilled") } + end + end end end end