Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c2aaf253

Von Moritz Bunkus vor etwa 7 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:

bin/mozilla/oe.pl
321 321
    $bar->add(
322 322
      action => [
323 323
        t8('Update'),
324
        submit    => [ '#form', { action_update => 1 } ],
324
        submit    => [ '#form', { action => "update" } ],
325 325
        id        => 'update_button',
326 326
        accesskey => 'enter',
327 327
      ],
......
329 329
      combobox => [
330 330
        action => [
331 331
          t8('Save'),
332
          submit  => [ '#form', { action_save => 1 } ],
332
          submit  => [ '#form', { action => "save" } ],
333 333
          checks  => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
334 334
        ],
335 335
        action => [
336 336
          t8('Save as new'),
337
          submit   => [ '#form', { action_save_as_new => 1 } ],
337
          submit   => [ '#form', { action => "save_as_new" } ],
338 338
          checks   => [ @req_trans_desc, @req_trans_cost_art ],
339 339
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
340 340
        ],
341 341
        action => [
342 342
          t8('Save and Close'),
343
          submit  => [ '#form', { action_save_and_close => 1 } ],
343
          submit  => [ '#form', { action => "save_and_close" } ],
344 344
          checks  => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
345 345
        ],
346 346
        action => [
347 347
          t8('Delete'),
348
          submit   => [ '#form', { action_delete => 1 } ],
348
          submit   => [ '#form', { action => "delete" } ],
349 349
          confirm  => t8('Do you really want to delete this object?'),
350 350
          disabled => !$form->{id}                                                                      ? t8('This record has not been saved yet.')
351 351
                    : (   ($params{is_sales_ord} && !$::instance_conf->get_sales_order_show_delete)
......
360 360
        action => [ t8('Workflow') ],
361 361
        (action => [
362 362
          t8('Sales Order'),
363
          submit   => [ '#form', { action_sales_order => 1 } ],
363
          submit   => [ '#form', { action => "sales_order" } ],
364 364
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
365 365
        ]) x !!$params{is_sales_quo},
366 366
        (action => [
367 367
          t8('Purchase Order'),
368
          submit   => [ '#form', { action_sales_order => 1 } ],
368
          submit   => [ '#form', { action => "sales_order" } ],
369 369
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
370 370
        ]) x !!$params{is_req_quo},
371 371
        (action => [
372 372
          t8('Delivery Order'),
373
          submit   => [ '#form', { action_delivery_order => 1 } ],
373
          submit   => [ '#form', { action => "delivery_order" } ],
374 374
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
375 375
        ]) x ($params{is_sales_ord} || $params{is_pur_ord}),
376 376
        (action => [
377 377
          t8('Invoice'),
378
          submit   => [ '#form', { action_invoice => 1 } ],
378
          submit   => [ '#form', { action => "invoice" } ],
379 379
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
380 380
        ]) x !!$allow_invoice,
381 381
        action => [
382 382
          t8('Quotation'),
383
          submit   => [ '#form', { action_quotation => 1 } ],
383
          submit   => [ '#form', { action => "quotation" } ],
384 384
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
385 385
        ],
386 386
        action => [
387 387
          t8('Request for Quotation'),
388
          submit   => [ '#form', { action_reqest_for_quotation => 1 } ],
388
          submit   => [ '#form', { action => "reqest_for_quotation" } ],
389 389
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
390 390
        ],
391 391
      ], # end of combobox "Workflow"
......
394 394
        action => [ t8('Export') ],
395 395
        action => [
396 396
          t8('Print'),
397
          submit => [ '#form', { action_print => 1 } ],
397
          call   => [ 'kivi.SalesPurchase.show_print_dialog' ],
398 398
          checks => [ @req_trans_desc ],
399 399
        ],
400 400
        action => [

Auch abrufbar als: Unified diff