Commit 46a0d508 authored by Jean-Noël Rouchon's avatar Jean-Noël Rouchon

Ajout de new_message dans les tickets

parent f0c87318
class TicketsController < ApplicationController
before_action :set_ticket, only: [:show, :edit, :update, :destroy]
before_action :set_ticket, only: [:show, :edit, :update, :destroy, :new_message]
before_action :super_admin_only
# GET /tickets
......@@ -12,6 +12,7 @@ class TicketsController < ApplicationController
# GET /tickets/1.json
def show
@ticket_messages = TicketMessage.where( ticket_id: @ticket.id)
@message = TicketMessage.new
end
# GET /tickets/new
......@@ -23,10 +24,6 @@ class TicketsController < ApplicationController
def edit
end
def messages
@messages = TicketMessage.where(ticket_id: params[:id])
end
# POST /tickets
# POST /tickets.json
def create
......@@ -46,6 +43,12 @@ class TicketsController < ApplicationController
end
end
# POST /tickets/1/new_message
def new_message
TicketMessage.create(user_id: current_user.id, ticket_id: @ticket.id, message: params[:message]) if params[:message]
redirect_to @ticket
end
# PATCH/PUT /tickets/1
# PATCH/PUT /tickets/1.json
def update
......
......@@ -24,10 +24,10 @@
<div class="field">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></span>
<%= f.text_area_tag(:message, "Sujet du ticket", :size => "100x20", class: "form-control" ) %>
<%= f.text_area_tag(:message, "", :size => "100x20", class: "form-control", placeholder: "Sujet du ticket" ) %>
</div>
</div>
<%= end %>
<% end %>
<div class="actions" align="center">
<%= button_tag(class: "btn btn-primary") do %>
<i></i> Valider
......
......@@ -28,9 +28,16 @@
<%= @ticket.config_module %>
</p>
<%= button_to"Edition du ticket", edit_ticket_path(@ticket) %> |
<%= button_to "Edition du ticket", edit_ticket_path(@ticket) %> |
<%= link_to 'Back', tickets_path %>
</div>
<%= form_for(@message, url: "/tickets/#{@ticket.id}/new_message", method: "post") do |f| %>
<%= f.text_area_tag(:message, "", :size => "100x20", class: "form-control" ) %>
<%= button_tag(class: "btn btn-primary") do %>
Valider
<% end %>
<% end %>
<h2>Messages</h2>
......
Rails.application.routes.draw do
resources :ticket_messages
resources :tickets
resources :ticket_categories
resources :ticket_statuses
......@@ -56,8 +56,7 @@ Rails.application.routes.draw do
get 'pads/:id/users' => 'pads#users', :defaults => { :format => :json }
delete 'pads/:id/users' => 'pads#destroy_users', :defaults => { :format => :json }
get 'tickets/:id/messages' => 'tickets#messages', :defaults => { :format => :json }
post 'tickets/:id/new_message' => 'tickets#new_message'
get 'dates' => "dates#index"
get 'pads' => "pads#show"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment