xref: /webtrees/resources/views/admin/components.phtml (revision 8c67195698d00428c7c321fc6588ad354a2d92e1)
1<?php use Fisharebest\Webtrees\Bootstrap4; ?>
2<?php use Fisharebest\Webtrees\Functions\FunctionsEdit; ?>
3<?php use Fisharebest\Webtrees\I18N; ?>
4<?php use Fisharebest\Webtrees\Module\ModuleConfigInterface;
5use Fisharebest\Webtrees\View; ?>
6
7<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), route('modules') => I18N::translate('Modules'), $title]]) ?>
8
9<h1><?= $title ?></h1>
10
11<form method="post">
12    <?= csrf_field() ?>
13    <table class="table table-bordered wt-table-menu">
14        <thead>
15            <tr>
16                <th><?= I18N::translate('Menu') ?></th>
17                <th class="text-center"><?= I18N::translate('Enabled') ?></th>
18                <?php if ($uses_access) : ?>
19                    <th class="text-center"><?= I18N::translate('Access level') ?></th>
20                <?php endif ?>
21                <?php if ($uses_sorting) : ?>
22                    <th class="text-center"><?= I18N::translate('Move up') ?></th>
23                    <th class="text-center"><?= I18N::translate('Move down') ?></th>
24                <?php endif ?>
25            </tr>
26        </thead>
27
28        <tbody>
29            <?php foreach ($modules as $module_name => $module) : ?>
30                <tr>
31                    <th scope="col">
32                        <input type="hidden" name="order[]" value="<?= e($module->name()) ?>"?>
33                        <span title="<?= e($module->description()) ?>">
34                            <?= $module->title() ?>
35                        </span>
36                        <?php if ($module instanceof ModuleConfigInterface) : ?>
37                            <a href="<?= e($module->getConfigLink()) ?>" title="<?= I18N::translate('Preferences') ?>">
38                                <?= view('icons/preferences') ?>
39                                <span class="sr-only">
40                                    <?= I18N::translate('Preferences') ?>
41                                </span>
42                            </a>
43                        <?php endif ?>
44                    </th>
45
46                    <td class="text-center">
47                        <label class="d-block">
48                            <input type="checkbox" name="status-<?= e($module->name()) ?>" id="status-<?= e($module->name()) ?>" <?= $module->isEnabled() ? 'checked' : '' ?>>
49                            <span class="sr-only">
50                                <?= I18N::translate('Enabled') ?>
51                            </span>
52                        </label>
53                    </td>
54
55                    <?php if ($uses_access) : ?>
56                        <td class="text-center">
57                        <div class="modal fade" id="access-level-<?= $module->name() ?>" tabindex="-1" role="dialog">
58                            <div class="modal-dialog" role="document">
59                                <div class="modal-content">
60                                    <div class="modal-header">
61                                        <h2 class="modal-title">
62                                            <?= e($module->title()) ?><?= I18N::translate('Access level') ?>
63                                        </h2>
64                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
65                                            <span aria-hidden="true">&times;</span>
66                                        </button>
67                                    </div>
68                                    <div class="modal-body">
69                                        <table class="table table-sm">
70                                            <tbody>
71                                                <?php foreach ($trees as $tree) : ?>
72                                                    <tr>
73                                                        <td>
74                                                            <?= e($tree->title()) ?>
75                                                        </td>
76                                                        <td>
77                                                            <?= Bootstrap4::select(FunctionsEdit::optionsAccessLevels(), $module->accessLevel($tree, $component), ['name' => 'access-' . $module->name() . '-' . $tree->id()]) ?>
78                                                        </td>
79                                                    </tr>
80                                                <?php endforeach ?>
81                                            </tbody>
82                                        </table>
83                                    </div>
84                                    <div class="modal-footer">
85                                        <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
86                                    </div>
87                                </div>
88                            </div>
89                        </div>
90
91                        <button type="button" class="btn btn-link" data-toggle="modal" data-target="#access-level-<?= $module->name() ?>">
92                            <?= view('icons/edit') ?>
93                            <span class="sr-only">
94                                 <?= I18N::translate('edit') ?>
95                            </span>
96                        </button>
97                    </td>
98                    <?php endif ?>
99
100                    <?php if ($uses_sorting) : ?>
101                        <td class="move up text-center">
102                            <a href="#" title="<?= I18N::translate('Move up') ?>">
103                                <?= view('icons/arrow-up') ?>
104                            </a>
105                        </td>
106
107                        <td class="move down text-center">
108                            <a href="#" title="<?= I18N::translate('Move down') ?>">
109                                <?= view('icons/arrow-down') ?>
110                            </a>
111                        </td>
112                    <?php endif ?>
113                </tr>
114            <?php endforeach ?>
115        </tbody>
116    </table>
117
118    <button class="btn btn-primary" type="submit">
119        <?= view('icons/save') ?>
120        <?= I18N::translate('save') ?>
121    </button>
122
123    <a class="btn btn-secondary" href="<?= e(route('admin-control-panel')) ?>">
124        <?= view('icons/cancel') ?>
125        <?= I18N::translate('cancel') ?>
126    </a>
127</form>
128
129
130<?php View::push('javascript') ?>
131<script>
132    $('.wt-table-menu td.move').click(function() {
133        var row = $(this).closest('tr');
134
135        if ($(this).hasClass('up')) {
136            row.prev().before(row);
137        } else {
138            row.next().after(row);
139        }
140
141        return false;
142    });
143</script>
144<?php View::endpush() ?>
145
146<?php View::push('styles') ?>
147<style>
148    .wt-table-menu tr:first-child .wt-icon-arrow-up {
149        display:none;
150    }
151    .wt-table-menu tr:last-child .wt-icon-arrow-down {
152        display:none;
153    }
154</style>
155<?php View::endpush() ?>
156