Skip to content

Commit 4e8985f

Browse files
author
Oleksandr Dubovyk
committed
MAGETWO-71785: [Magento Cloud] - Issue with long url
- fixed
1 parent beb058c commit 4e8985f

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

lib/web/mage/adminhtml/grid.js

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,45 @@ define([
368368
return url;
369369
},
370370

371+
/**
372+
* Builds the form with fields containing the and submits
373+
*
374+
* @param {String} url
375+
* @param {String} varName
376+
* @param {String} varValue
377+
* @private
378+
*/
379+
_buildFormAndSubmit: function (url, varName, varValue) {
380+
var re = new RegExp('\/(' + varName + '\/.*?\/)'),
381+
parts = url.split(new RegExp('\\?')),
382+
form = jQuery('<form/>'),
383+
inputProps = [
384+
{name: varName, value: varValue},
385+
{name: 'form_key', value: window.FORM_KEY}
386+
],
387+
input;
388+
389+
url = parts[0].replace(re, '/');
390+
391+
if (parts.size() > 1) {
392+
url += '?' + parts[1];
393+
}
394+
395+
form.attr('action', url);
396+
form.attr('method', 'POST');
397+
398+
inputProps.forEach(function (item) {
399+
input = jQuery('<input/>');
400+
input.attr('name', item.name);
401+
input.attr('type', 'hidden');
402+
input.val(item.value);
403+
form.append(input);
404+
});
405+
jQuery('[data-container="body"]').append(form);
406+
form.submit();
407+
form.remove();
408+
},
409+
371410
/**
372411
* @param {*} varName
373412
* @param {*} varValue
@@ -389,13 +428,14 @@ define([
389428
exportUrl = $(this.containerId + '_export').value;
390429

391430
if (this.massaction && this.massaction.checkedString) {
392-
exportUrl = this._addVarToUrl(
431+
this._buildFormAndSubmit(
393432
exportUrl,
394433
this.massaction.formFieldNameInternal,
395434
this.massaction.checkedString
396435
);
436+
} else {
437+
location.href = exportUrl;
397438
}
398-
location.href = exportUrl;
399439
}
400440
},
401441

0 commit comments

Comments
 (0)