From 4fa00e30d9bfcc5fe8e04659d5e93eda8e5686ab Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 30 Jan 2013 17:07:02 +0100 Subject: [PATCH] Verwaltung von Pflichtenhefttypen --- SL/Controller/RequirementSpecType.pm | 115 ++++++++++++++++++ SL/DB/RequirementSpecType.pm | 3 +- locale/de/all | 7 ++ .../webpages/requirement_spec_type/form.html | 24 ++++ .../webpages/requirement_spec_type/list.html | 42 +++++++ 5 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 SL/Controller/RequirementSpecType.pm create mode 100755 templates/webpages/requirement_spec_type/form.html create mode 100644 templates/webpages/requirement_spec_type/list.html diff --git a/SL/Controller/RequirementSpecType.pm b/SL/Controller/RequirementSpecType.pm new file mode 100644 index 000000000..e1e6aeebb --- /dev/null +++ b/SL/Controller/RequirementSpecType.pm @@ -0,0 +1,115 @@ +package SL::Controller::RequirementSpecType; + +use strict; + +use parent qw(SL::Controller::Base); + +use SL::DB::RequirementSpecType; +use SL::DB::Language; +use SL::Helper::Flash; +use SL::Locale::String; + +use Rose::Object::MakeMethods::Generic +( + scalar => [ qw(requirement_spec_type) ], +); + +__PACKAGE__->run_before('check_auth'); +__PACKAGE__->run_before('load_requirement_spec_type', only => [ qw(edit update destroy) ]); + +# +# actions +# + +sub action_list { + my ($self) = @_; + + $self->render('requirement_spec_type/list', + title => t8('Requirement Spec Types'), + REQUIREMENT_SPEC_TYPES => SL::DB::Manager::RequirementSpecType->get_all_sorted); +} + +sub action_new { + my ($self) = @_; + + $self->{requirement_spec_type} = SL::DB::RequirementSpecType->new; + $self->render('requirement_spec_type/form', title => t8('Create a new requirement spec type')); +} + +sub action_edit { + my ($self) = @_; + $self->render('requirement_spec_type/form', title => t8('Edit requirement spec type')); +} + +sub action_create { + my ($self) = @_; + + $self->{requirement_spec_type} = SL::DB::RequirementSpecType->new; + $self->create_or_update; +} + +sub action_update { + my ($self) = @_; + $self->create_or_update; +} + +sub action_destroy { + my ($self) = @_; + + if (eval { $self->{requirement_spec_type}->delete; 1; }) { + flash_later('info', t8('The requirement spec type has been deleted.')); + } else { + flash_later('error', t8('The requirement spec type is in use and cannot be deleted.')); + } + + $self->redirect_to(action => 'list'); +} + +sub action_reorder { + my ($self) = @_; + + SL::DB::RequirementSpecType->reorder_list(@{ $::form->{requirement_spec_type_id} || [] }); + + $self->render('1;', { type => 'js', inline => 1 }); +} + +# +# filters +# + +sub check_auth { + $::auth->assert('config'); +} + +# +# helpers +# + +sub create_or_update { + my $self = shift; + my $is_new = !$self->{requirement_spec_type}->id; + my $params = delete($::form->{requirement_spec_type}) || { }; + my $title = $is_new ? t8('Create a new requirement spec type') : t8('Edit requirement spec type'); + + $self->{requirement_spec_type}->assign_attributes(%{ $params }); + + my @errors = $self->{requirement_spec_type}->validate; + + if (@errors) { + flash('error', @errors); + $self->render('requirement_spec_type/form', title => $title); + return; + } + + $self->{requirement_spec_type}->save; + + flash_later('info', $is_new ? t8('The requirement spec type has been created.') : t8('The requirement spec type has been saved.')); + $self->redirect_to(action => 'list'); +} + +sub load_requirement_spec_type { + my ($self) = @_; + $self->{requirement_spec_type} = SL::DB::RequirementSpecType->new(id => $::form->{id})->load; +} + +1; diff --git a/SL/DB/RequirementSpecType.pm b/SL/DB/RequirementSpecType.pm index cf489542f..fa2c2429c 100644 --- a/SL/DB/RequirementSpecType.pm +++ b/SL/DB/RequirementSpecType.pm @@ -11,7 +11,8 @@ sub validate { my ($self) = @_; my @errors; - push @errors, t8('The description is missing.') if !$self->description; + push @errors, t8('The description is missing.') if !$self->description; + push @errors, t8('The description is not unique.') if $self->get_first_conflicting('description'); return @errors; } diff --git a/locale/de/all b/locale/de/all index 59e58b1bd..d5f1f489a 100755 --- a/locale/de/all +++ b/locale/de/all @@ -526,6 +526,7 @@ $self->{texts} = { 'Create a new printer' => 'Einen neuen Drucker anlegen', 'Create a new project' => 'Neues Projekt anlegen', 'Create a new project type' => 'Einen neuen Projekttypen anlegen', + 'Create a new requirement spec type' => 'Einen neuen Pflichtenhefttypen anlegen', 'Create a new user' => 'Einen neuen Benutzer anlegen', 'Create a new user group' => 'Eine neue Benutzergruppe erfassen', 'Create and edit RFQs' => 'Lieferantenanfragen erfassen und bearbeiten', @@ -861,6 +862,7 @@ $self->{texts} = { 'Edit project' => 'Projekt bearbeiten', 'Edit project #1' => 'Projekt #1 bearbeiten', 'Edit project type' => 'Projekttypen bearbeiten', + 'Edit requirement spec type' => 'Pflichtenhefttypen bearbeiten', 'Edit templates' => 'Vorlagen bearbeiten', 'Edit the Delivery Order' => 'Lieferschein bearbeiten', 'Edit the configuration for periodic invoices' => 'Konfiguration für wiederkehrende Rechnungen bearbeiten', @@ -1410,6 +1412,7 @@ $self->{texts} = { 'No problems were recognized.' => 'Es wurden keine Probleme gefunden.', 'No project type has been created yet.' => 'Es wurden noch keine Projekttypen angelegt.', 'No report with id #1' => 'Es gibt keinen Report mit der Id #1', + 'No requirement spec type has been created yet.' => 'Es wurden noch keine Pflichtenhefttypen angelegt.', 'No shipto selected to delete' => 'Keine Lieferadresse zum Löschen ausgewählt', 'No summary account' => 'Kein Sammelkonto', 'No transaction selected!' => 'Keine Transaktion ausgewählt', @@ -2251,6 +2254,10 @@ $self->{texts} = { 'The project type is in use and cannot be deleted.' => 'Der Projekttyp wird verwendet und kann nicht gelöscht werden.', 'The required information consists of the IBAN and the BIC.' => 'Die benötigten Informationen bestehen aus der IBAN und der BIC.', 'The required information consists of the IBAN, the BIC, the mandator ID and the mandate\'s date of signature.' => 'Die benötigten Informationen bestehen aus IBAN, BIC, Mandanten-ID und dem Unterschriftsdatum des Mandates.', + 'The requirement spec type has been created.' => 'Der Pflichtenhefttyp wurde angelegt.', + 'The requirement spec type has been deleted.' => 'Der Pflichtenhefttyp wurde gelöscht.', + 'The requirement spec type has been saved.' => 'Der Pflichtenhefttyp wurde gespeichert.', + 'The requirement spec type is in use and cannot be deleted.' => 'Der Pflichtenhefttyp wird verwendet und kann nicht gelöscht werden.', 'The second reason is that kivitendo allowed the user to enter the tax amount manually regardless of the taxkey used.' => 'Der zweite Grund war, dass kivitendo zuließ, dass die Benutzer beliebige, von den tatsächlichen Steuerschlüsseln unabhängige Steuerbeträge eintrugen.', 'The second way is to use Perl\'s CPAN module and let it download and install the module for you.' => 'Die zweite Variante besteht darin, Perls CPAN-Modul zu benutzen und es das Modul für Sie installieren zu lassen.', 'The selected bank account does not exist anymore.' => 'Das ausgewählte Bankkonto existiert nicht mehr.', diff --git a/templates/webpages/requirement_spec_type/form.html b/templates/webpages/requirement_spec_type/form.html new file mode 100755 index 000000000..36f2923df --- /dev/null +++ b/templates/webpages/requirement_spec_type/form.html @@ -0,0 +1,24 @@ +[% USE HTML %][% USE L %][% USE LxERP %] + +
+
[% FORM.title %]
+ +[%- INCLUDE 'common/flash.html' %] + + + + + + +
[% LxERP.t8('Description') %][% L.input_tag("requirement_spec_type.description", SELF.requirement_spec_type.description) %]
+ +

+ [% L.hidden_tag("id", SELF.requirement_spec_type.id) %] + [% L.hidden_tag("action", "RequirementSpecType/dispatch") %] + [% L.submit_tag("action_" _ (SELF.requirement_spec_type.id ? "update" : "create"), LxERP.t8('Save')) %] + [%- IF SELF.requirement_spec_type.id %] + [% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Do you really want to delete this object?')) %] + [%- END %] + [%- LxERP.t8('Abort') %] +

+
diff --git a/templates/webpages/requirement_spec_type/list.html b/templates/webpages/requirement_spec_type/list.html new file mode 100644 index 000000000..b1a6baacf --- /dev/null +++ b/templates/webpages/requirement_spec_type/list.html @@ -0,0 +1,42 @@ +[% USE HTML %][% USE L %][% USE LxERP %] + +
[% FORM.title %]
+ +[%- INCLUDE 'common/flash.html' %] + +
+ [% IF !REQUIREMENT_SPEC_TYPES.size %] +

+ [%- LxERP.t8('No requirement spec type has been created yet.') %] +

+ + [%- ELSE %] + + + + + + + + + + [%- FOREACH requirement_spec_type = REQUIREMENT_SPEC_TYPES %] + + + + + [%- END %] + +
[ LxERP.t8('reorder item') %][%- LxERP.t8('Description') %]
[ LxERP.t8('reorder item') %] + + [%- HTML.escape(requirement_spec_type.description) %] + +
+ [%- END %] + +

+ [%- LxERP.t8('Create a new requirement spec type') %] +

+
+ + [% L.sortable_element('#requirement_spec_type_list tbody', url => 'controller.pl?action=RequirementSpecType/reorder', with => 'requirement_spec_type_id') %] -- 2.20.1