diff options
Diffstat (limited to 'help/app')
-rw-r--r-- | help/app/controllers/tickets_controller.rb | 8 | ||||
-rw-r--r-- | help/app/models/ticket_selection.rb | 10 | ||||
-rw-r--r-- | help/app/views/tickets/_comment.html.haml | 26 | ||||
-rw-r--r-- | help/app/views/tickets/_new_comment.html.haml | 2 | ||||
-rw-r--r-- | help/app/views/tickets/_ticket_data.html.haml | 25 | ||||
-rw-r--r-- | help/app/views/tickets/new.html.haml | 21 | ||||
-rw-r--r-- | help/app/views/tickets/show.html.haml | 50 |
7 files changed, 74 insertions, 68 deletions
diff --git a/help/app/controllers/tickets_controller.rb b/help/app/controllers/tickets_controller.rb index 297de30..d4aa378 100644 --- a/help/app/controllers/tickets_controller.rb +++ b/help/app/controllers/tickets_controller.rb @@ -66,9 +66,9 @@ class TicketsController < ApplicationController end if @ticket.changed? and @ticket.save flash[:notice] = 'Ticket was successfully updated.' - if @ticket.is_open + if @ticket.is_open || !logged_in? respond_with @ticket - else #for closed tickets, redirect to index. + else #for closed tickets with authenticated users, redirect to index. redirect_to tickets_path end else @@ -83,13 +83,11 @@ class TicketsController < ApplicationController def index @all_tickets = Ticket.for_user(current_user, params, admin?) #for tests, useful to have as separate variable - - #below works if @tickets is a CouchRest::Model::Designs::View, but not if it is an Array @tickets = @all_tickets.page(params[:page]).per(10) - #respond_with(@tickets) end def destroy + # should we allow non-admins to delete their own tickets? i don't think necessary. @ticket = Ticket.find(params[:id]) @ticket.destroy if admin? redirect_to tickets_path diff --git a/help/app/models/ticket_selection.rb b/help/app/models/ticket_selection.rb index cb20f5b..bebe5fc 100644 --- a/help/app/models/ticket_selection.rb +++ b/help/app/models/ticket_selection.rb @@ -8,12 +8,7 @@ class TicketSelection end def tickets - #TODO: can this be more succinct? - if order - Ticket.send(finder_method).startkey(startkey).endkey(endkey).send(order) - else - Ticket.send(finder_method).startkey(startkey).endkey(endkey) - end + Ticket.send(finder_method).startkey(startkey).endkey(endkey).send(order) end protected @@ -47,7 +42,8 @@ class TicketSelection end def order - 'descending' if @options[:sort_order].end_with? 'desc' + # we have defined the ascending method to return the view itself: + (@options[:sort_order].end_with? 'desc') ? 'descending' : 'ascending' end diff --git a/help/app/views/tickets/_comment.html.haml b/help/app/views/tickets/_comment.html.haml index 1ba3bd1..26794dc 100644 --- a/help/app/views/tickets/_comment.html.haml +++ b/help/app/views/tickets/_comment.html.haml @@ -1,13 +1,15 @@ - # style is super ugly but just for now -%div{:style => "border: solid 1px"} - - if User.find(comment.posted_by) - Posted by - = User.find(comment.posted_by).login - - else - Unauthenticated post - %p - Posted at - = comment.posted_at - %p - = comment.body - %p
\ No newline at end of file +%tr + %td + - if commenter = User.find(comment.posted_by) + %b + = 'Posted by' + (commenter.is_admin? ? ' admin' : '') + ':' + = commenter.login + - else + Unauthenticated post + .pull-right + %b + Posted at: + = comment.posted_at.to_s(:short) + %br + = comment.body diff --git a/help/app/views/tickets/_new_comment.html.haml b/help/app/views/tickets/_new_comment.html.haml index 5697854..7307dad 100644 --- a/help/app/views/tickets/_new_comment.html.haml +++ b/help/app/views/tickets/_new_comment.html.haml @@ -1,2 +1,2 @@ = f.simple_fields_for :comments, @comment do |c| - = c.input :body, :label => 'Comment', :as => :text + = c.input :body, :label => 'Comment', :as => :text, :input_html => {:class => "span12", :rows=>4} diff --git a/help/app/views/tickets/_ticket_data.html.haml b/help/app/views/tickets/_ticket_data.html.haml new file mode 100644 index 0000000..3d301be --- /dev/null +++ b/help/app/views/tickets/_ticket_data.html.haml @@ -0,0 +1,25 @@ +.spam12 + %b + Created by: + - if User.find(@ticket.created_by) + = User.find(@ticket.created_by).login + - else + Unauthenticated ticket creator + - if @ticket.email + %b + email: + = @ticket.email + %b + Created at: + = @ticket.created_at.to_s(:short) + %b + Updated at: + = @ticket.updated_at.to_s(:short) + %b + = "Status:" + - if @ticket.is_open + = 'open' + = button_to 'Close', {:post => {:is_open => false}}, :method => :put, :class => 'btn btn-small' + - else + = 'closed' + = button_to 'Open', {:post => {:is_open => true}}, :method => :put, :class => 'btn btn-small'
\ No newline at end of file diff --git a/help/app/views/tickets/new.html.haml b/help/app/views/tickets/new.html.haml index a8c5f8f..750b990 100644 --- a/help/app/views/tickets/new.html.haml +++ b/help/app/views/tickets/new.html.haml @@ -1,10 +1,11 @@ -%h2=t :new_ticket -= simple_form_for(@ticket, :html => {:novalidate => true}) do |f| #turn off html5 validations to test - = f.input :title - = f.input :email if !current_user #hmm--might authenticated users want to submit an alternate email? - = render :partial => 'new_comment', :locals => {:f => f} - = # regarding_user if not logged in - = # email if not logged in - .form-actions - = f.button :submit, :class => 'btn-primary' - = link_to t(:cancel), tickets_path, :class => :btn +.span12 + %h2=t :new_ticket + = simple_form_for(@ticket, :html => {:novalidate => true}) do |f| #turn off html5 validations to test + = f.input :title + = f.input :email if !current_user #hmm--might authenticated users want to submit an alternate email? + = render :partial => 'new_comment', :locals => {:f => f} + = # regarding_user if not logged in + = # email if not logged in + .form-actions + = f.button :submit, :class => 'btn-primary' + = link_to t(:cancel), tickets_path, :class => :btn diff --git a/help/app/views/tickets/show.html.haml b/help/app/views/tickets/show.html.haml index 46d86de..3f00b35 100644 --- a/help/app/views/tickets/show.html.haml +++ b/help/app/views/tickets/show.html.haml @@ -1,34 +1,18 @@ -%h2= @ticket.title +.spam12 + %h2 + %a#title.editable.editable-click{"data-name" => "title", "data-resource" => "post", "data-type" => "text", "data-url" => ticket_path(@ticket.id), "data-pk" => @ticket.id, :href => "#"} + = @ticket.title + = render 'tickets/ticket_data' + %table.table-striped.table-bordered.table-hover{:style => "width:100%;"} + %tbody + = render(:partial => "comment", :collection => @ticket.comments) + = #render @ticket.comments should work if view is in /app/views/comments/_comment -%a#title.editable.editable-click{"data-name" => "title", "data-resource" => "post", "data-type" => "text", "data-url" => ticket_path(@ticket.id), "data-pk" => @ticket.id, :href => "#"} - = @ticket.title - -%p -- if @ticket.email - email: - = @ticket.email -%li - - if User.find(@ticket.created_by) - Created by - = User.find(@ticket.created_by).login - - else - Unauthenticated ticket creator -%li - = "status:" - - if @ticket.is_open - = 'open' - = button_to 'close', {:post => {:is_open => false}}, :method => :put - - else - = 'closed' - = button_to 'open', {:post => {:is_open => true}}, :method => :put -= render(:partial => "comment", :collection => @ticket.comments) -= #render @ticket.comments should work if view is in /app/views/comments/_comment - -= simple_form_for(@ticket, :html => {:novalidate => true}) do |f| #turn off html5 validations to test - = render :partial => 'new_comment', :locals => {:f => f} - = f.button :submit, @post_reply_str - - if @ticket.is_open - = f.button :submit, @reply_close_str, :class => 'btn-primary' -= #link_to t(:destroy), ticket_path, :confirm => 'are you sure?', :method => :delete, :class => :btn if admin? # for link_to to work with delete, need to figure out jquery interaction correctly. see http://stackoverflow.com/questions/3774925/delete-link-sends-get-instead-of-delete-in-rails-3-view etc.. -= button_to 'Destroy', ticket_path, :confirm => 'are you sure?', :class => 'btn btn-danger', :method => :delete if admin? -= link_to t(:cancel), tickets_path, :class => :btn + = simple_form_for(@ticket, :html => {:novalidate => true}) do |f| #turn off html5 validations to test + = render :partial => 'new_comment', :locals => {:f => f} + .span10.offset3 + = f.button :submit, @post_reply_str, :class => 'btn-primary' + - if @ticket.is_open + = f.button :submit, @reply_close_str + = link_to t(:Destroy), ticket_path, :confirm => 'are you sure?', :method => :delete, :class => 'btn btn-danger' if admin? + = link_to t(:cancel), tickets_path, :class => :btn |