Revision 3dc29e42
Von Sven Schöling vor fast 8 Jahren hinzugefügt
SL/Layout/ActionBar/Action.pm | ||
---|---|---|
6 | 6 |
use SL::Presenter; |
7 | 7 |
|
8 | 8 |
use Rose::Object::MakeMethods::Generic ( |
9 |
'scalar --get_set_init' => [ qw(id) ], |
|
9 |
'scalar --get_set_init' => [ qw(id params text) ],
|
|
10 | 10 |
); |
11 | 11 |
|
12 | 12 |
# subclassing interface |
... | ... | |
16 | 16 |
} |
17 | 17 |
|
18 | 18 |
sub script { |
19 |
die 'needs to be implemented';
|
|
19 |
sprintf q|$('#%s').data('action', %s);|, $_[0]->id, JSON->new->allow_blessed->convert_blessed->encode($_[0]->params);
|
|
20 | 20 |
} |
21 | 21 |
|
22 |
|
|
23 | 22 |
# static constructors |
24 | 23 |
|
25 | 24 |
sub from_descriptor { |
26 |
my ($class, $descriptor) = @_;a |
|
25 |
my ($class, $descriptor) = @_; |
|
26 |
require SL::Layout::ActionBar::Separator; |
|
27 | 27 |
|
28 | 28 |
{ |
29 | 29 |
separator => SL::Layout::ActionBar::Separator->new, |
... | ... | |
38 | 38 |
|
39 | 39 |
if ($params{submit}) { |
40 | 40 |
require SL::Layout::ActionBar::Submit; |
41 |
return SL::Layout::ActionBar::Submit->new(text => $text, %params); |
|
41 |
return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params);
|
|
42 | 42 |
} |
43 | 43 |
|
44 | 44 |
if ($params{function}) { |
45 | 45 |
require SL::Layout::ActionBar::ScriptButton; |
46 |
return SL::Layout::ActionBar::ScriptButton->new(text => $text, %params); |
|
46 |
return SL::Layout::ActionBar::ScriptButton->new(text => $text, params => \%params);
|
|
47 | 47 |
} |
48 | 48 |
|
49 | 49 |
if ($params{combobox}) { |
... | ... | |
66 | 66 |
1; |
67 | 67 |
|
68 | 68 |
__END__ |
69 |
|
|
70 |
=head 1 |
|
71 |
|
|
72 |
planned options for clickables: |
|
73 |
|
|
74 |
- checks => [ ... ] (done) |
|
75 |
|
|
76 |
a list of functions that need to return true before submitting |
|
77 |
|
|
78 |
- submit => [ form-selector, { params } ] (done) |
|
79 |
|
|
80 |
on click submit the form specified by form-selector with the additional params |
|
81 |
|
|
82 |
- function => function-name (done) |
|
83 |
|
|
84 |
on click call the specified function (is this a special case of checks?) |
|
85 |
|
|
86 |
- disabled => true/false (done) |
|
87 |
|
|
88 |
TODO: |
|
89 |
|
|
90 |
- runtime disable/enable |
|
91 |
|
Auch abrufbar als: Unified diff
ActionBar: calling conventions geändert, +check/disabled/confirm