use parent qw(SL::Controller::Base);
+use List::MoreUtils qw(none);
+
use SL::DB::RequirementSpecPredefinedText;
use SL::Helper::Flash;
use SL::Locale::String;
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'));
}
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;
__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' ]);
'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',
'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',
--- /dev/null
+-- @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;
<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>
[%- 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>
<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>