Pflichtenhefte vordef Textblöcke: Verwaltung Flags »benutzbar für…«
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 4 Nov 2014 08:58:13 +0000 (09:58 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 5 Nov 2014 08:11:37 +0000 (09:11 +0100)
SL/Controller/RequirementSpecPredefinedText.pm
SL/DB/MetaSetup/RequirementSpecPredefinedText.pm
locale/de/all
sql/Pg-upgrade2/requirement_spec_predefined_texts_for_sections.sql [new file with mode: 0644]
templates/webpages/requirement_spec_predefined_text/form.html
templates/webpages/requirement_spec_predefined_text/list.html

index 959a770..00c86b4 100644 (file)
@@ -4,6 +4,8 @@ use strict;
 
 use parent qw(SL::Controller::Base);
 
+use List::MoreUtils qw(none);
+
 use SL::DB::RequirementSpecPredefinedText;
 use SL::Helper::Flash;
 use SL::Locale::String;
@@ -32,7 +34,7 @@ sub action_list {
 sub action_new {
   my ($self) = @_;
 
-  $self->{requirement_spec_predefined_text} = SL::DB::RequirementSpecPredefinedText->new;
+  $self->{requirement_spec_predefined_text} = SL::DB::RequirementSpecPredefinedText->new(useable_for_text_blocks => 1);
   $self->render('requirement_spec_predefined_text/form', title => t8('Create a new predefined text'));
 }
 
@@ -95,6 +97,13 @@ sub create_or_update {
   my $params = delete($::form->{requirement_spec_predefined_text}) || { };
   my $title  = $is_new ? t8('Create a new predefined text') : t8('Edit predefined text');
 
+  # Force presence of booleans for the useable_* flags.
+  my @useable_flags = qw(text_blocks sections);
+  $params->{"useable_for_${_}"} = !!$params->{"useable_for_${_}"} for @useable_flags;
+
+  # Force usage for text blocks if none of the check boxes are marked.
+  $params->{useable_for_text_blocks} = 1 if none { $params->{"useable_for_${_}"} } @useable_flags;
+
   $self->{requirement_spec_predefined_text}->assign_attributes(%{ $params });
 
   my @errors = $self->{requirement_spec_predefined_text}->validate;
index 5cb179c..ec9847b 100644 (file)
@@ -9,13 +9,15 @@ use base qw(SL::DB::Object);
 __PACKAGE__->meta->table('requirement_spec_predefined_texts');
 
 __PACKAGE__->meta->columns(
-  description => { type => 'text', not_null => 1 },
-  id          => { type => 'serial', not_null => 1 },
-  itime       => { type => 'timestamp', default => 'now()' },
-  mtime       => { type => 'timestamp' },
-  position    => { type => 'integer', not_null => 1 },
-  text        => { type => 'text', not_null => 1 },
-  title       => { type => 'text', not_null => 1 },
+  description             => { type => 'text', not_null => 1 },
+  id                      => { type => 'serial', not_null => 1 },
+  itime                   => { type => 'timestamp', default => 'now()' },
+  mtime                   => { type => 'timestamp' },
+  position                => { type => 'integer', not_null => 1 },
+  text                    => { type => 'text', not_null => 1 },
+  title                   => { type => 'text', not_null => 1 },
+  useable_for_sections    => { type => 'boolean', default => 'false', not_null => 1 },
+  useable_for_text_blocks => { type => 'boolean', default => 'false', not_null => 1 },
 );
 
 __PACKAGE__->meta->primary_key_columns([ 'id' ]);
index 76b703b..c093608 100755 (executable)
@@ -2338,6 +2338,7 @@ $self->{texts} = {
   'Test database connectivity'  => 'Datenbankverbindung testen',
   'Text block actions'          => 'Textblockaktionen',
   'Text block picture actions'  => 'Aktionen für Textblockbilder',
+  'Text blocks'                 => 'Textblöcke',
   'Text blocks back'            => 'Textblöcke hinten',
   'Text blocks front'           => 'Textblöcke vorne',
   'Text field'                  => 'Textfeld',
@@ -2783,6 +2784,7 @@ $self->{texts} = {
   'Use WebDAV Repository'       => 'WebDAV-Ablage verwenden',
   'Use existing templates'      => 'Vorhandene Druckvorlagen verwenden',
   'Use master default bin for Default Transfer, if no default bin for the part is configured' => 'Standardlagerplatz für Ein- / Auslagern über Standard-Lagerplatz, falls für die Ware kein expliziter Lagerplatz konfiguriert ist',
+  'Useable for…'                => 'Benutzbar für…',
   'User'                        => 'Benutzer',
   'User Config'                 => 'Einstellungen',
   'User Groups'                 => 'Gruppen',
diff --git a/sql/Pg-upgrade2/requirement_spec_predefined_texts_for_sections.sql b/sql/Pg-upgrade2/requirement_spec_predefined_texts_for_sections.sql
new file mode 100644 (file)
index 0000000..14b5f1b
--- /dev/null
@@ -0,0 +1,14 @@
+-- @tag: requirement_spec_predefined_texts_for_sections
+-- @description: Verwendung von vordefinierten Pflichtenhefttextblöcken bei Abschnitten
+-- @depends: requirement_specs
+ALTER TABLE requirement_spec_predefined_texts ADD COLUMN useable_for_text_blocks BOOLEAN;
+ALTER TABLE requirement_spec_predefined_texts ADD COLUMN useable_for_sections    BOOLEAN;
+
+UPDATE requirement_spec_predefined_texts
+SET useable_for_text_blocks = TRUE, useable_for_sections = FALSE;
+
+ALTER TABLE requirement_spec_predefined_texts ALTER COLUMN useable_for_text_blocks SET DEFAULT FALSE;
+ALTER TABLE requirement_spec_predefined_texts ALTER COLUMN useable_for_sections    SET DEFAULT FALSE;
+
+ALTER TABLE requirement_spec_predefined_texts ALTER COLUMN useable_for_text_blocks SET NOT NULL;
+ALTER TABLE requirement_spec_predefined_texts ALTER COLUMN useable_for_sections    SET NOT NULL;
index 8285140..905d351 100755 (executable)
     <td>[% LxERP.t8("Content") %]</td>
     <td>[% L.textarea_tag("requirement_spec_predefined_text.text_as_restricted_html", SELF.requirement_spec_predefined_text.text_as_restricted_html, class='texteditor', style='width: 800px; height: 300px') %]</td>
    </tr>
+
+   <tr>
+    <td>[% LxERP.t8("Useable for…") %]</sup></td>
+    <td>
+     [% L.checkbox_tag("requirement_spec_predefined_text.useable_for_text_blocks", label=LxERP.t8("Text blocks"), value=1, checked=SELF.requirement_spec_predefined_text.useable_for_text_blocks) %]
+     [% L.checkbox_tag("requirement_spec_predefined_text.useable_for_sections",    label=LxERP.t8("Sections"),    value=1, checked=SELF.requirement_spec_predefined_text.useable_for_sections) %]
+    </td>
+   </tr>
   </table>
 
   <p>
index 358d646..85f9db2 100644 (file)
   [%- ELSE %]
    <table id="requirement_spec_predefined_text_list">
     <thead>
+    <tr class="listheading">
+     <th colspan="4"></th>
+     <th colspan="2" align="center">[% LxERP.t8("Useable for…") %]</th>
+    </tr>
     <tr class="listheading">
      <th align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></th>
      <th>[% LxERP.t8("Description") %]</th>
      <th>[% LxERP.t8("Title") %]</th>
      <th>[% LxERP.t8("Content") %]</th>
+     <th>[% LxERP.t8("Text blocks") %]</th>
+     <th>[% LxERP.t8("Sections") %]</th>
     </tr>
     </thead>
 
@@ -33,6 +39,8 @@
 
      <td>[% HTML.escape(requirement_spec_predefined_text.title) %]</td>
      <td>[% HTML.escape(L.truncate(requirement_spec_predefined_text.text_as_stripped_html)) %]</td>
+     <td align="right">[% IF requirement_spec_predefined_text.useable_for_text_blocks %][% LxERP.t8("Yes") %][% ELSE %][% LxERP.t8("No") %][% END %]</td>
+     <td align="right">[% IF requirement_spec_predefined_text.useable_for_sections %][% LxERP.t8("Yes") %][% ELSE %][% LxERP.t8("No") %][% END %]</td>
     </tr>
     [%- END %]
     </tbody>