Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Fixed an issue where a group could be added to a ticket even though it did not have the necessary permissions
- Fix tab redirect after save

## Add

Expand Down
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
"require": {
"php": ">=8.2"
},
"require-dev": {
"glpi-project/tools": "^0.7"
},
"config": {
"autoloader-suffix": "PluginMoreoptions",
"optimize-autoloader": true,
"platform": {
"php": "8.2.99"
Expand Down
29 changes: 28 additions & 1 deletion templates/config.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@
#}

<div class="asset mo-config">
<form action="{{ path('plugins/moreoptions/front/config.form.php') }}" method="post">
<form id="mo-config-form-{{ rand }}" action="{{ path('plugins/moreoptions/front/config.form.php') }}" method="post">
<ul class="nav nav-tabs" role="tablist">
{% for tab in tabs %}
<li class="nav-item">
<a
class="nav-link {{ loop.first ? 'active' : '' }}"
id="mo-tab-{{ tab.id }}-{{ rand }}"
data-mo-tab="{{ tab.id }}"
data-bs-toggle="tab"
href="#mo-pane-{{ tab.id }}-{{ rand }}"
role="tab"
Expand Down Expand Up @@ -134,3 +135,29 @@
{{ include('components/form/buttons.html.twig') }}
</form>
</div>

<script>
(() => {
// The page is reloaded once saved: back on the tab it was saved from.
const form = document.getElementById('mo-config-form-{{ rand }}');
const key = 'moreoptions_config_tab';
try {
const saved = sessionStorage.getItem(key);
sessionStorage.removeItem(key);
const tab = saved !== null ? form.querySelector(`[data-mo-tab="${CSS.escape(saved)}"]`) : null;
if (tab !== null) {
bootstrap.Tab.getOrCreateInstance(tab).show();
}
} catch {
// No storage (private browsing): the first tab is shown.
}

form.addEventListener('submit', () => {
try {
sessionStorage.setItem(key, form.querySelector('.nav-link.active')?.dataset.moTab ?? '');
} catch {
// Same
}
});
})();
</script>
Loading