xref: /webtrees/resources/views/admin/locations.phtml (revision 315eb31683006273e24c08b447e6e1095d6f2147)
11e653452SGreg Roach<?php
21e653452SGreg Roach
390949315SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\MapDataAdd;
494e35917SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\MapDataDelete;
590949315SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\MapDataEdit;
690949315SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\MapDataExportCSV;
790949315SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\MapDataExportGeoJson;
890949315SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\MapDataImportPage;
994e35917SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\MapDataList;
101e653452SGreg Roachuse Fisharebest\Webtrees\I18N;
1194e35917SGreg Roachuse Fisharebest\Webtrees\Module\PlaceHierarchyListModule;
12ed612bd3SGreg Roachuse Fisharebest\Webtrees\Tree;
13d2dac12aSGreg Roachuse Fisharebest\Webtrees\View;
14ed612bd3SGreg Roachuse Illuminate\Support\Collection;
151e653452SGreg Roach
1694e35917SGreg Roach/**
1794e35917SGreg Roach * @var array<stdClass>               $active
18ed612bd3SGreg Roach * @var Collection<Tree>              $all_trees
1994e35917SGreg Roach * @var array<string,string>          $breadcrumbs
2094e35917SGreg Roach * @var int                           $parent_id
2194e35917SGreg Roach * @var array<mixed>                  $placelist
22ed612bd3SGreg Roach * @var PlaceHierarchyListModule|null $list_module
2394e35917SGreg Roach * @var string                        $title
2494e35917SGreg Roach */
2594e35917SGreg Roach
261e653452SGreg Roach?>
27dd6b2bfcSGreg Roach
28dd6b2bfcSGreg Roach<?= view('components/breadcrumbs', ['links' => $breadcrumbs]) ?>
29dd6b2bfcSGreg Roach
30dd6b2bfcSGreg Roach<h1><?= $title ?></h1>
31dd6b2bfcSGreg Roach
32d2dac12aSGreg Roach<p>
33d2dac12aSGreg Roach    <label>
34*315eb316SGreg Roach        <input id="hide-unused-locations" type="checkbox" data-bs-toggle="collapse" data-bs-target=".unused-location">
35d2dac12aSGreg Roach        <?= I18N::translate('Hide unused locations') ?>
36d2dac12aSGreg Roach    </label>
37d2dac12aSGreg Roach</p>
38d2dac12aSGreg Roach
39d2dac12aSGreg Roach<table class="table table-bordered table-striped table-sm table-hover wt-table-locations">
40dd6b2bfcSGreg Roach    <thead class="thead-dark">
41dd6b2bfcSGreg Roach        <tr>
42dd6b2bfcSGreg Roach            <th><?= I18N::translate('Place') ?></th>
43dd6b2bfcSGreg Roach            <th><?= I18N::translate('Latitude') ?></th>
44dd6b2bfcSGreg Roach            <th><?= I18N::translate('Longitude') ?></th>
45e340fe65SGreg Roach            <!--
46dd6b2bfcSGreg Roach            <th><?= I18N::translate('Flag') ?> </th>
47e340fe65SGreg Roach            -->
48dd6b2bfcSGreg Roach            <th><?= I18N::translate('Edit') ?></th>
4994e35917SGreg Roach            <th><?= I18N::translate('Facts and events') ?></th>
50dd6b2bfcSGreg Roach            <th><?= I18N::translate('Delete') ?></th>
51dd6b2bfcSGreg Roach        </tr>
52dd6b2bfcSGreg Roach    </thead>
53dd6b2bfcSGreg Roach
547039fd97SGreg Roach    <tbody>
55dd6b2bfcSGreg Roach    <?php foreach ($placelist as $place) : ?>
5690949315SGreg Roach        <tr class="<?= $active[$place->key] ?? null ? '' : 'unused-location collapse show' ?>">
57dd6b2bfcSGreg Roach            <th scope="row">
5890949315SGreg Roach                <a href="<?= e(route(MapDataList::class, ['parent_id' => $place->id])) ?>">
59*315eb316SGreg Roach                    <bdi><?= e($place->place) ?></bdi>
6094e35917SGreg Roach                    <?php if ($place->no_coord > 0): ?>
6194e35917SGreg Roach                        <span class="badge badge-pill badge-secondary">
6294e35917SGreg Roach                            <?= view('icons/warning') ?>
6394e35917SGreg Roach                            <?= I18N::number($place->no_coord) ?>
6494e35917SGreg Roach                            /
65dd6b2bfcSGreg Roach                            <?= I18N::number($place->child_count) ?>
66dd6b2bfcSGreg Roach                        </span>
6794e35917SGreg Roach                    <?php elseif ($place->child_count > 0): ?>
6894e35917SGreg Roach                        <span class="badge badge-pill badge-secondary">
6994e35917SGreg Roach                            <?= I18N::number($place->child_count) ?>
7094e35917SGreg Roach                        </span>
7194e35917SGreg Roach                    <?php endif ?>
72dd6b2bfcSGreg Roach                </a>
73dd6b2bfcSGreg Roach            </th>
74d993d560SGreg Roach
750e7a2d23SGreg Roach            <td dir="ltr">
7690949315SGreg Roach                <?php if ($place->latitude === null) : ?>
77d993d560SGreg Roach                    <?= view('icons/warning') ?>
78d993d560SGreg Roach                <?php else : ?>
7990949315SGreg Roach                    <?= $place->latitude ?>
80d993d560SGreg Roach                <?php endif ?>
81dd6b2bfcSGreg Roach            </td>
82d993d560SGreg Roach
830e7a2d23SGreg Roach            <td dir="ltr">
8490949315SGreg Roach                <?php if ($place->longitude === null) : ?>
85d993d560SGreg Roach                    <?= view('icons/warning') ?>
86d993d560SGreg Roach                <?php else : ?>
8790949315SGreg Roach                    <?= $place->longitude ?>
88d993d560SGreg Roach                <?php endif ?>
89dd6b2bfcSGreg Roach            </td>
90d993d560SGreg Roach
91dd6b2bfcSGreg Roach            <td>
9290949315SGreg Roach                <a class="btn btn-primary" href="<?= e(route(MapDataEdit::class, ['place_id'  => $place->id])) ?>" title="<?= I18N::translate('Edit') ?>">
9339b853a7SGreg Roach                    <?= view('icons/edit') ?>
94*315eb316SGreg Roach                    <span class="visually-hidden">
9539b853a7SGreg Roach                        <?= I18N::translate('Edit') ?>
9639b853a7SGreg Roach                    </span>
9739b853a7SGreg Roach                </a>
98dd6b2bfcSGreg Roach            </td>
99d993d560SGreg Roach
100dd6b2bfcSGreg Roach            <td>
10190949315SGreg Roach                <?php if ($list_module !== null && array_key_exists($place->key, $active)): ?>
10290949315SGreg Roach                    <?php if (count($active[$place->key]) === 1): ?>
10390949315SGreg Roach                        <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'])) ?>">
10490949315SGreg Roach                            <?= e($active[$place->key][0]->tree_title) ?>
10594e35917SGreg Roach                        </a>
10694e35917SGreg Roach                    <?php else: ?>
10794e35917SGreg Roach                        <div class="dropdown">
108*315eb316SGreg Roach                            <a class="btn btn-link dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
10990949315SGreg Roach                                <?= I18N::plural('%s family tree', '%s family trees', count($active[$place->key]), I18N::number(count($active[$place->key]))) ?>
11094e35917SGreg Roach                            </a>
11194e35917SGreg Roach
11294e35917SGreg Roach                            <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
11390949315SGreg Roach                                <?php foreach ($active[$place->key] as $link): ?>
11490949315SGreg Roach                                    <a class="dropdown-item" href="<?= e($list_module->listUrl($all_trees->get($active[$place->key][0]->tree_name), ['place_id' => $link->p_id])) ?>">
11594e35917SGreg Roach                                        <?= e($link->tree_title) ?>
11694e35917SGreg Roach                                    </a>
11794e35917SGreg Roach                                <?php endforeach ?>
11894e35917SGreg Roach                            </div>
11994e35917SGreg Roach                        </div>
12094e35917SGreg Roach                    <?php endif ?>
12194e35917SGreg Roach                <?php endif ?>
12294e35917SGreg Roach            </td>
12394e35917SGreg Roach
12494e35917SGreg Roach            <td>
12590949315SGreg Roach                <?php if (!array_key_exists($place->key, $active)): ?>
12690949315SGreg Roach                    <form method="post" action="<?= e(route(MapDataDelete::class, ['place_id' => $place->id])) ?>">
127dd6b2bfcSGreg Roach                        <?= csrf_field() ?>
12894e35917SGreg Roach                        <button type="submit" class="btn btn-danger" aria-label="<?= I18N::translate('delete') ?>" data-confirm="<?= I18N::translate('Remove this location?') ?>">
1296a83cfe8SGreg Roach                            <?= view('icons/delete') ?>
130dd6b2bfcSGreg Roach                        </button>
131dd6b2bfcSGreg Roach                    </form>
132dd6b2bfcSGreg Roach                <?php endif ?>
133dd6b2bfcSGreg Roach            </td>
134dd6b2bfcSGreg Roach        </tr>
135dd6b2bfcSGreg Roach    <?php endforeach ?>
136dd6b2bfcSGreg Roach    </tbody>
1377039fd97SGreg Roach
138dd6b2bfcSGreg Roach    <tfoot>
139dd6b2bfcSGreg Roach        <tr>
140dd6b2bfcSGreg Roach            <td colspan="7">
14190949315SGreg Roach                <a class="btn btn-primary" href="<?= e(route(MapDataAdd::class, ['parent_id' => $parent_id])) ?>">
142d993d560SGreg Roach                    <?= view('icons/add') ?>
143dd6b2bfcSGreg Roach                    <?= /* I18N: A button label. */
144dd6b2bfcSGreg Roach                    I18N::translate('add place') ?>
145dd6b2bfcSGreg Roach                </a>
146dd6b2bfcSGreg Roach                <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"
147*315eb316SGreg Roach                        data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
148d993d560SGreg Roach                    <?= view('icons/download') ?>
149dd6b2bfcSGreg Roach                    <?= /* I18N: A button label. */
150dd6b2bfcSGreg Roach                    I18N::translate('export file') ?>
151dd6b2bfcSGreg Roach                </button>
152dd6b2bfcSGreg Roach                <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
15390949315SGreg Roach                    <a class="dropdown-item" href="<?= e(route(MapDataExportCSV::class, ['parent_id' => $parent_id])) ?>">
154dd6b2bfcSGreg Roach                        csv
155dd6b2bfcSGreg Roach                    </a>
15690949315SGreg Roach                    <a class="dropdown-item" href="<?= e(route(MapDataExportGeoJson::class, ['parent_id' => $parent_id])) ?>">
157dd6b2bfcSGreg Roach                        geoJSON
158dd6b2bfcSGreg Roach                    </a>
159dd6b2bfcSGreg Roach                </div>
16090949315SGreg Roach                <a class="btn btn-primary" href="<?= e(route(MapDataImportPage::class, ['parent_id' => $parent_id])) ?>">
161d993d560SGreg Roach                    <?= view('icons/upload') ?>
162dd6b2bfcSGreg Roach                    <?= /* I18N: A button label. */
163dd6b2bfcSGreg Roach                    I18N::translate('import file') ?>
164dd6b2bfcSGreg Roach                </a>
165dd6b2bfcSGreg Roach            </td>
166dd6b2bfcSGreg Roach        </tr>
167dd6b2bfcSGreg Roach    </tfoot>
168dd6b2bfcSGreg Roach</table>
169d2dac12aSGreg Roach
170d2dac12aSGreg Roach<?php View::push('javascript') ?>
171d2dac12aSGreg Roach<script>
172d2dac12aSGreg Roach  'use strict';
173d2dac12aSGreg Roach
174d2dac12aSGreg Roach  webtrees.persistentToggle("hide-unused-locations");
175d2dac12aSGreg Roach</script>
176d2dac12aSGreg Roach<?php View::endpush() ?>
177