Skip to content

Commit

Permalink
change configs
Browse files Browse the repository at this point in the history
  • Loading branch information
mfilip committed Jun 21, 2024
1 parent 7b4a6b6 commit f6b078d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 26 deletions.
51 changes: 34 additions & 17 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,6 @@
showInStore="1"
>
<label>Data</label>
<field
id="populate_organisation"
type="select"
translate="label,comment"
sortOrder="60"
showInDefault="1"
showInWebsite="1"
showInStore="1"
>
<label>Populate Organisation</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>idealpostcodes/settings/populate_organisation</config_path>
<comment>Fill the Company field based on selected address.</comment>
<depends>
<field id="enabled">1</field>
</depends>
</field>
<field
id="require_county"
type="select"
Expand Down Expand Up @@ -167,6 +150,23 @@
<field id="enabled">1</field>
</depends>
</field>
<field
id="remove_organisation_store"
type="select"
translate="label,comment"
sortOrder="90"
showInDefault="1"
showInWebsite="1"
showInStore="1"
>
<label>Remove Organisation</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>idealpostcodes/settings/remove_organisation_store</config_path>
<comment>Remove organisation name from first line of address.</comment>
<depends>
<field id="enabled">1</field>
</depends>
</field>
</group>
<group
id="store_admin_configuration"
Expand Down Expand Up @@ -196,6 +196,23 @@
<field id="enabled">1</field>
</depends>
</field>
<field
id="remove_organisation_admin"
type="select"
translate="label,comment"
sortOrder="90"
showInDefault="1"
showInWebsite="1"
showInStore="1"
>
<label>Remove Organisation</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>idealpostcodes/settings/remove_organisation_admin</config_path>
<comment>Remove organisation name from first line of address.</comment>
<depends>
<field id="enable_admin_integration">1</field>
</depends>
</field>
</group>
<group
id="admin"
Expand Down
3 changes: 2 additions & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<postcode_lookup>1</postcode_lookup>
<autocomplete>1</autocomplete>
<admin_autocomplete>1</admin_autocomplete>
<populate_organisation>1</populate_organisation>
<remove_organisation_store>1</remove_organisation_store>
<remove_organisation_admin>1</remove_organisation_admin>
<require_county>0</require_county>
<hoist_country>1</hoist_country>
<autocomplete_override>{}</autocomplete_override>
Expand Down
4 changes: 2 additions & 2 deletions view/adminhtml/templates/admin.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $script = '
document.addEventListener(\'DOMContentLoaded\', function() {
var apiKey = "' . $helper->getConfig('api_key') . '";
var autocomplete = ' . $helper->getConfig('addressAutocomplete') . ';
var populateOrganisation = ' . $helper->getConfig('populateOrganisation') . ';
var removeOrganisation = ' . $helper->getConfig('removeOrganisation') . ';
var populateCounty = ' . $helper->getConfig('requireCounty') . ';
var enabled = ' . $helper->getConfig('enabled') . ';
var customFields = ' . trim(preg_replace("/\r|\n/", "", $helper->getConfig('customFields'))) . ';
Expand All @@ -16,7 +16,7 @@ document.addEventListener(\'DOMContentLoaded\', function() {
postcodeLookup: false,
autocomplete: autocomplete,
populateCounty: populateCounty,
populateOrganisation: populateOrganisation,
removeOrganisation: removeOrganisation,
hoistCountry: false,
customFields: customFields
};
Expand Down
11 changes: 5 additions & 6 deletions view/frontend/templates/store.phtml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php
$helper = $this->helper('Idealpostcodes\Ukaddresssearch\Helper\Data'); ?>

<?php
$helper = $this->helper('Idealpostcodes\Ukaddresssearch\Helper\Data');
$script = '
console.log("should be here");
document.addEventListener(\'DOMContentLoaded\', function() {
var apiKey = "' . $helper->getConfig('api_key') . '";
var postcodeLookup = ' . $helper->getConfig('postcodeLookup') . ';
var autocomplete = ' . $helper->getConfig('addressAutocomplete') . ';
var populateOrganisation = ' . $helper->getConfig('populateOrganisation') . ';
var removeOrganisation = ' . $helper->getConfig('removeOrganisation') . ';
var hoistCountry = ' . $helper->getConfig('hoistCountryField') . ';
var populateCounty = ' . $helper->getConfig('requireCounty') . ';
var autocompleteOverride = ' . $helper->getConfig('autocompleteOverride') . ';
Expand All @@ -21,7 +20,7 @@ document.addEventListener(\'DOMContentLoaded\', function() {
postcodeLookup: postcodeLookup,
autocomplete: autocomplete,
populateCounty: populateCounty,
populateOrganisation: populateOrganisation,
removeOrganisation: removeOrganisation,
hoistCountry: hoistCountry,
autocompleteOverride: autocompleteOverride,
postcodeLookupOverride: postcodeLookupOverride,
Expand All @@ -31,4 +30,4 @@ document.addEventListener(\'DOMContentLoaded\', function() {
});
';
?>
<?= $secureRenderer->renderTag('script', [], $script, false); ?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', ['type' => 'text/javascript', 'id' => 'idpc-config'], $script, false); ?>

0 comments on commit f6b078d

Please sign in to comment.