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