1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2013 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
7
7
/** @var \Magento\Tax\Block\Adminhtml\Rate\Form $tmpBlock */
@@ -17,13 +17,49 @@ 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 {
47
+ selectEl.options.add(opt, 1);
48
+ } catch (e)
49
+ {
50
+ selectEl.insertBefore(opt, selectEl.options[1] || null);
51
+ }
52
+ }
53
+ selectEl.value = '*';
54
+ selectEl.disabled = true; // keep disable mode
55
+ }
56
+ if (!hasRegions && textEl) {
57
+ textEl.value = '*';
58
+ }
59
+ }
60
+ $('#tax_country_id').on('change', function () { setTimeout(enforceWildcard, 0); });
61
+ setTimeout(enforceWildcard, 0);
62
+
27
63
var zipIsRange = $('#zip_is_range')
28
64
.on('change.zipRange', function(){
29
65
var elem = $(this),
0 commit comments