From 942ce912a7551ef0756ba1b737b72f8756469730 Mon Sep 17 00:00:00 2001
From: Moritz Bunkus
Date: Tue, 21 Mar 2017 15:47:38 +0100
Subject: [PATCH] =?utf8?q?ActionBar:=20Verwendung=20bei=20=C2=BBSystem?=
=?utf8?q?=C2=AB=20=E2=86=92=20=C2=BBBenutzerdefinierte=20Variablen=C2=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
---
SL/Controller/CustomVariableConfig.pm | 55 +++++++++++++++++++
.../webpages/custom_variable_config/form.html | 12 +---
.../webpages/custom_variable_config/list.html | 6 --
3 files changed, 56 insertions(+), 17 deletions(-)
diff --git a/SL/Controller/CustomVariableConfig.pm b/SL/Controller/CustomVariableConfig.pm
index 1b780e5fc..0b124e9fb 100644
--- a/SL/Controller/CustomVariableConfig.pm
+++ b/SL/Controller/CustomVariableConfig.pm
@@ -46,6 +46,7 @@ sub action_list {
my $configs = SL::DB::Manager::CustomVariableConfig->get_all_sorted(where => [ module => $self->module ]);
+ $self->setup_list_action_bar;
$::form->header;
$self->render('custom_variable_config/list',
title => t8('List of custom variables'),
@@ -70,6 +71,7 @@ sub show_form {
$params{all_partsgroups} = SL::DB::Manager::PartsGroup->get_all();
$::request->layout->use_javascript("${_}.js") for qw(jquery.selectboxes jquery.multiselect2side);
+ $self->setup_form_action_bar;
$self->render('custom_variable_config/form', %params);
}
@@ -226,4 +228,57 @@ sub _set_cvar_validity {
}
}
+sub setup_list_action_bar {
+ my ($self) = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Add'),
+ link => $self->url_for(action => 'new', module => $self->module),
+ ],
+ );
+ }
+}
+
+sub setup_form_action_bar {
+ my ($self) = @_;
+
+ my $is_new = !$self->config->id;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ combobox => [
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => 'CustomVariableConfig/' . ($is_new ? 'create' : 'update') } ],
+ checks => [ 'check_prerequisites' ],
+ accesskey => 'enter',
+ ],
+
+ action => [
+ t8('Save as new'),
+ submit => [ '#form', { action => 'CustomVariableConfig/create'} ],
+ checks => [ 'check_prerequisites' ],
+ not_if => $is_new,
+ ],
+ ], # end of combobox "Save"
+
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => 'CustomVariableConfig/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', module => $self->module),
+ ],
+ );
+ }
+}
+
1;
diff --git a/templates/webpages/custom_variable_config/form.html b/templates/webpages/custom_variable_config/form.html
index eb6aee740..a33d9dfb1 100644
--- a/templates/webpages/custom_variable_config/form.html
+++ b/templates/webpages/custom_variable_config/form.html
@@ -1,6 +1,6 @@
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%][% HTML.escape(title) %]
-
-
-
-
- [%- 'Add' | $T8 %]
-
-
[% L.sortable_element('#cvarcfg_list tbody', url=SELF.url_for(action='reorder'), with='cvarcfg_id', params='"&module=" + encodeURIComponent($("#module").val())') %]