Skip to content

Commit 8d21b9f

Browse files
author
Ihor Melnychenko
committed
MAGETWO-45294: JS error on creditmemo view grid during export to CSV
1 parent f85e691 commit 8d21b9f

File tree

1 file changed

+29
-14
lines changed
  • app/code/Magento/Ui/view/base/web/js/grid

1 file changed

+29
-14
lines changed

app/code/Magento/Ui/view/base/web/js/grid/export.js

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
define([
66
'jquery',
77
'underscore',
8-
'uiElement'
9-
], function ($, _, Element) {
8+
'uiElement',
9+
'Magento_Ui/js/modal/alert',
10+
'mage/translate'
11+
], function ($, _, Element, alert) {
1012
'use strict';
1113

1214
return Element.extend({
1315
defaults: {
1416
template: 'ui/grid/exportButton',
1517
checked: '',
18+
title: $.mage.__('Attention'),
19+
message: $.mage.__('You haven\'t selected any items!'),
20+
1621
modules: {
1722
selections: '${ $.selectProvider }'
1823
}
@@ -36,23 +41,28 @@ define([
3641
this.options[0].value
3742
);
3843
}
44+
3945
return this;
4046
},
4147

4248
getParams: function () {
4349
var selections = this.selections(),
44-
data = selections.getSelections(),
50+
data = selections ? selections.getSelections() : {},
4551
itemsType = data.excludeMode ? 'excluded' : 'selected',
46-
result = {};
52+
result;
4753

48-
result['filters'] = data.params.filters;
49-
result['search'] = data.params.search;
50-
result['namespace'] = data.params.namespace;
51-
result[itemsType] = data[itemsType];
54+
if (selections) {
55+
result = {};
56+
result.filters = data.params.filters;
57+
result.search = data.params.search;
58+
result.namespace = data.params.namespace;
59+
result[itemsType] = data[itemsType];
5260

53-
if (!result[itemsType].length) {
54-
result[itemsType] = false;
61+
if (!result[itemsType].length) {
62+
result[itemsType] = false;
63+
}
5564
}
65+
5666
return result;
5767
},
5868

@@ -63,16 +73,21 @@ define([
6373
},
6474

6575
buildOptionUrl: function (option) {
66-
var url = option.url + '?';
67-
68-
return url + $.param(this.getParams());
76+
return this.getParams() ? option.url + '?' + $.param(this.getParams()) : '';
6977
},
7078

7179
applyOption: function () {
7280
var option = this.getActiveOption(),
7381
url = this.buildOptionUrl(option);
7482

75-
location.href = url;
83+
if (url) {
84+
location.href = url;
85+
} else {
86+
alert({
87+
title: this.title,
88+
content: this.message
89+
});
90+
}
7691
}
7792
});
7893
});

0 commit comments

Comments
 (0)