xref: /webtrees/resources/views/modules/hourglass-chart/chart.phtml (revision 1afbbc50a65bb73de1d13dc18d669efe80119058)
1cb0eb4a9SGreg Roach<?php
2cb0eb4a9SGreg Roach
3cb0eb4a9SGreg Roachuse Fisharebest\Webtrees\Family;
4cb0eb4a9SGreg Roachuse Fisharebest\Webtrees\Individual;
5cb0eb4a9SGreg Roachuse Fisharebest\Webtrees\View;
6cb0eb4a9SGreg Roachuse Illuminate\Support\Collection;
7cb0eb4a9SGreg Roach
8cb0eb4a9SGreg Roach/**
9cb0eb4a9SGreg Roach * @var int        $generations
10cb0eb4a9SGreg Roach * @var Individual $individual
1171378461SGreg Roach * @var bool       $spouses
12cb0eb4a9SGreg Roach */
13cb0eb4a9SGreg Roach
146c2179e2SGreg Roach$children = $individual->spouseFamilies()->map(static function (Family $family): Collection {
156c2179e2SGreg Roach    return $family->children();
166c2179e2SGreg Roach})->flatten();
17cb0eb4a9SGreg Roach
18cb0eb4a9SGreg Roach?>
19cb0eb4a9SGreg Roach
20cb0eb4a9SGreg Roach<div class="d-flex wt-chart-hourglass">
2171378461SGreg Roach    <?= view('modules/hourglass-chart/children', ['children' => $children, 'generations' => $generations - 1, 'spouses' => $spouses]) ?>
22cb0eb4a9SGreg Roach    <div class="align-self-center">
23cb0eb4a9SGreg Roach        <?= view('chart-box', ['individual' => $individual]) ?>
2471378461SGreg Roach        <?php if ($spouses): ?>
25cb0eb4a9SGreg Roach            <?php foreach ($individual->spouseFamilies() as $family): ?>
26cb0eb4a9SGreg Roach                <?= view('chart-box', ['individual' => $family->spouse($individual)]) ?>
27cb0eb4a9SGreg Roach            <?php endforeach ?>
28cb0eb4a9SGreg Roach        <?php endif ?>
29cb0eb4a9SGreg Roach    </div>
30*1afbbc50SGreg Roach    <?php if ($individual->childFamilies()->first() !== null): ?>
31cb0eb4a9SGreg Roach        <div class="wt-chart-horizontal-spacer">
32cb0eb4a9SGreg Roach            <div class="wt-chart-horizontal-line"></div>
33cb0eb4a9SGreg Roach        </div>
34*1afbbc50SGreg Roach        <?= view('modules/hourglass-chart/parents', ['generations' => $generations - 1, 'family' => $individual->childFamilies()->first()]) ?>
35cb0eb4a9SGreg Roach    <?php endif ?>
3626684e68SGreg Roach</div>
3726684e68SGreg Roach
38cb0eb4a9SGreg Roach<?php View::push('javascript') ?>
3926684e68SGreg Roach<script>
40fe69f605SGreg Roach    $(".wt-chart-hourglass").on("click", ".hourglass-arrow[data-xref]", function () {
41cb0eb4a9SGreg Roach        $(this.parentNode).load(this.dataset.xref);
4226684e68SGreg Roach
43cb0eb4a9SGreg Roach        return false;
4426684e68SGreg Roach    });
4526684e68SGreg Roach</script>
46cb0eb4a9SGreg Roach<?php View::endpush() ?>
47