diff options
author | elijah <elijah@riseup.net> | 2013-06-23 22:14:45 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2013-06-23 22:14:45 -0700 |
commit | fdf67344a80fcde0aab21c27d00412eeca609ca1 (patch) | |
tree | 4aef080bfabd06dc177ff5e1601f43268602b93f /help/app | |
parent | 9f8549fd485ee3dc9e63850a2af2a8859fdb70cc (diff) |
fix several issues with tickets: js error, when to redirect, navigation, localization.
Diffstat (limited to 'help/app')
-rw-r--r-- | help/app/assets/javascripts/tickets.js | 8 | ||||
-rw-r--r-- | help/app/controllers/tickets_controller.rb | 30 | ||||
-rw-r--r-- | help/app/views/tickets/_comment.html.haml | 4 | ||||
-rw-r--r-- | help/app/views/tickets/_edit_form.html.haml | 10 | ||||
-rw-r--r-- | help/app/views/tickets/_new_comment_form.html.haml | 5 | ||||
-rw-r--r-- | help/app/views/tickets/_status-nav.html.haml | 13 | ||||
-rw-r--r-- | help/app/views/tickets/new.html.haml | 3 |
7 files changed, 42 insertions, 31 deletions
diff --git a/help/app/assets/javascripts/tickets.js b/help/app/assets/javascripts/tickets.js index 5376a6e..bf7965c 100644 --- a/help/app/assets/javascripts/tickets.js +++ b/help/app/assets/javascripts/tickets.js @@ -1,4 +1,4 @@ -$(document).ready(function () { - $.fn.editable.defaults.mode = 'inline'; - $('#title').editable(); -});
\ No newline at end of file +//$(document).ready(function () { +// $.fn.editable.defaults.mode = 'inline'; +// $('#title').editable(); +//});
\ No newline at end of file diff --git a/help/app/controllers/tickets_controller.rb b/help/app/controllers/tickets_controller.rb index d478da9..3be7d10 100644 --- a/help/app/controllers/tickets_controller.rb +++ b/help/app/controllers/tickets_controller.rb @@ -42,19 +42,18 @@ class TicketsController < ApplicationController if params[:commit] == t(:close) @ticket.is_open = false @ticket.save - redirect_to tickets_path + redirect_to_tickets elsif params[:commit] == t(:open) @ticket.is_open = true @ticket.save redirect_to @ticket + elsif params[:commit] == t(:cancel) + redirect_to_tickets else @ticket.attributes = cleanup_ticket_params(params[:ticket]) if params[:commit] == t(:reply_and_close) @ticket.close - should_redirect = true - else - should_redirect = !logged_in? end if @ticket.comments_changed? @@ -64,11 +63,7 @@ class TicketsController < ApplicationController if @ticket.changed? if @ticket.save flash[:notice] = t(:changes_saved) - if should_redirect - redirect_to tickets_path - else - redirect_to @ticket - end + redirect_to_tickets else respond_with @ticket end @@ -97,6 +92,23 @@ class TicketsController < ApplicationController private + # + # redirects to ticket index, if appropriate. + # otherwise, just redirects to @ticket + # + def redirect_to_tickets + if logged_in? + if params[:commit] == t(:reply_and_close) + redirect_to tickets_url + else + redirect_to @ticket + end + else + # if we are not logged in, there is no index to view + redirect_to @ticket + end + end + # unset comments hash if no new comment was typed def cleanup_ticket_params(ticket) if ticket && ticket[:comments_attributes] diff --git a/help/app/views/tickets/_comment.html.haml b/help/app/views/tickets/_comment.html.haml index c02246c..4252eee 100644 --- a/help/app/views/tickets/_comment.html.haml +++ b/help/app/views/tickets/_comment.html.haml @@ -6,9 +6,9 @@ - if comment.posted_by_user = comment.posted_by_user.login - else - = t(:unknown) + = t(:anonymous) %div= comment.posted_at.to_s(:short) - - if comment.posted_by_user.is_admin? + - if comment.posted_by_user && comment.posted_by_user.is_admin? %div %span.label.label-inverse = t(:admin) diff --git a/help/app/views/tickets/_edit_form.html.haml b/help/app/views/tickets/_edit_form.html.haml index 3d1d879..151d6f1 100644 --- a/help/app/views/tickets/_edit_form.html.haml +++ b/help/app/views/tickets/_edit_form.html.haml @@ -20,8 +20,7 @@ - else %span.label.label-success= t(:closed) %span.label.label-clear= t(:created_by_on, :user => created_by, :time => @ticket.created_at.to_s(:short)).html_safe - = t(:subject) - %br + %div= t(:subject) = f.text_field :title, :class => 'large full-width' .row-fluid .span4 @@ -32,15 +31,14 @@ = f.text_field :email .span4 %div - = t(:regarding) + = t(:regarding_account) = regarding_user_link = f.text_field :regarding_user = f.submit t(:save), :class => 'btn' - if @ticket.is_open? = f.submit t(:close), :class => 'btn' - =# button_to t(:close), {:post => {:is_open => false}}, :method => :put, :class => 'btn' - else = f.submit t(:open), :class => 'btn' - =# button_to t(:open), {:post => {:is_open => true}}, :method => :put, :class => 'btn' - + - if admin? + = link_to t(:destroy), ticket_path, :confirm => 'are you sure?', :method => :delete, :class => 'btn' diff --git a/help/app/views/tickets/_new_comment_form.html.haml b/help/app/views/tickets/_new_comment_form.html.haml index b273503..de54259 100644 --- a/help/app/views/tickets/_new_comment_form.html.haml +++ b/help/app/views/tickets/_new_comment_form.html.haml @@ -7,7 +7,6 @@ - if admin? = c.input :private, :as => :boolean, :label => false, :inline_label => true = f.button :submit, t(:post_reply), :class => 'btn-primary' - - if @ticket.is_open + - if logged_in? && @ticket.is_open = f.button :submit, t(:reply_and_close) - = 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 + = link_to t(:cancel), tickets_path, :class => :btn diff --git a/help/app/views/tickets/_status-nav.html.haml b/help/app/views/tickets/_status-nav.html.haml index e1dca84..c8279ed 100644 --- a/help/app/views/tickets/_status-nav.html.haml +++ b/help/app/views/tickets/_status-nav.html.haml @@ -1,9 +1,10 @@ %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' + - if logged_in? + %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' %li{:class => ("active" if action?(:new))} = link_to icon(:plus, :black) + t(:new_ticket), new_ticket_path diff --git a/help/app/views/tickets/new.html.haml b/help/app/views/tickets/new.html.haml index acb9537..7d3f76c 100644 --- a/help/app/views/tickets/new.html.haml +++ b/help/app/views/tickets/new.html.haml @@ -14,4 +14,5 @@ = c.input :private, :as => :boolean, :label => false, :inline_label => true .form-actions = f.button :submit, :class => 'btn-primary' - = link_to t(:cancel), tickets_path, :class => :btn + - if logged_in? + = link_to t(:cancel), tickets_path, :class => :btn |