summaryrefslogtreecommitdiff
path: root/resources/views/admin/components.phtml
blob: 76d5fba5e50c8b61c252215d229d6e061aed7520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php use Fisharebest\Webtrees\Bootstrap4; ?>
<?php use Fisharebest\Webtrees\Functions\FunctionsEdit; ?>
<?php use Fisharebest\Webtrees\I18N; ?>
<?php use Fisharebest\Webtrees\Module\ModuleExternalUrlInterface; ?>
<?php use Fisharebest\Webtrees\Module\ModuleConfigInterface; ?>
<?php use Fisharebest\Webtrees\View; ?>

<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), route('modules') => I18N::translate('Modules'), $title]]) ?>

<h1><?= $title ?></h1>

<p><?= $description ?></p>

<form method="post">
    <?= csrf_field() ?>
    <table class="table table-bordered wt-table-menu">
        <thead>
            <tr>
                <th><?= I18N::translate('Module') ?></th>
                <th class="text-center"><?= I18N::translate('Enabled') ?></th>
                <?php if ($uses_access) : ?>
                    <th class="text-center"><?= I18N::translate('Access level') ?></th>
                <?php endif ?>
                <?php if ($uses_sorting) : ?>
                    <th class="text-center"><?= I18N::translate('Move up') ?></th>
                    <th class="text-center"><?= I18N::translate('Move down') ?></th>
                <?php endif ?>
            </tr>
        </thead>

        <tbody>
            <?php foreach ($modules as $module_name => $module) : ?>
                <tr>
                    <th scope="col">
                        <input type="hidden" name="order[]" value="<?= e($module->name()) ?>"?>
                        <span title="<?= e($module->description()) ?>">
                            <?= $module->title() ?>
                        </span>
                        <?php if ($module instanceof ModuleConfigInterface && $module->isEnabled()) : ?>
                            <a href="<?= e($module->getConfigLink()) ?>" title="<?= I18N::translate('Preferences') ?>">
                                <?= view('icons/preferences') ?>
                                <span class="sr-only">
                                    <?= I18N::translate('Preferences') ?>
                                </span>
                            </a>
                        <?php endif ?>
                        <?php if ($module instanceof ModuleExternalUrlInterface) : ?>
                            <br>
                            <a href="<?= e($module->externalUrl()) ?>">
                                <?= e($module->externalUrl()) ?>
                            </a>
                        <?php endif ?>
                    </th>

                    <td class="text-center">
                        <label class="d-block">
                            <input type="checkbox" name="status-<?= e($module->name()) ?>" id="status-<?= e($module->name()) ?>" <?= $module->isEnabled() ? 'checked' : '' ?>>
                            <span class="sr-only">
                                <?= I18N::translate('Enabled') ?>
                            </span>
                        </label>
                    </td>

                    <?php if ($uses_access) : ?>
                        <td class="text-center">
                        <div class="modal fade" id="access-level-<?= $module->name() ?>" tabindex="-1" role="dialog">
                            <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h2 class="modal-title">
                                            <?= e($module->title()) ?> – <?= I18N::translate('Access level') ?>
                                        </h2>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true">&times;</span>
                                        </button>
                                    </div>
                                    <div class="modal-body">
                                        <table class="table table-sm">
                                            <tbody>
                                                <?php foreach ($trees as $tree) : ?>
                                                    <tr>
                                                        <td>
                                                            <?= e($tree->title()) ?>
                                                        </td>
                                                        <td>
                                                            <?= Bootstrap4::select(FunctionsEdit::optionsAccessLevels(), $module->accessLevel($tree, $interface), ['name' => 'access-' . $module->name() . '-' . $tree->id()]) ?>
                                                        </td>
                                                    </tr>
                                                <?php endforeach ?>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <button type="button" class="btn btn-link" data-toggle="modal" data-target="#access-level-<?= $module->name() ?>">
                            <?= view('icons/edit') ?>
                            <span class="sr-only">
                                 <?= I18N::translate('edit') ?>
                            </span>
                        </button>
                    </td>
                    <?php endif ?>

                    <?php if ($uses_sorting) : ?>
                        <td class="move up text-center">
                            <a href="#" title="<?= I18N::translate('Move up') ?>">
                                <?= view('icons/arrow-up') ?>
                            </a>
                        </td>

                        <td class="move down text-center">
                            <a href="#" title="<?= I18N::translate('Move down') ?>">
                                <?= view('icons/arrow-down') ?>
                            </a>
                        </td>
                    <?php endif ?>
                </tr>
            <?php endforeach ?>
        </tbody>
    </table>

    <button class="btn btn-primary" type="submit">
        <?= view('icons/save') ?>
        <?= I18N::translate('save') ?>
    </button>

    <a class="btn btn-secondary" href="<?= e(route('admin-control-panel')) ?>">
        <?= view('icons/cancel') ?>
        <?= I18N::translate('cancel') ?>
    </a>
</form>


<?php View::push('javascript') ?>
<script>
    $('.wt-table-menu td.move').click(function() {
        var row = $(this).closest('tr');

        if ($(this).hasClass('up')) {
            row.prev().before(row);
        } else {
            row.next().after(row);
        }

        return false;
    });
</script>
<?php View::endpush() ?>

<?php View::push('styles') ?>
<style>
    .wt-table-menu tr:first-child .wt-icon-arrow-up {
        display:none;
    }
    .wt-table-menu tr:last-child .wt-icon-arrow-down {
        display:none;
    }
</style>
<?php View::endpush() ?>