Skip to content

Commit 8c188fc

Browse files
ENGCOM-5823: [Tax] Confirmation popup improvement #24538
- Merge Pull Request #24538 from eduard13/magento2:2.3-develop-24537-issue - Merged commits: 1. 635c38f 2. 054d959
2 parents 90b9c43 + 054d959 commit 8c188fc

File tree

1 file changed

+47
-41
lines changed
  • app/code/Magento/Tax/view/adminhtml/templates/rule

1 file changed

+47
-41
lines changed

app/code/Magento/Tax/view/adminhtml/templates/rule/edit.phtml

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
require([
1111
'jquery',
1212
'Magento_Ui/js/modal/alert',
13+
'Magento_Ui/js/modal/confirm',
1314
"jquery/ui",
1415
'mage/multiselect',
1516
"mage/mage",
1617
'Magento_Ui/js/modal/modal'
17-
], function($, alert){
18+
], function($, alert, confirm) {
1819

1920
$.widget("adminhtml.dialogRates", $.mage.modal, {
2021
options: {
@@ -160,53 +161,58 @@ require([
160161
taxRateField.find('.mselect-list')
161162
.on('click.mselect-edit', '.mselect-edit', this.edit)
162163
.on("click.mselect-delete", ".mselect-delete", function () {
163-
if (!confirm('<?= $block->escapeJs(__('Do you really want to delete this tax rate?')) ?>')) {
164-
return;
165-
}
166-
167164
var that = $(this),
168165
select = that.closest('.mselect-list').prev(),
169166
rateValue = that.parent().find('input[type="checkbox"]').val();
170167

171-
$('body').trigger('processStart');
172-
var ajaxOptions = {
173-
type: 'POST',
174-
data: {
175-
tax_calculation_rate_id: rateValue,
176-
form_key: $('input[name="form_key"]').val()
177-
},
178-
dataType: 'json',
179-
url: '<?= $block->escapeJs($block->escapeUrl($block->getTaxRateDeleteUrl())) ?>',
180-
success: function(result, status) {
181-
$('body').trigger('processStop');
182-
if (result.success) {
183-
that.parent().remove();
184-
select.find('option').each(function() {
185-
if (this.value === rateValue) {
186-
$(this).remove();
168+
confirm({
169+
content: '<?= $block->escapeJs(__('Do you really want to delete this tax rate?')) ?>',
170+
actions: {
171+
/**
172+
* Confirm action.
173+
*/
174+
confirm: function () {
175+
$('body').trigger('processStart');
176+
var ajaxOptions = {
177+
type: 'POST',
178+
data: {
179+
tax_calculation_rate_id: rateValue,
180+
form_key: $('input[name="form_key"]').val()
181+
},
182+
dataType: 'json',
183+
url: '<?= $block->escapeJs($block->escapeUrl($block->getTaxRateDeleteUrl())) ?>',
184+
success: function(result, status) {
185+
$('body').trigger('processStop');
186+
if (result.success) {
187+
that.parent().remove();
188+
select.find('option').each(function() {
189+
if (this.value === rateValue) {
190+
$(this).remove();
191+
}
192+
});
193+
select.trigger('change.hiddenSelect');
194+
} else {
195+
if (result.error_message)
196+
alert({
197+
content: result.error_message
198+
});
199+
else
200+
alert({
201+
content: '<?= $block->escapeJs($block->escapeHtml(__('An error occurred'))) ?>'
202+
});
203+
}
204+
},
205+
error: function () {
206+
$('body').trigger('processStop');
207+
alert({
208+
content: '<?= $block->escapeJs($block->escapeHtml(__('An error occurred'))) ?>'
209+
});
187210
}
188-
});
189-
select.trigger('change.hiddenSelect');
190-
} else {
191-
if (result.error_message)
192-
alert({
193-
content: result.error_message
194-
});
195-
else
196-
alert({
197-
content: '<?= $block->escapeJs($block->escapeHtml(__('An error occurred'))) ?>'
198-
});
211+
};
212+
$.ajax(ajaxOptions);
199213
}
200-
},
201-
error: function () {
202-
$('body').trigger('processStop');
203-
alert({
204-
content: '<?= $block->escapeJs($block->escapeHtml(__('An error occurred'))) ?>'
205-
});
206214
}
207-
};
208-
$.ajax(ajaxOptions);
209-
215+
});
210216
})
211217
.on('click.mselectAdd', '.mselect-button-add', function () {
212218
taxRateForm

0 commit comments

Comments
 (0)