|
1 | 1 | <?php /* @var $block \Meta\Sales\Block\Adminhtml\System\Config\PullOrders */ ?>
|
2 | 2 |
|
3 | 3 | <script>
|
4 |
| - require([ |
5 |
| - 'jquery', |
6 |
| - 'prototype' |
7 |
| - ], function (jQuery) { |
8 |
| - const resultBlock = jQuery('#fb_pull_orders_result'); |
9 |
| - const responseToggle = jQuery('#fb_pull_orders_result_response_toggle'); |
10 |
| - const responseTextBlock = jQuery('#fb_pull_orders_result_response'); |
| 4 | + require([ |
| 5 | + 'jquery', |
| 6 | + 'prototype' |
| 7 | + ], function (jQuery) { |
| 8 | + const resultBlock = jQuery('#fb_pull_orders_result'); |
| 9 | + const responseToggle = jQuery('#fb_pull_orders_result_response_toggle'); |
| 10 | + const responseTextBlock = jQuery('#fb_pull_orders_result_response'); |
11 | 11 |
|
12 |
| - responseToggle.click(function () { |
13 |
| - responseTextBlock.toggle(); |
14 |
| - }); |
15 |
| - |
16 |
| - jQuery('#fb_pull_orders_btn').click(function () { |
17 |
| - const params = {}; |
18 |
| - new Ajax.Request('<?= $block->escapeUrl($block->getAjaxUrl()) ?>', { |
19 |
| - parameters: params, |
20 |
| - loaderArea: false, |
21 |
| - asynchronous: true, |
22 |
| - onCreate: function () { |
23 |
| - resultBlock.find('.fb-pull-orders-finished').hide(); |
24 |
| - resultBlock.find('.fb-pull-orders-processing').show(); |
25 |
| - jQuery('#fb_pull_orders_result_text').text(''); |
26 |
| - responseToggle.hide(); |
27 |
| - responseTextBlock.hide(); |
28 |
| - }, |
29 |
| - onSuccess: function (response) { |
30 |
| - resultBlock.find('.fb-pull-orders-processing').hide(); |
| 12 | + responseToggle.click(function () { |
| 13 | + responseTextBlock.toggle(); |
| 14 | + }); |
31 | 15 |
|
32 |
| - let resultText = ''; |
33 |
| - let resultResponse = ''; |
34 |
| - if (response.status > 200) { |
35 |
| - resultText = response.statusText; |
36 |
| - } else { |
37 |
| - resultResponse = ' (' + response.responseText + ')'; |
38 |
| - resultText = 'Finished'; |
39 |
| - resultBlock.find('.fb-pull-orders-finished').show(); |
40 |
| - } |
41 |
| - jQuery('#fb_pull_orders_result_text').text(resultText); |
42 |
| - jQuery('#fb_pull_orders_result_response').text(resultResponse); |
43 |
| - responseToggle.show(); |
44 |
| - } |
45 |
| - }); |
46 |
| - }); |
| 16 | + jQuery('#fb_pull_orders_btn').click(function () { |
| 17 | + const params = {}; |
| 18 | + new Ajax.Request('<?= $block->escapeUrl($block->getAjaxUrl()) ?>', { |
| 19 | + parameters: params, |
| 20 | + loaderArea: false, |
| 21 | + asynchronous: true, |
| 22 | + onCreate: function () { |
| 23 | + resultBlock.find('.fb-pull-orders-finished').hide(); |
| 24 | + resultBlock.find('.fb-pull-orders-processing').show(); |
| 25 | + jQuery('#fb_pull_orders_result_text').text(''); |
| 26 | + responseToggle.hide(); |
| 27 | + responseTextBlock.hide(); |
| 28 | + }, |
| 29 | + onSuccess: function (response) { |
| 30 | + resultBlock.find('.fb-pull-orders-processing').hide(); |
47 | 31 |
|
| 32 | + let resultText = ''; |
| 33 | + let resultResponse = ''; |
| 34 | + if (response.status > 200) { |
| 35 | + resultText = response.statusText; |
| 36 | + } else { |
| 37 | + resultText = 'Finished'; |
| 38 | + resultBlock.find('.fb-pull-orders-finished').show(); |
| 39 | + } |
| 40 | + jQuery('#fb_pull_orders_result_text').text(resultText); |
| 41 | + let jsonObject = JSON.parse(response.responseText); |
| 42 | + let prettyJsonString = JSON.stringify(jsonObject, null, 2); |
| 43 | + jQuery('#fb_pull_orders_result_response').html('<pre style="white-space: pre-wrap;">' + prettyJsonString + '</pre>'); |
| 44 | + responseToggle.show(); |
| 45 | + } |
| 46 | + }); |
48 | 47 | });
|
| 48 | + |
| 49 | + }); |
49 | 50 | </script>
|
50 | 51 |
|
51 |
| -<?= /* @noEscape */ $block->getButtonHtml() ?> |
| 52 | +<?= /* @noEscape */ |
| 53 | +$block->getButtonHtml() ?> |
52 | 54 | <span id="fb_pull_orders_result">
|
53 | 55 | <img class="fb-pull-orders-processing" hidden="hidden" alt="Processing" style="margin:0 5px" src=
|
54 |
| - "<?= $block->escapeUrl($block->getViewFileUrl('images/process_spinner.gif')) ?>" |
| 56 | + "<?= $block->escapeUrl($block->getViewFileUrl('images/process_spinner.gif')) ?>" |
55 | 57 | />
|
56 |
| - <img class="fb-pull-orders-finished" hidden="hidden" alt="Finished" style="margin:-3px 5px" src= |
57 |
| - "<?= $block->escapeUrl($block->getViewFileUrl('images/rule_component_apply.gif')) ?>" |
| 58 | + <img class="fb-pull-orders-finished" hidden="hidden" alt="Finished" style="margin:-3px 5px" src= |
| 59 | + "<?= $block->escapeUrl($block->getViewFileUrl('images/rule_component_apply.gif')) ?>" |
58 | 60 | />
|
59 | 61 | <span id="fb_pull_orders_result_text"></span>
|
60 | 62 | <span id="fb_pull_orders_result_response_toggle"
|
|
0 commit comments