From 6d75a1bc95b6b7ea7c5a348fffc37a2b7fea35fd Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 30 Jan 2013 18:03:28 +0100 Subject: [PATCH] Verwaltung von Pflichtenheftstatus --- SL/Controller/RequirementSpecStatus.pm | 116 ++++++++++++++++++ SL/DB/RequirementSpecAcceptanceStatus.pm | 9 +- SL/DB/RequirementSpecStatus.pm | 10 +- locale/de/all | 9 ++ .../requirement_spec_status/form.html | 29 +++++ .../requirement_spec_status/list.html | 45 +++++++ 6 files changed, 215 insertions(+), 3 deletions(-) create mode 100644 SL/Controller/RequirementSpecStatus.pm create mode 100755 templates/webpages/requirement_spec_status/form.html create mode 100644 templates/webpages/requirement_spec_status/list.html diff --git a/SL/Controller/RequirementSpecStatus.pm b/SL/Controller/RequirementSpecStatus.pm new file mode 100644 index 000000000..debd18bab --- /dev/null +++ b/SL/Controller/RequirementSpecStatus.pm @@ -0,0 +1,116 @@ +package SL::Controller::RequirementSpecStatus; + +use strict; + +use parent qw(SL::Controller::Base); + +use SL::DB::RequirementSpecStatus; +use SL::DB::Language; +use SL::Helper::Flash; +use SL::Locale::String; + +use Rose::Object::MakeMethods::Generic +( + scalar => [ qw(requirement_spec_status valid_names) ], +); + +__PACKAGE__->run_before('check_auth'); +__PACKAGE__->run_before('load_requirement_spec_status', only => [ qw(edit update destroy) ]); +__PACKAGE__->run_before(sub { $_[0]->valid_names(\@SL::DB::RequirementSpecStatus::valid_names) }); + +# +# actions +# + +sub action_list { + my ($self) = @_; + + $self->render('requirement_spec_status/list', + title => t8('Requirement Spec Statuses'), + REQUIREMENT_SPEC_STATUSES => SL::DB::Manager::RequirementSpecStatus->get_all_sorted); +} + +sub action_new { + my ($self) = @_; + + $self->{requirement_spec_status} = SL::DB::RequirementSpecStatus->new; + $self->render('requirement_spec_status/form', title => t8('Create a new requirement spec status')); +} + +sub action_edit { + my ($self) = @_; + $self->render('requirement_spec_status/form', title => t8('Edit requirement spec status')); +} + +sub action_create { + my ($self) = @_; + + $self->{requirement_spec_status} = SL::DB::RequirementSpecStatus->new; + $self->create_or_update; +} + +sub action_update { + my ($self) = @_; + $self->create_or_update; +} + +sub action_destroy { + my ($self) = @_; + + if (eval { $self->{requirement_spec_status}->delete; 1; }) { + flash_later('info', t8('The requirement spec status has been deleted.')); + } else { + flash_later('error', t8('The requirement spec status is in use and cannot be deleted.')); + } + + $self->redirect_to(action => 'list'); +} + +sub action_reorder { + my ($self) = @_; + + SL::DB::RequirementSpecStatus->reorder_list(@{ $::form->{requirement_spec_status_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_status}->id; + my $params = delete($::form->{requirement_spec_status}) || { }; + my $title = $is_new ? t8('Create a new requirement spec status') : t8('Edit requirement spec status'); + + $self->{requirement_spec_status}->assign_attributes(%{ $params }); + + my @errors = $self->{requirement_spec_status}->validate; + + if (@errors) { + flash('error', @errors); + $self->render('requirement_spec_status/form', title => $title); + return; + } + + $self->{requirement_spec_status}->save; + + flash_later('info', $is_new ? t8('The requirement spec status has been created.') : t8('The requirement spec status has been saved.')); + $self->redirect_to(action => 'list'); +} + +sub load_requirement_spec_status { + my ($self) = @_; + $self->{requirement_spec_status} = SL::DB::RequirementSpecStatus->new(id => $::form->{id})->load; +} + +1; diff --git a/SL/DB/RequirementSpecAcceptanceStatus.pm b/SL/DB/RequirementSpecAcceptanceStatus.pm index ad50af835..e709f8dcd 100644 --- a/SL/DB/RequirementSpecAcceptanceStatus.pm +++ b/SL/DB/RequirementSpecAcceptanceStatus.pm @@ -2,16 +2,23 @@ package SL::DB::RequirementSpecAcceptanceStatus; use strict; +use List::MoreUtils qw(none); + use SL::DB::MetaSetup::RequirementSpecAcceptanceStatus; use SL::DB::Manager::RequirementSpecAcceptanceStatus; use SL::DB::Helper::ActsAsList; use SL::Locale::String; +our @valid_names = qw(accepted accepted_with_defects accepted_with_defects_to_be_fixed not_accepted); + sub validate { my ($self) = @_; my @errors; - push @errors, t8('The description is missing.') if !$self->description; + push @errors, t8('The name is missing.') if !$self->name; + push @errors, t8('The name and description are not unique.') if $self->get_first_conflicting('name', 'description'); + push @errors, t8('The name is invalid.') if none { $_ eq $self->name } @valid_names; + push @errors, t8('The description is missing.') if !$self->description; return @errors; } diff --git a/SL/DB/RequirementSpecStatus.pm b/SL/DB/RequirementSpecStatus.pm index fb808c64c..d1e3986c2 100644 --- a/SL/DB/RequirementSpecStatus.pm +++ b/SL/DB/RequirementSpecStatus.pm @@ -2,18 +2,24 @@ package SL::DB::RequirementSpecStatus; use strict; +use List::MoreUtils qw(none); + use SL::DB::MetaSetup::RequirementSpecStatus; use SL::DB::Manager::RequirementSpecStatus; use SL::DB::Helper::ActsAsList; use SL::Locale::String; +our @valid_names = qw(planning running done); + sub validate { my ($self) = @_; my @errors; - push @errors, t8('The name is missing.') if !$self->name; - push @errors, t8('The description is missing.') if !$self->description; + push @errors, t8('The name is missing.') if !$self->name; + push @errors, t8('The name and description are not unique.') if $self->get_first_conflicting('name', 'description'); + push @errors, t8('The name is invalid.') if none { $_ eq $self->name } @valid_names; + push @errors, t8('The description is missing.') if !$self->description; return @errors; } diff --git a/locale/de/all b/locale/de/all index d5f1f489a..951aedd86 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 status' => 'Einen neuen Pflichtenheftstatus 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', @@ -862,6 +863,7 @@ $self->{texts} = { 'Edit project' => 'Projekt bearbeiten', 'Edit project #1' => 'Projekt #1 bearbeiten', 'Edit project type' => 'Projekttypen bearbeiten', + 'Edit requirement spec status' => 'Pflichtenheftstatus bearbeiten', 'Edit requirement spec type' => 'Pflichtenhefttypen bearbeiten', 'Edit templates' => 'Vorlagen bearbeiten', 'Edit the Delivery Order' => 'Lieferschein bearbeiten', @@ -1412,6 +1414,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 statuses has been created yet.' => 'Es wurden noch keine Pflichtenheftstatus angelegt.', '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', @@ -2214,7 +2217,9 @@ $self->{texts} = { 'The login is not unique.' => 'Der Loginname ist nicht eindeutig.', 'The long description is missing.' => 'Der Langtext fehlt.', 'The master templates where not found.' => 'Der Vorlagensatz wurde nicht gefunden.', + 'The name and description are not unique.' => 'Name und Beschreibung sind nicht einmalig.', 'The name in row %d has already been used before.' => 'Der Name in Zeile %d wurde vorher bereits benutzt.', + 'The name is invalid.' => 'Der Name ist ungültigt.', 'The name is missing in row %d.' => 'Der Name fehlt in Zeile %d.', 'The name is missing.' => 'Der Name fehlt.', 'The name is not unique.' => 'Der Name ist nicht eindeutig.', @@ -2254,6 +2259,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 status has been created.' => 'Der Pflichtenheftstatus wurde angelegt.', + 'The requirement spec status has been deleted.' => 'Der Pflichtenheftstatus wurde gelöscht.', + 'The requirement spec status has been saved.' => 'Der Pflichtenheftstatus wurde gespeichert.', + 'The requirement spec status is in use and cannot be deleted.' => 'Der Pflichtenheftstatus wird verwendet und kann nicht gelöscht werden.', '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.', diff --git a/templates/webpages/requirement_spec_status/form.html b/templates/webpages/requirement_spec_status/form.html new file mode 100755 index 000000000..3b28c002e --- /dev/null +++ b/templates/webpages/requirement_spec_status/form.html @@ -0,0 +1,29 @@ +[% USE HTML %][% USE L %][% USE LxERP %] + +
+
[% FORM.title %]
+ +[%- INCLUDE 'common/flash.html' %] + + + + + + + + + + + +
[% LxERP.t8('Name') %][% L.select_tag("requirement_spec_status.name", SELF.valid_names, default = SELF.requirement_spec_status.name) %]
[% LxERP.t8('Description') %][% L.input_tag("requirement_spec_status.description", SELF.requirement_spec_status.description) %]
+ +

+ [% L.hidden_tag("id", SELF.requirement_spec_status.id) %] + [% L.hidden_tag("action", "RequirementSpecStatus/dispatch") %] + [% L.submit_tag("action_" _ (SELF.requirement_spec_status.id ? "update" : "create"), LxERP.t8('Save')) %] + [%- IF SELF.requirement_spec_status.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_status/list.html b/templates/webpages/requirement_spec_status/list.html new file mode 100644 index 000000000..0633d62fb --- /dev/null +++ b/templates/webpages/requirement_spec_status/list.html @@ -0,0 +1,45 @@ +[% USE HTML %][% USE L %][% USE LxERP %] + +
[% FORM.title %]
+ +[%- INCLUDE 'common/flash.html' %] + +
+ [% IF !REQUIREMENT_SPEC_STATUSES.size %] +

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

+ + [%- ELSE %] + + + + + + + + + + + [%- FOREACH requirement_spec_status = REQUIREMENT_SPEC_STATUSES %] + + + + + + + [%- END %] + +
[ LxERP.t8('reorder item') %][%- LxERP.t8('Name') %][%- LxERP.t8('Description') %]
[ LxERP.t8('reorder item') %] + + [%- HTML.escape(requirement_spec_status.name) %] + + [%- HTML.escape(requirement_spec_status.description) %]
+ [%- END %] + +

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

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