From 9c19433144efc5b50d90a969aa9ac6ea65b2dbbf Mon Sep 17 00:00:00 2001
From: Moritz Bunkus
Date: Wed, 1 Feb 2017 14:10:20 +0100
Subject: [PATCH] =?utf8?q?SimpleSystemSetting:=20Umstellung=20von=20=C2=BB?=
=?utf8?q?Warengruppen=C2=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
---
SL/Controller/PartsGroup.pm | 159 ------------------
SL/Controller/SimpleSystemSetting.pm | 14 ++
locale/de/all | 4 -
menus/user/00-erp.yaml | 3 +-
templates/webpages/partsgroup/form.html | 50 ------
templates/webpages/partsgroup/list.html | 33 ----
.../_parts_group_form.html | 13 ++
7 files changed, 29 insertions(+), 247 deletions(-)
delete mode 100644 SL/Controller/PartsGroup.pm
delete mode 100644 templates/webpages/partsgroup/form.html
delete mode 100644 templates/webpages/partsgroup/list.html
create mode 100644 templates/webpages/simple_system_setting/_parts_group_form.html
diff --git a/SL/Controller/PartsGroup.pm b/SL/Controller/PartsGroup.pm
deleted file mode 100644
index 603aa1258..000000000
--- a/SL/Controller/PartsGroup.pm
+++ /dev/null
@@ -1,159 +0,0 @@
-package SL::Controller::PartsGroup;
-
-use strict;
-
-use parent qw(SL::Controller::Base);
-
-use SL::Helper::Flash;
-use SL::Locale::String;
-use SL::DB::Default;
-use SL::DB::Manager::PartsGroup;
-
-use Rose::Object::MakeMethods::Generic (
- scalar => [ qw(partsgroup) ],
- 'scalar --get_set_init' => [ qw(all_partsgroups) ],
-);
-
-__PACKAGE__->run_before('check_auth');
-__PACKAGE__->run_before('load_partsgroup', only => [ qw(edit update delete) ]);
-
-#
-# actions
-#
-
-sub action_list {
- my ($self) = @_;
-
- $self->render('partsgroup/list',
- title => t8('Partsgroups'),
- );
-}
-
-sub action_new {
- my ($self) = @_;
-
- $self->partsgroup( SL::DB::PartsGroup->new );
- $self->render('partsgroup/form',
- title => t8('Add partsgroup'),
- );
-}
-
-sub action_edit {
- my ($self) = @_;
-
- $self->render('partsgroup/form',
- title => t8('Edit partsgroup'),
- );
-}
-
-sub action_create {
- my ($self) = @_;
-
- $self->partsgroup( SL::DB::PartsGroup->new );
- $self->create_or_update;
-}
-
-sub action_update {
- my ($self) = @_;
- $self->create_or_update;
-}
-
-sub action_delete {
- my ($self) = @_;
-
- if ( !$self->partsgroup->orphaned ) {
- flash_later('error', $::locale->text('The partsgroup has been used and cannot be deleted.'));
- } elsif ( eval { $self->partsgroup->delete; 1; } ) {
- flash_later('info', $::locale->text('The partsgroup has been deleted.'));
- } else {
- flash_later('error', $::locale->text('The partsgroup has been used and cannot be deleted.'));
- };
- $self->redirect_to(action => 'list');
-}
-
-sub action_reorder {
- my ($self) = @_;
-
- SL::DB::PartsGroup->reorder_list(@{ $::form->{partsgroup_id} || [] });
- $self->render(\'', { type => 'json' });
-}
-
-#
-# filters
-#
-
-sub check_auth {
- $::auth->assert('config');
-}
-
-sub load_partsgroup {
- my ($self) = @_;
-
- $self->partsgroup( SL::DB::PartsGroup->new(id => $::form->{id})->load );
-}
-
-sub init_all_partsgroups { SL::DB::Manager::PartsGroup->get_all_sorted }
-
-#
-# helpers
-#
-
-sub create_or_update {
- my ($self) = @_;
- my $is_new = !$self->partsgroup->id;
-
- my $params = delete($::form->{partsgroup}) || { };
-
- $self->partsgroup->assign_attributes(%{ $params });
-
- my @errors = $self->partsgroup->validate;
-
- if (@errors) {
- flash('error', @errors);
- $self->render('partsgroup/form',
- title => $is_new ? t8('Add partsgroup') : t8('Edit partsgroup'),
- );
- return;
- }
-
- $self->partsgroup->save;
-
- flash_later('info', $is_new ? t8('The partsgroup has been created.') : t8('The partsgroup has been saved.'));
- $self->redirect_to(action => 'list');
-}
-
-1;
-
-__END__
-
-=encoding utf-8
-
-=head1 NAME
-
-SL::Controller::PartsGroup - CRUD controller for partsgroups
-
-=head1 SYNOPSIS
-
-A new controller to create / edit / delete partsgroups.
-
-Partsgroups can only be deleted if they haven't been used anywhere.
-
-=head1 OBSOLETE PARTSGROUPS
-
-A partsgroup can be deleted if it hasn't been used anywhere / is orphaned.
-
-A partsgroup can be set to obsolete, which means new items can't be assigned
-that partsgroup, but old items with that partsgroup can keep it. And you can
-also still filter for these obsolete partsgroups in reports.
-
-=head1 ISSUES
-
-Unlike the old version (pe.pl/PE.pm), there is no way to filter/search the
-partsgroups in the overview page, it always shows the complete (ordered) list,
-ordered by sortkey.
-
-=head1 AUTHOR
-
-G. Richardson Egrichardson@kivitendo-premium.deE
-
-=cut
diff --git a/SL/Controller/SimpleSystemSetting.pm b/SL/Controller/SimpleSystemSetting.pm
index 429d2879b..9ce91f9f9 100644
--- a/SL/Controller/SimpleSystemSetting.pm
+++ b/SL/Controller/SimpleSystemSetting.pm
@@ -40,6 +40,20 @@ my %supported_types = (
],
},
+ parts_group => {
+ # Make locales.pl happy: $self->render("simple_system_setting/_parts_group_form")
+ class => 'PartsGroup',
+ titles => {
+ list => t8('Partsgroups'),
+ add => t8('Add partsgroup'),
+ edit => t8('Edit partsgroup'),
+ },
+ list_attributes => [
+ { method => 'partsgroup', title => t8('Description') },
+ { method => 'obsolete', title => t8('Obsolete'), formatter => sub { $_[0]->obsolete ? t8('yes') : t8('no') } },
+ ],
+ },
+
pricegroup => {
# Make locales.pl happy: $self->render("simple_system_setting/_pricegroup_form")
class => 'Pricegroup',
diff --git a/locale/de/all b/locale/de/all
index 55ca59862..7c4da9016 100644
--- a/locale/de/all
+++ b/locale/de/all
@@ -3074,10 +3074,6 @@ $self->{texts} = {
'The parts for this delivery order have already been transferred out.' => 'Die Artikel dieses Lieferscheins wurden bereits ausgelagert.',
'The parts have been removed.' => 'Die Waren wurden aus dem Lager entnommen.',
'The parts have been transferred.' => 'Die Waren wurden umgelagert.',
- 'The partsgroup has been created.' => 'Die Warengruppe wurde erstellt.',
- 'The partsgroup has been deleted.' => 'Die Warengruppe wurde gelöscht.',
- 'The partsgroup has been saved.' => 'Die Warengruppe wurde gespeichert.',
- 'The partsgroup has been used and cannot be deleted.' => 'Die Warengruppe wurde bereits verwendet und kann nicht gelöscht werden.',
'The password is too long (maximum length: #1).' => 'Das Passwort ist zu lang (maximale Länge: #1).',
'The password is too short (minimum length: #1).' => 'Das Password ist zu kurz (minimale Länge: #1).',
'The password is weak (e.g. it can be found in a dictionary).' => 'Das Passwort ist schwach (z.B. wenn es in einem Wörterbuch steht).',
diff --git a/menus/user/00-erp.yaml b/menus/user/00-erp.yaml
index 546891511..d1f54c21f 100644
--- a/menus/user/00-erp.yaml
+++ b/menus/user/00-erp.yaml
@@ -1072,7 +1072,8 @@
name: Partsgroups
order: 900
params:
- action: PartsGroup/list
+ action: SimpleSystemSetting/list
+ type: parts_group
- parent: system
id: system_part_classification
name: Parts Classification
diff --git a/templates/webpages/partsgroup/form.html b/templates/webpages/partsgroup/form.html
deleted file mode 100644
index 60134b736..000000000
--- a/templates/webpages/partsgroup/form.html
+++ /dev/null
@@ -1,50 +0,0 @@
-[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
-
-[% SET style="width: 400px" %]
-[% SET size=15 %]
-
-[% HTML.escape(title) %]
-
-
-
-
-
-[% L.sortable_element('#partsgroup_list tbody', url=SELF.url_for(action='reorder'), with='partsgroup_id') %]
-
-
- [%- 'Add' | $T8 %]
-
diff --git a/templates/webpages/simple_system_setting/_parts_group_form.html b/templates/webpages/simple_system_setting/_parts_group_form.html
new file mode 100644
index 000000000..8e9025a5b
--- /dev/null
+++ b/templates/webpages/simple_system_setting/_parts_group_form.html
@@ -0,0 +1,13 @@
+[%- USE LxERP -%][%- USE L -%]
+
+
+ [% LxERP.t8("Description") %] |
+
+ [%- L.input_tag("object.partsgroup", SELF.object.partsgroup, "data-validate"="required", "data-title"=LxERP.t8("Description")) %]
+ |
+
+
+ [% LxERP.t8("Obsolete") %] |
+ [% L.checkbox_tag("object.obsolete", checked=SELF.object.obsolete, for_submit=1) %] |
+
+
--
2.20.1