From 486d0a3bc8e6ff90823a1b5e0461d0b61c11b771 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Tue, 1 Oct 2019 18:15:33 +0200 Subject: [PATCH] Auftrags-Controller: Benutzereinstellung: Positions-Update aus Artikel-Stamm --- SL/AM.pm | 8 +++ SL/Controller/Order.pm | 12 +++- SL/Helper/UserPreferences/UpdatePositions.pm | 68 +++++++++++++++++++ bin/mozilla/am.pl | 1 + locale/de/all | 1 + locale/en/all | 1 + templates/webpages/am/config.html | 6 ++ templates/webpages/order/tabs/_row.html | 2 + templates/webpages/order/tabs/basic_data.html | 11 ++- 9 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 SL/Helper/UserPreferences/UpdatePositions.pm diff --git a/SL/AM.pm b/SL/AM.pm index 6302c2481..0ba1ec8f5 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -54,6 +54,7 @@ use SL::DB; use SL::GenericTranslations; use SL::Helper::UserPreferences::PositionsScrollbar; use SL::Helper::UserPreferences::PartPickerSearch; +use SL::Helper::UserPreferences::UpdatePositions; use strict; @@ -541,6 +542,10 @@ sub sales_search_customer_partnumber { SL::Helper::UserPreferences::PartPickerSearch->new()->get_sales_search_customer_partnumber(); } +sub positions_show_update_button { + SL::Helper::UserPreferences::UpdatePositions->new()->get_show_update_button(); +} + sub save_preferences { $main::lxdebug->enter_sub(); @@ -575,6 +580,9 @@ sub save_preferences { if (exists $form->{sales_search_customer_partnumber}) { SL::Helper::UserPreferences::PartPickerSearch->new()->store_sales_search_customer_partnumber($form->{sales_search_customer_partnumber}) } + if (exists $form->{positions_show_update_button}) { + SL::Helper::UserPreferences::UpdatePositions->new()->store_show_update_button($form->{positions_show_update_button}) + } $main::lxdebug->leave_sub(); diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 9b4c1bf4f..00efeca76 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -26,6 +26,7 @@ use SL::Helper::CreatePDF qw(:all); use SL::Helper::PrintOptions; use SL::Helper::ShippedQty; use SL::Helper::UserPreferences::PositionsScrollbar; +use SL::Helper::UserPreferences::UpdatePositions; use SL::Controller::Helper::GetModels; @@ -40,7 +41,7 @@ use Sort::Naturally; use Rose::Object::MakeMethods::Generic ( scalar => [ qw(item_ids_to_delete) ], - 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors search_cvpartnumber) ], + 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors search_cvpartnumber show_update_button) ], ); @@ -795,6 +796,7 @@ sub action_add_item { TYPE => $self->type, ALL_PRICE_FACTORS => $self->all_price_factors, SEARCH_CVPARTNUMBER => $self->search_cvpartnumber, + SHOW_UPDATE_BUTTON => $self->show_update_button, ); $self->js @@ -823,6 +825,7 @@ sub action_add_item { TYPE => $self->type, ALL_PRICE_FACTORS => $self->all_price_factors, SEARCH_CVPARTNUMBER => $self->search_cvpartnumber, + SHOW_UPDATE_BUTTON => $self->show_update_button, ); $self->js ->append('#row_table_id', $row_as_html); @@ -906,6 +909,7 @@ sub action_add_multi_items { TYPE => $self->type, ALL_PRICE_FACTORS => $self->all_price_factors, SEARCH_CVPARTNUMBER => $self->search_cvpartnumber, + SHOW_UPDATE_BUTTON => $self->show_update_button, ); $self->js->append('#row_table_id', $row_as_html); @@ -1208,6 +1212,12 @@ sub init_search_cvpartnumber { return $search_cvpartnumber; } +sub init_show_update_button { + my ($self) = @_; + + !!SL::Helper::UserPreferences::UpdatePositions->new()->get_show_update_button(); +} + sub init_p { SL::Presenter->get; } diff --git a/SL/Helper/UserPreferences/UpdatePositions.pm b/SL/Helper/UserPreferences/UpdatePositions.pm new file mode 100644 index 000000000..ae0628521 --- /dev/null +++ b/SL/Helper/UserPreferences/UpdatePositions.pm @@ -0,0 +1,68 @@ +package SL::Helper::UserPreferences::UpdatePositions; + +use strict; +use parent qw(Rose::Object); + +use Carp; +use List::MoreUtils qw(none); + +use SL::Helper::UserPreferences; + +use Rose::Object::MakeMethods::Generic ( + 'scalar --get_set_init' => [ qw(user_prefs) ], +); + +sub get_show_update_button { + !!$_[0]->user_prefs->get('show_update_button'); +} + +sub store_show_update_button { + $_[0]->user_prefs->store('show_update_button', $_[1]); +} + +sub init_user_prefs { + SL::Helper::UserPreferences->new( + namespace => $_[0]->namespace, + ) +} + +# read only stuff +sub namespace { 'UpdatePositions' } +sub version { 1 } + +1; + +__END__ + +=pod + +=encoding utf-8 + +=head1 NAME + +SL::Helper::UserPreferences::UpdatePositions - preferences intended +to store user settings for displaying an update button for the postions +of document forms to update the positions (parts) from master data. + +=head1 SYNOPSIS + + use SL::Helper::UserPreferences::UpdatePositions; + my $prefs = SL::Helper::UserPreferences::UpdatePositions->new(); + + $prefs->store_show_update_button(1); + my $value = $prefs->get_show_update_button; + +=head1 DESCRIPTION + +This module manages storing the user's choise for displaying an update button +in the positions area in forms (new order controller). + +=head1 BUGS + +None yet :) + +=head1 AUTHOR + +Bernd Bleßmann Ebernd@kivitendo-premium.deE + +=cut diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index f2987b61f..e992ebec5 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -663,6 +663,7 @@ sub config { $form->{positions_scrollbar_height} = AM->positions_scrollbar_height(); $form->{purchase_search_makemodel} = AM->purchase_search_makemodel(); $form->{sales_search_customer_partnumber} = AM->sales_search_customer_partnumber(); + $form->{positions_show_update_button} = AM->positions_show_update_button(); $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details})); $form->{CAN_CHANGE_PASSWORD} = $main::auth->can_change_password(); diff --git a/locale/de/all b/locale/de/all index 949125b0a..6a49a3de9 100755 --- a/locale/de/all +++ b/locale/de/all @@ -2959,6 +2959,7 @@ $self->{texts} = { 'Show the picture in the part form' => 'Bild in Warenmaske anzeigen', 'Show the pictures in the result for search parts' => 'Bilder in Suchergebnis für Stammdaten -> Berichte -> Waren anzeigen', 'Show the weights of articles and the total weight in orders, invoices and delivery notes?' => 'Sollen Warengewichte und Gesamtgewicht in Aufträgen, Rechnungen und Lieferscheinen angezeigt werden?', + 'Show update button for positions in order forms' => 'Aktualisieren-Knopf bei Positionen in Belegen anzeigen (neuer Auftrags-Controller)', 'Show weights' => 'Gewichte anzeigen', 'Show your TODO list after logging in' => 'Aufgabenliste nach dem Anmelden anzeigen', 'Show »not delivered qty/value« column in sales and purchase orders' => 'Spalte »Nicht gelieferte Menge/Wert« in Aufträgen anzeigen', diff --git a/locale/en/all b/locale/en/all index bbd4098a5..e86688b73 100644 --- a/locale/en/all +++ b/locale/en/all @@ -2959,6 +2959,7 @@ $self->{texts} = { 'Show the picture in the part form' => '', 'Show the pictures in the result for search parts' => '', 'Show the weights of articles and the total weight in orders, invoices and delivery notes?' => '', + 'Show update button for positions in order forms' => '', 'Show weights' => '', 'Show your TODO list after logging in' => '', 'Show »not delivered qty/value« column in sales and purchase orders' => '', diff --git a/templates/webpages/am/config.html b/templates/webpages/am/config.html index b8cef8334..6e65c4d57 100644 --- a/templates/webpages/am/config.html +++ b/templates/webpages/am/config.html @@ -168,6 +168,12 @@ [%- 'This also enables displaying a column with the customer partnumber (new order controller).' | $T8 %] + + [% 'Show update button for positions in order forms' | $T8 %] + + [% L.yes_no_tag('positions_show_update_button', positions_show_update_button) %] + + [%- END -%] diff --git a/templates/webpages/order/tabs/_row.html b/templates/webpages/order/tabs/_row.html index 20755d26b..42a7a7796 100644 --- a/templates/webpages/order/tabs/_row.html +++ b/templates/webpages/order/tabs/_row.html @@ -32,6 +32,7 @@ LxERP.t8("X"), confirm=LxERP.t8("Are you sure?")) %] + [%- IF SHOW_UPDATE_BUTTON -%] [%- L.img_tag(src="image/rotate_cw.svg", alt=LxERP.t8('Update from master data'), @@ -39,6 +40,7 @@ onclick="if (!confirm('" _ LxERP.t8("Are you sure to update this position from master data?") _ "')) return false; kivi.Order.update_row_from_master_data(this);", id='update_from_master') %] + [%- END -%]
[% HTML.escape(ITEM.part.partnumber) %]
diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index 26aedd524..c040f11ce 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -213,6 +213,7 @@ [%- 'position' | $T8 %] [%- LxERP.t8('reorder item') %] [%- LxERP.t8('delete item') %] + [%- IF SELF.show_update_button -%] [%- L.img_tag(src="image/rotate_cw.svg", alt=LxERP.t8('Update from master data'), @@ -220,6 +221,7 @@ onclick="if (!confirm('" _ LxERP.t8("Are you sure to update all positions from master data?") _ "')) return false; kivi.Order.update_all_rows_from_master_data();", id='update_from_master') %] + [%- END %] [%- 'Partnumber' | $T8 %] [%- IF SELF.search_cvpartnumber -%] [%- SELF.cv == "customer" ? LxERP.t8('Customer Part Number') : LxERP.t8('Model') %] @@ -240,7 +242,14 @@ [%- FOREACH item = SELF.order.items_sorted %] - [%- PROCESS order/tabs/_row.html ITEM=item ID=(item.id||item.new_fake_id) TYPE=SELF.type ALL_PRICE_FACTORS=SELF.all_price_factors SEARCH_CVPARTNUMBER=SELF.search_cvpartnumber %] + [%- PROCESS order/tabs/_row.html + ITEM=item + ID=(item.id||item.new_fake_id) + TYPE=SELF.type + ALL_PRICE_FACTORS=SELF.all_price_factors + SEARCH_CVPARTNUMBER=SELF.search_cvpartnumber + SHOW_UPDATE_BUTTON=SELF.show_update_button + -%] [%- END %] -- 2.20.1