Skip to content

Commit

Permalink
Fix: #4654 - expand/collapse edit fields wrongly linked
Browse files Browse the repository at this point in the history
  • Loading branch information
fisharebest committed Dec 23, 2022
1 parent 08bf05d commit 873d8d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
9 changes: 4 additions & 5 deletions resources/views/edit/edit-gedcom-fields.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ $collapse = [];

foreach ($keys as $num => $key) {
$hierarchy[$levels[$key]] = $tags[$key];
$full_tag = implode(':', array_slice($hierarchy, 0, 1 + $levels[$key]));
$elements[$key] = Registry::elementFactory()->make($full_tag);
$ids[$key] = Registry::idFactory()->id() . '-' . $full_tag;
$elements[$key] = Registry::elementFactory()->make(implode(':', array_slice($hierarchy, 0, 1 + $levels[$key])));
$ids[$key] = Registry::idFactory()->id() . '-' . implode('-', array_slice($hierarchy, 0, 1 + $levels[$key]));

// Does this element have any children?
$has_subtags = ($levels[$key + 1] ?? 0) > $levels[$key];
Expand All @@ -49,7 +48,7 @@ foreach ($keys as $num => $key) {
<?php foreach ($keys as $key) : ?>
<?php if ($indent[$key - 1] ?? false) : ?>
<?php if ($collapse[$key - 1] ?? false) : ?>
<div id="collapse-<?= $key ?>" class="collapse wt-nested-edit-fields">
<div id="collapse-<?= $ids[$key] ?>" class="collapse wt-nested-edit-fields">
<?php else : ?>
<div class="wt-nested-edit-fields">
<?php endif ?>
Expand All @@ -64,7 +63,7 @@ foreach ($keys as $num => $key) {
<label class="col-sm-3 col-form-label" for="<?= e($ids[$key]) ?>">
<?= $elements[$key]->label() ?>
<?php if ($collapse[$key]) : ?>
<button class="btn btn-link" data-bs-target="#collapse-<?= $key + 1 ?>" data-bs-toggle="collapse" aria-expanded="false" aria-controls="collapse-<?= $key + 1 ?>" type="button">
<button class="btn btn-link" data-bs-target="#collapse-<?= $ids[$key + 1] ?>" data-bs-toggle="collapse" aria-expanded="false" aria-controls="collapse-<?= $ids[$key + 1] ?>" type="button">
<?= view('icons/expand') ?>
<?= view('icons/collapse') ?>
</button>
Expand Down
10 changes: 5 additions & 5 deletions resources/views/edit/input-addon-edit-name.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ use Fisharebest\Webtrees\I18N;
// ROMN/FONE have children in a collapsable panel
container = container.nextSibling.nextSibling;
}
let NPFX = container.querySelector('[id$=":NPFX"]');
let GIVN = container.querySelector('[id$=":GIVN"]');
let SPFX = container.querySelector('[id$=":SPFX"]');
let SURN = container.querySelector('[id$=":SURN"]');
let NSFX = container.querySelector('[id$=":NSFX"]');
let NPFX = container.querySelector('[id$="-NPFX"]');
let GIVN = container.querySelector('[id$="-GIVN"]');
let SPFX = container.querySelector('[id$="-SPFX"]');
let SURN = container.querySelector('[id$="-SURN"]');
let NSFX = container.querySelector('[id$="-NSFX"]');

let generated_name = webtrees.buildNameFromParts(
NPFX ? NPFX.value : '',
Expand Down
4 changes: 2 additions & 2 deletions resources/views/modules/GEDFact_assistant/select-census.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use Fisharebest\Webtrees\I18N;
const option = select.options[select.selectedIndex];
const form = select.closest('form');

form.querySelector('[id$=CENS\\3a DATE]').value = option.dataset.wtDate;
form.querySelector('[id$=CENS\\3a PLAC]').value = option.dataset.wtPlace;
form.querySelector('[id$=CENS-DATE]').value = option.dataset.wtDate;
form.querySelector('[id$=CENS-PLAC]').value = option.dataset.wtPlace;
});
});
</script>

0 comments on commit 873d8d1

Please sign in to comment.