xref: /webtrees/resources/views/modules/hourglass-chart/chart.phtml (revision 4a9a60957058ca2a34e30a0d6f783e1540606590)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Family;
6use Fisharebest\Webtrees\Individual;
7use Fisharebest\Webtrees\View;
8use Illuminate\Support\Collection;
9
10/**
11 * @var int        $generations
12 * @var Individual $individual
13 * @var bool       $spouses
14 */
15
16$children = $individual->spouseFamilies()->map(static function (Family $family): Collection {
17    return $family->children();
18})->flatten();
19
20?>
21
22<div class="d-flex wt-chart-hourglass">
23    <?= view('modules/hourglass-chart/children', ['children' => $children, 'generations' => $generations - 1, 'spouses' => $spouses]) ?>
24    <div class="align-self-center">
25        <?= view('chart-box', ['individual' => $individual]) ?>
26        <?php if ($spouses) : ?>
27            <?php foreach ($individual->spouseFamilies() as $family) : ?>
28                <?= view('chart-box', ['individual' => $family->spouse($individual)]) ?>
29            <?php endforeach ?>
30        <?php endif ?>
31    </div>
32    <?php if ($individual->childFamilies()->first() !== null) : ?>
33        <?= view('modules/hourglass-chart/parents', ['generations' => $generations - 1, 'family' => $individual->childFamilies()->first()]) ?>
34    <?php endif ?>
35</div>
36
37<?php View::push('javascript') ?>
38<script>
39    $(".wt-chart-hourglass").on("click", ".hourglass-arrow[data-wt-chart-xref]", function () {
40        $(this.parentNode).load(this.dataset.wtChartXref);
41
42        return false;
43    });
44</script>
45<?php View::endpush() ?>
46