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