Revision 5dc93413
Von Moritz Bunkus vor fast 8 Jahren hinzugefügt
SL/Controller/RequirementSpecPredefinedText.pm | ||
---|---|---|
1 |
package SL::Controller::RequirementSpecPredefinedText; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use parent qw(SL::Controller::Base); |
|
6 |
|
|
7 |
use List::MoreUtils qw(none); |
|
8 |
|
|
9 |
use SL::DB::RequirementSpecPredefinedText; |
|
10 |
use SL::Helper::Flash; |
|
11 |
use SL::Locale::String; |
|
12 |
|
|
13 |
use Rose::Object::MakeMethods::Generic |
|
14 |
( |
|
15 |
scalar => [ qw(requirement_spec_predefined_text) ], |
|
16 |
); |
|
17 |
|
|
18 |
__PACKAGE__->run_before('check_auth'); |
|
19 |
__PACKAGE__->run_before('setup'); |
|
20 |
__PACKAGE__->run_before('load_requirement_spec_predefined_text', only => [ qw(edit update destroy) ]); |
|
21 |
|
|
22 |
# |
|
23 |
# actions |
|
24 |
# |
|
25 |
|
|
26 |
sub action_list { |
|
27 |
my ($self) = @_; |
|
28 |
|
|
29 |
$self->render('requirement_spec_predefined_text/list', |
|
30 |
title => t8('Pre-defined Texts'), |
|
31 |
REQUIREMENT_SPEC_PREDEFINED_TEXTS => SL::DB::Manager::RequirementSpecPredefinedText->get_all_sorted); |
|
32 |
} |
|
33 |
|
|
34 |
sub action_new { |
|
35 |
my ($self) = @_; |
|
36 |
|
|
37 |
$self->{requirement_spec_predefined_text} = SL::DB::RequirementSpecPredefinedText->new(useable_for_text_blocks => 1); |
|
38 |
$self->render('requirement_spec_predefined_text/form', title => t8('Create a new predefined text')); |
|
39 |
} |
|
40 |
|
|
41 |
sub action_edit { |
|
42 |
my ($self) = @_; |
|
43 |
$self->render('requirement_spec_predefined_text/form', title => t8('Edit predefined text')); |
|
44 |
} |
|
45 |
|
|
46 |
sub action_create { |
|
47 |
my ($self) = @_; |
|
48 |
|
|
49 |
$self->{requirement_spec_predefined_text} = SL::DB::RequirementSpecPredefinedText->new; |
|
50 |
$self->create_or_update; |
|
51 |
} |
|
52 |
|
|
53 |
sub action_update { |
|
54 |
my ($self) = @_; |
|
55 |
$self->create_or_update; |
|
56 |
} |
|
57 |
|
|
58 |
sub action_destroy { |
|
59 |
my ($self) = @_; |
|
60 |
|
|
61 |
if (eval { $self->{requirement_spec_predefined_text}->delete; 1; }) { |
|
62 |
flash_later('info', t8('The predefined text has been deleted.')); |
|
63 |
} else { |
|
64 |
flash_later('error', t8('The predefined text is in use and cannot be deleted.')); |
|
65 |
} |
|
66 |
|
|
67 |
$self->redirect_to(action => 'list'); |
|
68 |
} |
|
69 |
|
|
70 |
sub action_reorder { |
|
71 |
my ($self) = @_; |
|
72 |
|
|
73 |
SL::DB::RequirementSpecPredefinedText->reorder_list(@{ $::form->{requirement_spec_predefined_text_id} || [] }); |
|
74 |
|
|
75 |
$self->render(\'', { type => 'json' }); |
|
76 |
} |
|
77 |
|
|
78 |
# |
|
79 |
# filters |
|
80 |
# |
|
81 |
|
|
82 |
sub check_auth { |
|
83 |
$::auth->assert('config'); |
|
84 |
} |
|
85 |
|
|
86 |
sub setup { |
|
87 |
$::request->layout->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery); |
|
88 |
} |
|
89 |
|
|
90 |
# |
|
91 |
# helpers |
|
92 |
# |
|
93 |
|
|
94 |
sub create_or_update { |
|
95 |
my $self = shift; |
|
96 |
my $is_new = !$self->{requirement_spec_predefined_text}->id; |
|
97 |
my $params = delete($::form->{requirement_spec_predefined_text}) || { }; |
|
98 |
my $title = $is_new ? t8('Create a new predefined text') : t8('Edit predefined text'); |
|
99 |
|
|
100 |
# Force presence of booleans for the useable_* flags. |
|
101 |
my @useable_flags = qw(text_blocks sections); |
|
102 |
$params->{"useable_for_${_}"} = !!$params->{"useable_for_${_}"} for @useable_flags; |
|
103 |
|
|
104 |
# Force usage for text blocks if none of the check boxes are marked. |
|
105 |
$params->{useable_for_text_blocks} = 1 if none { $params->{"useable_for_${_}"} } @useable_flags; |
|
106 |
|
|
107 |
$self->{requirement_spec_predefined_text}->assign_attributes(%{ $params }); |
|
108 |
|
|
109 |
my @errors = $self->{requirement_spec_predefined_text}->validate; |
|
110 |
|
|
111 |
if (@errors) { |
|
112 |
flash('error', @errors); |
|
113 |
$self->render('requirement_spec_predefined_text/form', title => $title); |
|
114 |
return; |
|
115 |
} |
|
116 |
|
|
117 |
$self->{requirement_spec_predefined_text}->save; |
|
118 |
|
|
119 |
flash_later('info', $is_new ? t8('The predefined text has been created.') : t8('The predefined text has been saved.')); |
|
120 |
$self->redirect_to(action => 'list'); |
|
121 |
} |
|
122 |
|
|
123 |
sub load_requirement_spec_predefined_text { |
|
124 |
my ($self) = @_; |
|
125 |
$self->{requirement_spec_predefined_text} = SL::DB::RequirementSpecPredefinedText->new(id => $::form->{id})->load; |
|
126 |
} |
|
127 |
|
|
128 |
1; |
SL/Controller/SimpleSystemSetting.pm | ||
---|---|---|
141 | 141 |
}, |
142 | 142 |
}, |
143 | 143 |
|
144 |
requirement_spec_predefined_text => { |
|
145 |
# Make locales.pl happy: $self->render("simple_system_setting/_requirement_spec_predefined_text_form") |
|
146 |
class => 'RequirementSpecPredefinedText', |
|
147 |
titles => { |
|
148 |
list => t8('Pre-defined Texts'), |
|
149 |
add => t8('Add pre-defined text'), |
|
150 |
edit => t8('Edit pre-defined text'), |
|
151 |
}, |
|
152 |
list_attributes => [ |
|
153 |
{ method => 'description', title => t8('Description') }, |
|
154 |
{ method => 'title', title => t8('Title') }, |
|
155 |
{ title => t8('Content'), formatter => sub { my $t = $_[0]->text_as_stripped_html; length($t) > 50 ? substr($t, 0, 50) . '…' : $t } }, |
|
156 |
{ title => t8('Useable for text blocks'), formatter => sub { $_[0]->useable_for_text_blocks ? t8('yes') : t8('no') } }, |
|
157 |
{ title => t8('Useable for sections'), formatter => sub { $_[0]->useable_for_sections ? t8('yes') : t8('no') } }, |
|
158 |
], |
|
159 |
}, |
|
160 |
|
|
144 | 161 |
); |
145 | 162 |
|
146 | 163 |
my @default_list_attributes = ( |
locale/de/all | ||
---|---|---|
211 | 211 |
'Add partsgroup' => 'Warengruppe hinzufügen', |
212 | 212 |
'Add picture' => 'Bild hinzufügen', |
213 | 213 |
'Add picture to text block' => 'Bild dem Textblock hinzufügen', |
214 |
'Add pre-defined text' => 'Vordefinierten Textblock hinzufügen', |
|
214 | 215 |
'Add pricegroup' => 'Preisgruppe hinzufügen', |
215 | 216 |
'Add project status' => 'Projektstatus hinzufügen', |
216 | 217 |
'Add project type' => 'Projekttypen hinzufügen', |
... | ... | |
668 | 669 |
'Create a new delivery term' => 'Neue Lieferbedingungen anlegen', |
669 | 670 |
'Create a new group' => 'Neue Benutzergruppe erfassen', |
670 | 671 |
'Create a new payment term' => 'Neue Zahlungsbedingungen anlegen', |
671 |
'Create a new predefined text' => 'Einen neuen vordefinierten Textblock anlegen', |
|
672 | 672 |
'Create a new price rule' => 'Neue Preisregel anlegen', |
673 | 673 |
'Create a new printer' => 'Einen neuen Drucker anlegen', |
674 | 674 |
'Create a new project' => 'Neues Projekt anlegen', |
... | ... | |
1124 | 1124 |
'Edit partsgroup' => 'Warengruppe bearbeiten', |
1125 | 1125 |
'Edit payment term' => 'Zahlungsbedingungen bearbeiten', |
1126 | 1126 |
'Edit picture' => 'Bild bearbeiten', |
1127 |
'Edit predefined text' => 'Vordefinierten Textblock bearbeiten',
|
|
1127 |
'Edit pre-defined text' => 'Vordefinierten Textblock bearbeiten',
|
|
1128 | 1128 |
'Edit price rule' => 'Preisregel bearbeiten', |
1129 | 1129 |
'Edit pricegroup' => 'Preisgruppe bearbeiten', |
1130 | 1130 |
'Edit prices and discount (if not used, textfield is ONLY set readonly)' => 'Preise und Rabatt in Formularen frei anpassen (falls deaktiviert, wird allerdings NUR das textfield auf READONLY gesetzt / kann je nach Browserversion und technischen Fähigkeiten des Anwenders noch umgangen werden)', |
... | ... | |
1879 | 1879 |
'No payment term has been created yet.' => 'Es wurden noch keine Zahlungsbedingungen angelegt.', |
1880 | 1880 |
'No picture has been uploaded' => 'Es wurde kein Bild hochgeladen', |
1881 | 1881 |
'No picture uploaded yet' => 'Noch kein Bild hochgeladen', |
1882 |
'No predefined texts has been created yet.' => 'Es wurden noch keine vordefinierten Textblöcken angelegt.', |
|
1883 | 1882 |
'No prices will be updated because no prices have been entered.' => 'Es werden keine Preise aktualisiert, weil keine gültigen Preisänderungen eingegeben wurden.', |
1884 | 1883 |
'No print templates have been created for this client yet. Please do so in the client configuration.' => 'Für diesen Mandanten wurden noch keine Druckvorlagen angelegt. Bitte holen Sie dies in der Mandantenkonfiguration nach.', |
1885 | 1884 |
'No printers have been created yet.' => 'Es wurden noch keine Drucker angelegt.', |
... | ... | |
3058 | 3057 |
'The payment term has been saved.' => 'Die Zahlungsbedingungen wurden gespeichert.', |
3059 | 3058 |
'The payment term is in use and cannot be deleted.' => 'Die Zahlungsbedingungen werden bereits benutzt und können nicht gelöscht werden.', |
3060 | 3059 |
'The payments have been posted.' => 'Die Zahlungen wurden gebucht.', |
3061 |
'The predefined text has been created.' => 'Der vordefinierte Textblock wurde angelegt.', |
|
3062 |
'The predefined text has been deleted.' => 'Der vordefinierte Textblock wurde gelöscht.', |
|
3063 |
'The predefined text has been saved.' => 'Der vordefinierte Textblock wurde gespeichert.', |
|
3064 |
'The predefined text is in use and cannot be deleted.' => 'Der vordefinierte Textblock wird verwendet und kann nicht gelöscht werden.', |
|
3065 | 3060 |
'The preferred one is to install packages provided by your operating system distribution (e.g. Debian or RPM packages).' => 'Die bevorzugte Art, ein Perl-Modul zu installieren, ist durch Installation eines von Ihrem Betriebssystem zur Verfügung gestellten Paketes (z.B. Debian-Pakete oder RPM).', |
3066 | 3061 |
'The price rule for this discount does not exist anymore' => 'Die Preisregel für diesen Rabatt existiert nicht mehr', |
3067 | 3062 |
'The price rule for this price does not exist anymore' => 'Die Preisregel für diesen Preis existiert nicht mehr', |
... | ... | |
3438 | 3433 |
'Use this storage backend for all generated PDF-Files' => 'Verwende dieses Backend für generierte PDF-Dateien', |
3439 | 3434 |
'Use this storage backend for all uploaded attachments' => 'Verwende dieses Backend für hochgeladene Dateien', |
3440 | 3435 |
'Use this storage backend for uploaded images' => 'Verwende dieses Backend für hochgeladene Bilder', |
3436 |
'Useable for sections' => 'Für Abschnitte nutzbar', |
|
3437 |
'Useable for text blocks' => 'Für Textblöcke nutzbar', |
|
3441 | 3438 |
'Useable for…' => 'Benutzbar für…', |
3442 | 3439 |
'Used for Purchase' => 'im Einkauf verwenden', |
3443 | 3440 |
'Used for Sale' => 'im Verkauf verwenden', |
menus/user/00-erp.yaml | ||
---|---|---|
1140 | 1140 |
name: Pre-defined Texts |
1141 | 1141 |
order: 100 |
1142 | 1142 |
params: |
1143 |
action: RequirementSpecPredefinedText/list |
|
1143 |
action: SimpleSystemSetting/list |
|
1144 |
type: requirement_spec_predefined_text |
|
1144 | 1145 |
- parent: system_requirement_specs |
1145 | 1146 |
id: system_requirement_specs_requirement_spec_types |
1146 | 1147 |
name: Requirement Spec Types |
templates/webpages/requirement_spec_predefined_text/form.html | ||
---|---|---|
1 |
[% USE HTML %][% USE L %][% USE LxERP %] |
|
2 |
<h1>[% FORM.title %]</h1> |
|
3 |
|
|
4 |
<form method="post" action="controller.pl"> |
|
5 |
|
|
6 |
[%- INCLUDE 'common/flash.html' %] |
|
7 |
|
|
8 |
<table> |
|
9 |
<tr> |
|
10 |
<td>[% LxERP.t8("Description") %]</td> |
|
11 |
<td>[% L.input_tag("requirement_spec_predefined_text.description", SELF.requirement_spec_predefined_text.description, size=60, class='initial_focus') %]</td> |
|
12 |
</tr> |
|
13 |
|
|
14 |
<tr> |
|
15 |
<td>[% LxERP.t8("Title") %]</td> |
|
16 |
<td>[% L.input_tag("requirement_spec_predefined_text.title", SELF.requirement_spec_predefined_text.title, size=60) %]</td> |
|
17 |
</tr> |
|
18 |
|
|
19 |
<tr valign="top"> |
|
20 |
<td>[% LxERP.t8("Content") %]</td> |
|
21 |
<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> |
|
22 |
</tr> |
|
23 |
|
|
24 |
<tr> |
|
25 |
<td>[% LxERP.t8("Useable for…") %]</sup></td> |
|
26 |
<td> |
|
27 |
[% 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) %] |
|
28 |
[% 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) %] |
|
29 |
</td> |
|
30 |
</tr> |
|
31 |
</table> |
|
32 |
|
|
33 |
<p> |
|
34 |
[% L.hidden_tag("id", SELF.requirement_spec_predefined_text.id) %] |
|
35 |
[% L.hidden_tag("action", "RequirementSpecPredefinedText/dispatch") %] |
|
36 |
[% L.submit_tag("action_" _ (SELF.requirement_spec_predefined_text.id ? "update" : "create"), LxERP.t8('Save')) %] |
|
37 |
[%- IF SELF.requirement_spec_predefined_text.id %] |
|
38 |
[% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Do you really want to delete this object?')) %] |
|
39 |
[%- END %] |
|
40 |
<a href="[% SELF.url_for(action => 'list') %]">[%- LxERP.t8('Abort') %]</a> |
|
41 |
</p> |
|
42 |
</form> |
templates/webpages/requirement_spec_predefined_text/list.html | ||
---|---|---|
1 |
[% USE HTML %][% USE L %][% USE LxERP %] |
|
2 |
<h1>[% FORM.title %]</h1> |
|
3 |
|
|
4 |
[%- INCLUDE 'common/flash.html' %] |
|
5 |
|
|
6 |
<form method="post" action="controller.pl"> |
|
7 |
[% IF !REQUIREMENT_SPEC_PREDEFINED_TEXTS.size %] |
|
8 |
<p> |
|
9 |
[%- LxERP.t8('No predefined texts has been created yet.') %] |
|
10 |
</p> |
|
11 |
|
|
12 |
[%- ELSE %] |
|
13 |
<table id="requirement_spec_predefined_text_list"> |
|
14 |
<thead> |
|
15 |
<tr class="listheading"> |
|
16 |
<th colspan="4"></th> |
|
17 |
<th colspan="2" align="center">[% LxERP.t8("Useable for…") %]</th> |
|
18 |
</tr> |
|
19 |
<tr class="listheading"> |
|
20 |
<th align="center"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th> |
|
21 |
<th>[% LxERP.t8("Description") %]</th> |
|
22 |
<th>[% LxERP.t8("Title") %]</th> |
|
23 |
<th>[% LxERP.t8("Content") %]</th> |
|
24 |
<th>[% LxERP.t8("Text blocks") %]</th> |
|
25 |
<th>[% LxERP.t8("Sections") %]</th> |
|
26 |
</tr> |
|
27 |
</thead> |
|
28 |
|
|
29 |
<tbody> |
|
30 |
[%- FOREACH requirement_spec_predefined_text = REQUIREMENT_SPEC_PREDEFINED_TEXTS %] |
|
31 |
<tr class="listrow[% loop.count % 2 %]" id="requirement_spec_predefined_text_id_[% requirement_spec_predefined_text.id %]"> |
|
32 |
<td align="center" class="dragdrop"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></td> |
|
33 |
<td> |
|
34 |
<a href="[% SELF.url_for(action => 'edit', id => requirement_spec_predefined_text.id) %]"> |
|
35 |
[%- HTML.escape(requirement_spec_predefined_text.description) -%] |
|
36 |
</a> |
|
37 |
</td> |
|
38 |
|
|
39 |
<td>[% HTML.escape(requirement_spec_predefined_text.title) %]</td> |
|
40 |
<td>[% HTML.escape(L.truncate(requirement_spec_predefined_text.text_as_stripped_html)) %]</td> |
|
41 |
<td align="right">[% IF requirement_spec_predefined_text.useable_for_text_blocks %][% LxERP.t8("Yes") %][% ELSE %][% LxERP.t8("No") %][% END %]</td> |
|
42 |
<td align="right">[% IF requirement_spec_predefined_text.useable_for_sections %][% LxERP.t8("Yes") %][% ELSE %][% LxERP.t8("No") %][% END %]</td> |
|
43 |
</tr> |
|
44 |
[%- END %] |
|
45 |
</tbody> |
|
46 |
</table> |
|
47 |
[%- END %] |
|
48 |
|
|
49 |
<p> |
|
50 |
<a href="[% SELF.url_for(action => 'new') %]">[%- LxERP.t8("Create a new predefined text") %]</a> |
|
51 |
</p> |
|
52 |
</form> |
|
53 |
|
|
54 |
[% L.sortable_element('#requirement_spec_predefined_text_list tbody', url => 'controller.pl?action=RequirementSpecPredefinedText/reorder', with => 'requirement_spec_predefined_text_id') %] |
templates/webpages/simple_system_setting/_requirement_spec_predefined_text_form.html | ||
---|---|---|
1 |
[%- USE LxERP -%][%- USE L -%]<table> |
|
2 |
<tr> |
|
3 |
<th align="right">[% LxERP.t8("Description") %]</th> |
|
4 |
<td>[% L.input_tag("object.description", SELF.object.description, size=60, class="initial_focus", "data-validate"="required", "data-title"=LxERP.t8("Description")) %]</td> |
|
5 |
</tr> |
|
6 |
|
|
7 |
<tr> |
|
8 |
<th align="right">[% LxERP.t8("Title") %]</th> |
|
9 |
<td>[% L.input_tag("object.title", SELF.object.title, size=60) %]</td> |
|
10 |
</tr> |
|
11 |
|
|
12 |
<tr valign="top"> |
|
13 |
<th align="right">[% LxERP.t8("Content") %]</th> |
|
14 |
<td>[% L.textarea_tag("object.text_as_restricted_html", SELF.object.text_as_restricted_html, class="texteditor", style="width: 800px; height: 300px") %]</td> |
|
15 |
</tr> |
|
16 |
|
|
17 |
<tr> |
|
18 |
<th align="right">[% LxERP.t8("Useable for…") %]</th> |
|
19 |
<td> |
|
20 |
[% L.checkbox_tag("object.useable_for_text_blocks", label=LxERP.t8("Text blocks"), for_submit=1, value=1, checked=SELF.object.useable_for_text_blocks) %] |
|
21 |
[% L.checkbox_tag("object.useable_for_sections", label=LxERP.t8("Sections"), for_submit=1, value=1, checked=SELF.object.useable_for_sections) %] |
|
22 |
</td> |
|
23 |
</tr> |
|
24 |
</table> |
Auch abrufbar als: Unified diff
SimpleSystemSetting: Umstellung von »Pflichtenhefte« → »Vordefinierte Textblöcke«