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;
27 require SL::Layout::ActionBar::ComboBox;
30 separator => SL::Layout::ActionBar::Separator->new,
31 combobox => SL::Layout::ActionBar::ComboBox->new,
32 }->{$descriptor} or die 'unknown descriptor';
35 # TODO: this necessary?
37 my ($class, $data) = @_;
39 my ($text, %params) = @$data;
41 if ($params{submit}) {
42 require SL::Layout::ActionBar::Submit;
43 return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params);
46 if ($params{function}) {
47 require SL::Layout::ActionBar::ScriptButton;
48 return SL::Layout::ActionBar::ScriptButton->new(text => $text, params => \%params);
51 if ($params{actions}) {
52 require SL::Layout::ActionBar::ComboBox;
53 return SL::Layout::ActionBar::ComboBox->new(text => $text, %params);
57 # shortcut for presenter
63 # unique id to tie div and javascript together
65 $_[0]->p->name_to_id('action[]')
75 planned options for clickables:
77 - checks => [ ... ] (done)
79 a list of functions that need to return true before submitting
81 - submit => [ form-selector, { params } ] (done)
83 on click submit the form specified by form-selector with the additional params
85 - function => function-name (done)
87 on click call the specified function (is this a special case of checks?)
89 - disabled => true/false (done)
93 - runtime disable/enable