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