11<?php
22/**
3- * Copyright © Magento, Inc. All rights reserved.
4- * See COPYING.txt for license details .
3+ * Copyright 2014 Adobe
4+ * All Rights Reserved .
55 */
66
77/** @var \Magento\Tax\Block\Adminhtml\Rate\Form $tmpBlock */
@@ -17,13 +17,44 @@ require([
1717 "mage/adminhtml/form"
1818], function(jQuery){
1919
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 );
2121 updater.disableRegionValidation();
2222
2323 (function ($) {
2424 $(document).ready(function () {
2525 'use strict';
2626
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+
2758 var zipIsRange = $('#zip_is_range')
2859 .on('change.zipRange', function(){
2960 var elem = $(this),
0 commit comments