xref: /webtrees/resources/views/modules/stories/config.phtml (revision 81b514b4672980e5db010e9d89b55eaf131e798f)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
6use Fisharebest\Webtrees\Http\RequestHandlers\ModulesAllPage;
7use Fisharebest\Webtrees\I18N;
8use Fisharebest\Webtrees\Tree;
9use Illuminate\Support\Collection;
10
11/**
12 * @var Collection<int,object> $stories
13 * @var string                 $title
14 * @var Tree                   $tree
15 * @var array<string>          $tree_names
16 */
17
18?>
19
20<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(ModulesAllPage::class) => I18N::translate('Modules'), $title]]) ?>
21
22<h1><?= $title ?></h1>
23
24<form method="post" class="row">
25    <div class="col-auto">
26        <div class="input-group">
27            <?= view('components/select', ['name' => 'tree', 'selected' => $tree->name(), 'options' => $tree_names, 'aria_label' => I18N::translate('Family tree')]) ?>
28            <input type="submit" class="btn btn-primary" value="<?= I18N::translate('show') ?>">
29        </div>
30    </div>
31
32    <?= csrf_field() ?>
33</form>
34
35<p>
36    <a href="<?= e(route('module', ['module' => 'stories', 'action' => 'AdminEdit', 'tree' => $tree->name()])) ?>" class="btn btn-link">
37        <?= view('icons/add') ?>
38        <?= I18N::translate('Add a story') ?>
39    </a>
40</p>
41
42<table
43    class="table table-bordered table-sm datatables d-none"
44    <?= view('lists/datatables-attributes') ?>
45    data-columns="<?= e(json_encode([
46        null,
47        null,
48        ['sortable' => false],
49        ['sortable' => false],
50    ], JSON_THROW_ON_ERROR)) ?>"
51>
52    <caption>
53        <?= I18N::translate('Stories') ?>
54    </caption>
55
56    <thead>
57        <tr>
58            <th><?= I18N::translate('Individual') ?></th>
59            <th><?= I18N::translate('Story title') ?></th>
60            <th><?= I18N::translate('Edit') ?></th>
61            <th><?= I18N::translate('Delete') ?></th>
62        </tr>
63    </thead>
64
65    <tbody>
66        <?php foreach ($stories as $story) : ?>
67            <tr>
68                <td>
69                    <?php if ($story->individual !== null) : ?>
70                        <a href="<?= e($story->individual->url()) ?>#tab-stories">
71                            <?= $story->individual->fullName() ?>
72                        </a>
73                    <?php else : ?>
74                        <?= $story->xref ?>
75                    <?php endif ?>
76                </td>
77                <td>
78                    <?= e($story->title) ?>
79                </td>
80                <td>
81                    <a class="btn btn-primary" href="<?= e(route('module', ['module' => 'stories', 'action' => 'AdminEdit', 'tree' => $tree->name(), 'block_id' => $story->block_id])) ?>" aria-label="<?= I18N::translate('Edit') ?>">
82                        <?= view('icons/edit') ?>
83                        <?= I18N::translate('Edit') ?>
84                    </a>
85                </td>
86                <td>
87                    <form method="post" action="<?= e(route('module', ['module' => 'stories', 'action' => 'AdminDelete', 'tree' => $tree->name(), 'block_id' => $story->block_id])) ?>">
88                        <button type="submit" class="btn btn-danger" data-wt-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', e($story->title)) ?>" onclick="return confirm(this.dataset.confirm);" aria-label="<?= I18N::translate('Delete') ?>">
89                            <?= view('icons/delete') ?>
90                            <?= I18N::translate('Delete') ?>
91                        </button>
92
93                        <?= csrf_field() ?>
94                    </form>
95                </td>
96            </tr>
97        <?php endforeach ?>
98    </tbody>
99</table>
100