From d121373b7c21a29e47708e8b67aeb964202e52c5 Mon Sep 17 00:00:00 2001 From: elijah Date: Sun, 23 Jun 2013 22:14:45 -0700 Subject: fix several issues with tickets: js error, when to redirect, navigation, localization. --- help/app/controllers/tickets_controller.rb | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'help/app/controllers') 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] -- cgit v1.2.3