WIP remote change p_customer_sheet state

This commit is contained in:
Barnabé 2021-09-23 17:53:01 +02:00
parent 8e7442dcc0
commit fc9a97fe3f
3 changed files with 28 additions and 7 deletions

View File

@ -196,10 +196,13 @@ class Admin::PCustomerSheetsController < ApplicationController
if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!)
@p_customer = @p_customer_sheet.price_line_block.p_customer
redirect_to admin_p_customer_sheet_path(@p_customer_sheet)
@p_customer = @p_customer_sheet.price_line_block.p_customer
if params[:no_redirect] == "true"
@price_line_id = params[:price_line_id]
render "admin/buy_lists/index"
else
redirect_to admin_p_customer_sheet_path(@p_customer_sheet)
end
else
render action: "edit"
@ -207,7 +210,6 @@ class Admin::PCustomerSheetsController < ApplicationController
end
def destroy
@p_customer_sheet = PCustomerSheet.find(params[:id])
@p_customer_sheet.destroy

View File

@ -216,7 +216,7 @@
%tbody.detail
-ppr_lines.each do |price_line|
%tr
%tr{id: "price_line_row_#{price_line.id}"}
- if checkbox
%td
=check_box_tag :"price_line_ids[]", price_line.id
@ -235,7 +235,23 @@
=link_to price_line.p_customer.show_name, [:admin, price_line.p_customer]
%td
=state_helper price_line.price_line_block.price_lineable.state
-@p_customer_sheet = price_line.price_line_block.price_lineable
-if true
%form
=semantic_form_for [:admin, @p_customer_sheet], remote: true, authenticity_token: true do |f|
=f.inputs class: "form-inline d-flex flex-nowrap" do
=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
=hidden_field_tag :no_redirect, "true"
=hidden_field_tag :price_line_id, price_line.id
=f.button ic(:check), type: :submit, class: "btn btn-primary ml-1"
-if false
=f.actions class: "btn btn-primary ml-1" do
=f.action :submit, label: "#{ic(:check).html_safe}"
-if false
=form_with url: update_state_admin_p_customer_sheet_path(@p_customer_sheet), method: :get do |f|
=f.select :state, ["AV BPA", "PAS BPA","BPA", "Traitée"]
=f.submit
=#state_helper price_line.price_line_block.price_lineable.state
%td
=price_line.comment
@ -364,6 +380,7 @@
checkbox.prop("checked", false)
}
})
$('.plus-all').click()

View File

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