1<?php 2 3use Fisharebest\Webtrees\I18N; 4use Fisharebest\Webtrees\Tree; 5use Illuminate\Support\Collection; 6 7/** 8 * @var Collection<int,Tree> $all_trees 9 * @var Collection<int,Tree> $search_trees 10 */ 11 12?> 13 14<?php if ($all_trees->count() > 1) : ?> 15 <fieldset class="row form-group"> 16 <div class="col-sm-3 col-form-label wt-page-options-label"> 17 <?= I18N::translate('Family trees') ?> 18 </div> 19 <div class="col-sm-9 wt-page-options-value pt-2"> 20 <div id="search-trees"> 21 <?php if ($all_trees->count() > 3): ?> 22 <div class="d-flex"> 23 <?php if ($all_trees->count() > $search_trees->count()): ?> 24 <div class="me-2"> 25 <button type="button" data-bs-toggle="collapse" class="btn btn-secondary btn-sm" href="#more-trees,#select-all" aria-expanded="false" aria-controls="more-trees"> 26 <?= view('icons/expand') ?> 27 <?= view('icons/collapse') ?> 28 </button> 29 </div> 30 <?php endif ?> 31 <div> 32 <?php foreach ($search_trees as $n => $tree) : ?> 33 <?= view('components/checkbox', ['name' => 'search_trees[]', 'id' => 'chkbx-' . $n, 'checked' => $search_trees->containsStrict($tree), 'value' => e($tree->name()), 'label' => e($tree->title())]) ?> 34 <?php endforeach ?> 35 <div id="more-trees" class="<?= $all_trees->count() > $search_trees->count() ? 'collapse' : '' ?>"> 36 <?php foreach ($all_trees as $n => $tree) : ?> 37 <?php if (!$search_trees->containsStrict($tree)): ?> 38 <?= view('components/checkbox', ['name' => 'search_trees[]', 'id' => 'chkbx-' . $n, 'checked' => $search_trees->containsStrict($tree), 'value' => e($tree->name()), 'label' => e($tree->title())]) ?> 39 <?php endif ?> 40 <?php endforeach ?> 41 </div> 42 </div> 43 <div class="ms-auto <?= $all_trees->count() > $search_trees->count() ? 'collapse' : '' ?>" id="select-all"> 44 <button type="button" class="btn btn-sm btn-secondary mx-1" onclick="document.querySelectorAll('#search-trees [type=checkbox]').forEach((element) => {element.checked=true;});"> 45 <?= /* I18N: select all (of a list of options) */ I18N::translate('select all') ?> 46 </button> 47 <button type="button" class="btn btn-sm btn-secondary mx-1" onclick="document.querySelectorAll('#search-trees [type=checkbox]').forEach((element) => {element.checked=false;});"> 48 <?= /* I18N: select none (of a list of options) */ I18N::translate('select none') ?> 49 </button> 50 <?php if ($all_trees->count() > 10) : ?> 51 <button type="button" class="btn btn-sm btn-secondary mx-1" onclick="document.querySelectorAll('#search-trees [type=checkbox]').forEach((element) => {element.checked=!element.checked;});"> 52 <?= /* I18N: reverse the selection (of a list of options) */ I18N::translate('invert selection') ?> 53 </button> 54 <?php endif ?> 55 </div> 56 </div> 57 <?php else: ?> 58 <?php foreach ($all_trees as $n => $tree) : ?> 59 <?= view('components/checkbox-inline', ['name' => 'search_trees[]', 'id' => 'chkbx-' . $n, 'checked' => $search_trees->containsStrict($tree), 'value' => e($tree->name()), 'label' => e($tree->title())]) ?> 60 <?php endforeach ?> 61 <?php endif ?> 62 </div> 63 </div> 64 </fieldset> 65<?php endif ?> 66