454255c8c04eeb92e128e8c07120250b168b1bca
[kivitendo-erp.git] / SL / Layout / ActionBar / Action.pm
1 package SL::Layout::ActionBar::Action;
2
3 use strict;
4 use parent qw(Rose::Object);
5
6 use SL::Presenter;
7
8 use Rose::Object::MakeMethods::Generic (
9   'scalar --get_set_init' => [ qw(id) ],
10 );
11
12 # subclassing interface
13
14 sub render {
15   die 'needs to be implemented';
16 }
17
18 sub script {
19   die 'needs to be implemented';
20 }
21
22
23 # static constructors
24
25 sub from_descriptor {
26   my ($class, $descriptor) = @_;a
27
28   {
29      separator => SL::Layout::ActionBar::Separator->new,
30   } or die 'unknown descriptor';
31 }
32
33 # TODO: this necessary?
34 sub simple {
35   my ($class, $data) = @_;
36
37   my ($text, %params) = @$data;
38
39   if ($params{submit}) {
40     require SL::Layout::ActionBar::Submit;
41     return SL::Layout::ActionBar::Submit->new(text => $text, %params);
42   }
43
44   if ($params{function}) {
45     require SL::Layout::ActionBar::ScriptButton;
46     return SL::Layout::ActionBar::ScriptButton->new(text => $text, %params);
47   }
48
49   if ($params{combobox}) {
50
51   }
52 }
53
54 # shortcut for presenter
55
56 sub p {
57   SL::Presenter->get
58 }
59
60 # unique id to tie div and javascript together
61 sub init_id {
62   $_[0]->p->name_to_id('action[]')
63 }
64
65
66 1;
67
68 __END__