From 6b5fa71b6ef0f4613c719c5c67d0dca2df6877a8 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 11 Jan 2017 11:22:54 +0100 Subject: [PATCH] ActionBar: Verwendung im Part-Controller --- SL/Controller/Part.pm | 51 +++++++++++++++++++++++++++++-- templates/webpages/part/form.html | 14 --------- 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index 9666296aa..de2cb1d28 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -194,6 +194,7 @@ sub render_form { my ($self, %params) = @_; $self->_set_javascript; + $self->_setup_form_action_bar; my (%assortment_vars, %assembly_vars); %assortment_vars = %{ $self->prepare_assortment_render_vars } if $self->part->is_assortment; @@ -216,7 +217,6 @@ sub render_form { $self->render( 'part/form', title => $title_hash{$self->part->part_type}, - show_edit_buttons => $::auth->assert('part_service_assembly_edit'), %assortment_vars, %assembly_vars, translations_map => { map { ($_->language_id => $_) } @{$self->part->translations} }, @@ -596,6 +596,7 @@ sub add { check_has_valid_part_type($self->part->part_type); $self->_set_javascript; + $self->_setup_form_action_bar; my %title_hash = ( part => t8('Add Part'), assembly => t8('Add Assembly'), @@ -605,8 +606,7 @@ sub add { $self->render( 'part/form', - title => $title_hash{$self->part->part_type}, - show_edit_buttons => $::auth->assert('part_service_assembly_edit'), + title => $title_hash{$self->part->part_type}, ); } @@ -1127,6 +1127,51 @@ sub parse_add_items_to_objects { return \@item_objects; } +sub _setup_form_action_bar { + my ($self) = @_; + + my $may_edit = $::auth->assert('part_service_assembly_edit', 'may fail'); + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + combobox => [ + action => [ + t8('Save'), + call => [ 'kivi.Part.save' ], + disabled => !$may_edit ? t8('You do not have the permissions to access this function.') : undef, + ], + action => [ + t8('Use as new'), + call => [ 'kivi.Part.use_as_new' ], + disabled => !$self->part->id ? t8('The object has not been saved yet.') + : !$may_edit ? t8('You do not have the permissions to access this function.') + : undef, + ], + ], # end of combobox "Save" + + action => [ + t8('Delete'), + call => [ 'kivi.Part.delete' ], + confirm => t8('Do you really want to delete this object?'), + disabled => !$self->part->id ? t8('This object has not been saved yet.') + : !$may_edit ? t8('You do not have the permissions to access this function.') + : !$self->part->orphaned ? t8('This object has already been used.') + : undef, + ], + + 'separator', + + action => [ + t8('History'), + call => [ 'kivi.Part.open_history_popup' ], + disabled => !$self->part->id ? t8('This object has not been saved yet.') + : !$may_edit ? t8('You do not have the permissions to access this function.') + : undef, + ], + ); + } +} + 1; __END__ diff --git a/templates/webpages/part/form.html b/templates/webpages/part/form.html index 0d7ab0838..693af3e42 100644 --- a/templates/webpages/part/form.html +++ b/templates/webpages/part/form.html @@ -82,18 +82,4 @@ [%- END %] - -

- [% IF show_edit_buttons %] - [% L.button_tag('kivi.Part.save()', LxERP.t8('Save')) %] - [% IF SELF.part.id %] - [% L.button_tag('kivi.Part.use_as_new()', LxERP.t8('Use as new')) %] - [% IF SELF.part.orphaned %] - [% L.button_tag('kivi.Part.delete()', LxERP.t8('Delete')) %] - [% END %] - [% L.button_tag('kivi.Part.open_history_popup()', LxERP.t8('History')) %] - [% END %] - [% END %] -

- -- 2.20.1