Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision dd1ab30b

Von Sven Schöling vor etwa 7 Jahren hinzugefügt

  • ID dd1ab30b7c2a6bec318dd75100e54c9bfa400e77
  • Vorgänger 87599e47
  • Nachfolger 1f723230

ActionBar: by_description gefixt

Unterschiede anzeigen:

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

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

  
33 35
# TODO: this necessary?
......
46 48
    return SL::Layout::ActionBar::ScriptButton->new(text => $text, params => \%params);
47 49
  }
48 50

  
49
  if ($params{combobox}) {
50

  
51
  if ($params{actions}) {
52
    require SL::Layout::ActionBar::ComboBox;
53
    return SL::Layout::ActionBar::ComboBox->new(text => $text, %params);
51 54
  }
52 55
}
53 56

  
SL/Layout/ActionBar/ComboBox.pm
1
package SL::Layout::ActionBar::ComboBox;
2

  
3
use strict;
4
use parent qw(SL::Layout::ActionBar::Action);
5

  
6
use JSON;
7

  
8
use Rose::Object::MakeMethods::Generic (
9
  'scalar --get_set_init' => [ qw(actions) ],
10
);
11

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

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

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

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

  
35
sub init_actions { [] }
36

  
37
1;

Auch abrufbar als: Unified diff