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