Class: LesliSupport::TicketsController
- Inherits:
-
ApplicationController
- Object
- Lesli::ApplicationLesliController
- ApplicationController
- LesliSupport::TicketsController
- Defined in:
- app/controllers/lesli_support/tickets_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #images ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/lesli_support/tickets_controller.rb', line 52 def create ticket = TicketService.new(current_user, query).create(ticket_params) @ticket = ticket.result if ticket.successful? success('ticket creado de forma exitosass') respond_with_lesli( #:html => redirect_to(ticket_path(@ticket.id)), :turbo => stream_redirection(ticket_path(@ticket.id)) ) else respond_with_lesli( :turbo => ticket.errors_as_sentence ) end end |
#destroy ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/controllers/lesli_support/tickets_controller.rb', line 87 def destroy return respond_with_not_found unless @ticket return unless @ticket.is_editable_by?(current_user) ticket_destroy_response = TicketServices.destroy(current_user, @ticket) if ticket_destroy_response.successful? respond_with_successful else respond_with_error(ticket_destroy_response.payload.errors..to_sentence) end end |
#edit ⇒ Object
49 50 |
# File 'app/controllers/lesli_support/tickets_controller.rb', line 49 def edit end |
#images ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/controllers/lesli_support/tickets_controller.rb', line 100 def images return respond_with_not_found unless @ticket images = @ticket.files.filter do |file| file_name = "" file_name = file..downcase if file. file_name = file..downcase if file. file_name.end_with?('png') || file_name.end_with?('jpg') || file_name.end_with?('jpeg') end images = images.map do |image| { id: image.id, name: image.name, src: "/help/tickets/#{@ticket.id}/files/#{image.id}", href: "/help/tickets/#{@ticket.id}/files/#{image.id}?view=true" } end respond_with_successful(images) end |
#index ⇒ Object
37 38 39 |
# File 'app/controllers/lesli_support/tickets_controller.rb', line 37 def index @tickets = respond_with_pagination(TicketService.new(current_user, query).index) end |
#new ⇒ Object
45 46 47 |
# File 'app/controllers/lesli_support/tickets_controller.rb', line 45 def new @ticket = Ticket.new end |
#show ⇒ Object
41 42 43 |
# File 'app/controllers/lesli_support/tickets_controller.rb', line 41 def show @ticket = @ticket.show end |
#update ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/lesli_support/tickets_controller.rb', line 69 def update if @ticket.update(ticket_params) # log( # subject: @invite, # description: "Ticket updated successfully" # ) respond_with_lesli( :turbo => stream_notification_success("Ticket updated successfully") ) else respond_with_lesli( :turbo => stream_notification_danger(@ticket.errors) #:turbo => stream_notification_danger(@ticket.errors.full_messages.to_sentence) ) end end |