From: Moritz Bunkus Date: Wed, 1 Feb 2017 14:22:30 +0000 (+0100) Subject: SimpleSystemSetting: Umstellung von »Pflichtenhefte« → »Vordefinierte Textblöcke« X-Git-Tag: release-3.5.4~1554 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5dc93413e30e7dfa4f2b74a5c2a5fe27caca2200;p=kivitendo-erp.git SimpleSystemSetting: Umstellung von »Pflichtenhefte« → »Vordefinierte Textblöcke« --- diff --git a/SL/Controller/RequirementSpecPredefinedText.pm b/SL/Controller/RequirementSpecPredefinedText.pm deleted file mode 100644 index 00c86b474..000000000 --- a/SL/Controller/RequirementSpecPredefinedText.pm +++ /dev/null @@ -1,128 +0,0 @@ -package SL::Controller::RequirementSpecPredefinedText; - -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; - -use Rose::Object::MakeMethods::Generic -( - scalar => [ qw(requirement_spec_predefined_text) ], -); - -__PACKAGE__->run_before('check_auth'); -__PACKAGE__->run_before('setup'); -__PACKAGE__->run_before('load_requirement_spec_predefined_text', only => [ qw(edit update destroy) ]); - -# -# actions -# - -sub action_list { - my ($self) = @_; - - $self->render('requirement_spec_predefined_text/list', - title => t8('Pre-defined Texts'), - REQUIREMENT_SPEC_PREDEFINED_TEXTS => SL::DB::Manager::RequirementSpecPredefinedText->get_all_sorted); -} - -sub action_new { - my ($self) = @_; - - $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')); -} - -sub action_edit { - my ($self) = @_; - $self->render('requirement_spec_predefined_text/form', title => t8('Edit predefined text')); -} - -sub action_create { - my ($self) = @_; - - $self->{requirement_spec_predefined_text} = SL::DB::RequirementSpecPredefinedText->new; - $self->create_or_update; -} - -sub action_update { - my ($self) = @_; - $self->create_or_update; -} - -sub action_destroy { - my ($self) = @_; - - if (eval { $self->{requirement_spec_predefined_text}->delete; 1; }) { - flash_later('info', t8('The predefined text has been deleted.')); - } else { - flash_later('error', t8('The predefined text is in use and cannot be deleted.')); - } - - $self->redirect_to(action => 'list'); -} - -sub action_reorder { - my ($self) = @_; - - SL::DB::RequirementSpecPredefinedText->reorder_list(@{ $::form->{requirement_spec_predefined_text_id} || [] }); - - $self->render(\'', { type => 'json' }); -} - -# -# filters -# - -sub check_auth { - $::auth->assert('config'); -} - -sub setup { - $::request->layout->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery); -} - -# -# helpers -# - -sub create_or_update { - my $self = shift; - my $is_new = !$self->{requirement_spec_predefined_text}->id; - 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; - - if (@errors) { - flash('error', @errors); - $self->render('requirement_spec_predefined_text/form', title => $title); - return; - } - - $self->{requirement_spec_predefined_text}->save; - - flash_later('info', $is_new ? t8('The predefined text has been created.') : t8('The predefined text has been saved.')); - $self->redirect_to(action => 'list'); -} - -sub load_requirement_spec_predefined_text { - my ($self) = @_; - $self->{requirement_spec_predefined_text} = SL::DB::RequirementSpecPredefinedText->new(id => $::form->{id})->load; -} - -1; diff --git a/SL/Controller/SimpleSystemSetting.pm b/SL/Controller/SimpleSystemSetting.pm index 979c2d298..8cc577e3a 100644 --- a/SL/Controller/SimpleSystemSetting.pm +++ b/SL/Controller/SimpleSystemSetting.pm @@ -141,6 +141,23 @@ my %supported_types = ( }, }, + requirement_spec_predefined_text => { + # Make locales.pl happy: $self->render("simple_system_setting/_requirement_spec_predefined_text_form") + class => 'RequirementSpecPredefinedText', + titles => { + list => t8('Pre-defined Texts'), + add => t8('Add pre-defined text'), + edit => t8('Edit pre-defined text'), + }, + list_attributes => [ + { method => 'description', title => t8('Description') }, + { method => 'title', title => t8('Title') }, + { title => t8('Content'), formatter => sub { my $t = $_[0]->text_as_stripped_html; length($t) > 50 ? substr($t, 0, 50) . '…' : $t } }, + { title => t8('Useable for text blocks'), formatter => sub { $_[0]->useable_for_text_blocks ? t8('yes') : t8('no') } }, + { title => t8('Useable for sections'), formatter => sub { $_[0]->useable_for_sections ? t8('yes') : t8('no') } }, + ], + }, + ); my @default_list_attributes = ( diff --git a/locale/de/all b/locale/de/all index 71f09c10f..b8e147657 100755 --- a/locale/de/all +++ b/locale/de/all @@ -211,6 +211,7 @@ $self->{texts} = { 'Add partsgroup' => 'Warengruppe hinzufügen', 'Add picture' => 'Bild hinzufügen', 'Add picture to text block' => 'Bild dem Textblock hinzufügen', + 'Add pre-defined text' => 'Vordefinierten Textblock hinzufügen', 'Add pricegroup' => 'Preisgruppe hinzufügen', 'Add project status' => 'Projektstatus hinzufügen', 'Add project type' => 'Projekttypen hinzufügen', @@ -668,7 +669,6 @@ $self->{texts} = { 'Create a new delivery term' => 'Neue Lieferbedingungen anlegen', 'Create a new group' => 'Neue Benutzergruppe erfassen', 'Create a new payment term' => 'Neue Zahlungsbedingungen anlegen', - 'Create a new predefined text' => 'Einen neuen vordefinierten Textblock anlegen', 'Create a new price rule' => 'Neue Preisregel anlegen', 'Create a new printer' => 'Einen neuen Drucker anlegen', 'Create a new project' => 'Neues Projekt anlegen', @@ -1124,7 +1124,7 @@ $self->{texts} = { 'Edit partsgroup' => 'Warengruppe bearbeiten', 'Edit payment term' => 'Zahlungsbedingungen bearbeiten', 'Edit picture' => 'Bild bearbeiten', - 'Edit predefined text' => 'Vordefinierten Textblock bearbeiten', + 'Edit pre-defined text' => 'Vordefinierten Textblock bearbeiten', 'Edit price rule' => 'Preisregel bearbeiten', 'Edit pricegroup' => 'Preisgruppe bearbeiten', '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,7 +1879,6 @@ $self->{texts} = { 'No payment term has been created yet.' => 'Es wurden noch keine Zahlungsbedingungen angelegt.', 'No picture has been uploaded' => 'Es wurde kein Bild hochgeladen', 'No picture uploaded yet' => 'Noch kein Bild hochgeladen', - 'No predefined texts has been created yet.' => 'Es wurden noch keine vordefinierten Textblöcken angelegt.', 'No prices will be updated because no prices have been entered.' => 'Es werden keine Preise aktualisiert, weil keine gültigen Preisänderungen eingegeben wurden.', '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.', 'No printers have been created yet.' => 'Es wurden noch keine Drucker angelegt.', @@ -3058,10 +3057,6 @@ $self->{texts} = { 'The payment term has been saved.' => 'Die Zahlungsbedingungen wurden gespeichert.', 'The payment term is in use and cannot be deleted.' => 'Die Zahlungsbedingungen werden bereits benutzt und können nicht gelöscht werden.', 'The payments have been posted.' => 'Die Zahlungen wurden gebucht.', - 'The predefined text has been created.' => 'Der vordefinierte Textblock wurde angelegt.', - 'The predefined text has been deleted.' => 'Der vordefinierte Textblock wurde gelöscht.', - 'The predefined text has been saved.' => 'Der vordefinierte Textblock wurde gespeichert.', - 'The predefined text is in use and cannot be deleted.' => 'Der vordefinierte Textblock wird verwendet und kann nicht gelöscht werden.', '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).', 'The price rule for this discount does not exist anymore' => 'Die Preisregel für diesen Rabatt existiert nicht mehr', 'The price rule for this price does not exist anymore' => 'Die Preisregel für diesen Preis existiert nicht mehr', @@ -3438,6 +3433,8 @@ $self->{texts} = { 'Use this storage backend for all generated PDF-Files' => 'Verwende dieses Backend für generierte PDF-Dateien', 'Use this storage backend for all uploaded attachments' => 'Verwende dieses Backend für hochgeladene Dateien', 'Use this storage backend for uploaded images' => 'Verwende dieses Backend für hochgeladene Bilder', + 'Useable for sections' => 'Für Abschnitte nutzbar', + 'Useable for text blocks' => 'Für Textblöcke nutzbar', 'Useable for…' => 'Benutzbar für…', 'Used for Purchase' => 'im Einkauf verwenden', 'Used for Sale' => 'im Verkauf verwenden', diff --git a/menus/user/00-erp.yaml b/menus/user/00-erp.yaml index 3ad003fcf..7f06d8ac8 100644 --- a/menus/user/00-erp.yaml +++ b/menus/user/00-erp.yaml @@ -1140,7 +1140,8 @@ name: Pre-defined Texts order: 100 params: - action: RequirementSpecPredefinedText/list + action: SimpleSystemSetting/list + type: requirement_spec_predefined_text - parent: system_requirement_specs id: system_requirement_specs_requirement_spec_types name: Requirement Spec Types diff --git a/templates/webpages/requirement_spec_predefined_text/form.html b/templates/webpages/requirement_spec_predefined_text/form.html deleted file mode 100755 index 2f03e3501..000000000 --- a/templates/webpages/requirement_spec_predefined_text/form.html +++ /dev/null @@ -1,42 +0,0 @@ -[% USE HTML %][% USE L %][% USE LxERP %] -

[% FORM.title %]

- -
- -[%- INCLUDE 'common/flash.html' %] - - - - - - - - - - - - - - - - - - - - - -
[% LxERP.t8("Description") %][% L.input_tag("requirement_spec_predefined_text.description", SELF.requirement_spec_predefined_text.description, size=60, class='initial_focus') %]
[% LxERP.t8("Title") %][% L.input_tag("requirement_spec_predefined_text.title", SELF.requirement_spec_predefined_text.title, size=60) %]
[% LxERP.t8("Content") %][% 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') %]
[% LxERP.t8("Useable for…") %] - [% 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) %] -
- -

- [% L.hidden_tag("id", SELF.requirement_spec_predefined_text.id) %] - [% L.hidden_tag("action", "RequirementSpecPredefinedText/dispatch") %] - [% L.submit_tag("action_" _ (SELF.requirement_spec_predefined_text.id ? "update" : "create"), LxERP.t8('Save')) %] - [%- IF SELF.requirement_spec_predefined_text.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_predefined_text/list.html b/templates/webpages/requirement_spec_predefined_text/list.html deleted file mode 100644 index 52d213dc6..000000000 --- a/templates/webpages/requirement_spec_predefined_text/list.html +++ /dev/null @@ -1,54 +0,0 @@ -[% USE HTML %][% USE L %][% USE LxERP %] -

[% FORM.title %]

- -[%- INCLUDE 'common/flash.html' %] - -
- [% IF !REQUIREMENT_SPEC_PREDEFINED_TEXTS.size %] -

- [%- LxERP.t8('No predefined texts has been created yet.') %] -

- - [%- ELSE %] - - - - - - - - - - - - - - - - - - [%- FOREACH requirement_spec_predefined_text = REQUIREMENT_SPEC_PREDEFINED_TEXTS %] - - - - - - - - - - [%- END %] - -
[% LxERP.t8("Useable for…") %]
[%- LxERP.t8('reorder item') %][% LxERP.t8("Description") %][% LxERP.t8("Title") %][% LxERP.t8("Content") %][% LxERP.t8("Text blocks") %][% LxERP.t8("Sections") %]
[%- LxERP.t8('reorder item') %] - - [%- HTML.escape(requirement_spec_predefined_text.description) -%] - - [% HTML.escape(requirement_spec_predefined_text.title) %][% HTML.escape(L.truncate(requirement_spec_predefined_text.text_as_stripped_html)) %][% IF requirement_spec_predefined_text.useable_for_text_blocks %][% LxERP.t8("Yes") %][% ELSE %][% LxERP.t8("No") %][% END %][% IF requirement_spec_predefined_text.useable_for_sections %][% LxERP.t8("Yes") %][% ELSE %][% LxERP.t8("No") %][% END %]
- [%- END %] - -

- [%- LxERP.t8("Create a new predefined text") %] -

-
- - [% L.sortable_element('#requirement_spec_predefined_text_list tbody', url => 'controller.pl?action=RequirementSpecPredefinedText/reorder', with => 'requirement_spec_predefined_text_id') %] diff --git a/templates/webpages/simple_system_setting/_requirement_spec_predefined_text_form.html b/templates/webpages/simple_system_setting/_requirement_spec_predefined_text_form.html new file mode 100644 index 000000000..c302ca52f --- /dev/null +++ b/templates/webpages/simple_system_setting/_requirement_spec_predefined_text_form.html @@ -0,0 +1,24 @@ +[%- USE LxERP -%][%- USE L -%] + + + + + + + + + + + + + + + + + + + +
[% LxERP.t8("Description") %][% L.input_tag("object.description", SELF.object.description, size=60, class="initial_focus", "data-validate"="required", "data-title"=LxERP.t8("Description")) %]
[% LxERP.t8("Title") %][% L.input_tag("object.title", SELF.object.title, size=60) %]
[% LxERP.t8("Content") %][% L.textarea_tag("object.text_as_restricted_html", SELF.object.text_as_restricted_html, class="texteditor", style="width: 800px; height: 300px") %]
[% LxERP.t8("Useable for…") %] + [% 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) %] + [% L.checkbox_tag("object.useable_for_sections", label=LxERP.t8("Sections"), for_submit=1, value=1, checked=SELF.object.useable_for_sections) %] +