Skip to content

Commit

Permalink
Merge pull request #21 from surprisehighway/release/2.1.1
Browse files Browse the repository at this point in the history
Release/2.1.1
  • Loading branch information
imagehat authored Jun 8, 2020
2 parents 0655e5e + 1be1dc2 commit 2df2566
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 44 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
51 changes: 8 additions & 43 deletions src/templates/settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>#{setting}</code> setting in the <code>config/avatax.php</code> 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 %}

<input type="hidden" name="action" value="plugins/save-plugin-settings">
<input type="hidden" name="pluginHandle" value="avatax">

Expand Down Expand Up @@ -65,7 +52,6 @@
name: 'accountId',
value: settings['accountId'],
warning: configWarning('accountId'),
readonly: configDisabled('accountId'),
errors: settings.getErrors('accountId')
})
}}
Expand All @@ -77,7 +63,6 @@
name: 'licenseKey',
value: settings['licenseKey'],
warning: configWarning('licenseKey'),
readonly: configDisabled('licenseKey'),
errors: settings.getErrors('licenseKey')
})
}}
Expand All @@ -89,7 +74,6 @@
name: 'companyCode',
value: settings['companyCode'],
warning: configWarning('companyCode'),
readonly: configDisabled('companyCode'),
errors: settings.getErrors('companyCode')
})
}}
Expand All @@ -105,7 +89,6 @@
name: 'sandboxAccountId',
value: settings['sandboxAccountId'],
warning: configWarning('sandboxAccountId'),
readonly: configDisabled('sandboxAccountId'),
errors: settings.getErrors('sandboxAccountId')
})
}}
Expand All @@ -117,7 +100,6 @@
name: 'sandboxLicenseKey',
value: settings['sandboxLicenseKey'],
warning: configWarning('sandboxLicenseKey'),
readonly: configDisabled('sandboxLicenseKey'),
errors: settings.getErrors('sandboxLicenseKey')
})
}}
Expand All @@ -129,7 +111,6 @@
name: 'sandboxCompanyCode',
value: settings['sandboxCompanyCode'],
warning: configWarning('sandboxCompanyCode'),
readonly: configDisabled('sandboxCompanyCode'),
errors: settings.getErrors('sandboxCompanyCode')
})
}}
Expand All @@ -139,7 +120,7 @@
<h2>Origin Ship From Address</h2>


{% if (configDisabled('shipFromName') or configDisabled('shipFromZipCode')) %}
{% if (configWarning('shipFromName') or configWarning('shipFromZipCode')) %}
<div class="field">
<p class="warning">Origin Ship From Address is being overridden by the shipFrom config setting in your `avataxtax.php` config file.</p>
</div>
Expand All @@ -153,7 +134,6 @@
name: 'shipFromName',
value: settings.shipFromName,
required: true,
readonly: configDisabled('shipFromName'),
errors: settings.getErrors('shipFromName')
})
}}
Expand All @@ -165,7 +145,6 @@
name: 'shipFromStreet1',
value: settings.shipFromStreet1,
required: true,
readonly: configDisabled('shipFromStreet1'),
errors: settings.getErrors('shipFromStreet1')
})
}}
Expand All @@ -176,7 +155,6 @@
id: 'shipFromStreet2',
name: 'shipFromStreet2',
value: settings.shipFromStreet2,
readonly: configDisabled('shipFromStreet2'),
errors: settings.getErrors('shipFromStreet2')
})
}}
Expand All @@ -187,7 +165,6 @@
id: 'shipFromStreet3',
name: 'shipFromStreet3',
value: settings.shipFromStreet3,
readonly: configDisabled('shipFromStreet3'),
errors: settings.getErrors('shipFromStreet3')
})
}}
Expand All @@ -201,7 +178,6 @@
name: 'shipFromCity',
value: settings.shipFromCity,
required: true,
readonly: configDisabled('shipFromCity'),
errors: settings.getErrors('shipFromCity')
})
}}
Expand All @@ -214,7 +190,6 @@
name: 'shipFromState',
value: settings.shipFromState,
required: true,
readonly: configDisabled('shipFromState'),
errors: settings.getErrors('shipFromState')
})
}}
Expand All @@ -230,7 +205,6 @@
name: 'shipFromCountry',
value: settings.shipFromCountry,
required: true,
readonly: configDisabled('shipFromCountry'),
errors: settings.getErrors('shipFromCountry')
})
}}
Expand All @@ -243,14 +217,13 @@
name: 'shipFromZipCode',
value: settings.shipFromZipCode,
required: true,
readonly: configDisabled('shipFromZipCode'),
errors: settings.getErrors('shipFromZipCode')
})
}}
</div>
</div>

{% if (configDisabled('shipFromName') or configDisabled('shipFromZipCode')) %}
{% if (configWarning('shipFromName') or configWarning('shipFromZipCode')) %}
<div class="field">
<p class="warning">Origin Ship From Address is being overridden by the shipFrom config setting in your `avataxtax.php` config file.</p>
</div>
Expand All @@ -267,7 +240,6 @@
name: 'defaultTaxCode',
value: settings.defaultTaxCode,
required: true,
readonly: configDisabled('defaultTaxCode'),
warning: configWarning('defaultTaxCode'),
errors: settings.getErrors('defaultTaxCode')
})
Expand All @@ -280,7 +252,6 @@
name: 'defaultShippingCode',
value: settings.defaultShippingCode,
required: true,
readonly: configDisabled('defaultShippingCode'),
warning: configWarning('defaultShippingCode'),
errors: settings.getErrors('defaultShippingCode')
})
Expand All @@ -293,7 +264,6 @@
name: 'defaultDiscountCode',
value: settings.defaultDiscountCode,
required: true,
readonly: configDisabled('defaultDiscountCode'),
warning: configWarning('defaultDiscountCode'),
errors: settings.getErrors('defaultDiscountCode')
})
Expand All @@ -315,12 +285,11 @@
id: 'enableTaxCalculation',
name: 'enableTaxCalculation',
on: settings['enableTaxCalculation'],
readonly: configDisabled('enableTaxCalculation'),
errors: settings.getErrors('enableTaxCalculation')
})
}}

{% if configDisabled('enableTaxCalculation') %}
{% if configWarning('enableTaxCalculation') %}
<p class="warning">{{ configWarning('enableTaxCalculation') }}</p>
{% endif %}
</div>
Expand All @@ -337,12 +306,11 @@
id: 'enableCommitting',
name: 'enableCommitting',
on: settings['enableCommitting'],
readonly: configDisabled('enableCommitting'),
errors: settings.getErrors('enableCommitting')
})
}}

{% if configDisabled('enableCommitting') %}
{% if configWarning('enableCommitting') %}
<p class="warning">{{ configWarning('enableCommitting') }}</p>
{% endif %}
</div>
Expand All @@ -359,12 +327,11 @@
id: 'enableAddressValidation',
name: 'enableAddressValidation',
on: settings['enableAddressValidation'],
readonly: configDisabled('enableAddressValidation'),
errors: settings.getErrors('enableAddressValidation')
})
}}

{% if configDisabled('enableAddressValidation') %}
{% if configWarning('enableAddressValidation') %}
<p class="warning">{{ configWarning('enableAddressValidation') }}</p>
{% endif %}
</div>
Expand All @@ -381,12 +348,11 @@
id: 'enablePartialRefunds',
name: 'enablePartialRefunds',
on: settings['enablePartialRefunds'],
readonly: configDisabled('enablePartialRefunds'),
errors: settings.getErrors('enablePartialRefunds')
})
}}

{% if configDisabled('enablePartialRefunds') %}
{% if configWarning('enablePartialRefunds') %}
<p class="warning">{{ configWarning('enablePartialRefunds') }}</p>
{% endif %}
</div>
Expand All @@ -407,12 +373,11 @@
id: 'debug',
name: 'debug',
on: settings.debug,
readonly: configDisabled('debug'),
errors: settings.getErrors('debug')
})
}}

{% if configDisabled('debug') %}
{% if configWarning('debug') %}
<p class="warning">{{ configWarning('debug') }}</p>
{% endif %}
</div>
Expand Down

0 comments on commit 2df2566

Please sign in to comment.