xref: /webtrees/resources/views/modules/favorites/favorites.phtml (revision 1270d2767576ed4a83917769b0ee3613e3b010bf)
18ec20abdSGreg Roach<?php
28ec20abdSGreg Roach
310e06497SGreg Roachdeclare(strict_types=1);
410e06497SGreg Roach
58ec20abdSGreg Roachuse Fisharebest\Webtrees\I18N;
68ec20abdSGreg Roachuse Fisharebest\Webtrees\Individual;
74062e425SGreg Roachuse Fisharebest\Webtrees\Tree;
88ec20abdSGreg Roachuse Illuminate\Support\Collection;
98ec20abdSGreg Roach
108ec20abdSGreg Roach/**
118ec20abdSGreg Roach * @var int                    $block_id
128ec20abdSGreg Roach * @var bool                   $can_edit
1336779af1SGreg Roach * @var Collection<int,object> $favorites
148ec20abdSGreg Roach * @var string                 $module_name
154062e425SGreg Roach * @var Tree                   $tree
168ec20abdSGreg Roach */
178ec20abdSGreg Roach?>
188ec20abdSGreg Roach
198ec20abdSGreg Roach<?php foreach ($favorites as $favorite) : ?>
2065910300SGreg Roach    <div class="pt-2">
218ec20abdSGreg Roach        <?php if ($favorite->favorite_type === 'URL') : ?>
228ec20abdSGreg Roach            <a href="<?= e($favorite->url) ?>"><b><?= e($favorite->title) ?></b></a>
238ec20abdSGreg Roach        <?php elseif ($favorite->record instanceof Individual) : ?>
24516bb6deSGreg Roach            <?= view('chart-box', ['individual' => $favorite->record]) ?>
258ec20abdSGreg Roach        <?php elseif ($favorite->record !== null) : ?>
268ec20abdSGreg Roach            <?= $favorite->record->formatList() ?>
278ec20abdSGreg Roach        <?php endif ?>
288ec20abdSGreg Roach
298ec20abdSGreg Roach        <div class="wt-favorites-block-note">
308ec20abdSGreg Roach            <?= e((string) $favorite->note) ?>
318ec20abdSGreg Roach        </div>
328ec20abdSGreg Roach    </div>
338ec20abdSGreg Roach
348ec20abdSGreg Roach    <?php if ($can_edit) : ?>
35d72b284aSGreg Roach        <form method="post" action="<?= e(route('module', ['module' => $module_name, 'action' => 'DeleteFavorite', 'tree' => $tree->name(), 'favorite_id' => $favorite->favorite_id])) ?>">
36*1270d276SGreg Roach            <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?') ?>">
378ec20abdSGreg Roach                <?= I18N::translate('Remove') ?>
388ec20abdSGreg Roach            </button>
3981443e3cSGreg Roach
4081443e3cSGreg Roach            <?= csrf_field() ?>
418ec20abdSGreg Roach        </form>
428ec20abdSGreg Roach    <?php endif ?>
438ec20abdSGreg Roach<?php endforeach ?>
448ec20abdSGreg Roach
458ec20abdSGreg Roach<?php if ($can_edit) : ?>
46315eb316SGreg Roach    <button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-backdrop="static" data-bs-target="#favorite-form-<?= e($block_id) ?>">
478ec20abdSGreg Roach        <?= I18N::translate('Add a favorite') ?>
488ec20abdSGreg Roach    </button>
498ec20abdSGreg Roach
508ec20abdSGreg Roach    <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">
518ec20abdSGreg Roach        <div class="modal-dialog modal-xl" role="document">
528ec20abdSGreg Roach            <div class="modal-content">
53d72b284aSGreg Roach                <form method="post" action="<?= e(route('module', ['module' => $module_name, 'action' => 'AddFavorite', 'tree' => $tree->name()])) ?>">
548ec20abdSGreg Roach                    <div class="modal-header">
558ec20abdSGreg Roach                        <h5 class="modal-title" id="favorite-form-<?= e($block_id) ?>-label">
568ec20abdSGreg Roach                            <?= I18N::translate('Add a favorite') ?>
578ec20abdSGreg Roach                        </h5>
58b854e1f1SGreg Roach                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="<?= I18N::translate('close') ?>">
598ec20abdSGreg Roach                        </button>
608ec20abdSGreg Roach                    </div>
614062e425SGreg Roach                    <div class="modal-body">
629e3c2cf9SGreg Roach                        <div class="row mb-3">
638ec20abdSGreg Roach                            <div class="col-sm-4 col-md-3">
648ec20abdSGreg Roach                                <div class="form-check">
658ec20abdSGreg Roach                                    <input class="form-check-input" type="radio" name="type" value="indi" id="fav-indi-<?= e($block_id) ?>" checked>
664062e425SGreg Roach                                    <label class="form-check-label" for="fav-indi-<?= e($block_id) ?>">
678ec20abdSGreg Roach                                        <?= I18N::translate('Individual') ?>
688ec20abdSGreg Roach                                    </label>
698ec20abdSGreg Roach                                </div>
708ec20abdSGreg Roach                            </div>
718ec20abdSGreg Roach                            <div class="col-sm-8 col-md-9">
72b6c326d8SGreg Roach                                <?= view('components/select-individual', ['name' => 'indi-xref', 'tree' => $tree]) ?>
738ec20abdSGreg Roach                            </div>
744062e425SGreg Roach                        </div>
758ec20abdSGreg Roach
769e3c2cf9SGreg Roach                        <div class="row mb-3">
778ec20abdSGreg Roach                            <div class="col-sm-4 col-md-3">
788ec20abdSGreg Roach                                <div class="form-check">
798ec20abdSGreg Roach                                    <input class="form-check-input" type="radio" name="type" value="fam" id="fav-fam-<?= e($block_id) ?>">
804062e425SGreg Roach                                    <label class="form-check-label" for="fav-fam-<?= e($block_id) ?>">
818ec20abdSGreg Roach                                        <?= I18N::translate('Family') ?>
828ec20abdSGreg Roach                                    </label>
838ec20abdSGreg Roach                                </div>
848ec20abdSGreg Roach                            </div>
858ec20abdSGreg Roach                            <div class="col-sm-8 col-md-9">
86b6c326d8SGreg Roach                                <?= view('components/select-family', ['name' => 'fam-xref', 'tree' => $tree]) ?>
878ec20abdSGreg Roach                            </div>
884062e425SGreg Roach                        </div>
898ec20abdSGreg Roach
909e3c2cf9SGreg Roach                        <div class="row mb-3">
918ec20abdSGreg Roach                            <div class="col-sm-4 col-md-3">
928ec20abdSGreg Roach                                <div class="form-check">
938ec20abdSGreg Roach                                    <input class="form-check-input" type="radio" name="type" value="obje" id="fav-obje-<?= e($block_id) ?>">
944062e425SGreg Roach                                    <label class="form-check-label" for="fav-obje-<?= e($block_id) ?>">
958ec20abdSGreg Roach                                        <?= I18N::translate('Media object') ?>
968ec20abdSGreg Roach                                    </label>
978ec20abdSGreg Roach                                </div>
988ec20abdSGreg Roach                            </div>
998ec20abdSGreg Roach                            <div class="col-sm-8 col-md-9">
100b6c326d8SGreg Roach                                <?= view('components/select-media', ['name' => 'obje-xref', 'tree' => $tree]) ?>
1018ec20abdSGreg Roach                            </div>
1024062e425SGreg Roach                        </div>
1038ec20abdSGreg Roach
1049e3c2cf9SGreg Roach                        <div class="row mb-3">
1058ec20abdSGreg Roach                            <div class="col-sm-4 col-md-3">
1068ec20abdSGreg Roach                                <div class="form-check">
1078ec20abdSGreg Roach                                    <input class="form-check-input" type="radio" name="type" value="sour" id="fav-sour-<?= e($block_id) ?>">
1084062e425SGreg Roach                                    <label class="form-check-label" for="fav-sour-<?= e($block_id) ?>">
1098ec20abdSGreg Roach                                        <?= I18N::translate('Source') ?>
1108ec20abdSGreg Roach                                    </label>
1118ec20abdSGreg Roach                                </div>
1128ec20abdSGreg Roach                            </div>
1138ec20abdSGreg Roach                            <div class="col-sm-8 col-md-9">
114b6c326d8SGreg Roach                                <?= view('components/select-source', ['name' => 'sour-xref', 'tree' => $tree]) ?>
1158ec20abdSGreg Roach                            </div>
1164062e425SGreg Roach                        </div>
1178ec20abdSGreg Roach
1189e3c2cf9SGreg Roach                        <div class="row mb-3">
1198ec20abdSGreg Roach                            <div class="col-sm-4 col-md-3">
1208ec20abdSGreg Roach                                <div class="form-check">
1218ec20abdSGreg Roach                                    <input class="form-check-input" type="radio" name="type" value="repo" id="fav-repo-<?= e($block_id) ?>">
1224062e425SGreg Roach                                    <label class="form-check-label" for="fav-repo-<?= e($block_id) ?>">
1238ec20abdSGreg Roach                                        <?= I18N::translate('Repository') ?>
1248ec20abdSGreg Roach                                    </label>
1258ec20abdSGreg Roach                                </div>
1268ec20abdSGreg Roach                            </div>
127b6c326d8SGreg Roach                            <div class="col-sm-8 col-md-9">
128b6c326d8SGreg Roach                                <?= view('components/select-repository', ['name' => 'repo-xref', 'tree' => $tree]) ?>
1298ec20abdSGreg Roach                            </div>
1304062e425SGreg Roach                        </div>
1318ec20abdSGreg Roach
1329e3c2cf9SGreg Roach                        <div class="row mb-3">
1338ec20abdSGreg Roach                            <div class="col-sm-4 col-md-3">
1348ec20abdSGreg Roach                                <div class="form-check">
1358ec20abdSGreg Roach                                    <input class="form-check-input" type="radio" name="type" value="url" id="fav-url-<?= e($block_id) ?>">
1364062e425SGreg Roach                                    <label class="form-check-label" for="fav-url-<?= e($block_id) ?>">
1378ec20abdSGreg Roach                                        <?= I18N::translate('URL') ?>
1388ec20abdSGreg Roach                                    </label>
1398ec20abdSGreg Roach                                </div>
1408ec20abdSGreg Roach                            </div>
141b51c2707SGreg Roach                            <div class="col-sm-8 col-md-9">
1424062e425SGreg Roach                                <label>
143315eb316SGreg Roach                                    <span class="visually-hidden">
1444062e425SGreg Roach                                        <?= I18N::translate('URL') ?>
1454062e425SGreg Roach                                    </span>
1464062e425SGreg Roach                                    <input type="text" class="form-control" name="url" id="url" value="" placeholder="<?= I18N::translate('URL') ?>">
1474062e425SGreg Roach                                </label>
1484062e425SGreg Roach                                <label>
149315eb316SGreg Roach                                    <span class="visually-hidden">
1504062e425SGreg Roach                                        <?= I18N::translate('Title') ?>
1514062e425SGreg Roach                                    </span>
1524062e425SGreg Roach                                    <input type="text" class="form-control" name="title" id="title" value="" placeholder="<?= I18N::translate('Title') ?>">
1534062e425SGreg Roach                                </label>
1544062e425SGreg Roach                            </div>
1558ec20abdSGreg Roach                        </div>
1568ec20abdSGreg Roach
1579e3c2cf9SGreg Roach                        <div class="row mb-3">
1588ec20abdSGreg Roach                            <div class="col-sm-4 col-md-3">
1598ec20abdSGreg Roach                                <label for="fav-note-<?= e($block_id) ?>">
1608ec20abdSGreg Roach                                    <?= I18N::translate('Note') ?>
1618ec20abdSGreg Roach                                </label>
1628ec20abdSGreg Roach                            </div>
163b51c2707SGreg Roach                            <div class="col-sm-8 col-md-9">
1644062e425SGreg Roach                                <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>
1654062e425SGreg Roach                            </div>
1668ec20abdSGreg Roach                        </div>
1678ec20abdSGreg Roach                    </div>
1688ec20abdSGreg Roach
1698ec20abdSGreg Roach                    <div class="modal-footer">
170315eb316SGreg Roach                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
1718ec20abdSGreg Roach                            <?= view('icons/cancel') ?>
1728ec20abdSGreg Roach                            <?= I18N::translate('cancel') ?>
1738ec20abdSGreg Roach                        </button>
1748ec20abdSGreg Roach                        <button type="submit" class="btn btn-primary">
1758ec20abdSGreg Roach                            <?= view('icons/save') ?>
1768ec20abdSGreg Roach                            <?= I18N::translate('save') ?>
1778ec20abdSGreg Roach                        </button>
1788ec20abdSGreg Roach                    </div>
17981443e3cSGreg Roach
18081443e3cSGreg Roach                    <?= csrf_field() ?>
1818ec20abdSGreg Roach                </form>
1828ec20abdSGreg Roach            </div>
1838ec20abdSGreg Roach        </div>
1848ec20abdSGreg Roach    </div>
1858ec20abdSGreg Roach<?php endif ?>
186