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