xref: /webtrees/resources/views/modules/favorites/favorites.phtml (revision e912737efd7b5f6ff699538fb31df8e084fad9d6)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\I18N;
6use Fisharebest\Webtrees\Individual;
7use Fisharebest\Webtrees\Tree;
8use Illuminate\Support\Collection;
9
10/**
11 * @var int                    $block_id
12 * @var bool                   $can_edit
13 * @var Collection<int,object> $favorites
14 * @var string                 $module_name
15 * @var Tree                   $tree
16 */
17?>
18
19<?php foreach ($favorites as $favorite) : ?>
20    <div class="pt-2">
21        <?php if ($favorite->favorite_type === 'URL') : ?>
22            <a href="<?= e($favorite->url) ?>"><b><?= e($favorite->title) ?></b></a>
23        <?php elseif ($favorite->record instanceof Individual) : ?>
24            <?= view('chart-box', ['individual' => $favorite->record]) ?>
25        <?php elseif ($favorite->record !== null) : ?>
26            <?= $favorite->record->formatList() ?>
27        <?php endif ?>
28
29        <div class="wt-favorites-block-note">
30            <?= e((string) $favorite->note) ?>
31        </div>
32    </div>
33
34    <?php if ($can_edit) : ?>
35        <form method="post" action="<?= e(route('module', ['module' => $module_name, 'action' => 'DeleteFavorite', 'tree' => $tree->name(), 'favorite_id' => $favorite->favorite_id])) ?>">
36            <button type="submit" class="btn btn-link" data-wt-confirm="<?= I18N::translate('Are you sure you want to remove this item from your list of favorites?') ?>">
37                <?= I18N::translate('Remove') ?>
38            </button>
39
40            <?= csrf_field() ?>
41        </form>
42    <?php endif ?>
43<?php endforeach ?>
44
45<?php if ($can_edit) : ?>
46    <button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-backdrop="static" data-bs-target="#favorite-form-<?= e($block_id) ?>">
47        <?= I18N::translate('Add a favorite') ?>
48    </button>
49
50    <div class="modal fade" id="favorite-form-<?= e($block_id) ?>" tabindex="-1" role="dialog" aria-labelledby="favorite-form-<?= e($block_id) ?>-label" aria-hidden="true">
51        <div class="modal-dialog modal-xl" role="document">
52            <div class="modal-content">
53                <form method="post" action="<?= e(route('module', ['module' => $module_name, 'action' => 'AddFavorite', 'tree' => $tree->name()])) ?>">
54                    <div class="modal-header">
55                        <h5 class="modal-title" id="favorite-form-<?= e($block_id) ?>-label">
56                            <?= I18N::translate('Add a favorite') ?>
57                        </h5>
58                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="<?= I18N::translate('close') ?>">
59                        </button>
60                    </div>
61                    <div class="modal-body">
62                        <div class="row mb-3">
63                            <div class="col-sm-4 col-md-3">
64                                <div class="form-check">
65                                    <input class="form-check-input" type="radio" name="type" value="indi" id="fav-indi-<?= e($block_id) ?>" checked>
66                                    <label class="form-check-label" for="fav-indi-<?= e($block_id) ?>">
67                                        <?= I18N::translate('Individual') ?>
68                                    </label>
69                                </div>
70                            </div>
71                            <div class="col-sm-8 col-md-9">
72                                <?= view('components/select-individual', ['name' => 'indi-xref', 'tree' => $tree]) ?>
73                            </div>
74                        </div>
75
76                        <div class="row mb-3">
77                            <div class="col-sm-4 col-md-3">
78                                <div class="form-check">
79                                    <input class="form-check-input" type="radio" name="type" value="fam" id="fav-fam-<?= e($block_id) ?>">
80                                    <label class="form-check-label" for="fav-fam-<?= e($block_id) ?>">
81                                        <?= I18N::translate('Family') ?>
82                                    </label>
83                                </div>
84                            </div>
85                            <div class="col-sm-8 col-md-9">
86                                <?= view('components/select-family', ['name' => 'fam-xref', 'tree' => $tree]) ?>
87                            </div>
88                        </div>
89
90                        <div class="row mb-3">
91                            <div class="col-sm-4 col-md-3">
92                                <div class="form-check">
93                                    <input class="form-check-input" type="radio" name="type" value="obje" id="fav-obje-<?= e($block_id) ?>">
94                                    <label class="form-check-label" for="fav-obje-<?= e($block_id) ?>">
95                                        <?= I18N::translate('Media object') ?>
96                                    </label>
97                                </div>
98                            </div>
99                            <div class="col-sm-8 col-md-9">
100                                <?= view('components/select-media', ['name' => 'obje-xref', 'tree' => $tree]) ?>
101                            </div>
102                        </div>
103
104                        <div class="row mb-3">
105                            <div class="col-sm-4 col-md-3">
106                                <div class="form-check">
107                                    <input class="form-check-input" type="radio" name="type" value="sour" id="fav-sour-<?= e($block_id) ?>">
108                                    <label class="form-check-label" for="fav-sour-<?= e($block_id) ?>">
109                                        <?= I18N::translate('Source') ?>
110                                    </label>
111                                </div>
112                            </div>
113                            <div class="col-sm-8 col-md-9">
114                                <?= view('components/select-source', ['name' => 'sour-xref', 'tree' => $tree]) ?>
115                            </div>
116                        </div>
117
118                        <div class="row mb-3">
119                            <div class="col-sm-4 col-md-3">
120                                <div class="form-check">
121                                    <input class="form-check-input" type="radio" name="type" value="repo" id="fav-repo-<?= e($block_id) ?>">
122                                    <label class="form-check-label" for="fav-repo-<?= e($block_id) ?>">
123                                        <?= I18N::translate('Repository') ?>
124                                    </label>
125                                </div>
126                            </div>
127                            <div class="col-sm-8 col-md-9">
128                                <?= view('components/select-repository', ['name' => 'repo-xref', 'tree' => $tree]) ?>
129                            </div>
130                        </div>
131
132                        <div class="row mb-3">
133                            <div class="col-sm-4 col-md-3">
134                                <div class="form-check">
135                                    <input class="form-check-input" type="radio" name="type" value="url" id="fav-url-<?= e($block_id) ?>">
136                                    <label class="form-check-label" for="fav-url-<?= e($block_id) ?>">
137                                        <?= I18N::translate('URL') ?>
138                                    </label>
139                                </div>
140                            </div>
141                            <div class="col-sm-8 col-md-9">
142                                <label>
143                                    <span class="visually-hidden">
144                                        <?= I18N::translate('URL') ?>
145                                    </span>
146                                    <input type="text" class="form-control" name="url" id="url" value="" placeholder="<?= I18N::translate('URL') ?>">
147                                </label>
148                                <label>
149                                    <span class="visually-hidden">
150                                        <?= I18N::translate('Title') ?>
151                                    </span>
152                                    <input type="text" class="form-control" name="title" id="title" value="" placeholder="<?= I18N::translate('Title') ?>">
153                                </label>
154                            </div>
155                        </div>
156
157                        <div class="row mb-3">
158                            <div class="col-sm-4 col-md-3">
159                                <label for="fav-note-<?= e($block_id) ?>">
160                                    <?= I18N::translate('Note') ?>
161                                </label>
162                            </div>
163                            <div class="col-sm-8 col-md-9">
164                                <textarea name="note" id="fav-note-<?= e($block_id) ?>" class="form-control" placeholder="<?= I18N::translate('Enter an optional note about this favorite') ?>" rows="3" dir="auto"></textarea>
165                            </div>
166                        </div>
167                    </div>
168
169                    <div class="modal-footer">
170                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
171                            <?= view('icons/cancel') ?>
172                            <?= I18N::translate('cancel') ?>
173                        </button>
174                        <button type="submit" class="btn btn-primary">
175                            <?= view('icons/save') ?>
176                            <?= I18N::translate('save') ?>
177                        </button>
178                    </div>
179
180                    <?= csrf_field() ?>
181                </form>
182            </div>
183        </div>
184    </div>
185<?php endif ?>
186