1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2014 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
7
7
/** @var \Magento\Tax\Block\Adminhtml\Rate\Form $tmpBlock */
@@ -17,13 +17,44 @@ require([
17
17
"mage/adminhtml/form"
18
18
], function(jQuery){
19
19
20
- var updater = new RegionUpdater('tax_country_id', 'tax_region', 'tax_region_id', {$ regionJson }, 'disable');
20
+ var updater = new RegionUpdater('tax_country_id', 'tax_region', 'tax_region_id', {$ regionJson }, 'disable', true );
21
21
updater.disableRegionValidation();
22
22
23
23
(function ($) {
24
24
$(document).ready(function () {
25
25
'use strict';
26
26
27
+ function enforceWildcard() {
28
+ var country = $('#tax_country_id').val(),
29
+ selectEl = document.getElementById('tax_region_id'),
30
+ textEl = document.getElementById('tax_region'),
31
+ hasRegions = !!(window.updater && window.updater.sortedRegions &&
32
+ window.updater.sortedRegions[country] &&
33
+ window.updater.sortedRegions[country].length);
34
+
35
+ if (!hasRegions && selectEl) {
36
+ var hasWildcard = false, i;
37
+
38
+ for (i = 0; i < selectEl.options.length; i++) {
39
+ if (selectEl.options[i].value === '*') { hasWildcard = true; break; }
40
+ }
41
+ if (!hasWildcard) {
42
+ var opt = document.createElement('option');
43
+ opt.value = '*';
44
+ opt.text = '*';
45
+ opt.title = '*';
46
+ try { selectEl.options.add(opt, 1); } catch (e) { selectEl.insertBefore(opt, selectEl.options[1] || null); }
47
+ }
48
+ selectEl.value = '*';
49
+ selectEl.disabled = true; // keep disable mode
50
+ }
51
+ if (!hasRegions && textEl) {
52
+ textEl.value = '*';
53
+ }
54
+ }
55
+ $('#tax_country_id').on('change', function () { setTimeout(enforceWildcard, 0); });
56
+ setTimeout(enforceWildcard, 0);
57
+
27
58
var zipIsRange = $('#zip_is_range')
28
59
.on('change.zipRange', function(){
29
60
var elem = $(this),
0 commit comments