xref: /webtrees/resources/views/modules/stories/config.phtml (revision 3d2c98d1066d5e178a3d1ceb3bdc58b7ba8ee926)
1<?php
2
3use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
4use Fisharebest\Webtrees\Http\RequestHandlers\ModulesAllPage;
5use Fisharebest\Webtrees\I18N;
6use Fisharebest\Webtrees\Tree;
7use Illuminate\Support\Collection;
8
9/**
10 * @var Collection<stdClass> $stories
11 * @var string               $title
12 * @var Tree                 $tree
13 * @var array<string>        $tree_names
14 */
15
16?>
17
18<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(ModulesAllPage::class) => I18N::translate('Modules'), $title]]) ?>
19
20<h1><?= $title ?></h1>
21
22<form method="post" class="form-inline mb-4">
23    <?= csrf_field() ?>
24
25    <label for="tree" class="sr-only">
26        <?= I18N::translate('Family tree') ?>
27    </label>
28
29    <?= view('components/select', ['name' => 'tree', 'selected' => $tree->name(), 'options' => $tree_names]) ?>
30    <button type="submit" class="btn btn-primary">
31        <?= I18N::translate('show') ?>
32    </button>
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    ])) ?>"
51>
52    <thead>
53        <tr>
54            <th><?= I18N::translate('Individual') ?></th>
55            <th><?= I18N::translate('Story title') ?></th>
56            <th><?= I18N::translate('Edit') ?></th>
57            <th><?= I18N::translate('Delete') ?></th>
58        </tr>
59    </thead>
60    <tbody>
61        <?php foreach ($stories as $story) : ?>
62            <tr>
63                <td>
64                    <?php if ($story->individual !== null) : ?>
65                        <a href="<?= e($story->individual->url()) ?>#tab-stories">
66                            <?= $story->individual->fullName() ?>
67                        </a>
68                    <?php else : ?>
69                        <?= $story->xref ?>
70                    <?php endif ?>
71                </td>
72                <td>
73                    <?= e($story->title) ?>
74                </td>
75                <td>
76                    <a class="btn btn-primary" href="<?= e(route('module', ['module' => 'stories', 'action' => 'AdminEdit', 'tree' => $tree->name(), 'block_id' => $story->block_id])) ?>">
77                        <?= view('icons/edit') ?>
78                        <?= I18N::translate('Edit') ?>
79                    </a>
80                </td>
81                <td>
82                    <form method="post" action="<?= e(route('module', ['module' => 'stories', 'action' => 'AdminDelete', 'tree' => $tree->name(), 'block_id' => $story->block_id])) ?>">
83                        <?= csrf_field() ?>
84                        <button type="submit" class="btn btn-danger" data-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', e($story->title)) ?>" onclick="return confirm(this.dataset.confirm);">
85                            <?= view('icons/delete') ?>
86                            <?= I18N::translate('Delete') ?>
87                        </button>
88                    </form>
89                </td>
90            </tr>
91        <?php endforeach ?>
92    </tbody>
93</table>
94