diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2021-02-03 16:25:48 +0000 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2021-02-03 16:25:48 +0000 |
| commit | a45ad69d9fe14e475a431f9eb0e7184dab266144 (patch) | |
| tree | cbfd4bc9eba6ff829a2ec1241a7b090858be9b13 /resources | |
| parent | e04233f94df2a4ebf85185b9e8350a7369ed80a8 (diff) | |
| download | webtrees-a45ad69d9fe14e475a431f9eb0e7184dab266144.tar.gz webtrees-a45ad69d9fe14e475a431f9eb0e7184dab266144.tar.bz2 webtrees-a45ad69d9fe14e475a431f9eb0e7184dab266144.zip | |
Fix: #3707 - populate place name from geocoder when adding new place
Diffstat (limited to 'resources')
| -rw-r--r-- | resources/views/admin/location-edit.phtml | 3 | ||||
| -rw-r--r-- | resources/views/edit/input-addon-edit-name.phtml | 66 |
2 files changed, 68 insertions, 1 deletions
diff --git a/resources/views/admin/location-edit.phtml b/resources/views/admin/location-edit.phtml index 1a2f7093cd..e99abc4f6d 100644 --- a/resources/views/admin/location-edit.phtml +++ b/resources/views/admin/location-edit.phtml @@ -97,7 +97,8 @@ use Fisharebest\Webtrees\View; let provider = <?= json_encode($provider) ?>; let map = null; - let add_place = <?= json_encode($location->id() === 0) ?>; + let add_place = <?= json_encode($location->id() === null) ?>; + console.log(add_place); // map components diff --git a/resources/views/edit/input-addon-edit-name.phtml b/resources/views/edit/input-addon-edit-name.phtml new file mode 100644 index 0000000000..4d020a686e --- /dev/null +++ b/resources/views/edit/input-addon-edit-name.phtml @@ -0,0 +1,66 @@ +<?php + +use Fisharebest\Webtrees\I18N; + +?> + +<div class="input-group-prepend"> + <span class="input-group-text"> + <a id="<?= e($id) ?>-edit" href="#" title="<?= I18N::translate('Edit the name') ?>"> + <?= view('icons/edit') ?> + <span class="sr-only"> + <?= I18N::translate('Edit the name') ?> + </span> + </a> + </span> +</div> +<script> + document.getElementById('<?= e($id) ?>-edit').addEventListener('click', function (event) { + event.preventDefault(); + let element = document.getElementById('<?= e($id) ?>'); + element.readOnly = false; + element.focus(); + + let input_addon = this.parentNode.parentNode; + input_addon.parentNode.removeChild(input_addon); + }); + document.addEventListener('DOMContentLoaded', function () { + let container = document.getElementById('<?= e($id) ?>').parentNode.parentNode.parentNode.parentNode; + let NAME = container.querySelector('[id$="INDI:NAME"]'); + let NPFX = container.querySelector('[id$="INDI:NAME:NPFX"]'); + let GIVN = container.querySelector('[id$="INDI:NAME:GIVN"]'); + let SPFX = container.querySelector('[id$="INDI:NAME:SPFX"]'); + let SURN = container.querySelector('[id$="INDI:NAME:SURN"]'); + let NSFX = container.querySelector('[id$="INDI:NAME:NSFX"]'); + + if (NAME.value !== webtrees.buildNameFromParts( + NPFX ? NPFX.value : '', + GIVN ? GIVN.value : '', + SPFX ? SPFX.value : '', + SURN ? SURN.value : '', + NSFX ? NSFX.value : '', + 'U' + )) { + document.getElementById('<?= e($id) ?>-edit').click(); + } else { + let fn = function () { + if (NAME.readOnly === true) { + NAME.value = webtrees.buildNameFromParts( + NPFX ? NPFX.value : '', + GIVN ? GIVN.value : '', + SPFX ? SPFX.value : '', + SURN ? SURN.value : '', + NSFX ? NSFX.value : '', + 'U' + ); + } + } + NPFX.addEventListener('input', fn); + GIVN.addEventListener('input', fn); + SPFX.addEventListener('input', fn); + SURN.addEventListener('input', fn); + SURN.addEventListener('blur', fn); // For autocompleted entries + NSFX.addEventListener('input', fn); + } + }); +</script>
\ No newline at end of file |
