diff options
author | Azul <azul@leap.se> | 2012-11-27 10:01:07 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-11-27 10:01:07 +0100 |
commit | be479d2c55d502c6e4303700b68e0a619f646834 (patch) | |
tree | 1ff9e4f0db9ab9bee2d2e0f3ace5f099bff28034 /help | |
parent | a8b8a7b5431f57ebcf295b8d9389d44cc3a49e8e (diff) |
bunch of refactoring for the ticket index
* using different partials for different parts of the view
* using render @tickets.all to iterate over the tickets. #all is necessary because of CouchRest Model
* using helpers for easier querying for the open_status and admin_status params
* using helper for avoiding duplication when linking to status
Diffstat (limited to 'help')
-rw-r--r-- | help/app/helpers/tickets_helper.rb | 15 | ||||
-rw-r--r-- | help/app/views/tickets/_admin-nav.html.haml | 5 | ||||
-rw-r--r-- | help/app/views/tickets/_order-nav.html.haml | 7 | ||||
-rw-r--r-- | help/app/views/tickets/_status-nav.html.haml | 7 | ||||
-rw-r--r-- | help/app/views/tickets/_table-nav.html.haml | 5 | ||||
-rw-r--r-- | help/app/views/tickets/_ticket.html.haml | 13 | ||||
-rw-r--r-- | help/app/views/tickets/index.html.haml | 37 |
7 files changed, 56 insertions, 33 deletions
diff --git a/help/app/helpers/tickets_helper.rb b/help/app/helpers/tickets_helper.rb new file mode 100644 index 0000000..c683be3 --- /dev/null +++ b/help/app/helpers/tickets_helper.rb @@ -0,0 +1,15 @@ +module TicketsHelper + + def status + params[:open_status] || 'open' + end + + def admin + params[:admin_status] || 'all' + end + + def link_to_status(new_status) + label = new_status + ' issues' + link_to label, :open_status => new_status, :admin_status => admin + end +end diff --git a/help/app/views/tickets/_admin-nav.html.haml b/help/app/views/tickets/_admin-nav.html.haml new file mode 100644 index 0000000..acd45d7 --- /dev/null +++ b/help/app/views/tickets/_admin-nav.html.haml @@ -0,0 +1,5 @@ +%ul.nav.nav-pills.nav-stacked + %li{:class => ("active" if admin == 'mine')} + = link_to 'tickets i admin', {:admin_status => 'mine', :open_status => status} + %li{:class => ("active" if admin_status == 'all')} + = link_to 'all tickets', {:admin_status => 'all', :open_status => status} diff --git a/help/app/views/tickets/_order-nav.html.haml b/help/app/views/tickets/_order-nav.html.haml new file mode 100644 index 0000000..176acdc --- /dev/null +++ b/help/app/views/tickets/_order-nav.html.haml @@ -0,0 +1,7 @@ +%ul.nav.nav-pills.pull-right + %li + = link_to 'created at' + %li{:class=> ("active" if true)} + = link_to do + %i.icon-arrow-up + updated at diff --git a/help/app/views/tickets/_status-nav.html.haml b/help/app/views/tickets/_status-nav.html.haml new file mode 100644 index 0000000..69f4248 --- /dev/null +++ b/help/app/views/tickets/_status-nav.html.haml @@ -0,0 +1,7 @@ +%ul.nav.nav-tabs + %li{:class => ("active" if status == 'open')} + = link_to_status 'open' + %li{:class => ("active" if status == 'closed')} + = link_to_status 'closed' + %li{:class => ("active" if status == 'all')} + = link_to_status 'all' diff --git a/help/app/views/tickets/_table-nav.html.haml b/help/app/views/tickets/_table-nav.html.haml new file mode 100644 index 0000000..635b59b --- /dev/null +++ b/help/app/views/tickets/_table-nav.html.haml @@ -0,0 +1,5 @@ +.row + .span6 + = render 'tickets/status-nav' + .span4 + = render 'tickets/order-nav' diff --git a/help/app/views/tickets/_ticket.html.haml b/help/app/views/tickets/_ticket.html.haml new file mode 100644 index 0000000..3edfa8b --- /dev/null +++ b/help/app/views/tickets/_ticket.html.haml @@ -0,0 +1,13 @@ +%tr + %td + %b + = link_to ticket.title, ticket + %br + %small + created: + = ticket.created_at.to_s(:short) + updated: + = ticket.updated_at.to_s(:short) + %small.pull-right + comments by: + = ticket.commenters diff --git a/help/app/views/tickets/index.html.haml b/help/app/views/tickets/index.html.haml index 7f8fa34..fdbeec5 100644 --- a/help/app/views/tickets/index.html.haml +++ b/help/app/views/tickets/index.html.haml @@ -7,41 +7,12 @@ Create a .row .span2 - if admin? - %h4 whose tickets - %ul.nav.nav-pills.nav-stacked - %li{:class => ("active" if params[:admin_status] == 'mine')} - = link_to 'tickets i admin', {:admin_status => 'mine', :open_status => params[:open_status]} - %li{:class => ("active" if params[:admin_status] != 'mine')} - = link_to 'all tickets', {:admin_status => 'all', :open_status => params[:open_status]} + = render 'tickets/admin-nav' .span10 - .row - .span6 - %ul.nav.nav-tabs - %li{:class => ("active" if params[:open_status] != 'closed' and params[:open_status] != 'all')} - = link_to 'open issues', {:open_status => 'open', :admin_status => params[:admin_status]} - %li{:class => ("active" if params[:open_status] == 'closed')} - = link_to 'closed issues', {:open_status => 'closed', :admin_status => params[:admin_status]} - = #%a{:href => "#"} closed issue - %li{:class => ("active" if params[:open_status] == 'all')} - = link_to 'open & closed issues', {:open_status => 'all', :admin_status => params[:admin_status]} - .span4 - %ul.nav.nav-pills.pull-right - %li - = link_to 'created at' - %li{:class=> ("active" if true)} - = link_to 'updated at' - %table.table-striped.table-bordered.table-hover + = render 'tickets/table-nav' + %table.table-striped.table-bordered.table-hover{:style => "width:100%;"} %tbody - - @tickets.each do |ticket| - %tr - %td - = link_to ticket.title, ticket - created: - = ticket.created_at.to_s(:short) - updated: - = ticket.updated_at.to_s(:short) - comments by: - = ticket.commenters + = render @tickets.all = paginate @tickets %div{"data-pjax-container" => ""} |