summaryrefslogtreecommitdiff
path: root/help
diff options
context:
space:
mode:
authorjessib <jessib@leap.se>2012-12-11 16:18:37 -0800
committerjessib <jessib@leap.se>2012-12-11 16:18:37 -0800
commit524bb47fa5782ca1e0aaf16a4a0836defadfbe48 (patch)
treefca69fdd24858e2b565d19ef1c55d7af25bd25c1 /help
parent4259cad450fee703dc34ebe5322de994d06a5448 (diff)
Start to using x-editable to have title editable.
Diffstat (limited to 'help')
-rw-r--r--help/app/assets/javascripts/tickets.js6
-rw-r--r--help/app/assets/javascripts/tickets.js.coffee6
-rw-r--r--help/app/controllers/tickets_controller.rb21
-rw-r--r--help/app/views/tickets/show.html.haml5
4 files changed, 27 insertions, 11 deletions
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