Verwaltung von Pflichtenhefttypen
authorMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 30 Jan 2013 16:07:02 +0000 (17:07 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 1 Apr 2014 11:02:23 +0000 (13:02 +0200)
SL/Controller/RequirementSpecType.pm [new file with mode: 0644]
SL/DB/RequirementSpecType.pm
locale/de/all
templates/webpages/requirement_spec_type/form.html [new file with mode: 0755]
templates/webpages/requirement_spec_type/list.html [new file with mode: 0644]

diff --git a/SL/Controller/RequirementSpecType.pm b/SL/Controller/RequirementSpecType.pm
new file mode 100644 (file)
index 0000000..e1e6aee
--- /dev/null
@@ -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;
index cf48954..fa2c242 100644 (file)
@@ -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;
 }
index 59e58b1..d5f1f48 100755 (executable)
@@ -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&uuml;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 (executable)
index 0000000..36f2923
--- /dev/null
@@ -0,0 +1,24 @@
+[% USE HTML %][% USE L %][% USE LxERP %]
+
+ <form method="post" action="controller.pl">
+  <div class="listtop">[% FORM.title %]</div>
+
+[%- INCLUDE 'common/flash.html' %]
+
+  <table>
+   <tr>
+    <td>[% LxERP.t8('Description') %]</td>
+    <td>[% L.input_tag("requirement_spec_type.description", SELF.requirement_spec_type.description) %]</td>
+   </tr>
+  </table>
+
+  <p>
+   [% 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 %]
+   <a href="[% SELF.url_for(action => 'list') %]">[%- LxERP.t8('Abort') %]</a>
+  </p>
+ </form>
diff --git a/templates/webpages/requirement_spec_type/list.html b/templates/webpages/requirement_spec_type/list.html
new file mode 100644 (file)
index 0000000..b1a6baa
--- /dev/null
@@ -0,0 +1,42 @@
+[% USE HTML %][% USE L %][% USE LxERP %]
+
+ <div class="listtop">[% FORM.title %]</div>
+
+[%- INCLUDE 'common/flash.html' %]
+
+ <form method="post" action="controller.pl">
+  [% IF !REQUIREMENT_SPEC_TYPES.size %]
+   <p>
+    [%- LxERP.t8('No requirement spec type has been created yet.') %]
+   </p>
+
+  [%- ELSE %]
+   <table id="requirement_spec_type_list">
+    <thead>
+    <tr class="listheading">
+     <th align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></th>
+     <th>[%- LxERP.t8('Description') %]</th>
+    </tr>
+    </thead>
+
+    <tbody>
+    [%- FOREACH requirement_spec_type = REQUIREMENT_SPEC_TYPES %]
+    <tr class="listrow[% loop.count % 2 %]" id="requirement_spec_type_id_[% requirement_spec_type.id %]">
+     <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
+     <td>
+      <a href="[% SELF.url_for(action => 'edit', id => requirement_spec_type.id) %]">
+       [%- HTML.escape(requirement_spec_type.description) %]
+      </a>
+     </td>
+    </tr>
+    [%- END %]
+    </tbody>
+   </table>
+  [%- END %]
+
+  <p>
+   <a href="[% SELF.url_for(action => 'new') %]">[%- LxERP.t8('Create a new requirement spec type') %]</a>
+  </p>
+ </form>
+
+ [% L.sortable_element('#requirement_spec_type_list tbody', url => 'controller.pl?action=RequirementSpecType/reorder', with => 'requirement_spec_type_id') %]