]> wagnertech.de Git - kivitendo-erp.git/commitdiff
ActionBar: existierende Inputs namens »action« vor Submit entfernen
authorMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 11 Jan 2017 08:51:34 +0000 (09:51 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 28 Feb 2017 09:43:58 +0000 (10:43 +0100)
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
bin/mozilla/do.pl
bin/mozilla/ir.pl
bin/mozilla/is.pl
bin/mozilla/oe.pl
js/kivi.ActionBar.js
js/kivi.SalesPurchase.js
templates/webpages/customer_vendor/form.html
templates/webpages/do/form_footer.html
templates/webpages/is/form_footer.html
templates/webpages/oe/form_footer.html

index 98b668e3ec7951b1c4477b8295f6b427880d9c7c..6b0362a588315a5a08c1a6a631d15203fe7714d0 100644 (file)
@@ -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.')
index 6bb2bcc20c69b2f83093af91e145da56b9e7c5bb..d4e312365e2c564626437ee16312cd550478bb29 100644 (file)
@@ -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 => [
index 95ada94e52e410f16b8043c6f6c87b017cff8f73..b9e79d6dedfdbc185e9dc18cdbfec047e68e499e 100644 (file)
@@ -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
index def63a961ce46f928e80e1dbc2e5e560ff1f55bc..4f7e9e410ab39acac191578e8d4b09a053c774d7 100644 (file)
@@ -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,
         ],
index ac1c6149e8a112ab8a866acba80fdb6432db1150..f2461211284d2d2b82e962ad34372196586fd8f1 100644 (file)
@@ -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 => [
index 2836add6327560ce7d8143aa5e3abffaf193a55f..2afedfff7e099dbe869bd7bafec93244847fa2fe 100644 (file)
@@ -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 = $('<input type=hidden>');
             $hidden.attr('name', key);
             $hidden.attr('value', params[key]);
index 2659c858ecfa4a138e7e3d195ac7a2456369c786..98111dadc76b8c3c9b3193bcc8cfac817254d02c 100644 (file)
@@ -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;
   };
index 25c388e7053f1bb5de1a516ed8761191818b5064..4c473a9d7a3e995a6126d484cbe80ad68959f1bb 100644 (file)
       [% PROCESS "customer_vendor/tabs/price_rules.html" %]
     [% END %]
   </div>
-
-  <br>
-
-  [% L.hidden_tag('action', 'CustomerVendor/dispatch') %]
 </form>
 
 <script type="text/javascript">
index a24ad0a0f67b4042bb760d239f770ebad3c698c0..13456ca7bcf3b01489a92d7ff8d31d5fe29966e0 100644 (file)
@@ -62,8 +62,6 @@
  </div>
 </div>
 
-   <input type="hidden" name="action" id="action" value="dispatcher">
-
   <input type="hidden" name="rowcount" value="[% HTML.escape(rowcount) %]">
   <input name="callback" type="hidden" value="[% HTML.escape(callback) %]">
 
index d7e01c30b8798711a3717e1c6bde879e1eacf50e..837cd46dc884e516ce54d84e610fe520ab46206f 100644 (file)
 </div>
 </div>
 
-<input type="hidden" name="action" id="action" value="dispatcher">
 <input type="hidden" name="rowcount" value="[% rowcount %]">
 <input type="hidden" name="callback" value="[% callback | html %]">
 [% P.hidden_tag('draft_id', draft_id) %]
index 80892da5bec7c909d319969abccf6688381f6e1c..43b48f80cfcc075879977d4a8359deef5b31c942 100644 (file)
 </div>
 </div>
 
-<input type="hidden" name="action" id="action" value="dispatcher">
 <input type="hidden" name="saved_xyznumber" value="[% HTML.escape(saved_xyznumber) %]">
 [% L.hidden_tag("rowcount", rowcount) %]
 <input type="hidden" name="callback" value="[% callback | html %]">