X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FProject.pm;h=601b245b7cd7cf2d004816ceab81b3bb82b2313d;hb=161082b04bdd3320fe94ff448e80a0b4d19bc29b;hp=06d43847b3f4356cdefba1e2b0fbc15562b1d46a;hpb=3705b3749fa74d720841294775973ffea0d34772;p=kivitendo-erp.git diff --git a/SL/Controller/Project.pm b/SL/Controller/Project.pm index 06d43847b..601b245b7 100644 --- a/SL/Controller/Project.pm +++ b/SL/Controller/Project.pm @@ -51,12 +51,16 @@ sub action_search { include_prefix => 'l_', include_value => 'Y'); + $self->setup_search_action_bar; + $self->render('project/search', %params); } sub action_list { my ($self) = @_; + $self->setup_search_action_bar; + $self->make_filter_summary; $self->prepare_report; @@ -69,14 +73,14 @@ sub action_new { $self->project(SL::DB::Project->new); $self->display_form(title => $::locale->text('Create a new project'), - callback => $::form->{callback} || $self->url_for(action => 'new')); + callback => $::form->{callback} || $self->url_for(action => 'list')); } sub action_edit { my ($self) = @_; $self->display_form(title => $::locale->text('Edit project #1', $self->project->projectnumber), - callback => $::form->{callback} || $self->url_for(action => 'edit', id => $self->project->id)); + callback => $::form->{callback} || $self->url_for(action => 'list')); } sub action_create { @@ -232,6 +236,8 @@ sub display_form { CVar->render_inputs(variables => $params{CUSTOM_VARIABLES}) if @{ $params{CUSTOM_VARIABLES} }; + $self->setup_edit_action_bar(callback => $params{callback}); + $self->render('project/form', %params); } @@ -291,7 +297,7 @@ sub prepare_report { project_type => { sub => sub { $_[0]->project_type->description } }, project_status => { sub => sub { $_[0]->project_status->description }, text => t8('Status') }, customer => { sub => sub { !$_[0]->customer_id ? '' : $_[0]->customer->name }, - raw_data => sub { !$_[0]->customer_id ? '' : $self->presenter->customer($_[0]->customer, display => 'table-cell', callback => $callback) } }, + raw_data => sub { !$_[0]->customer_id ? '' : $_[0]->customer->presenter->customer(display => 'table-cell', callback => $callback) } }, active => { sub => sub { $_[0]->active ? $::locale->text('Active') : $::locale->text('Inactive') }, text => $::locale->text('Active') }, valid => { sub => sub { $_[0]->valid ? $::locale->text('Valid') : $::locale->text('Invalid') }, @@ -372,4 +378,60 @@ sub make_filter_summary { $self->{filter_summary} = join ', ', @filter_strings; } + +sub setup_edit_action_bar { + my ($self, %params) = @_; + + my $is_new = !$self->project->id; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + combobox => [ + action => [ + t8('Save'), + submit => [ '#form', { action => 'Project/' . ($is_new ? 'create' : 'update') } ], + accesskey => 'enter', + ], + action => [ + t8('Save as new'), + submit => [ '#form', { action => 'Project/create' }], + disabled => $is_new ? t8('The object has not been saved yet.') : undef, + ], + ], # end of combobox "Save" + + action => [ + t8('Delete'), + submit => [ '#form', { action => 'Project/destroy' } ], + confirm => $::locale->text('Do you really want to delete this object?'), + disabled => $is_new ? t8('This object has not been saved yet.') + : $self->project->is_used ? t8('This object has already been used.') + : undef, + ], + + link => [ + t8('Abort'), + link => $params{callback} || $self->url_for(action => 'list'), + ], + ); + } +} + +sub setup_search_action_bar { + my ($self, %params) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Update'), + submit => [ '#search_form', { action => 'Project/list' } ], + accesskey => 'enter', + ], + link => [ + t8('Add'), + link => $self->url_for(action => 'new'), + ], + ); + } +} + 1;