1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
<?php
use Fisharebest\Webtrees\Http\RequestHandlers\MapDataAdd;
use Fisharebest\Webtrees\Http\RequestHandlers\MapDataDelete;
use Fisharebest\Webtrees\Http\RequestHandlers\MapDataEdit;
use Fisharebest\Webtrees\Http\RequestHandlers\MapDataExportCSV;
use Fisharebest\Webtrees\Http\RequestHandlers\MapDataExportGeoJson;
use Fisharebest\Webtrees\Http\RequestHandlers\MapDataImportPage;
use Fisharebest\Webtrees\Http\RequestHandlers\MapDataList;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Module\PlaceHierarchyListModule;
use Fisharebest\Webtrees\Tree;
use Fisharebest\Webtrees\View;
use Illuminate\Support\Collection;
/**
* @var array<stdClass> $active
* @var Collection<Tree> $all_trees
* @var array<string,string> $breadcrumbs
* @var int $parent_id
* @var array<mixed> $placelist
* @var PlaceHierarchyListModule|null $list_module
* @var string $title
*/
?>
<?= view('components/breadcrumbs', ['links' => $breadcrumbs]) ?>
<h1><?= $title ?></h1>
<p>
<label>
<input id="hide-unused-locations" type="checkbox" data-bs-toggle="collapse" data-bs-target=".unused-location">
<?= I18N::translate('Hide unused locations') ?>
</label>
</p>
<table class="table table-bordered table-striped table-sm table-hover wt-table-locations">
<thead class="thead-dark">
<tr>
<th><?= I18N::translate('Place') ?></th>
<th><?= I18N::translate('Latitude') ?></th>
<th><?= I18N::translate('Longitude') ?></th>
<!--
<th><?= I18N::translate('Flag') ?> </th>
-->
<th><?= I18N::translate('Edit') ?></th>
<th><?= I18N::translate('Facts and events') ?></th>
<th><?= I18N::translate('Delete') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($placelist as $place) : ?>
<tr class="<?= $active[$place->key] ?? null ? '' : 'unused-location collapse show' ?>">
<th scope="row">
<a href="<?= e(route(MapDataList::class, ['parent_id' => $place->id])) ?>">
<bdi><?= e($place->place) ?></bdi>
<?php if ($place->no_coord > 0): ?>
<span class="badge bg-secondary rounded-pill">
<?= view('icons/warning') ?>
<?= I18N::number($place->no_coord) ?>
/
<?= I18N::number($place->child_count) ?>
</span>
<?php elseif ($place->child_count > 0): ?>
<span class="badge bg-secondary rounded-pill">
<?= I18N::number($place->child_count) ?>
</span>
<?php endif ?>
</a>
</th>
<td dir="ltr">
<?php if ($place->latitude === null) : ?>
<?= view('icons/warning') ?>
<?php else : ?>
<?= $place->latitude ?>
<?php endif ?>
</td>
<td dir="ltr">
<?php if ($place->longitude === null) : ?>
<?= view('icons/warning') ?>
<?php else : ?>
<?= $place->longitude ?>
<?php endif ?>
</td>
<td>
<a class="btn btn-primary" href="<?= e(route(MapDataEdit::class, ['place_id' => $place->id])) ?>" title="<?= I18N::translate('Edit') ?>">
<?= view('icons/edit') ?>
<span class="visually-hidden">
<?= I18N::translate('Edit') ?>
</span>
</a>
</td>
<td>
<?php if ($list_module !== null && array_key_exists($place->key, $active)): ?>
<?php if (count($active[$place->key]) === 1): ?>
<a class="btn btn-link" href="<?= e($list_module->listUrl($all_trees->get($active[$place->key][0]->tree_name), ['place_id' => $active[$place->key][0]->p_id, 'action2' => 'hierarchy-e'])) ?>">
<?= e($active[$place->key][0]->tree_title) ?>
</a>
<?php else: ?>
<div class="dropdown">
<a class="btn btn-link dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<?= I18N::plural('%s family tree', '%s family trees', count($active[$place->key]), I18N::number(count($active[$place->key]))) ?>
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<?php foreach ($active[$place->key] as $link): ?>
<a class="dropdown-item" href="<?= e($list_module->listUrl($all_trees->get($active[$place->key][0]->tree_name), ['place_id' => $link->p_id])) ?>">
<?= e($link->tree_title) ?>
</a>
<?php endforeach ?>
</div>
</div>
<?php endif ?>
<?php endif ?>
</td>
<td>
<?php if (!array_key_exists($place->key, $active)): ?>
<form method="post" action="<?= e(route(MapDataDelete::class, ['place_id' => $place->id])) ?>">
<?= csrf_field() ?>
<button type="submit" class="btn btn-danger" aria-label="<?= I18N::translate('delete') ?>" data-confirm="<?= I18N::translate('Remove this location?') ?>">
<?= view('icons/delete') ?>
</button>
</form>
<?php endif ?>
</td>
</tr>
<?php endforeach ?>
</tbody>
<tfoot>
<tr>
<td colspan="7">
<a class="btn btn-primary" href="<?= e(route(MapDataAdd::class, ['parent_id' => $parent_id])) ?>">
<?= view('icons/add') ?>
<?= /* I18N: A button label. */
I18N::translate('add place') ?>
</a>
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<?= view('icons/download') ?>
<?= /* I18N: A button label. */
I18N::translate('export file') ?>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="<?= e(route(MapDataExportCSV::class, ['parent_id' => $parent_id])) ?>">
csv
</a>
<a class="dropdown-item" href="<?= e(route(MapDataExportGeoJson::class, ['parent_id' => $parent_id])) ?>">
geoJSON
</a>
</div>
<a class="btn btn-primary" href="<?= e(route(MapDataImportPage::class, ['parent_id' => $parent_id])) ?>">
<?= view('icons/upload') ?>
<?= /* I18N: A button label. */
I18N::translate('import file') ?>
</a>
</td>
</tr>
</tfoot>
</table>
<?php View::push('javascript') ?>
<script>
'use strict';
webtrees.persistentToggle("hide-unused-locations");
</script>
<?php View::endpush() ?>
|