From c2aaf253649281fee8e79a3300d81c827d9a1fd1 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 11 Jan 2017 09:51:34 +0100 Subject: [PATCH] =?utf8?q?ActionBar:=20existierende=20Inputs=20namens=20?= =?utf8?q?=C2=BBaction=C2=AB=20vor=20Submit=20entfernen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Wenn man zuerst druckt und dabei »action« auf z.B. »print« gesetzt wird, so wird anschließend das PDF heruntergeladen. Allerdings verbleibt die »action=print« in der Form. Wenn dann anschließend einer der Menüpunkte angeklickt wird, z.B. »Erneuern«, so wurde nur ein weiterer Hidden namens »action_update=1« ergänzt und die Form abgeschickt. Da aber »action=print« weiterhin gilt (und nicht »action=dispatch«), wird weiterhin das Drucken ausgeführt und nicht das Erneuern. Ähnlich sähe es aus, wenn beim Drucken nicht »action=print« sondern »action_print=1« hinzugefügt wird. Auch dann würde beim Erneuern »action_update=1« hinzugefügt, und schon hätte man zwei »action_…«-Einträge in der Form. Dann käme es darauf an, in welcher Reihenfolge die »sub dispatch« die gesetzten Actions überprüft. Generell ist das Problem bei jedem Submit via JavaScript, dass die auszuführende Action irgendwie gesetzt werden muss, und dass man sich andererseits auch nicht darauf verlassen kann, dass »action=dispatch« gilt. Die einzig zuverlässige Variante ist: 1. den Dispatcher-Mechanismus von bin/mozilla gar nicht benutzen, weil sich der darauf verlässt, dass »action=dispatch« gilt, 2. zuerst dafür zu sorgen, dass in der Form keine Input mit Namen »action« vorhanden ist und 3. anschließend einen Input mit Namen »action=gewünschte Action« hinzuzufügen. Das ist genau das, was dieser Commit implementiert. --- SL/Controller/CustomerVendor.pm | 18 +++++++-------- bin/mozilla/do.pl | 22 +++++++++--------- bin/mozilla/ir.pl | 14 ++++++------ bin/mozilla/is.pl | 20 ++++++++-------- bin/mozilla/oe.pl | 24 ++++++++++---------- js/kivi.ActionBar.js | 1 + js/kivi.SalesPurchase.js | 3 +-- templates/webpages/customer_vendor/form.html | 4 ---- templates/webpages/do/form_footer.html | 2 -- templates/webpages/is/form_footer.html | 1 - templates/webpages/oe/form_footer.html | 1 - 11 files changed, 51 insertions(+), 59 deletions(-) diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm index 98b668e3e..6b0362a58 100644 --- a/SL/Controller/CustomerVendor.pm +++ b/SL/Controller/CustomerVendor.pm @@ -954,12 +954,12 @@ sub _setup_form_action_bar { combobox => [ action => [ t8('Save'), - submit => [ '#form', { action_save => 1 } ], + submit => [ '#form', { action => "CustomerVendor/save" } ], checks => [ 'check_taxzone_and_ustid' ], ], action => [ t8('Save and Close'), - submit => [ '#form', { action_save_and_close => 1 } ], + submit => [ '#form', { action => "CustomerVendor/save_and_close" } ], checks => [ 'check_taxzone_and_ustid' ], ], ], # end of combobox "Save" @@ -968,39 +968,39 @@ sub _setup_form_action_bar { action => [ t8('Workflow') ], (action => [ t8('Save and AP Transaction'), - submit => [ '#form', { action_save_and_ap_transaction => 1 } ], + submit => [ '#form', { action => "CustomerVendor/save_and_ap_transaction" } ], checks => [ 'check_taxzone_and_ustid' ], ]) x !!$self->is_vendor, (action => [ t8('Save and AR Transaction'), - submit => [ '#form', { action_save_and_ar_transaction => 1 } ], + submit => [ '#form', { action => "CustomerVendor/save_and_ar_transaction" } ], checks => [ 'check_taxzone_and_ustid' ], ]) x !$self->is_vendor, action => [ t8('Save and Invoice'), - submit => [ '#form', { action_save_and_invoice => 1 } ], + submit => [ '#form', { action => "CustomerVendor/save_and_invoice" } ], checks => [ 'check_taxzone_and_ustid' ], ], action => [ t8('Save and Order'), - submit => [ '#form', { action_save_and_order => 1 } ], + submit => [ '#form', { action => "CustomerVendor/save_and_order" } ], checks => [ 'check_taxzone_and_ustid' ], ], (action => [ t8('Save and RFQ'), - submit => [ '#form', { action_save_and_rfq => 1 } ], + submit => [ '#form', { action => "CustomerVendor/save_and_rfq" } ], checks => [ 'check_taxzone_and_ustid' ], ]) x !!$self->is_vendor, (action => [ t8('Save and Quotation'), - submit => [ '#form', { action_save_and_quotation => 1 } ], + submit => [ '#form', { action => "CustomerVendor/save_and_quotation" } ], checks => [ 'check_taxzone_and_ustid' ], ]) x !$self->is_vendor, ], # end of combobox "Workflow" action => [ t8('Delete'), - submit => [ '#form', { action_delete => 1 } ], + submit => [ '#form', { action => "CustomerVendor/delete" } ], confirm => t8('Do you really want to delete this object?'), disabled => !$self->{cv}->id ? t8('This object has not been saved yet.') : !$self->is_orphaned ? t8('This object has already been used.') diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index 6bb2bcc20..d4e312365 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -244,26 +244,26 @@ sub setup_do_action_bar { $bar->add( action => [ t8('Update'), - submit => [ '#form', { action_update => 1 } ], + submit => [ '#form', { action => "update" } ], accesskey => 'enter', ], combobox => [ action => [ t8('Save'), - submit => [ '#form', { action_save => 1 } ], + submit => [ '#form', { action => "save" } ], checks => [ @req_trans_desc ], disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef, ], action => [ t8('Save as new'), - submit => [ '#form', { action_save_as_new => 1 } ], + submit => [ '#form', { action => "save_as_new" } ], checks => [ @req_trans_desc ], disabled => !$::form->{id}, ], action => [ t8('Mark as closed'), - submit => [ '#form', { action_mark_closed => 1 } ], + submit => [ '#form', { action => "mark_closed" } ], checks => [ @req_trans_desc ], confirm => t8('This will remove the delivery order from showing as open even if contents are not delivered. Proceed?'), disabled => !$::form->{id} ? t8('This record has not been saved yet.') @@ -274,7 +274,7 @@ sub setup_do_action_bar { action => [ t8('Delete'), - submit => [ '#form', { action_delete => 1 } ], + submit => [ '#form', { action => "delete" } ], confirm => t8('Do you really want to delete this object?'), disabled => !$::form->{id} ? t8('This record has not been saved yet.') : $::form->{delivered} ? t8('This record has already been delivered.') @@ -286,25 +286,25 @@ sub setup_do_action_bar { combobox => [ (action => [ t8('Transfer out'), - submit => [ '#form', { action_transfer_out => 1 } ], + submit => [ '#form', { action => "transfer_out" } ], checks => [ @req_trans_desc, @transfer_qty ], disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef, ]) x ($::form->{vc} eq 'customer'), (action => [ t8('Transfer out via default'), - submit => [ '#form', { action_transfer_out_default => 1 } ], + submit => [ '#form', { action => "transfer_out_default" } ], checks => [ @req_trans_desc, @transfer_qty ], disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef, ]) x ($::form->{vc} eq 'customer' && $::instance_conf->get_transfer_default), (action => [ t8('Transfer in'), - submit => [ '#form', { action_transfer_in => 1 } ], + submit => [ '#form', { action => "transfer_in"> 1 } ], checks => [ @req_trans_desc, @transfer_qty ], disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef, ]) x ($::form->{vc} eq 'vendor'), (action => [ t8('Transfer in via default'), - submit => [ '#form', { action_transfer_in_default => 1 } ], + submit => [ '#form', { action => "transfer_in_default" } ], checks => [ @req_trans_desc, @transfer_qty ], disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef, ]) x ($::form->{vc} eq 'vendor' && $::instance_conf->get_transfer_default), @@ -315,7 +315,7 @@ sub setup_do_action_bar { action => [ t8('Invoice'), - submit => [ '#form', { action_invoice => 1 } ], + submit => [ '#form', { action => "invoice" } ], disabled => !$::form->{id} ? t8('This record has not been saved yet.') : undef, ], @@ -323,7 +323,7 @@ sub setup_do_action_bar { action => [ t8('Export') ], action => [ t8('Print'), - submit => [ '#form', { action_print => 1 } ], + submit => [ '#form', { action => "print" } ], checks => [ @req_trans_desc ], ], action => [ diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 95ada94e5..b9e79d6de 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -225,7 +225,7 @@ sub setup_ir_action_bar { $bar->add( action => [ t8('Update'), - submit => [ '#form', { action_update => 1 } ], + submit => [ '#form', { action => "update" } ], id => 'update_button', accesskey => 'enter', ], @@ -233,7 +233,7 @@ sub setup_ir_action_bar { combobox => [ action => [ t8('Post'), - submit => [ '#form', { action_post => 1 } ], + submit => [ '#form', { action => "post" } ], disabled => $form->{locked} ? t8('The billing period has already been locked.') : $form->{storno} ? t8('A canceled invoice cannot be posted.') : ($form->{id} && $change_never) ? t8('Changing invoices has been disabled in the configuration.') @@ -242,12 +242,12 @@ sub setup_ir_action_bar { ], action => [ t8('Post Payment'), - submit => [ '#form', { action_post_payment => 1 } ], + submit => [ '#form', { action => "post_payment" } ], disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, ], (action => [ t8('Mark as paid'), - submit => [ '#form', { action_mark_as_paid => 1 } ], + submit => [ '#form', { action => "mark_as_paid" } ], confirm => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'), disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, ]) x !!$::instance_conf->get_ir_show_mark_as_paid, @@ -255,12 +255,12 @@ sub setup_ir_action_bar { combobox => [ action => [ t8('Storno'), - submit => [ '#form', { action_storno => 1 } ], + submit => [ '#form', { action => "storno" } ], confirm => t8('Do you really want to cancel this invoice?'), disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, ], action => [ t8('Delete'), - submit => [ '#form', { action_delete => 1 } ], + submit => [ '#form', { action => "delete" } ], confirm => t8('Do you really want to delete this object?'), disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : $form->{locked} ? t8('The billing period has already been locked.') @@ -364,7 +364,7 @@ sub form_header { # hiddens $TMPL_VAR{HIDDENS} = [qw( - id action type media format queued printed emailed title vc discount + id type queued printed emailed title vc discount title creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id max_dunning_level dunning_amount shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptogln shiptocontact shiptophone shiptofax diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index def63a961..4f7e9e410 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -262,7 +262,7 @@ sub setup_is_action_bar { $bar->add( action => [ t8('Update'), - submit => [ '#form', { action_update => 1 } ], + submit => [ '#form', { action => "update" } ], disabled => $form->{locked} ? t8('The billing period has already been locked.') : undef, id => 'update_button', accesskey => 'enter', @@ -271,7 +271,7 @@ sub setup_is_action_bar { combobox => [ action => [ t8('Post'), - submit => [ '#form', { action_post => 1 } ], + submit => [ '#form', { action => "post" } ], checks => [ @req_trans_desc ], disabled => $form->{locked} ? t8('The billing period has already been locked.') : $form->{storno} ? t8('A canceled invoice cannot be posted.') @@ -281,12 +281,12 @@ sub setup_is_action_bar { ], action => [ t8('Post Payment'), - submit => [ '#form', { action_post_payment => 1 } ], + submit => [ '#form', { action => "post_payment" } ], checks => [ @req_trans_desc ], disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, ], (action => [ t8('Mark as paid'), - submit => [ '#form', { action_mark_as_paid => 1 } ], + submit => [ '#form', { action => "mark_as_paid" } ], confirm => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'), disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, ]) x !!$::instance_conf->get_is_show_mark_as_paid, @@ -294,13 +294,13 @@ sub setup_is_action_bar { combobox => [ action => [ t8('Storno'), - submit => [ '#form', { action_storno => 1 } ], + submit => [ '#form', { action => "storno" } ], confirm => t8('Do you really want to cancel this invoice?'), checks => [ @req_trans_desc ], disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, ], action => [ t8('Delete'), - submit => [ '#form', { action_delete => 1 } ], + submit => [ '#form', { action => "delete" } ], confirm => t8('Do you really want to delete this object?'), checks => [ @req_trans_desc ], disabled => !$form->{id} ? t8('This invoice has not been posted yet.') @@ -317,12 +317,12 @@ sub setup_is_action_bar { action => [ t8('Workflow') ], action => [ t8('Use As New'), - submit => [ '#form', { action_use_as_new => 1 } ], + submit => [ '#form', { action => "use_as_new" } ], disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, ], action => [ t8('Credit Note'), - submit => [ '#form', { action_credit_note => 1 } ], + submit => [ '#form', { action => "credit_note" } ], checks => [ @req_trans_desc ], disabled => $form->{type} eq "credit_note" ? t8('Credit notes cannot be converted into other credit notes.') : !$form->{id} ? t8('This invoice has not been posted yet.') @@ -330,7 +330,7 @@ sub setup_is_action_bar { ], action => [ t8('Sales Order'), - submit => [ '#form', { action_sales_order => 1 } ], + submit => [ '#form', { action => "sales_order" } ], disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, ], ], # end of combobox "Workflow" @@ -339,7 +339,7 @@ sub setup_is_action_bar { action => [ t8('Export') ], action => [ ($form->{id} ? t8('Print') : t8('Preview')), - submit => [ '#form', { action_print => 1 } ], + submit => [ '#form', { action => "print" } ], checks => [ @req_trans_desc ], disabled => !$form->{id} && $form->{locked} ? t8('The billing period has already been locked.') : undef, ], diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index ac1c6149e..f24612112 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -321,7 +321,7 @@ sub setup_oe_action_bar { $bar->add( action => [ t8('Update'), - submit => [ '#form', { action_update => 1 } ], + submit => [ '#form', { action => "update" } ], id => 'update_button', accesskey => 'enter', ], @@ -329,23 +329,23 @@ sub setup_oe_action_bar { combobox => [ action => [ t8('Save'), - submit => [ '#form', { action_save => 1 } ], + submit => [ '#form', { action => "save" } ], checks => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ], ], action => [ t8('Save as new'), - submit => [ '#form', { action_save_as_new => 1 } ], + submit => [ '#form', { action => "save_as_new" } ], checks => [ @req_trans_desc, @req_trans_cost_art ], disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, ], action => [ t8('Save and Close'), - submit => [ '#form', { action_save_and_close => 1 } ], + submit => [ '#form', { action => "save_and_close" } ], checks => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ], ], action => [ t8('Delete'), - submit => [ '#form', { action_delete => 1 } ], + submit => [ '#form', { action => "delete" } ], confirm => t8('Do you really want to delete this object?'), disabled => !$form->{id} ? t8('This record has not been saved yet.') : ( ($params{is_sales_ord} && !$::instance_conf->get_sales_order_show_delete) @@ -360,32 +360,32 @@ sub setup_oe_action_bar { action => [ t8('Workflow') ], (action => [ t8('Sales Order'), - submit => [ '#form', { action_sales_order => 1 } ], + submit => [ '#form', { action => "sales_order" } ], disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, ]) x !!$params{is_sales_quo}, (action => [ t8('Purchase Order'), - submit => [ '#form', { action_sales_order => 1 } ], + submit => [ '#form', { action => "sales_order" } ], disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, ]) x !!$params{is_req_quo}, (action => [ t8('Delivery Order'), - submit => [ '#form', { action_delivery_order => 1 } ], + submit => [ '#form', { action => "delivery_order" } ], disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, ]) x ($params{is_sales_ord} || $params{is_pur_ord}), (action => [ t8('Invoice'), - submit => [ '#form', { action_invoice => 1 } ], + submit => [ '#form', { action => "invoice" } ], disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, ]) x !!$allow_invoice, action => [ t8('Quotation'), - submit => [ '#form', { action_quotation => 1 } ], + submit => [ '#form', { action => "quotation" } ], disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, ], action => [ t8('Request for Quotation'), - submit => [ '#form', { action_reqest_for_quotation => 1 } ], + submit => [ '#form', { action => "reqest_for_quotation" } ], disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, ], ], # end of combobox "Workflow" @@ -394,7 +394,7 @@ sub setup_oe_action_bar { action => [ t8('Export') ], action => [ t8('Print'), - submit => [ '#form', { action_print => 1 } ], + call => [ 'kivi.SalesPurchase.show_print_dialog' ], checks => [ @req_trans_desc ], ], action => [ diff --git a/js/kivi.ActionBar.js b/js/kivi.ActionBar.js index 2836add63..2afedfff7 100644 --- a/js/kivi.ActionBar.js +++ b/js/kivi.ActionBar.js @@ -153,6 +153,7 @@ namespace('kivi', function(k){ var form = data.submit[0]; var params = data.submit[1]; for (key in params) { + $('[name=' + key + ']').remove(); $hidden = $(''); $hidden.attr('name', key); $hidden.attr('value', params[key]); diff --git a/js/kivi.SalesPurchase.js b/js/kivi.SalesPurchase.js index 2659c858e..98111dadc 100644 --- a/js/kivi.SalesPurchase.js +++ b/js/kivi.SalesPurchase.js @@ -239,8 +239,7 @@ namespace('kivi.SalesPurchase', function(ns) { $('#send_email_dialog').children().remove().appendTo('#email_inputs'); $('#send_email_dialog').dialog('close'); - $('#action').val('send_sales_purchase_email'); - $('#form').submit(); + kivi.submit_form_with_action('#form', 'send_sales_purchase_email'); return true; }; diff --git a/templates/webpages/customer_vendor/form.html b/templates/webpages/customer_vendor/form.html index 25c388e70..4c473a9d7 100644 --- a/templates/webpages/customer_vendor/form.html +++ b/templates/webpages/customer_vendor/form.html @@ -53,10 +53,6 @@ [% PROCESS "customer_vendor/tabs/price_rules.html" %] [% END %] - -
- - [% L.hidden_tag('action', 'CustomerVendor/dispatch') %]