1 package SL::Layout::ActionBar::Action;
4 use parent qw(Rose::Object);
8 use Rose::Object::MakeMethods::Generic (
9 'scalar --get_set_init' => [ qw(id params text) ],
12 # subclassing interface
15 die 'needs to be implemented';
19 sprintf q|$('#%s').data('action', %s);|, $_[0]->id, JSON->new->allow_blessed->convert_blessed->encode($_[0]->params);
25 my ($class, $descriptor) = @_;
26 require SL::Layout::ActionBar::Separator;
29 separator => SL::Layout::ActionBar::Separator->new,
30 } or die 'unknown descriptor';
33 # TODO: this necessary?
35 my ($class, $data) = @_;
37 my ($text, %params) = @$data;
39 if ($params{submit}) {
40 require SL::Layout::ActionBar::Submit;
41 return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params);
44 if ($params{function}) {
45 require SL::Layout::ActionBar::ScriptButton;
46 return SL::Layout::ActionBar::ScriptButton->new(text => $text, params => \%params);
49 if ($params{combobox}) {
54 # shortcut for presenter
60 # unique id to tie div and javascript together
62 $_[0]->p->name_to_id('action[]')
72 planned options for clickables:
74 - checks => [ ... ] (done)
76 a list of functions that need to return true before submitting
78 - submit => [ form-selector, { params } ] (done)
80 on click submit the form specified by form-selector with the additional params
82 - function => function-name (done)
84 on click call the specified function (is this a special case of checks?)
86 - disabled => true/false (done)
90 - runtime disable/enable