ActionBar: Verwendung bei »System« → »Zahlungsbedingungen«
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 21 Mar 2017 14:32:21 +0000 (15:32 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 21 Mar 2017 14:32:21 +0000 (15:32 +0100)
SL/Controller/PaymentTerm.pm
locale/de/all
templates/webpages/payment_term/form.html
templates/webpages/payment_term/list.html

index f1eeb44..bf3083d 100644 (file)
@@ -7,6 +7,7 @@ use parent qw(SL::Controller::Base);
 use SL::DB::PaymentTerm;
 use SL::DB::Language;
 use SL::Helper::Flash;
 use SL::DB::PaymentTerm;
 use SL::DB::Language;
 use SL::Helper::Flash;
+use SL::Locale::String qw(t8);
 
 use Rose::Object::MakeMethods::Generic
 (
 
 use Rose::Object::MakeMethods::Generic
 (
@@ -25,6 +26,7 @@ __PACKAGE__->run_before('setup',             only => [ qw(new      edit) ]);
 sub action_list {
   my ($self) = @_;
 
 sub action_list {
   my ($self) = @_;
 
+  $self->setup_list_action_bar;
   $self->render('payment_term/list',
                 title         => $::locale->text('Payment terms'),
                 PAYMENT_TERMS => SL::DB::Manager::PaymentTerm->get_all_sorted);
   $self->render('payment_term/list',
                 title         => $::locale->text('Payment terms'),
                 PAYMENT_TERMS => SL::DB::Manager::PaymentTerm->get_all_sorted);
@@ -34,12 +36,14 @@ sub action_new {
   my ($self) = @_;
 
   $self->{payment_term} = SL::DB::PaymentTerm->new(auto_calculation => 1);
   my ($self) = @_;
 
   $self->{payment_term} = SL::DB::PaymentTerm->new(auto_calculation => 1);
+  $self->setup_form_action_bar;
   $self->render('payment_term/form', title => $::locale->text('Create a new payment term'));
 }
 
 sub action_edit {
   my ($self) = @_;
 
   $self->render('payment_term/form', title => $::locale->text('Create a new payment term'));
 }
 
 sub action_edit {
   my ($self) = @_;
 
+  $self->setup_form_action_bar;
   $self->render('payment_term/form', title => $::locale->text('Edit payment term'));
 }
 
   $self->render('payment_term/form', title => $::locale->text('Edit payment term'));
 }
 
@@ -127,4 +131,48 @@ sub load_languages {
   $self->{languages} = SL::DB::Manager::Language->get_all_sorted;
 }
 
   $self->{languages} = SL::DB::Manager::Language->get_all_sorted;
 }
 
+sub setup_list_action_bar {
+  my ($self) = @_;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      link => [
+        t8('Add'),
+        link => $self->url_for(action => 'new'),
+      ],
+    );
+  }
+}
+
+sub setup_form_action_bar {
+  my ($self) = @_;
+
+  my $is_new = !$self->payment_term->id;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      action => [
+        t8('Save'),
+        submit    => [ '#form', { action => 'PaymentTerm/' . ($is_new ? 'create' : 'update') } ],
+        checks    => [ 'kivi.validate_form' ],
+        accesskey => 'enter',
+      ],
+
+      action => [
+        t8('Delete'),
+        submit   => [ '#form', { action => 'PaymentTerm/destroy' } ],
+        confirm  => t8('Do you really want to delete this object?'),
+        disabled => $is_new ? t8('This object has not been saved yet.') : undef,
+      ],
+
+      'separator',
+
+      link => [
+        t8('Abort'),
+        link => $self->url_for(action => 'list'),
+      ],
+    );
+  }
+}
+
 1;
 1;
index 066901f..3f576a5 100755 (executable)
@@ -302,7 +302,6 @@ $self->{texts} = {
   'Are you sure you want to delete Invoice Number' => 'Soll die Rechnung mit folgender Nummer wirklich gelöscht werden:',
   'Are you sure you want to delete this delivery term?' => 'Wollen Sie diese Lieferbedingungen wirklich löschen?',
   'Are you sure you want to delete this letter?' => 'Sind Sie sicher, dass Sie diesen Brief löschen wollen?',
   'Are you sure you want to delete Invoice Number' => 'Soll die Rechnung mit folgender Nummer wirklich gelöscht werden:',
   'Are you sure you want to delete this delivery term?' => 'Wollen Sie diese Lieferbedingungen wirklich löschen?',
   'Are you sure you want to delete this letter?' => 'Sind Sie sicher, dass Sie diesen Brief löschen wollen?',
-  'Are you sure you want to delete this payment term?' => 'Wollen Sie diese Zahlungsbedingungen wirklich löschen?',
   'Are you sure you want to remove the marked entries from the queue?' => 'Sind Sie sicher, dass die markierten Einträge von der Warteschlange gelöscht werden sollen?',
   'Are you sure you want to update the prices' => 'Sind Sie sicher, dass Sie die Preise aktualisieren wollen?',
   'Are you sure you want to update the selected record template with the current values? This cannot be undone.' => 'Sind Sie sicher, dass Sie die ausgewählte Belegvorlage mit den aktuellen Daten aktualisieren wollen? Das kann nicht rückgängig gemacht werden.',
   'Are you sure you want to remove the marked entries from the queue?' => 'Sind Sie sicher, dass die markierten Einträge von der Warteschlange gelöscht werden sollen?',
   'Are you sure you want to update the prices' => 'Sind Sie sicher, dass Sie die Preise aktualisieren wollen?',
   'Are you sure you want to update the selected record template with the current values? This cannot be undone.' => 'Sind Sie sicher, dass Sie die ausgewählte Belegvorlage mit den aktuellen Daten aktualisieren wollen? Das kann nicht rückgängig gemacht werden.',
@@ -714,7 +713,6 @@ $self->{texts} = {
   'Create new'                  => 'Neu erfassen',
   'Create new client #1'        => 'Neuen Mandanten #1 anlegen',
   'Create new delivery term'    => 'Neue Lieferbedingungen anlegen',
   'Create new'                  => 'Neu erfassen',
   'Create new client #1'        => 'Neuen Mandanten #1 anlegen',
   'Create new delivery term'    => 'Neue Lieferbedingungen anlegen',
-  'Create new payment term'     => 'Neue Zahlungsbedingung anlegen',
   'Create new quotation or order' => 'Neues Angebot oder neuen Auftrag anlegen',
   'Create new quotation/order'  => 'Neues Angebot/neuen Auftrag anlegen',
   'Create new qutoation/order'  => 'Neues Angebot/neuen Auftrag anlegen',
   'Create new quotation or order' => 'Neues Angebot oder neuen Auftrag anlegen',
   'Create new quotation/order'  => 'Neues Angebot/neuen Auftrag anlegen',
   'Create new qutoation/order'  => 'Neues Angebot/neuen Auftrag anlegen',
@@ -1725,6 +1723,8 @@ $self->{texts} = {
   'Long Description'            => 'Langtext',
   'Long Description (invoices)' => 'Langtext (Rechnungen)',
   'Long Description (quotations & orders)' => 'Langtext (Angebote & Aufträge)',
   'Long Description'            => 'Langtext',
   'Long Description (invoices)' => 'Langtext (Rechnungen)',
   'Long Description (quotations & orders)' => 'Langtext (Angebote & Aufträge)',
+  'Long Description for invoices' => 'Langtext für Rechnungen',
+  'Long Description for quotations & orders' => 'Langtext für Angebote & Aufträge',
   'Luxembourg'                  => 'Luxemburg',
   'MAILED'                      => 'Gesendet',
   'MD'                          => 'PT',
   'Luxembourg'                  => 'Luxemburg',
   'MAILED'                      => 'Gesendet',
   'MD'                          => 'PT',
index db7fdb1..c371c46 100755 (executable)
@@ -1,7 +1,7 @@
-[% USE HTML %][% USE T8 %][% USE L %][% USE LxERP %]
+[% USE HTML %][% USE T8 %][% USE L %][% USE LxERP %][%- USE P -%]
 <h1>[% FORM.title %]</h1>
 
 <h1>[% FORM.title %]</h1>
 
- <form method="post" action="controller.pl">
+ <form method="post" action="controller.pl" id="form">
 
 [%- INCLUDE 'common/flash.html' %]
 
 
 [%- INCLUDE 'common/flash.html' %]
 
@@ -14,7 +14,7 @@
    <tr>
     <td>[%- 'Description' | $T8 %]</td>
     <td>
    <tr>
     <td>[%- 'Description' | $T8 %]</td>
     <td>
-     <input name="payment_term.description" value="[%- HTML.escape(SELF.payment_term.description) %]">
+     [% P.input_tag("payment_term.description", SELF.payment_term.description, "data-validate"="required", "data-title"=LxERP.t8("Description")) %]
     </td>
    </tr>
 
     </td>
    </tr>
 
    <tr>
     <td>[%- 'Long Description' | $T8 %]</td>
     <td>
    <tr>
     <td>[%- 'Long Description' | $T8 %]</td>
     <td>
-     <input name="payment_term.description_long" value="[%- HTML.escape(SELF.payment_term.description_long) %]" size="60">
+     [% P.input_tag("payment_term.description_long", SELF.payment_term.description_long, size="60", "data-validate"="required", "data-title"=LxERP.t8("Long Description for quotations & orders")) %]
     </td>
 
     <td>
     </td>
 
     <td>
-     <input name="payment_term.description_long_invoice" value="[%- HTML.escape(SELF.payment_term.description_long_invoice) %]" size="60">
+     [% P.input_tag("payment_term.description_long_invoice", SELF.payment_term.description_long_invoice, size="60", "data-validate"="required", "data-title"=LxERP.t8("Long Description for invoices")) %]
     </td>
    </tr>
 
     </td>
    </tr>
 
    [%- END %]
   </table>
 
    [%- END %]
   </table>
 
-  <p>
-   <input type="hidden" name="id" value="[% SELF.payment_term.id %]">
-   <input type="hidden" name="action" value="PaymentTerm/dispatch">
-   <input type="submit" class="submit" name="action_[% IF SELF.payment_term.id %]update[% ELSE %]create[% END %]" value="[% 'Save' | $T8 %]">
-   [%- IF SELF.payment_term.id %]
-    <input type="submit" class="submit" name="action_destroy" value="[% 'Delete' | $T8 %]"
-           onclick="if (confirm('[% 'Are you sure you want to delete this payment term?' | $T8 %]')) return true; else return false;">
-   [%- END %]
-   <a href="[% SELF.url_for(action => 'list') %]">[%- 'Abort' | $T8 %]</a>
-  </p>
+  [% P.hidden_tag("id", SELF.payment_term.id) %]
 
   <hr size="3" noshade>
 
 
   <hr size="3" noshade>
 
index 7bedec8..bc56b91 100644 (file)
     </tbody>
    </table>
   [%- END %]
     </tbody>
    </table>
   [%- END %]
-
-  <p>
-   <a href="[% SELF.url_for(action => 'new') %]">[%- 'Create new payment term' | $T8 %]</a>
-  </p>
  </form>
 
  [% L.sortable_element('#payment_term_list tbody', url => 'controller.pl?action=PaymentTerm/reorder', with => 'payment_term_id') %]
  </form>
 
  [% L.sortable_element('#payment_term_list tbody', url => 'controller.pl?action=PaymentTerm/reorder', with => 'payment_term_id') %]