From 9c29f7183bb2e2861553339789d7ac8ba7dd188d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= <s.schoeling@linet-services.de> Date: Tue, 19 Dec 2017 15:31:51 +0100 Subject: [PATCH] Presenter: Neue Struktur im Warenstamm umgesetzt --- SL/Controller/Part.pm | 5 +- SL/IC.pm | 11 ++-- bin/mozilla/ic.pl | 5 +- templates/webpages/ic/search.html | 2 +- templates/webpages/part/_assembly.html | 3 +- templates/webpages/part/_assembly_row.html | 4 +- templates/webpages/part/_assortment.html | 3 +- templates/webpages/part/_assortment_row.html | 2 +- templates/webpages/part/_basic_data.html | 2 +- templates/webpages/part/_makemodel.html | 3 +- .../webpages/part/_multi_items_result.html | 2 +- .../webpages/part/_part_picker_result.html | 2 +- templates/webpages/part/test_page.html | 53 ++++++++++--------- 13 files changed, 52 insertions(+), 45 deletions(-) diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index f152e0844..53d51ced5 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -19,6 +19,7 @@ use SL::DB::Helper::ValidateAssembly qw(validate_assembly); use SL::CVar; use SL::MoreCommon qw(save_form); use Carp; +use SL::Presenter::EscapedText qw(escape is_escaped); use Rose::Object::MakeMethods::Generic ( 'scalar --get_set_init' => [ qw(parts models part p warehouses multi_items_models @@ -408,10 +409,10 @@ sub action_multi_items_update_result { my $count = $_[0]->multi_items_models->count; if ($count == 0) { - my $text = SL::Presenter::EscapedText->new(text => $::locale->text('No results.')); + my $text = escape($::locale->text('No results.')); $_[0]->render($text, { layout => 0 }); } elsif ($count > $max_count) { - my $text = SL::Presenter::EscapedText->new(text => $::locale->text('Too many results (#1 from #2).', $count, $max_count)); + my $text = escpae($::locale->text('Too many results (#1 from #2).', $count, $max_count)); $_[0]->render($text, { layout => 0 }); } else { my $multi_items = $_[0]->multi_items_models->get; diff --git a/SL/IC.pm b/SL/IC.pm index 54a2c5d78..0b836a0a1 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -45,6 +45,7 @@ use SL::HTML::Restrict; use SL::TransNumber; use SL::Util qw(trim); use SL::DB; +use SL::Presenter::Part qw(type_abbreviation classification_abbreviation separate_abbreviation); use Carp; use strict; @@ -640,8 +641,8 @@ sub get_parts { } $j++; - $form->{"type_and_classific_$j"} = $::request->presenter->type_abbreviation($ref->{part_type}). - $::request->presenter->classification_abbreviation($ref->{classification_id}); + $form->{"type_and_classific_$j"} = type_abbreviation($ref->{part_type}). + classification_abbreviation($ref->{classification_id}); $form->{"id_$j"} = $ref->{id}; $form->{"partnumber_$j"} = $ref->{partnumber}; $form->{"description_$j"} = $ref->{description}; @@ -938,11 +939,11 @@ sub prepare_parts_for_printing { my $id = $form->{"${prefix}${i}"}; next unless $id; my $prt = $parts_by_id{$id}; - my $type_abbr = $::request->presenter->type_abbreviation($prt->part_type); + my $type_abbr = type_abbreviation($prt->part_type); push @{ $template_arrays{part_type} }, $prt->part_type; push @{ $template_arrays{part_abbreviation} }, $type_abbr; - push @{ $template_arrays{type_and_classific}}, $type_abbr.$::request->presenter->classification_abbreviation($prt->classification_id); - push @{ $template_arrays{separate} }, $::request->presenter->separate_abbreviation($prt->classification_id); + push @{ $template_arrays{type_and_classific}}, $type_abbr . classification_abbreviation($prt->classification_id); + push @{ $template_arrays{separate} }, separate_abbreviation($prt->classification_id); } $main::lxdebug->leave_sub(); diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index 784cc1ad2..9fd05898d 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -41,6 +41,7 @@ use SL::CVar; use SL::IC; use SL::Helper::Flash qw(flash); use SL::HTML::Util; +use SL::Presenter::Part; use SL::ReportGenerator; #use SL::PE; @@ -556,8 +557,8 @@ sub generate_report { map { $row->{$_}{link} = $ref->{$_} } qw(drawing microfiche); $row->{notes}{data} = SL::HTML::Util->strip($ref->{notes}); - $row->{type_and_classific}{data} = $::request->presenter->type_abbreviation($ref->{part_type}). - $::request->presenter->classification_abbreviation($ref->{classification_id}); + $row->{type_and_classific}{data} = SL::Presenter::Part::type_abbreviation($ref->{part_type}). + SL::Presenter::Part::classification_abbreviation($ref->{classification_id}); $report->add_data($row); diff --git a/templates/webpages/ic/search.html b/templates/webpages/ic/search.html index 0df68022d..0b3dd0809 100644 --- a/templates/webpages/ic/search.html +++ b/templates/webpages/ic/search.html @@ -54,7 +54,7 @@ </tr> <tr> <th align="right" nowrap>[% 'Part Classification' | $T8 %]:</th> - <td>[% P.select_classification('classification_id', style=style) %]</td> + <td>[% P.part.select_classification('classification_id', style=style) %]</td> </tr> <tr> <th align="right" nowrap>[% 'Part Description' | $T8 %]</th> diff --git a/templates/webpages/part/_assembly.html b/templates/webpages/part/_assembly.html index bec2f89d1..629122947 100644 --- a/templates/webpages/part/_assembly.html +++ b/templates/webpages/part/_assembly.html @@ -2,6 +2,7 @@ [%- USE HTML %] [%- USE LxERP %] [%- USE L %] +[%- USE P %] <div id="assembly" name="assembly"> @@ -41,7 +42,7 @@ <td></td> <td></td> <td align="right">[% 'Part' | $T8 %]:</td> - <td>[% L.part_picker('add_items[+].parts_id', '', style='width: 300px', multiple=1, id='assembly_picker', action={set_multi_items='kivi.Part.set_multi_assembly_items', commit_one='kivi.Part.add_assembly_item'}) %]</td> + <td>[% P.part.picker('add_items[+].parts_id', '', style='width: 300px', multiple=1, id='assembly_picker', action={set_multi_items='kivi.Part.set_multi_assembly_items', commit_one='kivi.Part.add_assembly_item'}) %]</td> <td>[%- L.button_tag("kivi.Part.add_assembly_item()", LxERP.t8("Add")) %]</td> <td>[% L.button_tag('$("#assembly_picker").data("part_picker").open_dialog()', LxERP.t8('Add multiple items')) %]</td> <td>[% L.hidden_tag('add_items[].qty_as_number', 1) %]</td> diff --git a/templates/webpages/part/_assembly_row.html b/templates/webpages/part/_assembly_row.html index 4be4f4c94..95c097ac5 100644 --- a/templates/webpages/part/_assembly_row.html +++ b/templates/webpages/part/_assembly_row.html @@ -22,10 +22,10 @@ <img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"> </td> <td nowrap> - [% P.part(ITEM.part) %] + [% ITEM.part.presenter.part %] </td> <td nowrap> - [% P.type_abbreviation(ITEM.part.part_type) %][% P.classification_abbreviation(ITEM.part.classification_id) %] + [% P.part.type_abbreviation(ITEM.part.part_type) %][% P.classification_abbreviation(ITEM.part.classification_id) %] </td> <td> [% HTML.escape(ITEM.part.description) %] diff --git a/templates/webpages/part/_assortment.html b/templates/webpages/part/_assortment.html index 934bdc459..55b04e83f 100644 --- a/templates/webpages/part/_assortment.html +++ b/templates/webpages/part/_assortment.html @@ -2,6 +2,7 @@ [%- USE HTML %] [%- USE LxERP %] [%- USE L %] +[%- USE P %] <div id="assortment" name="assortment"> @@ -40,7 +41,7 @@ <td></td> <td></td> <td align="right">[% 'Part' | $T8 %]:</td> - <td>[% L.part_picker('add_items[+].parts_id', '', style='width: 300px', multiple=1, id='assortment_picker', action={set_multi_items='kivi.Part.set_multi_assortment_items'}) %]</td> + <td>[% P.part.picker('add_items[+].parts_id', '', style='width: 300px', multiple=1, id='assortment_picker', action={set_multi_items='kivi.Part.set_multi_assortment_items'}) %]</td> <td>[%- L.button_tag("kivi.Part.add_assortment_item()", LxERP.t8("Add")) %]</td> <td>[% L.button_tag('$("#assortment_picker").data("part_picker").open_dialog()', LxERP.t8('Add multiple items')) %]</td> <td>[% L.hidden_tag('add_items[].qty_as_number', 1) %]</td> diff --git a/templates/webpages/part/_assortment_row.html b/templates/webpages/part/_assortment_row.html index a86412c91..fcd88fd8f 100644 --- a/templates/webpages/part/_assortment_row.html +++ b/templates/webpages/part/_assortment_row.html @@ -22,7 +22,7 @@ <img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"> </td> <td nowrap> - [% P.part(ITEM.part) %] + [% ITEM.part.presenter.part %] </td> <td> [% HTML.escape(ITEM.part.description) %] diff --git a/templates/webpages/part/_basic_data.html b/templates/webpages/part/_basic_data.html index 00ee4adf7..06a704180 100644 --- a/templates/webpages/part/_basic_data.html +++ b/templates/webpages/part/_basic_data.html @@ -23,7 +23,7 @@ </tr> <tr> <th align="right">[% 'Part Classification' | $T8 %]</th> - <td>[% P.select_classification('part.classification_id', default => SELF.part.classification_id, type => SELF.parts_classification_filter ) %]</td> + <td>[% P.part.select_classification('part.classification_id', default => SELF.part.classification_id, type => SELF.parts_classification_filter ) %]</td> </tr> <tr> <th align="right">[% 'Part Description' | $T8 %]</th> diff --git a/templates/webpages/part/_makemodel.html b/templates/webpages/part/_makemodel.html index 8822aba0d..6f3ecc7a8 100644 --- a/templates/webpages/part/_makemodel.html +++ b/templates/webpages/part/_makemodel.html @@ -1,5 +1,6 @@ [%- USE T8 %] [%- USE L %] +[%- USE P %] [%- USE HTML %] [%- USE LxERP %] <tr> @@ -30,7 +31,7 @@ <td></td> <td></td> <td align="right">[% 'Vendor' | $T8 %]</td> - <td rowspan="2">[% L.customer_vendor_picker('add_makemodel', '', type='vendor', style='width: 300px', class="add_makemodel_input") %]</td> + <td rowspan="2">[% P.customer_vendor.picker('add_makemodel', '', type='vendor', style='width: 300px', class="add_makemodel_input") %]</td> <td rowspan="2" align="right">[% L.button_tag('kivi.Part.add_makemodel_row()', LxERP.t8('Add')) %]</td> </tr> </tbody> diff --git a/templates/webpages/part/_multi_items_result.html b/templates/webpages/part/_multi_items_result.html index a06fe3d00..7a710fb48 100644 --- a/templates/webpages/part/_multi_items_result.html +++ b/templates/webpages/part/_multi_items_result.html @@ -25,7 +25,7 @@ class = 'multi_items_qty numeric') %] </td> <td>[% HTML.escape(item.unit) %]</td> - <td>[% P.part(item) %] [% HTML.escape(item.description) %]</td> + <td>[% item.presenter.part %] [% HTML.escape(item.description) %]</td> <td class="numeric">[% HTML.escape(item.sellprice_as_number) %]</td> <td class="numeric">[% HTML.escape(item.partsgroup.partsgroup) %]</td> </tr> diff --git a/templates/webpages/part/_part_picker_result.html b/templates/webpages/part/_part_picker_result.html index d6a386fcc..677e772db 100644 --- a/templates/webpages/part/_part_picker_result.html +++ b/templates/webpages/part/_part_picker_result.html @@ -16,7 +16,7 @@ <span class='ppp_block_description'>[% part.description | html %]</span> <div style='clear:both;'></div> <span class='ppp_block_sellprice'>[% 'Sellprice' | $T8 %]: [% part.sellprice_as_number | html %]</span> - <span class='ppp_block_description'>[% P.typeclass_abbreviation(part) %]</span> + <span class='ppp_block_description'>[% part.presenter.typeclass_abbreviation %]</span> </div> [%- END %] diff --git a/templates/webpages/part/test_page.html b/templates/webpages/part/test_page.html index 4527534ab..fb7853f3f 100644 --- a/templates/webpages/part/test_page.html +++ b/templates/webpages/part/test_page.html @@ -1,52 +1,53 @@ [% USE L %] +[% USE P %] <h1>Part Picker Testpage</h1> <br> Alle: <br> -[% L.part_picker('part_id') %] text<br> +[% P.part.picker('part_id') %] text<br> Nur Waren: <br> -[% L.part_picker('part_id2', undef, part_type='part') %]<br> +[% P.part.picker('part_id2', undef, part_type='part') %]<br> Nur Dienstleistungen: <br> -[% L.part_picker('part_id3', undef, part_type='service') %]<br> +[% P.part.picker('part_id3', undef, part_type='service') %]<br> Nur Erzeugnisse: <br> -[% L.part_picker('part_id4', undef, part_type='assembly') %]<br> +[% P.part.picker('part_id4', undef, part_type='assembly') %]<br> Waren und Dienstleistungen: <br> -[% L.part_picker('part_id5', undef, part_type='part,service') %]<br> +[% P.part.picker('part_id5', undef, part_type='part,service') %]<br> Artikel-Klassifizierung: Einkauf <br> -[% L.part_picker('part_id10', undef, classification_id='1') %]<br> +[% P.part.picker('part_id10', undef, classification_id='1') %]<br> Artikel-Klassifizierung: Verkauf <br> -[% L.part_picker('part_id11', undef, classification_id='2') %]<br> +[% P.part.picker('part_id11', undef, classification_id='2') %]<br> Artikel-Klassifizierung: Handelsware <br> -[% L.part_picker('part_id12', undef, classification_id='3') %]<br> +[% P.part.picker('part_id12', undef, classification_id='3') %]<br> Artikel-Klassifizierung: Produktion <br> -[% L.part_picker('part_id13', undef, classification_id='4') %]<br> +[% P.part.picker('part_id13', undef, classification_id='4') %]<br> Artikel-Klassifizierung: Eink.,Verk.,Prod. <br> -[% L.part_picker('part_id14', undef, classification_id='1,2,4') %]<br> +[% P.part.picker('part_id14', undef, classification_id='1,2,4') %]<br> Pre-filled:<br> -[% L.part_picker('part_id6', pre_filled_part) %]<br> +[% P.part.picker('part_id6', pre_filled_part) %]<br> Convertible unit 'Std': (only select parts with unit Tag/Std/Min)<br> -[% L.part_picker('part_id7', undef, convertible_unit='Std') %]<br> +[% P.part.picker('part_id7', undef, convertible_unit='Std') %]<br> With multi select popup<br> -[% L.part_picker('part_id8', undef, multiple=1) %]<br> +[% P.part.picker('part_id8', undef, multiple=1) %]<br> <h2>Styling</h2> In a span: -<span>Leading text: [% L.part_picker('p1', undef, part_type='part,service') %] and text after with spacing</span><br> -<span>Leading text:[% L.part_picker('p2', undef, part_type='part,service') %]and text after without spacing</span><br> -<div>Leading text: [% L.part_picker('p3', undef, part_type='part,service') %] and text after with spacing with div</div><br> -<div>Leading text:[% L.part_picker('p4', undef, part_type='part,service') %]and text after with spacing with div</div><br> +<span>Leading text: [% P.part.picker('p1', undef, part_type='part,service') %] and text after with spacing</span><br> +<span>Leading text:[% P.part.picker('p2', undef, part_type='part,service') %]and text after without spacing</span><br> +<div>Leading text: [% P.part.picker('p3', undef, part_type='part,service') %] and text after with spacing with div</div><br> +<div>Leading text:[% P.part.picker('p4', undef, part_type='part,service') %]and text after with spacing with div</div><br> -<span>Picker + input next to each other: [% L.part_picker('p5', undef, part_type='part,service', width="100%") %]<input type=text></span> +<span>Picker + input next to each other: [% P.part.picker('p5', undef, part_type='part,service', width="100%") %]<input type=text></span> -<div>[% L.part_picker('p6', undef, part_type='part,service', style="width:500px") %] 500px width</div> -<div>[% L.part_picker('p7', undef, part_type='part,service', style="width:200px") %] 200px width</div> -<div>[% L.part_picker('p8', undef, part_type='part,service', style="height:40px") %] 40px height</div> +<div>[% P.part.picker('p6', undef, part_type='part,service', style="width:500px") %] 500px width</div> +<div>[% P.part.picker('p7', undef, part_type='part,service', style="width:200px") %] 200px width</div> +<div>[% P.part.picker('p8', undef, part_type='part,service', style="height:40px") %] 40px height</div> [%# FOREACH i IN 1..50 %] -[%# L.part_picker('part_id_' _ i) %] <br> +[%# P.part.picker('part_id_' _ i) %] <br> [%# END %] <h2>In tables</h2> @@ -56,11 +57,11 @@ In a span: <table> <tr> <th>Part picker in table heading</th> - <th>[% L.part_picker('p9', undef, part_type='part,service') %]</th> + <th>[% P.part.picker('p9', undef, part_type='part,service') %]</th> </tr> <tr> <td>Part picker in table cell</td> - <td>[% L.part_picker('p10', undef, part_type='part,service') %]</td> + <td>[% P.part.picker('p10', undef, part_type='part,service') %]</td> </tr> </table> @@ -69,10 +70,10 @@ In a span: <table> <tr class=listheading> <th>Part picker in table heading</th> - <th>[% L.part_picker('p11', undef, part_type='part,service') %]</th> + <th>[% P.part.picker('p11', undef, part_type='part,service') %]</th> </tr> <tr class=listrow> <td>Part picker in table cell</td> - <td>[% L.part_picker('p12', undef, part_type='part,service') %]</td> + <td>[% P.part.picker('p12', undef, part_type='part,service') %]</td> </tr> </table> -- 2.20.1