Revision 6ce40ffc
Von Sven Schöling vor fast 8 Jahren hinzugefügt
SL/Layout/ActionBar/Action.pm | ||
---|---|---|
4 | 4 |
use parent qw(Rose::Object); |
5 | 5 |
|
6 | 6 |
use SL::Presenter; |
7 |
require SL::Layout::ActionBar::Submit; |
|
7 | 8 |
|
8 | 9 |
use Rose::Object::MakeMethods::Generic ( |
9 | 10 |
'scalar --get_set_init' => [ qw(id params text) ], |
... | ... | |
29 | 30 |
return { |
30 | 31 |
separator => SL::Layout::ActionBar::Separator->new, |
31 | 32 |
combobox => SL::Layout::ActionBar::ComboBox->new, |
32 |
}->{$descriptor} or die 'unknown descriptor';
|
|
33 |
}->{$descriptor} || do { die 'unknown descriptor' };
|
|
33 | 34 |
} |
34 | 35 |
|
35 |
# TODO: this necessary?
|
|
36 |
# this is mostly so that outside consumer don't need to load subclasses themselves
|
|
36 | 37 |
sub simple { |
37 | 38 |
my ($class, $data) = @_; |
38 | 39 |
|
39 | 40 |
my ($text, %params) = @$data; |
40 |
|
|
41 |
if ($params{submit}) { |
|
42 |
require SL::Layout::ActionBar::Submit; |
|
43 |
return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params); |
|
44 |
} |
|
45 |
|
|
46 |
if ($params{function}) { |
|
47 |
require SL::Layout::ActionBar::ScriptButton; |
|
48 |
return SL::Layout::ActionBar::ScriptButton->new(text => $text, params => \%params); |
|
49 |
} |
|
50 |
|
|
51 |
if ($params{actions}) { |
|
52 |
require SL::Layout::ActionBar::ComboBox; |
|
53 |
return SL::Layout::ActionBar::ComboBox->new(text => $text, %params); |
|
54 |
} |
|
41 |
return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params); |
|
55 | 42 |
} |
56 | 43 |
|
57 | 44 |
# shortcut for presenter |
SL/Layout/ActionBar/ScriptButton.pm | ||
---|---|---|
1 |
package SL::Layout::ActionBar::ScriptButton; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Layout::ActionBar::Action); |
|
5 |
|
|
6 |
sub render { |
|
7 |
$_[0]->p->html_tag('div', $_[0]->text, |
|
8 |
id => $_[0]->id, |
|
9 |
class => 'layout-actionbar-action layout-actionbar-scriptbutton', |
|
10 |
); |
|
11 |
} |
|
12 |
|
|
13 |
1; |
SL/Layout/ActionBar/Separator.pm | ||
---|---|---|
7 | 7 |
$_[0]->p->html_tag('div', '', class => 'layout-actionbar-separator'); |
8 | 8 |
} |
9 | 9 |
|
10 |
sub script { |
|
11 |
() |
|
12 |
} |
|
13 |
|
|
10 | 14 |
1; |
css/lx-office-erp/main.css | ||
---|---|---|
562 | 562 |
padding-top: 25px; |
563 | 563 |
} |
564 | 564 |
|
565 |
div.layout-actionbar-separator { |
|
566 |
display: inline-block; |
|
567 |
width: 10px; |
|
568 |
} |
|
569 |
|
|
565 | 570 |
div.layout-actionbar div.layout-actionbar-submit, |
566 | 571 |
div.layout-actionbar div.layout-actionbar-scriptbutton, |
567 | 572 |
div.layout-actionbar div.layout-actionbar-submit:focus, |
js/kivi.ActionBar.js | ||
---|---|---|
1 | 1 |
namespace('kivi', function(k){ |
2 | 2 |
'use strict'; |
3 | 3 |
|
4 |
var CLASSES = { |
|
5 |
disabled: 'layout-actionbar-action-disabled' |
|
6 |
} |
|
7 |
|
|
4 | 8 |
k.ActionBarAction = function(e) { |
5 | 9 |
var data = $(e).data('action'); |
10 |
if (undefined === data) return; |
|
11 |
|
|
12 |
if (data.disabled) { |
|
13 |
$(e).addClass(CLASSES.disabled); |
|
14 |
} |
|
6 | 15 |
|
7 |
if (data.disabled) |
|
8 |
$(e).addClass('layout-actionbar-action-disabled'); |
|
9 |
// dispatch as needed |
|
10 |
if (data.submit) { |
|
11 |
var form = data.submit[0]; |
|
12 |
var params = data.submit[1]; |
|
16 |
if (data.call || data.submit) { |
|
13 | 17 |
$(e).click(function(event) { |
14 | 18 |
var $hidden, key, func, check; |
15 |
if (data.disabled) return;
|
|
19 |
if ($(e).hasClass(CLASSES.disabled)) return;
|
|
16 | 20 |
if (data.checks) { |
17 | 21 |
for (var i=0; i < data.checks.length; i++) { |
18 | 22 |
check = data.checks[i]; |
... | ... | |
22 | 26 |
} |
23 | 27 |
} |
24 | 28 |
if (data.confirm && !confirm(data.confirm)) return; |
25 |
for (key in params) { |
|
26 |
$hidden = $('<input type=hidden>') |
|
27 |
$hidden.attr('name', key) |
|
28 |
$hidden.attr('value', params[key]) |
|
29 |
$(form).append($hidden) |
|
29 |
if (data.call) { |
|
30 |
func = kivi.get_function_by_name(data.call[0]); |
|
31 |
func.apply(document, data.call.slice(1)) |
|
30 | 32 |
} |
31 |
$(form).submit() |
|
32 |
}) |
|
33 |
} else if (data.function) { |
|
34 |
// TODO: what to do with templated calls |
|
35 |
$(e).click(function(event) { |
|
36 |
var func; |
|
37 |
if (data.disabled) return; |
|
38 |
if (data.checks) { |
|
39 |
for (var i=0; i < data.checks.length; i++) { |
|
40 |
check = data.checks[i]; |
|
41 |
func = kivi.get_function_by_name(check); |
|
42 |
if (!func) console.log('Cannot find check function: ' + check); |
|
43 |
if (!func()) return; |
|
33 |
if (data.submit) { |
|
34 |
var form = data.submit[0]; |
|
35 |
var params = data.submit[1]; |
|
36 |
for (key in params) { |
|
37 |
$hidden = $('<input type=hidden>') |
|
38 |
$hidden.attr('name', key) |
|
39 |
$hidden.attr('value', params[key]) |
|
40 |
$(form).append($hidden) |
|
44 | 41 |
} |
42 |
$(form).submit(); |
|
45 | 43 |
} |
46 |
if (data.confirm && !confirm(data.confirm)) return; |
|
47 |
func = kivi.get_function_by_name(data.function[0]); |
|
48 |
func.apply(document, data.function.slice(1)) |
|
49 | 44 |
}); |
50 | 45 |
} |
51 | 46 |
} |
Auch abrufbar als: Unified diff
ActionBar: separator implementiert und ScriptButton in Submit gemergt