Permalink
Browse files

Lots of styling love for the new ticket form. It is probably the best…

… form I've built yet.

Allow the user to select a business section when creating a ticket and save that as the component (list of available components goes in app_config.rb).

Remember the user and component in a cookie after they enter them in the new ticket form the first time.

Use cookies to keep 'flash' messages to show whether ticket posting was successful or not.

Rescue from the right exception when creating a new ticket.

Getting there!
  • Loading branch information...
timriley committed Jan 26, 2009
1 parent 0f92461 commit 333242ba2e4e8bad2487a0d6e2991de07a899703
Showing with 134 additions and 30 deletions.
  1. +8 −6 TODO
  2. +5 −1 app_config.example.rb
  3. +17 −1 lib/ticket.rb
  4. +8 −2 unfuddle_mirror.rb
  5. +49 −15 views/new_ticket.haml
  6. +1 −1 views/stylesheets/_base.sass
  7. +38 −3 views/stylesheets/screen.sass
  8. +8 −1 views/ticket_report.haml
View
14 TODO
@@ -1,10 +1,7 @@
+- html escape the data that is submitted in new ticket
+
- put a box around the ticket description when viewing a single ticket
-- clean up the view for submitting tickets
- - need to allow select box for business area (component)
- - use cookies to remember name and component
- - use cookies for the flash[:notice] business
-
- add a button to submit new tickets on the front page
- show ticket comments in the view ticket page (& show how many comments there are per ticket in the index view)
@@ -22,4 +19,9 @@ DONE
- unassigned tickets that are still within the 24 hour period should be a neutral color (grey?)
- only the unassigned tickets that are outside the 24 hour timeframe should be red
-- try to use the real unfuddle reporter if there is no '--reported-->' string in the summary
+- try to use the real unfuddle reporter if there is no '--reported-->' string in the summary
+
+- clean up the view for submitting tickets
+ - need to allow select box for business area (component)
+ - use cookies to remember name and component
+ - use cookies for the flash[:notice] business
View
@@ -2,4 +2,8 @@
:unfuddle_username => 'myuser',
:unfuddle_password => 'mypass',
:unfuddle_project_id => 123,
- :unfuddle_ticket_report_id => 123
+ :unfuddle_ticket_report_id => 123,
+ :unfuddle_components => [
+ [1234, 'Component 1'],
+ [5678, 'Component 2']
+ ]
View
@@ -6,8 +6,16 @@ def self.find(id)
end
def self.create(attrs)
+ attrs = prepare_attributes(attrs)
+
post( "https://#{Sinatra::Application.unfuddle_subdomain}.unfuddle.com/api/v1/projects/#{Sinatra::Application.unfuddle_project_id}/tickets",
- :body => "<ticket><priority>3</priority><summary>#{attrs[:name]}#{delimiter}#{attrs[:summary]}</summary><description>#{attrs[:description]}</description></ticket>",
+ :body => "
+ <ticket>
+ <priority>3</priority>
+ <component-id>#{attrs[:component_id]}</component-id>
+ <summary>#{attrs[:name]}#{delimiter}#{attrs[:summary]}</summary>
+ <description>#{attrs[:description]}</description>
+ </ticket>",
:headers => {'Content-type' => 'application/xml'})
end
@@ -56,4 +64,12 @@ def ticket_summary
end
end
end
+
+ private
+
+ def self.prepare_attributes(attrs)
+ attrs[:name].capitalize!
+ attrs[:summary].capitalize!
+ attrs
+ end
end
View
@@ -70,9 +70,15 @@ def relative_time(time)
end
post '/tickets' do
- success = Ticket.post_ticket(params)
+ response.set_cookie('name', params[:name])
+ response.set_cookie('component_id', params[:component_id])
- set_cookie('notice', success ? 'ticket_successful' : 'ticket_failed')
+ begin
+ Ticket.create(params)
+ response.set_cookie('notice', 'ticket_success')
+ rescue Net::HTTPServerException
+ response.set_cookie('notice', 'ticket_error')
+ end
redirect '/'
end
View
@@ -1,15 +1,49 @@
-%form{:action => '/tickets', :method => 'post'}
- %label{:for => 'name'} Name
- %br/
- %input{:type => 'text', :name => 'name'}/
- %br/
- %label{:for => 'summary'} Summary
- %br/
- %input{:type => 'text', :name => 'summary'}/
- %br/
- %label{:for => 'description'} Description
- %br/
- %textarea{:name => 'desciption'}
- %br/
- %input{:type => 'submit', :value => 'Submit'}/
-
+#new-ticket
+ %h1 Submit an Issue
+
+ %form{:action => '/tickets', :method => 'post'}
+
+ %h3 Your Details
+ .new-ticket-fields
+ %fieldset
+ .field
+ %label{:for => 'name'} Name
+ %input{:type => 'text', :name => 'name', :value => request.cookies['name']}/
+ .field
+ %label{:for => 'component_id'} Section
+ %select{:name => 'component_id'}
+ - Sinatra::Application.unfuddle_components.each do |component|
+ - if request.cookies['component_id'].to_i == component[0].to_i
+ %option{:value => component[0], :selected => 'selected'}= h(component[1])
+ - else
+ %option{:value => component[0]}= h(component[1])
+ .new-ticket-help
+ .help
+ %p
+ We'll remember these details for next time.
+
+ %h3 Your Issue
+ .new-ticket-fields
+ %fieldset
+ .field
+ %label{:for => 'summary'} Summary
+ %input{:type => 'text', :name => 'summary'}/
+ .field
+ %label{:for => 'description'} Description
+ %textarea{:name => 'desciption'}
+ .new-ticket-help
+ .help
+ %p
+ Provide a descriptive summary and include as much information as possible in the description. This will help us address the issue faster.
+ .help
+ %p
+ If you need to provide screenshots or images, please <a href="mailto:helpdesk@amc.org.au">email helpdesk</a> with the images attached.
+
+ %h3 All Done?
+ .new-ticket-fields
+ %fieldset.submit
+ %p
+ Thanks for letting us know about your issue. We'll do our best to get back to you within 24 hours.
+ %p
+ If your issue is urgent, please escalate it to the IT Manager by phone after submitting it here.
+ %input{:type => 'submit', :value => 'Submit'}/
@@ -1,7 +1,7 @@
@import compass/reset.sass
@import compass/utilities.sass
@import blueprint.sass
-@import blueprint/modules/debug.sass
+@import blueprint/modules/interaction.sass
=reset-blueprint-typography
body
@@ -10,17 +10,24 @@ h1
body.blueprint
+blueprint-grid
- +blueprint-debug("../images/grid.png")
.container
+container
body#index
+has-menubar
+has-titlebar
+ .success
+ :background #bbff91
+ :padding .8em
+ :margin-bottom 1em
+ .error
+ :background #ffd4d4
+ :padding .8em
+ :margin-bottom 1em
#tickets
+column(24)
table
- / for assigned tickets ('normal' table rows)
+ / for assigned tickets (the 'normal' table rows)
+alternating-rows-and-columns(#bbff91,#ddffc8,#000)
/ alternating colors for unassigned tickets
tr.unassigned.odd
@@ -45,4 +52,32 @@ body#index
:line-height 1
:margin-bottom 0.5em
:font-weight bold
- :color red
+ :color red
+ #new-ticket
+ +column(18, true)
+ +append(6)
+ h3
+ :clear both
+ :margin-bottom 0.25em
+ .new-ticket-fields
+ +column(12)
+ :margin-bottom 1em
+ fieldset
+ :padding 5px
+ :background #ddffc8
+ .field
+ :margin-bottom 0.75em
+ .new-ticket-help
+ +column(6,true)
+ .help
+ :padding-left 5px
+ :padding-right 5px
+ :background #bbff91
+ label
+ :display block
+ input[type='text']
+ :width 450px
+ :font-size 1.5em
+ textarea
+ :width 455px
+ :height 200px
View
@@ -1,4 +1,11 @@
#tickets
+ - if request.cookies['notice'] == 'ticket_success'
+ .success
+ Ticket added successfully.
+ - elsif request.cookies['notice'] == 'ticket_error'
+ .error
+ Error adding your ticket. Please try again or contact IT.
+
%h1 Helpdesk Tickets
- @ticket_report.ticket_groups.each do |group|
@@ -23,7 +30,7 @@
- group.assigned_tickets.each do |ticket|
%tr{:class => cycle}
= partial('ticket_row', :locals => {:ticket => ticket})
-/
+
/ #sidebar
/ %p
/ %a{:href => '/tickets/new'} New ticket

0 comments on commit 333242b

Please sign in to comment.