1 package SL::Layout::ActionBar::Action;
4 use parent qw(Rose::Object);
7 require SL::Layout::ActionBar::Submit;
9 use Rose::Object::MakeMethods::Generic (
10 'scalar --get_set_init' => [ qw(id params text) ],
13 # subclassing interface
16 die 'needs to be implemented';
20 sprintf q|$('#%s').data('action', %s);|, $_[0]->id, JSON->new->allow_blessed->convert_blessed->encode($_[0]->params);
26 my ($class, $descriptor) = @_;
27 require SL::Layout::ActionBar::Separator;
28 require SL::Layout::ActionBar::ComboBox;
31 separator => SL::Layout::ActionBar::Separator->new,
32 combobox => SL::Layout::ActionBar::ComboBox->new,
33 }->{$descriptor} || do { die 'unknown descriptor' };
36 # this is mostly so that outside consumer don't need to load subclasses themselves
38 my ($class, $data) = @_;
40 my ($text, %params) = @$data;
41 return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params);
44 # shortcut for presenter
50 # unique id to tie div and javascript together
52 $_[0]->p->name_to_id('action[]')
62 planned options for clickables:
64 - checks => [ ... ] (done)
66 a list of functions that need to return true before submitting
68 - submit => [ form-selector, { params } ] (done)
70 on click submit the form specified by form-selector with the additional params
72 - function => function-name (done)
74 on click call the specified function (is this a special case of checks?)
76 - disabled => true/false (done)
80 - runtime disable/enable