From 14b824ae47b746673eb94885b0c972fd5a84a62a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 30 Jan 2013 18:23:41 +0100 Subject: [PATCH] =?utf8?q?Verwaltung=20von=20vordefinierten=20Textbl=C3=B6?= =?utf8?q?cken=20f=C3=BCr=20Pflichtenhefte?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../RequirementSpecPredefinedText.pm | 115 ++++++++++++++++++ SL/DB/RequirementSpecPredefinedText.pm | 5 +- locale/de/all | 9 ++ .../form.html | 34 ++++++ .../list.html | 47 +++++++ 5 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 SL/Controller/RequirementSpecPredefinedText.pm create mode 100755 templates/webpages/requirement_spec_predefined_text/form.html create mode 100644 templates/webpages/requirement_spec_predefined_text/list.html diff --git a/SL/Controller/RequirementSpecPredefinedText.pm b/SL/Controller/RequirementSpecPredefinedText.pm new file mode 100644 index 000000000..24d6f9110 --- /dev/null +++ b/SL/Controller/RequirementSpecPredefinedText.pm @@ -0,0 +1,115 @@ +package SL::Controller::RequirementSpecPredefinedText; + +use strict; + +use parent qw(SL::Controller::Base); + +use SL::DB::RequirementSpecPredefinedText; +use SL::DB::Language; +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('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('Predefined 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; + $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('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_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'); + + $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/DB/RequirementSpecPredefinedText.pm b/SL/DB/RequirementSpecPredefinedText.pm index a63a903c8..f0d25cafd 100644 --- a/SL/DB/RequirementSpecPredefinedText.pm +++ b/SL/DB/RequirementSpecPredefinedText.pm @@ -11,8 +11,9 @@ sub validate { my ($self) = @_; my @errors; - push @errors, t8('The title is missing.') if !$self->title; - 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'); + push @errors, t8('The title is missing.') if !$self->title; return @errors; } diff --git a/locale/de/all b/locale/de/all index 951aedd86..a8c40012c 100755 --- a/locale/de/all +++ b/locale/de/all @@ -497,6 +497,7 @@ $self->{texts} = { 'Contact person (surname)' => 'Ansprechperson (Nachname)', 'Contact persons' => 'Ansprechpersonen', 'Contacts' => 'Ansprechpersonen', + 'Content' => 'Inhalt', 'Continue' => 'Weiter', 'Contra' => 'gegen', 'Conversion of "birthday" contact person attribute' => 'Umstellung des Kontaktpersonenfeldes "Geburtstag"', @@ -524,6 +525,7 @@ $self->{texts} = { 'Create a new group' => 'Neue Benutzergruppe erfassen', 'Create a new payment term' => 'Neue Zahlungsbedingungen anlegen', 'Create a new printer' => 'Einen neuen Drucker anlegen', + 'Create a new predefined text' => 'Einen neuen vordefinierten Textblock anlegen', 'Create a new project' => 'Neues Projekt anlegen', 'Create a new project type' => 'Einen neuen Projekttypen anlegen', 'Create a new requirement spec status' => 'Einen neuen Pflichtenheftstatus anlegen', @@ -859,6 +861,7 @@ $self->{texts} = { 'Edit greetings' => 'Anreden bearbeiten', 'Edit note' => 'Notiz bearbeiten', 'Edit payment term' => 'Zahlungsbedingungen bearbeiten', + 'Edit predefined text' => 'Vordefinierten Textblock 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)', 'Edit project' => 'Projekt bearbeiten', 'Edit project #1' => 'Projekt #1 bearbeiten', @@ -1408,6 +1411,7 @@ $self->{texts} = { 'No or an unknown authenticantion module specified in "config/kivitendo.conf".' => 'Es wurde kein oder ein unbekanntes Authentifizierungsmodul in "config/kivitendo.conf" angegeben.', 'No part was found matching the search parameters.' => 'Es wurde kein Artikel gefunden, auf den die Suchparameter zutreffen.', 'No payment term has been created yet.' => 'Es wurden noch keine Zahlungsbedingungen angelegt.', + '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.', @@ -1631,6 +1635,7 @@ $self->{texts} = { 'Postscript' => 'Postscript', 'Posustva_coa' => 'USTVA Kennz.', 'Pre-defined Texts' => 'Vordefinierte Textblöcke', + 'Predefined Texts' => 'Vordefinierte Textblöcke', 'Preferences' => 'Einstellungen', 'Preferences saved!' => 'Einstellungen gespeichert!', 'Prefix for the new bins\' names' => 'Namenspräfix für die neuen Lagerplätze', @@ -2240,6 +2245,10 @@ $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 printer could not be deleted.' => 'Der Drucker konnte nicht gelöscht werden.', 'The printer has been created.' => 'Der Drucker wurde angelegt.', diff --git a/templates/webpages/requirement_spec_predefined_text/form.html b/templates/webpages/requirement_spec_predefined_text/form.html new file mode 100755 index 000000000..9a790387e --- /dev/null +++ b/templates/webpages/requirement_spec_predefined_text/form.html @@ -0,0 +1,34 @@ +[% 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) %]
[% 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", SELF.requirement_spec_predefined_text.text, rows=10, cols=80) %]
+ +

+ [% 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 new file mode 100644 index 000000000..c8251b146 --- /dev/null +++ b/templates/webpages/requirement_spec_predefined_text/list.html @@ -0,0 +1,47 @@ +[% 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('reorder item') %][% LxERP.t8("Description") %][% LxERP.t8("Title") %][% LxERP.t8("Content") %]
[ 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)) %]
+ [%- 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') %] -- 2.20.1