![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-weee/view/adminhtml/web/js/ |
/** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ define([ 'Magento_Ui/js/form/components/group', 'uiRegistry', 'Magento_Ui/js/lib/validation/validator', 'mage/translate', 'underscore' ], function (Group, uiRegistry, validation, $t, _) { 'use strict'; return Group.extend({ defaults: { visible: true, label: '', showLabel: true, required: false, template: 'ui/group/group', fieldTemplate: 'ui/form/field', breakLine: true, validateWholeGroup: false, additionalClasses: {} }, /** @inheritdoc */ initialize: function () { validation.addRule('validate-fpt-group', function (value) { if (value.indexOf('?') !== -1) { return false; } return true; }, $t( 'Set unique country-state combinations within the same fixed product tax. ' + 'Verify the combinations and try again.' )); this._super(); }, /** * * @private */ _handleOptionsAvailability: function () { var parent, dup; dup = {}; parent = uiRegistry.get(uiRegistry.get(this.parentName).parentName); _.each(parent.elems(), function (elem) { var country, state, val, key; country = uiRegistry.get(elem.name + '.countryState.country'); state = uiRegistry.get(elem.name + '.countryState.state'); val = uiRegistry.get(elem.name + '.countryState.val'); key = country.value() + (state.value() > 0 ? state.value() : 0); dup[key]++; if (!dup[key]) { dup[key] = 1; val.value(''); } else { dup[key]++; val.value(country.value() + '?' + country.name); } }); }, /** @inheritdoc */ initElement: function (elem) { var obj; obj = this; this._super(); elem.on('value', function () { obj._handleOptionsAvailability(); }); return this; } }); });