Merge branch 'buy-list-remote-state' into pre-prod

This commit is contained in:
Barnabé 2021-10-15 10:05:27 +02:00
commit d600bfdb45
5 changed files with 33 additions and 18 deletions

View File

@ -149,12 +149,13 @@ class Admin::BuyListsController < ApplicationController
@p_customer_sheet = PCustomerSheet.find(params[:id]) @p_customer_sheet = PCustomerSheet.find(params[:id])
@p_customer = @p_customer_sheet.p_customer @p_customer = @p_customer_sheet.p_customer
@price_line_id = params[:price_line_id]
if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!) if @p_customer_sheet.update(state: params[:state])
@p_customer_sheets = PCustomerSheet.order(:id).all @p_customer_sheets = PCustomerSheet.where(:state => ["AV BPA", "PAS BPA", "BPA"])
return @p_customer_sheet
redirect_to admin_p_customer_sheet_path(@p_customer_sheet) # redirect_to admin_p_customer_sheet_path(@p_customer_sheet)
else else
render action: "edit" render action: "edit"
@ -235,6 +236,4 @@ class Admin::BuyListsController < ApplicationController
end end
end end

View File

@ -193,13 +193,13 @@ class Admin::PCustomerSheetsController < ApplicationController
@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
respond_to do |format|
format.html{redirect_to admin_p_customer_sheet_path(@p_customer_sheet)}
redirect_to admin_p_customer_sheet_path(@p_customer_sheet) format.js{}
end
else else
render action: "edit" render action: "edit"
@ -207,7 +207,6 @@ class Admin::PCustomerSheetsController < ApplicationController
end end
def destroy def destroy
@p_customer_sheet = PCustomerSheet.find(params[:id]) @p_customer_sheet = PCustomerSheet.find(params[:id])
@p_customer_sheet.destroy @p_customer_sheet.destroy

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

@ -216,7 +216,7 @@
%tbody.detail %tbody.detail
-ppr_lines.each do |price_line| -ppr_lines.each do |price_line|
%tr %tr{id: "price_line_row_#{price_line.id}"}
- if checkbox - if checkbox
%td %td
=check_box_tag :"price_line_ids[]", price_line.id =check_box_tag :"price_line_ids[]", price_line.id
@ -235,7 +235,20 @@
=link_to price_line.p_customer.show_name, [:admin, price_line.p_customer] =link_to price_line.p_customer.show_name, [:admin, price_line.p_customer]
%td %td
=state_helper price_line.price_line_block.price_lineable.state -@p_customer_sheet = price_line.price_line_block.price_lineable
.dropdown
%button.btn.btn-default.dropdown-toggle{"aria-expanded" => "true", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"}
%span.span_cat{'class' => "p_customer_sheet_#{@p_customer_sheet.id}"}
=#@p_customer_sheet.state
=state_helper @p_customer_sheet.state
%span.caret
%ul.dropdown-menu{"aria-labelledby" => "dropdownMenu1"}
-PCustomerSheet::STATES.each do |state|
%li
=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
=ic :check if false
%span=state_helper state
%td %td
=price_line.comment =price_line.comment
@ -364,6 +377,7 @@
checkbox.prop("checked", false) checkbox.prop("checked", false)
} }
}) })
$('.plus-all').click()

View File

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