From 6b04ec86027cf768594a58c25fb1f17cab78c5e8 Mon Sep 17 00:00:00 2001 From: hanneshal Date: Mon, 3 Dec 2012 22:53:00 +0100 Subject: [PATCH] possible fix for issue #10 please review my implementation --- .../agent_ticket_history.js.coffee | 37 ++++++++++++++++++- .../app/views/agent_ticket_history.jst.eco | 1 + 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee index dd2352800..59e7ba1b7 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee @@ -1,4 +1,9 @@ class App.TicketHistory extends App.ControllerModal + + events: + 'click [data-type=sortorder]': 'sortorder', + 'click .close': 'close', + constructor: -> super @fetch(@ticket_id) @@ -48,4 +53,34 @@ class App.TicketHistory extends App.ControllerModal @userPopups() # show frontend times - @delay( @frontendTimeUpdate, 200 ) \ No newline at end of file + @delay( @frontendTimeUpdate, 200 ) + + sortorder: -> + isSorted = @el.find('.sorted') + @log 'is sorted?', isSorted + if isSorted.length + @sortstate = 'notsorted' + @html App.view('agent_ticket_history')( + objects: App.Collection.all( type: 'History' ), + state: @sortstate + ) + else + @sortstate = 'sorted' + @html App.view('agent_ticket_history')( + objects: App.Collection.all( type: 'History' ).reverse(), + state: @sortstate + ) + + + @modalShow() + + # enable user popups + @userPopups() + + # show frontend times + @delay( @frontendTimeUpdate, 200 ) + + close: -> + # close modal + @modalHide() + diff --git a/app/assets/javascripts/app/views/agent_ticket_history.jst.eco b/app/assets/javascripts/app/views/agent_ticket_history.jst.eco index 3cb1f2038..00f1c7161 100644 --- a/app/assets/javascripts/app/views/agent_ticket_history.jst.eco +++ b/app/assets/javascripts/app/views/agent_ticket_history.jst.eco @@ -1,6 +1,7 @@