From 524bb47fa5782ca1e0aaf16a4a0836defadfbe48 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 11 Dec 2012 16:18:37 -0800 Subject: Start to using x-editable to have title editable. --- help/app/controllers/tickets_controller.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'help/app/controllers/tickets_controller.rb') diff --git a/help/app/controllers/tickets_controller.rb b/help/app/controllers/tickets_controller.rb index 3ff19b8..b79dc0f 100644 --- a/help/app/controllers/tickets_controller.rb +++ b/help/app/controllers/tickets_controller.rb @@ -1,6 +1,6 @@ class TicketsController < ApplicationController - respond_to :html #, :json + respond_to :html, :json #has_scope :open, :type => boolean before_filter :set_strings @@ -52,7 +52,24 @@ class TicketsController < ApplicationController @ticket = Ticket.find(params[:id]) if !ticket_access_denied? - if status = params[:change_status] #close or open button was pressed + + if params[:post][:title] #title was changed with x-editable form + + respond_to do |format| + if @ticket.update_attributes(params[:post]) + format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' } + format.json { head :no_content } # 204 No Content + else + format.html { render action: "show" } + format.json { render json: @ticket.errors, status: :unprocessable_entity } + end + return + end + # TODO: do we want to keep the history of title changes? one possibility was adding a comment that said something like 'user changed the title from a to b' + + # TODO: this is throwing a missing template error + return + elsif status = params[:change_status] #close or open button was pressed @ticket.close if params[:change_status] == 'close' @ticket.reopen if params[:change_status] == 'open' else -- cgit v1.2.3