xref: /webtrees/resources/views/admin/components.phtml (revision 6b32f095be5c3cb4ce449204a7be279de6f6c5c0)
10cb66f86SGreg Roach<?php use Fisharebest\Webtrees\Bootstrap4; ?>
20cb66f86SGreg Roach<?php use Fisharebest\Webtrees\Functions\FunctionsEdit; ?>
30cb66f86SGreg Roach<?php use Fisharebest\Webtrees\I18N; ?>
48e5c5efeSGreg Roach<?php use Fisharebest\Webtrees\Module\ModuleExternalUrlInterface; ?>
58e5c5efeSGreg Roach<?php use Fisharebest\Webtrees\Module\ModuleConfigInterface; ?>
68e5c5efeSGreg Roach<?php use Fisharebest\Webtrees\View; ?>
70cb66f86SGreg Roach
80cb66f86SGreg Roach<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), route('modules') => I18N::translate('Modules'), $title]]) ?>
90cb66f86SGreg Roach
100cb66f86SGreg Roach<h1><?= $title ?></h1>
110cb66f86SGreg Roach
128e5c5efeSGreg Roach<p><?= $description ?></p>
138e5c5efeSGreg Roach
140cb66f86SGreg Roach<form method="post">
150cb66f86SGreg Roach    <?= csrf_field() ?>
160cb66f86SGreg Roach    <table class="table table-bordered wt-table-menu">
170cb66f86SGreg Roach        <thead>
180cb66f86SGreg Roach            <tr>
190cb66f86SGreg Roach                <th><?= I18N::translate('Menu') ?></th>
200cb66f86SGreg Roach                <th class="text-center"><?= I18N::translate('Enabled') ?></th>
2133c34396SGreg Roach                <?php if ($uses_access) : ?>
220cb66f86SGreg Roach                    <th class="text-center"><?= I18N::translate('Access level') ?></th>
2333c34396SGreg Roach                <?php endif ?>
2433c34396SGreg Roach                <?php if ($uses_sorting) : ?>
250cb66f86SGreg Roach                    <th class="text-center"><?= I18N::translate('Move up') ?></th>
260cb66f86SGreg Roach                    <th class="text-center"><?= I18N::translate('Move down') ?></th>
270cb66f86SGreg Roach                <?php endif ?>
280cb66f86SGreg Roach            </tr>
290cb66f86SGreg Roach        </thead>
300cb66f86SGreg Roach
310cb66f86SGreg Roach        <tbody>
320cb66f86SGreg Roach            <?php foreach ($modules as $module_name => $module) : ?>
330cb66f86SGreg Roach                <tr>
340cb66f86SGreg Roach                    <th scope="col">
350cb66f86SGreg Roach                        <input type="hidden" name="order[]" value="<?= e($module->name()) ?>"?>
3633c34396SGreg Roach                        <span title="<?= e($module->description()) ?>">
370cb66f86SGreg Roach                            <?= $module->title() ?>
3833c34396SGreg Roach                        </span>
39*6b32f095SGreg Roach                        <?php if ($module instanceof ModuleConfigInterface && $module->isEnabled()) : ?>
400cb66f86SGreg Roach                            <a href="<?= e($module->getConfigLink()) ?>" title="<?= I18N::translate('Preferences') ?>">
410cb66f86SGreg Roach                                <?= view('icons/preferences') ?>
420cb66f86SGreg Roach                                <span class="sr-only">
430cb66f86SGreg Roach                                    <?= I18N::translate('Preferences') ?>
440cb66f86SGreg Roach                                </span>
450cb66f86SGreg Roach                            </a>
460cb66f86SGreg Roach                        <?php endif ?>
478e5c5efeSGreg Roach                        <?php if ($module instanceof ModuleExternalUrlInterface) : ?>
488e5c5efeSGreg Roach                            <br>
498e5c5efeSGreg Roach                            <a href="<?= e($module->externalUrl()) ?>">
508e5c5efeSGreg Roach                                <?= e($module->externalUrl()) ?>
518e5c5efeSGreg Roach                            </a>
528e5c5efeSGreg Roach                        <?php endif ?>
530cb66f86SGreg Roach                    </th>
540cb66f86SGreg Roach
550cb66f86SGreg Roach                    <td class="text-center">
560cb66f86SGreg Roach                        <label class="d-block">
570cb66f86SGreg Roach                            <input type="checkbox" name="status-<?= e($module->name()) ?>" id="status-<?= e($module->name()) ?>" <?= $module->isEnabled() ? 'checked' : '' ?>>
580cb66f86SGreg Roach                            <span class="sr-only">
590cb66f86SGreg Roach                                <?= I18N::translate('Enabled') ?>
600cb66f86SGreg Roach                            </span>
610cb66f86SGreg Roach                        </label>
620cb66f86SGreg Roach                    </td>
630cb66f86SGreg Roach
6433c34396SGreg Roach                    <?php if ($uses_access) : ?>
650cb66f86SGreg Roach                        <td class="text-center">
660cb66f86SGreg Roach                        <div class="modal fade" id="access-level-<?= $module->name() ?>" tabindex="-1" role="dialog">
670cb66f86SGreg Roach                            <div class="modal-dialog" role="document">
680cb66f86SGreg Roach                                <div class="modal-content">
690cb66f86SGreg Roach                                    <div class="modal-header">
700cb66f86SGreg Roach                                        <h2 class="modal-title">
710cb66f86SGreg Roach                                            <?= e($module->title()) ?><?= I18N::translate('Access level') ?>
720cb66f86SGreg Roach                                        </h2>
730cb66f86SGreg Roach                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
740cb66f86SGreg Roach                                            <span aria-hidden="true">&times;</span>
750cb66f86SGreg Roach                                        </button>
760cb66f86SGreg Roach                                    </div>
770cb66f86SGreg Roach                                    <div class="modal-body">
780cb66f86SGreg Roach                                        <table class="table table-sm">
790cb66f86SGreg Roach                                            <tbody>
800cb66f86SGreg Roach                                                <?php foreach ($trees as $tree) : ?>
810cb66f86SGreg Roach                                                    <tr>
820cb66f86SGreg Roach                                                        <td>
830cb66f86SGreg Roach                                                            <?= e($tree->title()) ?>
840cb66f86SGreg Roach                                                        </td>
850cb66f86SGreg Roach                                                        <td>
860cb66f86SGreg Roach                                                            <?= Bootstrap4::select(FunctionsEdit::optionsAccessLevels(), $module->accessLevel($tree, $component), ['name' => 'access-' . $module->name() . '-' . $tree->id()]) ?>
870cb66f86SGreg Roach                                                        </td>
880cb66f86SGreg Roach                                                    </tr>
890cb66f86SGreg Roach                                                <?php endforeach ?>
900cb66f86SGreg Roach                                            </tbody>
910cb66f86SGreg Roach                                        </table>
920cb66f86SGreg Roach                                    </div>
930cb66f86SGreg Roach                                    <div class="modal-footer">
940cb66f86SGreg Roach                                        <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
950cb66f86SGreg Roach                                    </div>
960cb66f86SGreg Roach                                </div>
970cb66f86SGreg Roach                            </div>
980cb66f86SGreg Roach                        </div>
990cb66f86SGreg Roach
1000cb66f86SGreg Roach                        <button type="button" class="btn btn-link" data-toggle="modal" data-target="#access-level-<?= $module->name() ?>">
1010cb66f86SGreg Roach                            <?= view('icons/edit') ?>
1020cb66f86SGreg Roach                            <span class="sr-only">
1030cb66f86SGreg Roach                                 <?= I18N::translate('edit') ?>
1040cb66f86SGreg Roach                            </span>
1050cb66f86SGreg Roach                        </button>
1060cb66f86SGreg Roach                    </td>
10733c34396SGreg Roach                    <?php endif ?>
1080cb66f86SGreg Roach
10933c34396SGreg Roach                    <?php if ($uses_sorting) : ?>
1100cb66f86SGreg Roach                        <td class="move up text-center">
1110cb66f86SGreg Roach                            <a href="#" title="<?= I18N::translate('Move up') ?>">
1120cb66f86SGreg Roach                                <?= view('icons/arrow-up') ?>
1130cb66f86SGreg Roach                            </a>
1140cb66f86SGreg Roach                        </td>
1150cb66f86SGreg Roach
1160cb66f86SGreg Roach                        <td class="move down text-center">
1170cb66f86SGreg Roach                            <a href="#" title="<?= I18N::translate('Move down') ?>">
1180cb66f86SGreg Roach                                <?= view('icons/arrow-down') ?>
1190cb66f86SGreg Roach                            </a>
1200cb66f86SGreg Roach                        </td>
1210cb66f86SGreg Roach                    <?php endif ?>
1220cb66f86SGreg Roach                </tr>
1230cb66f86SGreg Roach            <?php endforeach ?>
1240cb66f86SGreg Roach        </tbody>
1250cb66f86SGreg Roach    </table>
1260cb66f86SGreg Roach
1270cb66f86SGreg Roach    <button class="btn btn-primary" type="submit">
1280cb66f86SGreg Roach        <?= view('icons/save') ?>
1290cb66f86SGreg Roach        <?= I18N::translate('save') ?>
1300cb66f86SGreg Roach    </button>
1310cb66f86SGreg Roach
1320cb66f86SGreg Roach    <a class="btn btn-secondary" href="<?= e(route('admin-control-panel')) ?>">
1330cb66f86SGreg Roach        <?= view('icons/cancel') ?>
1340cb66f86SGreg Roach        <?= I18N::translate('cancel') ?>
1350cb66f86SGreg Roach    </a>
1360cb66f86SGreg Roach</form>
1370cb66f86SGreg Roach
1380cb66f86SGreg Roach
1390cb66f86SGreg Roach<?php View::push('javascript') ?>
1400cb66f86SGreg Roach<script>
1410cb66f86SGreg Roach    $('.wt-table-menu td.move').click(function() {
1420cb66f86SGreg Roach        var row = $(this).closest('tr');
1430cb66f86SGreg Roach
1440cb66f86SGreg Roach        if ($(this).hasClass('up')) {
1450cb66f86SGreg Roach            row.prev().before(row);
1460cb66f86SGreg Roach        } else {
1470cb66f86SGreg Roach            row.next().after(row);
1480cb66f86SGreg Roach        }
1490cb66f86SGreg Roach
1500cb66f86SGreg Roach        return false;
1510cb66f86SGreg Roach    });
1520cb66f86SGreg Roach</script>
1530cb66f86SGreg Roach<?php View::endpush() ?>
1540cb66f86SGreg Roach
1550cb66f86SGreg Roach<?php View::push('styles') ?>
1560cb66f86SGreg Roach<style>
1570cb66f86SGreg Roach    .wt-table-menu tr:first-child .wt-icon-arrow-up {
1580cb66f86SGreg Roach        display:none;
1590cb66f86SGreg Roach    }
1600cb66f86SGreg Roach    .wt-table-menu tr:last-child .wt-icon-arrow-down {
1610cb66f86SGreg Roach        display:none;
1620cb66f86SGreg Roach    }
1630cb66f86SGreg Roach</style>
1640cb66f86SGreg Roach<?php View::endpush() ?>
165