Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c2aaf253

Von Moritz Bunkus vor etwa 8 Jahren hinzugefügt

  • ID c2aaf253649281fee8e79a3300d81c827d9a1fd1
  • Vorgänger 87e1fb0d
  • Nachfolger ef26fcde

ActionBar: existierende Inputs namens »action« vor Submit entfernen

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.

Unterschiede anzeigen:

SL/Controller/CustomerVendor.pm
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"
......
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.')
bin/mozilla/do.pl
$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.')
......
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.')
......
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),
......
action => [
t8('Invoice'),
submit => [ '#form', { action_invoice => 1 } ],
submit => [ '#form', { action => "invoice" } ],
disabled => !$::form->{id} ? t8('This record has not been saved yet.') : undef,
],
......
action => [ t8('Export') ],
action => [
t8('Print'),
submit => [ '#form', { action_print => 1 } ],
submit => [ '#form', { action => "print" } ],
checks => [ @req_trans_desc ],
],
action => [
bin/mozilla/ir.pl
$bar->add(
action => [
t8('Update'),
submit => [ '#form', { action_update => 1 } ],
submit => [ '#form', { action => "update" } ],
id => 'update_button',
accesskey => 'enter',
],
......
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.')
......
],
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,
......
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.')
......
# 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
bin/mozilla/is.pl
$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',
......
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.')
......
],
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,
......
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.')
......
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.')
......
],
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"
......
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,
],
bin/mozilla/oe.pl
$bar->add(
action => [
t8('Update'),
submit => [ '#form', { action_update => 1 } ],
submit => [ '#form', { action => "update" } ],
id => 'update_button',
accesskey => 'enter',
],
......
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)
......
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"
......
action => [ t8('Export') ],
action => [
t8('Print'),
submit => [ '#form', { action_print => 1 } ],
call => [ 'kivi.SalesPurchase.show_print_dialog' ],
checks => [ @req_trans_desc ],
],
action => [
js/kivi.ActionBar.js
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]);
js/kivi.SalesPurchase.js
$('#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;
};
templates/webpages/customer_vendor/form.html
[% PROCESS "customer_vendor/tabs/price_rules.html" %]
[% END %]
</div>
<br>
[% L.hidden_tag('action', 'CustomerVendor/dispatch') %]
</form>
<script type="text/javascript">
templates/webpages/do/form_footer.html
</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) %]">
templates/webpages/is/form_footer.html
</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) %]
templates/webpages/oe/form_footer.html
</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 %]">

Auch abrufbar als: Unified diff