summaryrefslogtreecommitdiff
path: root/resources/views/modules/hourglass-chart/chart.phtml
blob: 48e9e2be030aa5d5b1d4e00f29891835c24296c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\View;
use Illuminate\Support\Collection;

/**
 * @var int        $generations
 * @var Individual $individual
 * @var bool       $show_spouse
 */

$children = $individual->spouseFamilies()->map(static function (Family $family): Collection {
    return $family->children();
})->flatten();

?>

<div class="d-flex wt-chart-hourglass">
    <?= view('modules/hourglass-chart/children', ['children' => $children, 'generations' => $generations - 1, 'show_spouse' => $show_spouse]) ?>
    <div class="align-self-center">
        <?= view('chart-box', ['individual' => $individual]) ?>
        <?php if ($show_spouse): ?>
            <?php foreach ($individual->spouseFamilies() as $family): ?>
                <?= view('chart-box', ['individual' => $family->spouse($individual)]) ?>
            <?php endforeach ?>
        <?php endif ?>
    </div>
    <?php if ($individual->primaryChildFamily() !== null): ?>
        <div class="wt-chart-horizontal-spacer">
            <div class="wt-chart-horizontal-line"></div>
        </div>
        <?= view('modules/hourglass-chart/parents', ['generations' => $generations - 1, 'family' => $individual->primaryChildFamily()]) ?>
    <?php endif ?>
</div>

<?php View::push('javascript') ?>
<script>
    $(".wt-chart-hourglass").on("click", ".hourglass-arrow[data-xref]", function () {
        $(this.parentNode).load(this.dataset.xref);

        return false;
    });
</script>
<?php View::endpush() ?>