Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ff424b75

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID ff424b75f8f66c796eae294d0239f0440741e578
  • Vorgänger 6f1da6d4
  • Nachfolger c37fb9ef

ActionBar: API-Umstellung fürs Hinzufügen

Designziele:

• möglichst wenig Funktionsaufrufe auf eine ActionBar-Instanz
• Hash-artige Struktur der Daten zwecks bekanntem Aussehen und leichter
Verständlichkeit
• Leichter um neue Typen erweiterbar
• Rekursiv parsend (für Comboboxen)

Unterschiede anzeigen:

SL/Layout/ActionBar.pm
3 3
use strict;
4 4
use parent qw(SL::Layout::Base);
5 5

  
6
use Carp;
7
use Scalar::Util qw(blessed);
6 8
use SL::Layout::ActionBar::Action;
9
use SL::Layout::ActionBar::ComboBox;
10
use SL::Layout::ActionBar::Separator;
7 11

  
8 12
use constant HTML_CLASS => 'layout-actionbar';
9 13

  
......
11 15
  'scalar --get_set_init' => [ qw(actions) ],
12 16
);
13 17

  
18
my %class_descriptors = (
19
  action    => { class => 'SL::Layout::ActionBar::Action',    num_params => 1, },
20
  combobox  => { class => 'SL::Layout::ActionBar::ComboBox',  num_params => 1, },
21
  separator => { class => 'SL::Layout::ActionBar::Separator', num_params => 0, },
22
);
14 23

  
15 24
###### Layout overrides
16 25

  
......
32 41

  
33 42
###### interface
34 43

  
35
sub add_actions {
44
sub add {
36 45
  my ($self, @actions) = @_;
37
  push @{ $self->actions }, map {
38
       !ref $_ ? SL::Layout::ActionBar::Action->from_descriptor($_)
39
     :  ref $_ && 'ARRAY' eq ref $_ ? SL::Layout::ActionBar::Action->simple($_)
40
     :  ref $_ && $_->isa('SL::Layout::Action') ? $_
41
     : do { die 'invalid action' };
42
  } @actions;
43
}
44 46

  
45
sub init_actions {
46
  []
47
  push @{ $self->actions }, $self->parse_actions(@actions);
48

  
49
  return $self->actions->[-1];
47 50
}
48 51

  
52
sub parse_actions {
53
  my ($self_or_class, @actions) = @_;
54

  
55
  my @parsed;
56

  
57
  while (my $type = shift(@actions)) {
58
    if (blessed($type) && $type->isa('SL::Layout::ActionBar::Action')) {
59
      push @parsed, $type;
60
      continue;
61
    }
49 62

  
63
    my $descriptor = $class_descriptors{lc $type} || croak("Unknown action type '${type}'");
64
    my @params     = splice(@actions, 0, $descriptor->{num_params});
50 65

  
66
    push @parsed, $descriptor->{class}->from_params(@params);
67
  }
68

  
69
  return @parsed;
70
}
71

  
72
sub init_actions {
73
  []
74
}
51 75

  
52 76
1;
53 77

  
SL/Layout/ActionBar/Action.pm
20 20
  sprintf q|$('#%s').data('action', %s);|, $_[0]->id, JSON->new->allow_blessed->convert_blessed->encode($_[0]->params);
21 21
}
22 22

  
23
# static constructors
24

  
25
sub from_descriptor {
26
  my ($class, $descriptor) = @_;
27
  require SL::Layout::ActionBar::Separator;
28
  require SL::Layout::ActionBar::ComboBox;
29

  
30
  return {
31
     separator => SL::Layout::ActionBar::Separator->new,
32
     combobox  => SL::Layout::ActionBar::ComboBox->new,
33
  }->{$descriptor} || do { die 'unknown descriptor' };
34
}
35

  
36 23
# this is mostly so that outside consumer don't need to load subclasses themselves
37
sub simple {
24
sub from_params {
38 25
  my ($class, $data) = @_;
39 26

  
40 27
  my ($text, %params) = @$data;
......
83 70
TODO:
84 71

  
85 72
- runtime disable/enable
86

  
SL/Layout/ActionBar/ComboBox.pm
9 9
  'scalar --get_set_init' => [ qw(actions) ],
10 10
);
11 11

  
12
sub parsed_actions {
13
  $_[0]{parsed_actions} ||=
14
    [ map { SL::Layout::ActionBar::Action->simple($_) } @{ $_[0]->actions || [] } ];
15
}
12
sub from_params {
13
  my ($class, $actions) = @_;
14

  
15
  my $combobox = $class->new;
16
  push @{ $combobox->actions }, SL::Layout::ActionBar->parse_actions(@{ $actions });
16 17

  
17
sub add_actions {
18
  push @{$_[0]{actions} //= $_[0]->init_actions}, @_[1..$#_]
18
  return $combobox;
19 19
}
20 20

  
21 21
sub render {
22
  my ($first, @rest) = @{ $_[0]->parsed_actions };
22
  my ($first, @rest) = @{ $_[0]->actions };
23 23
  $_[0]->p->html_tag('div',
24 24
    $_[0]->p->html_tag('div', $first->render . $_[0]->p->html_tag('span'), class => 'layout-actionbar-combobox-head') .
25 25
    $_[0]->p->html_tag('div', join('', map { $_->render } @rest), class => 'layout-actionbar-combobox-list'),
......
29 29
}
30 30

  
31 31
sub script {
32
  map { $_->script } @{ $_[0]->parsed_actions }
32
  map { $_->script } @{ $_[0]->actions }
33 33
}
34 34

  
35 35
sub init_actions { [] }
SL/Layout/ActionBar/Separator.pm
3 3
use strict;
4 4
use parent qw(SL::Layout::ActionBar::Action);
5 5

  
6
sub from_params { $_[0]->new }
7

  
6 8
sub render {
7 9
  $_[0]->p->html_tag('div', '', class => 'layout-actionbar-separator');
8 10
}
bin/mozilla/ir.pl
222 222
  my $change_on_same_day_only = $::instance_conf->get_ir_changeable == 2 && ($form->current_date(\%::myconfig) ne $form->{gldate});
223 223

  
224 224
  for my $bar ($::request->layout->get('actionbar')) {
225
    $bar->add_actions([ t8('Update'),
226
      submit    => [ '#form', { action_update => 1 } ],
227
      id        => 'update_button',
228
      accesskey => 'enter',
229
    ]);
230

  
231
    $bar->add_actions("combobox");
232
    $bar->actions->[-1]->add_actions([ t8('Post'),
233
      submit   => [ '#form', { action_post => 1 } ],
234
      disabled => $form->{locked}                           ? t8('The billing period has already been locked.')
235
                : $form->{storno}                           ? t8('A canceled invoice cannot be posted.')
236
                : ($form->{id} && $change_never)            ? t8('Changing invoices has been disabled in the configuration.')
237
                : ($form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.')
238
                :                                             undef,
239
    ]);
240
    $bar->actions->[-1]->add_actions([ t8('Post Payment'),
241
      submit   => [ '#form', { action_post_payment => 1 } ],
242
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
243
    ]);
244
    $bar->actions->[-1]->add_actions([ t8('mark as paid'),
245
      submit   => [ '#form', { action_mark_as_paid => 1 } ],
246
      confirm  => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
247
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
248
    ]) if $::instance_conf->get_ir_show_mark_as_paid;
249

  
250

  
251
    $bar->add_actions("combobox");
252
    $bar->actions->[-1]->add_actions([ t8('Storno'),
253
      submit   => [ '#form', { action_storno => 1 } ],
254
      confirm  => t8('Do you really want to cancel this invoice?'),
255
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
256
    ]);
257
    $bar->actions->[-1]->add_actions([ t8('Delete'),
258
      submit   => [ '#form', { action_delete => 1 } ],
259
      confirm  => t8('Do you really want to delete this object?'),
260
      disabled => !$form->{id}             ? t8('This invoice has not been posted yet.')
261
                : $form->{locked}          ? t8('The billing period has already been locked.')
262
                : $change_never            ? t8('Changing invoices has been disabled in the configuration.')
263
                : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
264
                :                            undef,
265
    ]);
266

  
267
    $bar->add_actions('separator');
268

  
269
    $bar->add_actions('combobox');
270
    $bar->actions->[-1]->add_actions([ t8('more') ]);
271
    $bar->actions->[-1]->add_actions([ t8('History'),
272
      call     => [ 'set_history_window', $::form->{id} * 1, 'id', 'glid' ],
273
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
274
    ]);
275
    $bar->actions->[-1]->add_actions([ t8('Follow-Up'),
276
      call     => [ 'follow_up_window' ],
277
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
278
    ]);
279
    $bar->actions->[-1]->add_actions([ t8('Drafts'),
280
      call     => [ 'kivi.Draft.popup', 'ir', 'invoice', $::form->{draft_id}, $::form->{draft_description} ],
281
      disabled => $form->{id}     ? t8('This invoice has already been posted.')
282
                : $form->{locked} ? t8('The billing period has already been locked.')
283
                :                   undef,
284
    ]);
225
    $bar->add(
226
      action => [
227
        t8('Update'),
228
        submit    => [ '#form', { action_update => 1 } ],
229
        id        => 'update_button',
230
        accesskey => 'enter',
231
      ],
232

  
233
      combobox => [
234
        action => [
235
          t8('Post'),
236
          submit   => [ '#form', { action_post => 1 } ],
237
          disabled => $form->{locked}                           ? t8('The billing period has already been locked.')
238
                    : $form->{storno}                           ? t8('A canceled invoice cannot be posted.')
239
                    : ($form->{id} && $change_never)            ? t8('Changing invoices has been disabled in the configuration.')
240
                    : ($form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.')
241
                    :                                             undef,
242
        ],
243
        action => [
244
          t8('Post Payment'),
245
          submit   => [ '#form', { action_post_payment => 1 } ],
246
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
247
        ],
248
        (action => [
249
          t8('mark as paid'),
250
          submit   => [ '#form', { action_mark_as_paid => 1 } ],
251
          confirm  => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
252
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
253
        ]) x !!$::instance_conf->get_ir_show_mark_as_paid,
254
      ], # end of combobox "Post"
255

  
256
      combobox => [
257
        action => [ t8('Storno'),
258
          submit   => [ '#form', { action_storno => 1 } ],
259
          confirm  => t8('Do you really want to cancel this invoice?'),
260
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
261
        ],
262
        action => [ t8('Delete'),
263
          submit   => [ '#form', { action_delete => 1 } ],
264
          confirm  => t8('Do you really want to delete this object?'),
265
          disabled => !$form->{id}             ? t8('This invoice has not been posted yet.')
266
                    : $form->{locked}          ? t8('The billing period has already been locked.')
267
                    : $change_never            ? t8('Changing invoices has been disabled in the configuration.')
268
                    : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
269
                    :                            undef,
270
        ],
271
      ], # end of combobox "Storno"
272

  
273
      'separator',
274

  
275
      combobox => [
276
        action => [ t8('more') ],
277
        action => [
278
          t8('History'),
279
          call     => [ 'set_history_window', $::form->{id} * 1, 'id', 'glid' ],
280
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
281
        ],
282
        action => [
283
          t8('Follow-Up'),
284
          call     => [ 'follow_up_window' ],
285
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
286
        ],
287
        action => [
288
          t8('Drafts'),
289
          call     => [ 'kivi.Draft.popup', 'ir', 'invoice', $::form->{draft_id}, $::form->{draft_description} ],
290
          disabled => $form->{id}     ? t8('This invoice has already been posted.')
291
                    : $form->{locked} ? t8('The billing period has already been locked.')
292
                    :                   undef,
293
        ],
294
      ], # end of combobox "more"
295
    );
285 296
  }
286 297
}
287 298

  
bin/mozilla/is.pl
259 259
  my @req_trans_desc          = qw(kivi.SalesPurchase.check_transaction_description) x!!$::instance_conf->get_require_transaction_description_ps;
260 260

  
261 261
  for my $bar ($::request->layout->get('actionbar')) {
262
    $bar->add_actions([ t8('Update'),
263
      submit    => [ '#form', { action_update => 1 } ],
264
      disabled  => $form->{locked} ? t8('The billing period has already been locked.') : undef,
265
      id        => 'update_button',
266
      accesskey => 'enter',
267
    ]);
268

  
269
    $bar->add_actions("combobox");
270
    $bar->actions->[-1]->add_actions([ t8('Post'),
271
      submit   => [ '#form', { action_post => 1 } ],
272
      checks   => [ @req_trans_desc ],
273
      disabled => $form->{locked}                           ? t8('The billing period has already been locked.')
274
                : $form->{storno}                           ? t8('A canceled invoice cannot be posted.')
275
                : ($form->{id} && $change_never)            ? t8('Changing invoices has been disabled in the configuration.')
276
                : ($form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.')
277
                :                                             undef,
278
    ]);
279
    $bar->actions->[-1]->add_actions([ t8('Post Payment'),
280
      submit   => [ '#form', { action_post_payment => 1 } ],
281
      checks   => [ @req_trans_desc ],
282
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
283
    ]);
284
    $bar->actions->[-1]->add_actions([ t8('mark as paid'),
285
      submit   => [ '#form', { action_mark_as_paid => 1 } ],
286
      confirm  => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
287
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
288
    ]) if $::instance_conf->get_is_show_mark_as_paid;
289

  
290

  
291
    $bar->add_actions("combobox");
292
    $bar->actions->[-1]->add_actions([ t8('Storno'),
293
      submit   => [ '#form', { action_storno => 1 } ],
294
      confirm  => t8('Do you really want to cancel this invoice?'),
295
      checks   => [ @req_trans_desc ],
296
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
297
    ]);
298
    $bar->actions->[-1]->add_actions([ t8('Delete'),
299
      submit   => [ '#form', { action_delete => 1 } ],
300
      confirm  => t8('Do you really want to delete this object?'),
301
      checks   => [ @req_trans_desc ],
302
      disabled => !$form->{id}             ? t8('This invoice has not been posted yet.')
303
                : $form->{locked}          ? t8('The billing period has already been locked.')
304
                : $change_never            ? t8('Changing invoices has been disabled in the configuration.')
305
                : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
306
                :                            undef,
307
    ]);
308

  
309
    $bar->add_actions('separator');
310

  
311
    $bar->add_actions('combobox');
312
    $bar->actions->[-1]->add_actions([ t8('Workflow') ]);
313
    $bar->actions->[-1]->add_actions([ t8('Use As New'),
314
      submit   => [ '#form', { action_use_as_new    => 1 } ],
315
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
316
    ]);
317
    $bar->actions->[-1]->add_actions([ t8('Credit Note'),
318
      submit   => [ '#form', { action_credit_note    => 1 } ],
319
      checks   => [ @req_trans_desc ],
320
      disabled => $form->{type} eq "credit_note" ? t8('Credit notes cannot be converted into other credit notes.')
321
                : !$form->{id}                   ? t8('This invoice has not been posted yet.')
322
                :                                  undef,
323
    ]);
324
    $bar->actions->[-1]->add_actions([ t8('Sales Order'),
325
      submit   => [ '#form', { action_sales_order   => 1 } ],
326
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
327
    ]);
328

  
329
    $bar->add_actions('combobox');
330
    $bar->actions->[-1]->add_actions([ t8('Export') ]);
331
    $bar->actions->[-1]->add_actions([ ($form->{id} ? t8('Print') : t8('Preview')),
332
      submit   => [ '#form', { action_print => 1 } ],
333
      checks   => [ @req_trans_desc ],
334
      disabled => !$form->{id} && $form->{locked} ? t8('The billing period has already been locked.') : undef,
335
    ]);
336
    $bar->actions->[-1]->add_actions([ t8('E Mail'),
337
      submit   => [ '#form', { action_print => 1 } ],
338
      checks   => [ @req_trans_desc ],
339
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
340
    ]);
341
    $bar->add_actions('combobox');
342
    $bar->actions->[-1]->add_actions([ t8('more') ]);
343
    $bar->actions->[-1]->add_actions([ t8('History'),
344
      call     => [ 'set_history_window', $form->{id} * 1, 'id' ],
345
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
346
    ]);
347
    $bar->actions->[-1]->add_actions([ t8('Follow-Up'),
348
      call     => [ 'follow_up_window' ],
349
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
350
    ]);
351
    $bar->actions->[-1]->add_actions([ t8('Drafts'),
352
      call     => [ 'kivi.Draft.popup', 'is', 'invoice', $form->{draft_id}, $form->{draft_description} ],
353
      disabled => $form->{id}     ? t8('This invoice has already been posted.')
354
                : $form->{locked} ? t8('The billing period has already been locked.')
355
                :                   undef,
356
    ]);
262
    $bar->add(
263
      action => [
264
        t8('Update'),
265
        submit    => [ '#form', { action_update => 1 } ],
266
        disabled  => $form->{locked} ? t8('The billing period has already been locked.') : undef,
267
        id        => 'update_button',
268
        accesskey => 'enter',
269
      ],
270

  
271
      combobox => [
272
        action => [
273
          t8('Post'),
274
          submit   => [ '#form', { action_post => 1 } ],
275
          checks   => [ @req_trans_desc ],
276
          disabled => $form->{locked}                           ? t8('The billing period has already been locked.')
277
                    : $form->{storno}                           ? t8('A canceled invoice cannot be posted.')
278
                    : ($form->{id} && $change_never)            ? t8('Changing invoices has been disabled in the configuration.')
279
                    : ($form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.')
280
                    :                                             undef,
281
        ],
282
        action => [
283
          t8('Post Payment'),
284
          submit   => [ '#form', { action_post_payment => 1 } ],
285
          checks   => [ @req_trans_desc ],
286
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
287
        ],
288
        (action => [ t8('mark as paid'),
289
          submit   => [ '#form', { action_mark_as_paid => 1 } ],
290
          confirm  => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
291
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
292
        ]) x !!$::instance_conf->get_is_show_mark_as_paid,
293
      ], # end of combobox "Post"
294

  
295
      combobox => [
296
        action => [ t8('Storno'),
297
          submit   => [ '#form', { action_storno => 1 } ],
298
          confirm  => t8('Do you really want to cancel this invoice?'),
299
          checks   => [ @req_trans_desc ],
300
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
301
        ],
302
        action => [ t8('Delete'),
303
          submit   => [ '#form', { action_delete => 1 } ],
304
          confirm  => t8('Do you really want to delete this object?'),
305
          checks   => [ @req_trans_desc ],
306
          disabled => !$form->{id}             ? t8('This invoice has not been posted yet.')
307
                    : $form->{locked}          ? t8('The billing period has already been locked.')
308
                    : $change_never            ? t8('Changing invoices has been disabled in the configuration.')
309
                    : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
310
                    :                            undef,
311
        ],
312
      ], # end of combobox "Storno"
313

  
314
      'separator',
315

  
316
      combobox => [
317
        action => [ t8('Workflow') ],
318
        action => [
319
          t8('Use As New'),
320
          submit   => [ '#form', { action_use_as_new => 1 } ],
321
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
322
        ],
323
        action => [
324
          t8('Credit Note'),
325
          submit   => [ '#form', { action_credit_note => 1 } ],
326
          checks   => [ @req_trans_desc ],
327
          disabled => $form->{type} eq "credit_note" ? t8('Credit notes cannot be converted into other credit notes.')
328
                    : !$form->{id}                   ? t8('This invoice has not been posted yet.')
329
                    :                                  undef,
330
        ],
331
        action => [
332
          t8('Sales Order'),
333
          submit   => [ '#form', { action_sales_order   => 1 } ],
334
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
335
        ],
336
      ], # end of combobox "Workflow"
337

  
338
      combobox => [
339
        action => [ t8('Export') ],
340
        action => [
341
          ($form->{id} ? t8('Print') : t8('Preview')),
342
          submit   => [ '#form', { action_print => 1 } ],
343
          checks   => [ @req_trans_desc ],
344
          disabled => !$form->{id} && $form->{locked} ? t8('The billing period has already been locked.') : undef,
345
        ],
346
        action => [ t8('E Mail'),
347
          submit   => [ '#form', { action_print => 1 } ],
348
          checks   => [ @req_trans_desc ],
349
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
350
        ],
351
      ], # end of combobox "Export"
352

  
353
      combobox => [
354
        action => [ t8('more') ],
355
        action => [
356
          t8('History'),
357
          call     => [ 'set_history_window', $form->{id} * 1, 'id' ],
358
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
359
        ],
360
        action => [
361
          t8('Follow-Up'),
362
          call     => [ 'follow_up_window' ],
363
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
364
        ],
365
        action => [
366
          t8('Drafts'),
367
          call     => [ 'kivi.Draft.popup', 'is', 'invoice', $form->{draft_id}, $form->{draft_description} ],
368
          disabled => $form->{id}     ? t8('This invoice has already been posted.')
369
                    : $form->{locked} ? t8('The billing period has already been locked.')
370
                    :                   undef,
371
        ],
372
      ], # end of combobox "more"
373
    );
357 374
  }
358 375
}
359 376

  
bin/mozilla/oe.pl
317 317
  my @warn_p_invoice     = qw(kivi.SalesPurchase.oe_warn_save_active_periodic_invoice)  x!!$has_active_periodic_invoice;
318 318

  
319 319
  for my $bar ($::request->layout->get('actionbar')) {
320
    $bar->add_actions([ t8('Update'),
321
      submit    => [ '#form', { action_update => 1 } ],
322
      id        => 'update_button',
323
      accesskey => 'enter',
324
    ]);
325

  
326
    $bar->add_actions("combobox");
327
    $bar->actions->[-1]->add_actions([ t8('Save'),
328
      submit  => [ '#form', { action_save => 1 } ],
329
      checks  => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
330
    ]);
331
    $bar->actions->[-1]->add_actions([ t8('Save as new'),
332
      submit   => [ '#form', { action_save_as_new => 1 } ],
333
      checks   => [ @req_trans_desc, @req_trans_cost_art ],
334
      disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
335
    ]);
336
     $bar->actions->[-1]->add_actions([ t8('Save and Close'),
337
      submit  => [ '#form', { action_save_and_close => 1 } ],
338
      checks  => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
339
    ]);
340
    $bar->add_actions([ t8('Delete'),
341
      submit   => [ '#form', { action_delete => 1 } ],
342
      confirm  => t8('Do you really want to delete this object?'),
343
      disabled => !$form->{id}                                                                      ? t8('This record has not been saved yet.')
344
                : (   ($params{is_sales_ord} && !$::instance_conf->get_sales_order_show_delete)
345
                   || ($params{is_pur_ord}   && !$::instance_conf->get_purchase_order_show_delete)) ? t8('Deleting this type of record has been disabled in the configuration.')
346
                :                                                                                     undef,
347
    ]);
348

  
349
    $bar->add_actions('separator');
350

  
351
    $bar->add_actions('combobox');
352
    $bar->actions->[-1]->add_actions([ t8('Workflow') ]);
353
    $bar->actions->[-1]->add_actions([ t8('Sales Order'),
354
      submit   => [ '#form', { action_sales_order => 1 } ],
355
      disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
356
    ]) if $params{is_sales_quo};
357
    $bar->actions->[-1]->add_actions([ t8('Purchase Order'),
358
      submit   => [ '#form', { action_sales_order => 1 } ],
359
      disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
360
    ]) if $params{is_req_quo};
361
    $bar->actions->[-1]->add_actions([ t8('Delivery Order'),
362
      submit   => [ '#form', { action_delivery_order => 1 } ],
363
      disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
364
    ]) if $params{is_sales_ord} || $params{is_pur_ord};
365
    $bar->actions->[-1]->add_actions([ t8('Invoice'),
366
      submit   => [ '#form', { action_invoice => 1 } ],
367
      disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
368
    ]) if $allow_invoice;
369
    $bar->actions->[-1]->add_actions([ t8('Quotation'),
370
      submit   => [ '#form', { action_quotation => 1 } ],
371
      disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
372
    ]);
373
    $bar->actions->[-1]->add_actions([ t8('Request for Quotation'),
374
      submit   => [ '#form', { action_reqest_for_quotation => 1 } ],
375
      disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
376
    ]);
377

  
378
    $bar->add_actions('combobox');
379
    $bar->actions->[-1]->add_actions([ t8('Export') ]);
380
    $bar->actions->[-1]->add_actions([ t8('Print'),
381
      submit => [ '#form', { action_print => 1 } ],
382
      checks => [ @req_trans_desc ],
383
    ]);
384
    $bar->actions->[-1]->add_actions([ t8('E Mail'),
385
      submit => [ '#form', { action_print => 1 } ],
386
      checks => [ @req_trans_desc ],
387
    ]);
388
    $bar->add_actions('combobox');
389
    $bar->actions->[-1]->add_actions([ t8('more') ]);
390
    $bar->actions->[-1]->add_actions([ t8('History'),
391
      call     => [ 'set_history_window', $form->{id} * 1, 'id' ],
392
      disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
393
    ]);
394
    $bar->actions->[-1]->add_actions([ t8('Follow-Up'),
395
      call     => [ 'follow_up_window' ],
396
      disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
397
    ]);
320
    $bar->add(
321
      action => [
322
        t8('Update'),
323
        submit    => [ '#form', { action_update => 1 } ],
324
        id        => 'update_button',
325
        accesskey => 'enter',
326
      ],
327

  
328
      combobox => [
329
        action => [
330
          t8('Save'),
331
          submit  => [ '#form', { action_save => 1 } ],
332
          checks  => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
333
        ],
334
        action => [
335
          t8('Save as new'),
336
          submit   => [ '#form', { action_save_as_new => 1 } ],
337
          checks   => [ @req_trans_desc, @req_trans_cost_art ],
338
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
339
        ],
340
        action => [
341
          t8('Save and Close'),
342
          submit  => [ '#form', { action_save_and_close => 1 } ],
343
          checks  => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
344
        ],
345
        action => [
346
          t8('Delete'),
347
          submit   => [ '#form', { action_delete => 1 } ],
348
          confirm  => t8('Do you really want to delete this object?'),
349
          disabled => !$form->{id}                                                                      ? t8('This record has not been saved yet.')
350
                    : (   ($params{is_sales_ord} && !$::instance_conf->get_sales_order_show_delete)
351
                       || ($params{is_pur_ord}   && !$::instance_conf->get_purchase_order_show_delete)) ? t8('Deleting this type of record has been disabled in the configuration.')
352
                    :                                                                                     undef,
353
        ],
354
      ], # end of combobox "Save"
355

  
356
      'separator',
357

  
358
      combobox => [
359
        action => [ t8('Workflow') ],
360
        (action => [
361
          t8('Sales Order'),
362
          submit   => [ '#form', { action_sales_order => 1 } ],
363
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
364
        ]) x !!$params{is_sales_quo},
365
        (action => [
366
          t8('Purchase Order'),
367
          submit   => [ '#form', { action_sales_order => 1 } ],
368
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
369
        ]) x !!$params{is_req_quo},
370
        (action => [
371
          t8('Delivery Order'),
372
          submit   => [ '#form', { action_delivery_order => 1 } ],
373
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
374
        ]) x ($params{is_sales_ord} || $params{is_pur_ord}),
375
        (action => [
376
          t8('Invoice'),
377
          submit   => [ '#form', { action_invoice => 1 } ],
378
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
379
        ]) x !!$allow_invoice,
380
        action => [
381
          t8('Quotation'),
382
          submit   => [ '#form', { action_quotation => 1 } ],
383
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
384
        ],
385
        action => [
386
          t8('Request for Quotation'),
387
          submit   => [ '#form', { action_reqest_for_quotation => 1 } ],
388
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
389
        ],
390
      ], # end of combobox "Workflow"
391

  
392
      combobox => [
393
        action => [ t8('Export') ],
394
        action => [
395
          t8('Print'),
396
          submit => [ '#form', { action_print => 1 } ],
397
          checks => [ @req_trans_desc ],
398
        ],
399
        action => [
400
          t8('E Mail'),
401
          submit => [ '#form', { action_print => 1 } ],
402
          checks => [ @req_trans_desc ],
403
        ],
404
      ], #end of combobox "Export"
405

  
406
      combobox => [
407
        action => [ t8('more') ],
408
        action => [
409
          t8('History'),
410
          call     => [ 'set_history_window', $form->{id} * 1, 'id' ],
411
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
412
        ],
413
        action => [
414
          t8('Follow-Up'),
415
          call     => [ 'follow_up_window' ],
416
          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
417
        ],
418
      ], # end of combobox "more"
419
    );
398 420
  }
399 421
}
400 422

  

Auch abrufbar als: Unified diff