From: Sven Schöling Date: Tue, 18 Oct 2016 09:57:27 +0000 (+0200) Subject: ActionBar: separator implementiert und ScriptButton in Submit gemergt X-Git-Tag: release-3.5.4~1404 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6ce40ffcc8bed8fe566e2be63298d289211175fc;p=kivitendo-erp.git ActionBar: separator implementiert und ScriptButton in Submit gemergt --- diff --git a/SL/Layout/ActionBar/Action.pm b/SL/Layout/ActionBar/Action.pm index 8b83295c5..e73387769 100644 --- a/SL/Layout/ActionBar/Action.pm +++ b/SL/Layout/ActionBar/Action.pm @@ -4,6 +4,7 @@ use strict; use parent qw(Rose::Object); use SL::Presenter; + require SL::Layout::ActionBar::Submit; use Rose::Object::MakeMethods::Generic ( 'scalar --get_set_init' => [ qw(id params text) ], @@ -29,29 +30,15 @@ sub from_descriptor { return { separator => SL::Layout::ActionBar::Separator->new, combobox => SL::Layout::ActionBar::ComboBox->new, - }->{$descriptor} or die 'unknown descriptor'; + }->{$descriptor} || do { die 'unknown descriptor' }; } -# TODO: this necessary? +# this is mostly so that outside consumer don't need to load subclasses themselves sub simple { my ($class, $data) = @_; my ($text, %params) = @$data; - - if ($params{submit}) { - require SL::Layout::ActionBar::Submit; - return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params); - } - - if ($params{function}) { - require SL::Layout::ActionBar::ScriptButton; - return SL::Layout::ActionBar::ScriptButton->new(text => $text, params => \%params); - } - - if ($params{actions}) { - require SL::Layout::ActionBar::ComboBox; - return SL::Layout::ActionBar::ComboBox->new(text => $text, %params); - } + return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params); } # shortcut for presenter diff --git a/SL/Layout/ActionBar/ScriptButton.pm b/SL/Layout/ActionBar/ScriptButton.pm deleted file mode 100644 index 501c15d23..000000000 --- a/SL/Layout/ActionBar/ScriptButton.pm +++ /dev/null @@ -1,13 +0,0 @@ -package SL::Layout::ActionBar::ScriptButton; - -use strict; -use parent qw(SL::Layout::ActionBar::Action); - -sub render { - $_[0]->p->html_tag('div', $_[0]->text, - id => $_[0]->id, - class => 'layout-actionbar-action layout-actionbar-scriptbutton', - ); -} - -1; diff --git a/SL/Layout/ActionBar/Separator.pm b/SL/Layout/ActionBar/Separator.pm index 9fc172c17..b6b7b9443 100644 --- a/SL/Layout/ActionBar/Separator.pm +++ b/SL/Layout/ActionBar/Separator.pm @@ -7,4 +7,8 @@ sub render { $_[0]->p->html_tag('div', '', class => 'layout-actionbar-separator'); } +sub script { + () +} + 1; diff --git a/css/lx-office-erp/main.css b/css/lx-office-erp/main.css index 28b24718e..97239b2cb 100644 --- a/css/lx-office-erp/main.css +++ b/css/lx-office-erp/main.css @@ -562,6 +562,11 @@ div.layout-actionbar ~ div { padding-top: 25px; } +div.layout-actionbar-separator { + display: inline-block; + width: 10px; +} + div.layout-actionbar div.layout-actionbar-submit, div.layout-actionbar div.layout-actionbar-scriptbutton, div.layout-actionbar div.layout-actionbar-submit:focus, diff --git a/js/kivi.ActionBar.js b/js/kivi.ActionBar.js index 44f0d6efe..d87b578c8 100644 --- a/js/kivi.ActionBar.js +++ b/js/kivi.ActionBar.js @@ -1,18 +1,22 @@ namespace('kivi', function(k){ 'use strict'; + var CLASSES = { + disabled: 'layout-actionbar-action-disabled' + } + k.ActionBarAction = function(e) { var data = $(e).data('action'); + if (undefined === data) return; + + if (data.disabled) { + $(e).addClass(CLASSES.disabled); + } - if (data.disabled) - $(e).addClass('layout-actionbar-action-disabled'); - // dispatch as needed - if (data.submit) { - var form = data.submit[0]; - var params = data.submit[1]; + if (data.call || data.submit) { $(e).click(function(event) { var $hidden, key, func, check; - if (data.disabled) return; + if ($(e).hasClass(CLASSES.disabled)) return; if (data.checks) { for (var i=0; i < data.checks.length; i++) { check = data.checks[i]; @@ -22,30 +26,21 @@ namespace('kivi', function(k){ } } if (data.confirm && !confirm(data.confirm)) return; - for (key in params) { - $hidden = $('') - $hidden.attr('name', key) - $hidden.attr('value', params[key]) - $(form).append($hidden) + if (data.call) { + func = kivi.get_function_by_name(data.call[0]); + func.apply(document, data.call.slice(1)) } - $(form).submit() - }) - } else if (data.function) { - // TODO: what to do with templated calls - $(e).click(function(event) { - var func; - if (data.disabled) return; - if (data.checks) { - for (var i=0; i < data.checks.length; i++) { - check = data.checks[i]; - func = kivi.get_function_by_name(check); - if (!func) console.log('Cannot find check function: ' + check); - if (!func()) return; + if (data.submit) { + var form = data.submit[0]; + var params = data.submit[1]; + for (key in params) { + $hidden = $('') + $hidden.attr('name', key) + $hidden.attr('value', params[key]) + $(form).append($hidden) } + $(form).submit(); } - if (data.confirm && !confirm(data.confirm)) return; - func = kivi.get_function_by_name(data.function[0]); - func.apply(document, data.function.slice(1)) }); } }