From 6770b19ab3f0dc0d8b00f70d8aab74149354a181 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Mon, 14 May 2018 16:17:53 +0200 Subject: [PATCH] calculate_qty (Formel): auf Dialog umgestellt --- bin/mozilla/common.pl | 7 ++-- bin/mozilla/io.pl | 2 +- js/calculate_qty.js | 32 ++++++++++++------- js/kivi.Order.js | 4 +-- js/locale/de.js | 1 + js/locale/en.js | 1 + templates/webpages/generic/calculate_qty.html | 14 ++++---- templates/webpages/order/tabs/_row.html | 2 +- 8 files changed, 36 insertions(+), 27 deletions(-) diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index b03ca4c09..5eb06c9ea 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -181,10 +181,9 @@ sub calculate_qty { }, @header_sort; $form->{formel} = $formel; - $form->{title} = $locale->text("Please enter values"); - $form->header(no_layout => 1); - print $form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header, - "VARIABLES" => \@variable, }); + my $html = $form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header, + "VARIABLES" => \@variable, }); + print $::form->ajax_response_header, $html; $main::lxdebug->leave_sub(); } diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index d376d4c5f..14b8cf220 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -319,7 +319,7 @@ sub display_row { my $qty_dec = ($form->{"qty_$i"} =~ /\.(\d+)/) ? length $1 : 2; $column_data{qty} = $cgi->textfield(-name => "qty_$i", -size => 5, -class => "numeric", -value => $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec)); - $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i', '', 'formel_$i', '')", -value => $locale->text('*/')) + $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_dialog('qty_$i', '', 'formel_$i', '')", -value => $locale->text('*/')) . $cgi->hidden(-name => "formel_$i", -value => $form->{"formel_$i"}) if $form->{"formel_$i"}; diff --git a/js/calculate_qty.js b/js/calculate_qty.js index 01fa5bfe5..ee36cf0f6 100644 --- a/js/calculate_qty.js +++ b/js/calculate_qty.js @@ -1,17 +1,27 @@ -function calculate_qty_selection_window(input_name, input_id, formel_name, formel_id) { - var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes"; - var action = "calculate_qty"; +function calculate_qty_selection_dialog(input_name, input_id, formel_name, formel_id) { + // The target input element is determined by it's dom id or by it's name. + // The formula input element (the one containing the formula) is determined by it's dom id or by it's name. + // If the id is not provided the name is used. if (formel_id) { var formel = $('#' + formel_id).val(); } else { var formel = $('[name="' + formel_name + '"]').val(); } - url = "common.pl?" + - "INPUT_ENCODING=UTF-8&" + - "action=" + action + "&" + - "input_name=" + encodeURIComponent(input_name) + "&" + - "input_id=" + encodeURIComponent(input_id) + "&" + - "formel=" + encodeURIComponent(formel); - //alert(url); - window.open(url, "_new_generic", parm); + var url = "common.pl"; + var data = { + action: "calculate_qty", + input_name: input_name, + input_id: input_id, + formel: formel + }; + kivi.popup_dialog({ + id: 'calc_qty_dialog', + url: url, + data: data, + dialog: { + width: 500, + height: 400, + title: kivi.t8('Please enter values'), + } + }); } diff --git a/js/kivi.Order.js b/js/kivi.Order.js index b6a9642e5..f60b5ffcd 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -626,9 +626,9 @@ namespace('kivi.Order', function(ns) { ns.show_calculate_qty_dialog = function(clicked) { var row = $(clicked).parents("tbody").first(); var input_id = $(row).find('[name="order.orderitems[].qty_as_number"]').attr('id'); - var formula_id = $(row).find('[name="formula"]').attr('id'); + var formula_id = $(row).find('[name="formula[+]"]').attr('id'); - calculate_qty_selection_window("", input_id, "", formula_id); + calculate_qty_selection_dialog("", input_id, "", formula_id); return true; } diff --git a/js/locale/de.js b/js/locale/de.js index 7447111c9..8b70fd8db 100644 --- a/js/locale/de.js +++ b/js/locale/de.js @@ -80,6 +80,7 @@ namespace("kivi").setupLocale({ "Paste":"Einfügen", "Paste template":"Vorlage einfügen", "Please enter the new name:":"Bitte geben Sie den neuen Namen ein:", +"Please enter values":"Bitte Werte eingeben", "Please select a customer.":"Bitte wählen Sie einen Kunden aus.", "Please select a vendor.":"Bitte wählen Sie einen Lieferanten aus.", "Price Types":"Preistypen", diff --git a/js/locale/en.js b/js/locale/en.js index 946ac245c..46ae5337a 100644 --- a/js/locale/en.js +++ b/js/locale/en.js @@ -78,6 +78,7 @@ namespace("kivi").setupLocale({ "Paste":"", "Paste template":"", "Please enter the new name:":"", +"Please enter values":"", "Please select a customer.":"", "Please select a vendor.":"", "Price Types":"", diff --git a/templates/webpages/generic/calculate_qty.html b/templates/webpages/generic/calculate_qty.html index 3d2910cbe..bd347aa81 100644 --- a/templates/webpages/generic/calculate_qty.html +++ b/templates/webpages/generic/calculate_qty.html @@ -1,8 +1,6 @@ [%- USE T8 %] [%- USE HTML %] -

[% title %]

- -
+ @@ -37,16 +35,16 @@