From 8631a825ebe02f537dae531fd5ec712a12c53f0f Mon Sep 17 00:00:00 2001
From: Moritz Bunkus
Date: Tue, 31 Jan 2017 15:29:53 +0100
Subject: [PATCH] =?utf8?q?ActionBar:=20Verwendung=20bei=20=C2=BBSteuerzone?=
=?utf8?q?n=C2=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
---
SL/Controller/Taxzones.pm | 50 +++++++++++++++++++++++++++
templates/webpages/taxzones/form.html | 28 ++-------------
templates/webpages/taxzones/list.html | 7 ----
3 files changed, 52 insertions(+), 33 deletions(-)
diff --git a/SL/Controller/Taxzones.pm b/SL/Controller/Taxzones.pm
index 1594b9b37..e0125695c 100644
--- a/SL/Controller/Taxzones.pm
+++ b/SL/Controller/Taxzones.pm
@@ -27,6 +27,7 @@ sub action_list {
my $taxzones = SL::DB::Manager::TaxZone->get_all_sorted();
+ $self->setup_list_action_bar;
$self->render('taxzones/list',
title => t8('List of tax zones'),
TAXZONES => $taxzones);
@@ -42,6 +43,7 @@ sub action_new {
sub show_form {
my ($self, %params) = @_;
+ $self->setup_show_form_action_bar;
$self->render('taxzones/form', %params,
BUCHUNGSGRUPPEN => SL::DB::Manager::Buchungsgruppe->get_all_sorted);
}
@@ -179,4 +181,52 @@ sub create_or_update {
sub init_defaults { SL::DB::Default->get };
+#
+# helpers
+#
+
+sub setup_show_form_action_bar {
+ my ($self) = @_;
+
+ my $is_new = !$self->config->id;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => 'Taxzones/' . ($is_new ? 'create' : 'update') } ],
+ checks => [ 'kivi.validate_form' ],
+ accesskey => 'enter',
+ ],
+
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => 'Taxzones/delete' } ],
+ confirm => t8('Do you really want to delete this object?'),
+ disabled => $is_new ? t8('This object has not been saved yet.')
+ : !$self->config->orphaned ? t8('The object is in use and cannot be deleted.')
+ : undef,
+ ],
+
+ link => [
+ t8('Abort'),
+ link => $self->url_for(action => 'list'),
+ ],
+ );
+ }
+}
+
+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'),
+ ],
+ );
+ }
+}
+
1;
diff --git a/templates/webpages/taxzones/form.html b/templates/webpages/taxzones/form.html
index d6153788c..9cddd46e9 100644
--- a/templates/webpages/taxzones/form.html
+++ b/templates/webpages/taxzones/form.html
@@ -1,13 +1,13 @@
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%][% HTML.escape(title) %]
[% SET style="width: 400px" %]
-
diff --git a/templates/webpages/taxzones/list.html b/templates/webpages/taxzones/list.html
index 46c1a0ba1..793f88c87 100644
--- a/templates/webpages/taxzones/list.html
+++ b/templates/webpages/taxzones/list.html
@@ -22,11 +22,4 @@
-
-
[% L.sortable_element('#taxzone_list tbody', url=SELF.url_for(action='reorder'), with='tzone_id') %]
-
-
- [%- 'Add' | $T8 %]
-
-
--
2.20.1