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