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