diff options
-rw-r--r-- | app/assets/javascripts/application.js | 1 | ||||
-rw-r--r-- | app/views/home/index.html.haml | 3 | ||||
-rw-r--r-- | help/app/assets/javascripts/tickets.js | 6 | ||||
-rw-r--r-- | help/app/assets/javascripts/tickets.js.coffee | 6 | ||||
-rw-r--r-- | help/app/controllers/tickets_controller.rb | 21 | ||||
-rw-r--r-- | help/app/views/tickets/show.html.haml | 5 |
6 files changed, 28 insertions, 14 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 57e6d62..3fd641c 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -20,6 +20,7 @@ //= require bootstrap-editable-rails //= require bootstrap-editable-inline //= require jquery.pjax +//= require tickets $(function() { $('a:not([data-remote]):not([data-behavior]):not([data-skip-pjax])').pjax('[data-pjax-container]'); diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index dd7e5aa..c02dcad 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,6 +1,3 @@ -%h1 spacer for firefox -%h1 spacer for firefox - Try to fetch a = link_to "cert", cert_path diff --git a/help/app/assets/javascripts/tickets.js b/help/app/assets/javascripts/tickets.js new file mode 100644 index 0000000..524df6f --- /dev/null +++ b/help/app/assets/javascripts/tickets.js @@ -0,0 +1,6 @@ +$("#title").editable({ + }); + +$(document).ready(function () { + $('#title').editable(); +});
\ No newline at end of file diff --git a/help/app/assets/javascripts/tickets.js.coffee b/help/app/assets/javascripts/tickets.js.coffee deleted file mode 100644 index 039ce91..0000000 --- a/help/app/assets/javascripts/tickets.js.coffee +++ /dev/null @@ -1,6 +0,0 @@ -$("#title").editable({ - type: 'text', - pk: 1, - url: '/blah', - title: 'TEXT here' - });
\ No newline at end of file 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 diff --git a/help/app/views/tickets/show.html.haml b/help/app/views/tickets/show.html.haml index 3e4acb9..f09f525 100644 --- a/help/app/views/tickets/show.html.haml +++ b/help/app/views/tickets/show.html.haml @@ -1,8 +1,7 @@ %h2= @ticket.title -= #%a#title.editable.editable-click{"data-name" => "title", "data-original-title" => "Enter username", "data-resource" => "post", "data-type" => "text", "data-url" => ticket_path(@ticket.id), "data-pk" => @ticket.id, :href => "#"} test - -%a#title.editable.editable-click{:href => "#"} test +%a#title.editable.editable-click{"data-name" => "title", "data-original-title" => "Enter username", "data-resource" => "post", "data-type" => "text", "data-url" => ticket_path(@ticket.id), "data-pk" => @ticket.id, :href => "#"} + = @ticket.title %p - if @ticket.email |