From cb0ae4e41048ffba9a7e3c6f52c21ea11728f42d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 2 Apr 2015 15:29:15 +0200 Subject: [PATCH] PriceRule: Inline Report JS ausgelagert Hatte sich mit dem SalesPriceInformation Javascript verheddert, welches auch mal ausgelagert werden solle. --- bin/mozilla/ic.pl | 3 ++- js/kivi.PriceRule.js | 24 ++++++++++++++++++++++++ templates/webpages/ic/form_footer.html | 25 ------------------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index 0c1ab688d..76f086938 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -1633,7 +1633,8 @@ sub form_header { CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}, show_disabled_message => 1, partsgroup_id => $partsgroup_id) if (scalar @{ $form->{CUSTOM_VARIABLES} }); - $::request->layout->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery); + $::request->layout->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery kivi.PriceRule); + $::request->layout->add_javascripts_inline("\$(function(){kivi.PriceRule.load_price_rules_for_part(@{[ $::form->{id} * 1 ]})})") if $::form->{id}; $form->header; #print $form->parse_html_template('ic/form_header', { ALL_PRICE_FACTORS => $form->{ALL_PRICE_FACTORS}, # ALL_UNITS => $form->{ALL_UNITS}, diff --git a/js/kivi.PriceRule.js b/js/kivi.PriceRule.js index 00ed4fb36..d3c6a2aef 100644 --- a/js/kivi.PriceRule.js +++ b/js/kivi.PriceRule.js @@ -33,6 +33,29 @@ namespace('kivi.PriceRule', function(ns) { } } + ns.inline_report = function(target, source, data){ + $.ajax({ + url: source, + success: function (rsp) { + $(target).html(rsp); + $(target).find('.paginate').find('a').click(function(event){ ns.redirect_event(event, target) }); + $(target).find('a.report-generator-header-link').click(function(event){ ns.redirect_event(event, target) }); + }, + data: data, + }); + }; + ns.redirect_event = function(event, target){ + event.preventDefault(); + ns.inline_report(target, event.target + '', {}); + }; + + ns.load_price_rules_for_part = function(id) { + window.setTimeout(function(){ + ns.inline_report('#price_rules_customer_report', 'controller.pl', { action: 'PriceRule/list', 'filter.item_type_matches[].part': id, 'filter.type': 'customer', inline: 1 }); + ns.inline_report('#price_rules_vendor_report', 'controller.pl', { action: 'PriceRule/list', 'filter.item_type_matches[].part': id, 'filter.type': 'vendor', inline: 1 }); + }, 200); + } + $(function() { $('#price_rule_item_add').click(function() { ns.add_new_row($('#price_rules_empty_item_select').val()); @@ -43,4 +66,5 @@ namespace('kivi.PriceRule', function(ns) { $('#price_rule_price_type_help').click(ns.open_price_type_help_popup); $('#price_rule_filter_type').change(ns.on_change_filter_type); }); + }); diff --git a/templates/webpages/ic/form_footer.html b/templates/webpages/ic/form_footer.html index 977fafda8..9e0cfa52e 100644 --- a/templates/webpages/ic/form_footer.html +++ b/templates/webpages/ic/form_footer.html @@ -99,28 +99,3 @@ -[%- IF id %] - -[%- END %] -- 2.20.1