summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-06-23 22:14:45 -0700
committerelijah <elijah@riseup.net>2013-06-23 22:14:45 -0700
commitfdf67344a80fcde0aab21c27d00412eeca609ca1 (patch)
tree4aef080bfabd06dc177ff5e1601f43268602b93f
parent9f8549fd485ee3dc9e63850a2af2a8859fdb70cc (diff)
fix several issues with tickets: js error, when to redirect, navigation, localization.
-rw-r--r--help/app/assets/javascripts/tickets.js8
-rw-r--r--help/app/controllers/tickets_controller.rb30
-rw-r--r--help/app/views/tickets/_comment.html.haml4
-rw-r--r--help/app/views/tickets/_edit_form.html.haml10
-rw-r--r--help/app/views/tickets/_new_comment_form.html.haml5
-rw-r--r--help/app/views/tickets/_status-nav.html.haml13
-rw-r--r--help/app/views/tickets/new.html.haml3
-rw-r--r--help/config/locales/en.yml9
-rw-r--r--help/leap_web_help.gemspec2
9 files changed, 50 insertions, 34 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
diff --git a/help/config/locales/en.yml b/help/config/locales/en.yml
index 901cd76..79e745f 100644
--- a/help/config/locales/en.yml
+++ b/help/config/locales/en.yml
@@ -1,5 +1,8 @@
en:
- access_ticket_text: "You can later access this ticket at the url %{full_url}. You might want to bookmark this page to find it again. Anybody with this URL will be able to access this ticket, so if you are on a shared computer you might want to remove it from the browser history"
+ access_ticket_text: >
+ You can later access this ticket at the url %{full_url}. You might want to bookmark this page to find it again.
+ Anybody with this URL will be able to access this ticket, so if you are on a shared computer you might want to
+ remove it from the browser history.
support_tickets: "Support Tickets"
all_tickets: "All Tickets"
my_tickets: "My Tickets"
@@ -14,4 +17,6 @@ en:
close: "Close"
post_reply: "Post Reply"
reply_and_close: "Reply and Close"
- description: "Description" \ No newline at end of file
+ description: "Description"
+ ticket: "Ticket"
+ regarding_account: "Regarding Account" \ No newline at end of file
diff --git a/help/leap_web_help.gemspec b/help/leap_web_help.gemspec
index 09827dc..4914694 100644
--- a/help/leap_web_help.gemspec
+++ b/help/leap_web_help.gemspec
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.summary = "Help Desk for LeapWeb"
s.description = "Managing Tickets for a Leap provider"
- s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "Readme.md"]
+ s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]
s.add_dependency "leap_web_core", LeapWeb::VERSION