diff --git a/CHANGELOG.md b/CHANGELOG.md index bd27f73..cf4bfec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 2.1.1 +### Fixed +- Fixed an issue where settings fields were readonly even when not being overridden by config file. [#20](https://github.com/surprisehighway/craft-avatax/issues/20) + ## 2.1.0 - 2020-02-20 ### Added - Added Commerce 3 compatibility. diff --git a/composer.json b/composer.json index 2ed819e..0dfaafa 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "surprisehighway/craft-avatax", "description": "Calculate and add sales tax to an order's base tax using Avalara's Avatax service.", "type": "craft-plugin", - "version": "2.1.0", + "version": "2.1.1", "keywords": [ "craft", "cms", diff --git a/src/templates/settings.twig b/src/templates/settings.twig index 610e4f1..dc49f58 100644 --- a/src/templates/settings.twig +++ b/src/templates/settings.twig @@ -11,25 +11,12 @@ {% macro configWarning(setting) -%} {%- set configArray = craft.app.config.getConfigFromFile("avatax") -%} {%- if configArray[setting] is defined -%} - {{- "This is being overridden by the `#{setting}` setting in the `config/avatax.php` file."|raw }} - {%- else -%} - {{ false }} + {{- "This is being overridden by the #{setting} setting in the config/avatax.php file."|raw }} {%- endif -%} {%- endmacro %} {% from _self import configWarning %} -{% macro configDisabled(setting) -%} - {%- set configArray = craft.app.config.getConfigFromFile("avatax") -%} - {%- if configArray[setting] is defined -%} - {{ true }} - {%- else -%} - {{ false }} - {%- endif -%} -{%- endmacro %} - -{% from _self import configDisabled %} - @@ -65,7 +52,6 @@ name: 'accountId', value: settings['accountId'], warning: configWarning('accountId'), - readonly: configDisabled('accountId'), errors: settings.getErrors('accountId') }) }} @@ -77,7 +63,6 @@ name: 'licenseKey', value: settings['licenseKey'], warning: configWarning('licenseKey'), - readonly: configDisabled('licenseKey'), errors: settings.getErrors('licenseKey') }) }} @@ -89,7 +74,6 @@ name: 'companyCode', value: settings['companyCode'], warning: configWarning('companyCode'), - readonly: configDisabled('companyCode'), errors: settings.getErrors('companyCode') }) }} @@ -105,7 +89,6 @@ name: 'sandboxAccountId', value: settings['sandboxAccountId'], warning: configWarning('sandboxAccountId'), - readonly: configDisabled('sandboxAccountId'), errors: settings.getErrors('sandboxAccountId') }) }} @@ -117,7 +100,6 @@ name: 'sandboxLicenseKey', value: settings['sandboxLicenseKey'], warning: configWarning('sandboxLicenseKey'), - readonly: configDisabled('sandboxLicenseKey'), errors: settings.getErrors('sandboxLicenseKey') }) }} @@ -129,7 +111,6 @@ name: 'sandboxCompanyCode', value: settings['sandboxCompanyCode'], warning: configWarning('sandboxCompanyCode'), - readonly: configDisabled('sandboxCompanyCode'), errors: settings.getErrors('sandboxCompanyCode') }) }} @@ -139,7 +120,7 @@

Origin Ship From Address

- {% if (configDisabled('shipFromName') or configDisabled('shipFromZipCode')) %} + {% if (configWarning('shipFromName') or configWarning('shipFromZipCode')) %}

Origin Ship From Address is being overridden by the shipFrom config setting in your `avataxtax.php` config file.

@@ -153,7 +134,6 @@ name: 'shipFromName', value: settings.shipFromName, required: true, - readonly: configDisabled('shipFromName'), errors: settings.getErrors('shipFromName') }) }} @@ -165,7 +145,6 @@ name: 'shipFromStreet1', value: settings.shipFromStreet1, required: true, - readonly: configDisabled('shipFromStreet1'), errors: settings.getErrors('shipFromStreet1') }) }} @@ -176,7 +155,6 @@ id: 'shipFromStreet2', name: 'shipFromStreet2', value: settings.shipFromStreet2, - readonly: configDisabled('shipFromStreet2'), errors: settings.getErrors('shipFromStreet2') }) }} @@ -187,7 +165,6 @@ id: 'shipFromStreet3', name: 'shipFromStreet3', value: settings.shipFromStreet3, - readonly: configDisabled('shipFromStreet3'), errors: settings.getErrors('shipFromStreet3') }) }} @@ -201,7 +178,6 @@ name: 'shipFromCity', value: settings.shipFromCity, required: true, - readonly: configDisabled('shipFromCity'), errors: settings.getErrors('shipFromCity') }) }} @@ -214,7 +190,6 @@ name: 'shipFromState', value: settings.shipFromState, required: true, - readonly: configDisabled('shipFromState'), errors: settings.getErrors('shipFromState') }) }} @@ -230,7 +205,6 @@ name: 'shipFromCountry', value: settings.shipFromCountry, required: true, - readonly: configDisabled('shipFromCountry'), errors: settings.getErrors('shipFromCountry') }) }} @@ -243,14 +217,13 @@ name: 'shipFromZipCode', value: settings.shipFromZipCode, required: true, - readonly: configDisabled('shipFromZipCode'), errors: settings.getErrors('shipFromZipCode') }) }} - {% if (configDisabled('shipFromName') or configDisabled('shipFromZipCode')) %} + {% if (configWarning('shipFromName') or configWarning('shipFromZipCode')) %}

Origin Ship From Address is being overridden by the shipFrom config setting in your `avataxtax.php` config file.

@@ -267,7 +240,6 @@ name: 'defaultTaxCode', value: settings.defaultTaxCode, required: true, - readonly: configDisabled('defaultTaxCode'), warning: configWarning('defaultTaxCode'), errors: settings.getErrors('defaultTaxCode') }) @@ -280,7 +252,6 @@ name: 'defaultShippingCode', value: settings.defaultShippingCode, required: true, - readonly: configDisabled('defaultShippingCode'), warning: configWarning('defaultShippingCode'), errors: settings.getErrors('defaultShippingCode') }) @@ -293,7 +264,6 @@ name: 'defaultDiscountCode', value: settings.defaultDiscountCode, required: true, - readonly: configDisabled('defaultDiscountCode'), warning: configWarning('defaultDiscountCode'), errors: settings.getErrors('defaultDiscountCode') }) @@ -315,12 +285,11 @@ id: 'enableTaxCalculation', name: 'enableTaxCalculation', on: settings['enableTaxCalculation'], - readonly: configDisabled('enableTaxCalculation'), errors: settings.getErrors('enableTaxCalculation') }) }} - {% if configDisabled('enableTaxCalculation') %} + {% if configWarning('enableTaxCalculation') %}

{{ configWarning('enableTaxCalculation') }}

{% endif %} @@ -337,12 +306,11 @@ id: 'enableCommitting', name: 'enableCommitting', on: settings['enableCommitting'], - readonly: configDisabled('enableCommitting'), errors: settings.getErrors('enableCommitting') }) }} - {% if configDisabled('enableCommitting') %} + {% if configWarning('enableCommitting') %}

{{ configWarning('enableCommitting') }}

{% endif %} @@ -359,12 +327,11 @@ id: 'enableAddressValidation', name: 'enableAddressValidation', on: settings['enableAddressValidation'], - readonly: configDisabled('enableAddressValidation'), errors: settings.getErrors('enableAddressValidation') }) }} - {% if configDisabled('enableAddressValidation') %} + {% if configWarning('enableAddressValidation') %}

{{ configWarning('enableAddressValidation') }}

{% endif %} @@ -381,12 +348,11 @@ id: 'enablePartialRefunds', name: 'enablePartialRefunds', on: settings['enablePartialRefunds'], - readonly: configDisabled('enablePartialRefunds'), errors: settings.getErrors('enablePartialRefunds') }) }} - {% if configDisabled('enablePartialRefunds') %} + {% if configWarning('enablePartialRefunds') %}

{{ configWarning('enablePartialRefunds') }}

{% endif %} @@ -407,12 +373,11 @@ id: 'debug', name: 'debug', on: settings.debug, - readonly: configDisabled('debug'), errors: settings.getErrors('debug') }) }} - {% if configDisabled('debug') %} + {% if configWarning('debug') %}

{{ configWarning('debug') }}

{% endif %}