Dropdown ok

This commit is contained in:
Barnabé 2021-10-15 10:03:31 +02:00
parent 0199f0e520
commit a7b4ec4c19
5 changed files with 22 additions and 30 deletions

View File

@ -192,16 +192,13 @@ class Admin::PCustomerSheetsController < ApplicationController
def update def update
@p_customer_sheet = PCustomerSheet.find(params[:id]) @p_customer_sheet = PCustomerSheet.find(params[:id])
if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!) if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!)
@p_customer = @p_customer_sheet.price_line_block.p_customer @p_customer = @p_customer_sheet.price_line_block.p_customer
if params[:no_redirect] == "true" respond_to do |format|
@price_line_id = params[:price_line_id] format.html{redirect_to admin_p_customer_sheet_path(@p_customer_sheet)}
render "admin/buy_lists/index" format.js{}
else
redirect_to admin_p_customer_sheet_path(@p_customer_sheet)
end end
else else
render action: "edit" render action: "edit"

View File

@ -44,6 +44,8 @@ class PCustomerSheet < ApplicationRecord
:actions => {:name => "Actions", :reorder => false}, :actions => {:name => "Actions", :reorder => false},
} }
# STATES = ["brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"]
STATES = ["AV BPA", "PAS BPA","BPA", "Traitée"]
def personalised_archive def personalised_archive
@ -328,7 +330,6 @@ class PCustomerSheet < ApplicationRecord
end end
STATES = ["brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"]
def unblock_price def unblock_price

View File

@ -236,25 +236,19 @@
%td %td
-@p_customer_sheet = price_line.price_line_block.price_lineable -@p_customer_sheet = price_line.price_line_block.price_lineable
-form = false .dropdown
-if form %button.btn.btn-default.dropdown-toggle{"aria-expanded" => "true", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"}
%form %span.span_cat{'class' => "p_customer_sheet_#{@p_customer_sheet.id}"}
=semantic_form_for [:admin, @p_customer_sheet], remote: true, authenticity_token: true do |f| =#@p_customer_sheet.state
=f.inputs class: "form-inline d-flex flex-nowrap" do =state_helper @p_customer_sheet.state
=f.input :state, collection: ["AV BPA", "PAS BPA","BPA", "Traitée"], as: :select, :include_blank => false, label: false, selected: f.object.state, input_html: {class: "custom-select"}, remote: true %span.caret
=hidden_field_tag :no_redirect, "true" %ul.dropdown-menu{"aria-labelledby" => "dropdownMenu1"}
=hidden_field_tag :price_line_id, price_line.id -PCustomerSheet::STATES.each do |state|
=f.button ic(:check), type: :submit, class: "btn btn-primary ml-1" %li
-if false =link_to admin_p_customer_sheet_path(:id => @p_customer_sheet.id, :p_customer_sheet => {:state => state}), :method => :put, :remote => true, :onclick => "$('.dropdown-toggle').dropdown('hide');$(\".p_customer_sheet_#{@p_customer_sheet.id}\").html($(this).find('span').html());", :class => "dropdown-item" do
=f.actions class: "btn btn-primary ml-1" do =ic :check if false
=f.action :submit, label: "#{ic(:check).html_safe}" %span=state_helper state
-if !form
%form
=form_with url: admin_buy_list_path(@p_customer_sheet), method: :patch, remote: true, authenticity_token: true, id: "p_customer_sheet_state_#{@p_customer_sheet.id}" do |f|
=hidden_field_tag :price_line_id, price_line.id
=f.select :state, ["AV BPA", "PAS BPA","BPA", "Traitée"]
=f.submit for: "p_customer_sheet_state_#{@p_customer_sheet.id}"
=#state_helper price_line.price_line_block.price_lineable.state
%td %td
=price_line.comment =price_line.comment

View File

@ -1,2 +0,0 @@
console.log('coucou');
$('#price_line_row_<%= @price_line_id %>').replaceWith("<%= escape_javascript(render(@p_customer_sheet))%>");

View File

@ -1,2 +1,4 @@
$('#p_customer_sheets_rows').html("<%= escape_javascript(render(@p_customer_sheets))%>"); <% if @p_customer_sheets %>
close_pane_hover(); $('#p_customer_sheets_rows').html("<%= escape_javascript(render(@p_customer_sheets))%>");
<% end %>
close_pane_hover();