mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Readd tab remember function to improve UX.
This commit is contained in:
parent
9cc5208223
commit
47130846a2
7 changed files with 40 additions and 36 deletions
|
@ -43,7 +43,7 @@ require('bootstrap');
|
||||||
import "./sidebar"
|
import "./sidebar"
|
||||||
import "./datatables";
|
import "./datatables";
|
||||||
import "./error_handler";
|
import "./error_handler";
|
||||||
//import "./tab_remember";
|
import "./tab_remember";
|
||||||
import "./register_events";
|
import "./register_events";
|
||||||
import "./tristate_checkboxes";
|
import "./tristate_checkboxes";
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import 'datatables.net-responsive-bs5';
|
||||||
import './lib/datatables';
|
import './lib/datatables';
|
||||||
|
|
||||||
|
|
||||||
const DatatablesHelper = class {
|
class DatatablesHelper {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.registerLoadHandler(() => this.initDataTables());
|
this.registerLoadHandler(() => this.initDataTables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as bootbox from "bootbox";
|
||||||
* If this class is imported the user is shown an error dialog if he calls an page via Turbo and an error is responded.
|
* If this class is imported the user is shown an error dialog if he calls an page via Turbo and an error is responded.
|
||||||
* @type {ErrorHandlerHelper}
|
* @type {ErrorHandlerHelper}
|
||||||
*/
|
*/
|
||||||
const ErrorHandlerHelper = class {
|
class ErrorHandlerHelper {
|
||||||
constructor() {
|
constructor() {
|
||||||
console.log('Error Handler registered');
|
console.log('Error Handler registered');
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import "bootstrap-fileinput";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const RegisterEventHelper = class {
|
class RegisterEventHelper {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.registerTooltips();
|
this.registerTooltips();
|
||||||
this.registerJumpToTopBtn();
|
this.registerJumpToTopBtn();
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import "patternfly-bootstrap-treeview/src/css/bootstrap-treeview.css"
|
import "patternfly-bootstrap-treeview/src/css/bootstrap-treeview.css"
|
||||||
import "patternfly-bootstrap-treeview";
|
import "patternfly-bootstrap-treeview";
|
||||||
|
|
||||||
const SidebarHelper = class {
|
class SidebarHelper {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.BASE = $("body").data("base-url");
|
this.BASE = $("body").data("base-url");
|
||||||
//If path doesn't end with slash, add it.
|
//If path doesn't end with slash, add it.
|
||||||
|
|
|
@ -5,11 +5,15 @@
|
||||||
* that tab on reload. That means that if the user changes something, he does not have to switch back to the tab
|
* that tab on reload. That means that if the user changes something, he does not have to switch back to the tab
|
||||||
* where he was before submit.
|
* where he was before submit.
|
||||||
*/
|
*/
|
||||||
let TabRememberHelper = new class {
|
class TabRememberHelper {
|
||||||
constructor() {
|
constructor() {
|
||||||
document.addEventListener("turbo:load", () => {
|
document.addEventListener("turbo:load", this.onLoad);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onLoad(event) {
|
||||||
//Determine which tab should be shown (use hash if specified, otherwise use localstorage)
|
//Determine which tab should be shown (use hash if specified, otherwise use localstorage)
|
||||||
var $activeTab = null;
|
let $activeTab = null;
|
||||||
if (location.hash) {
|
if (location.hash) {
|
||||||
$activeTab = $('a[href=\'' + location.hash + '\']');
|
$activeTab = $('a[href=\'' + location.hash + '\']');
|
||||||
} else if (localStorage.getItem('activeTab')) {
|
} else if (localStorage.getItem('activeTab')) {
|
||||||
|
@ -26,7 +30,7 @@ let TabRememberHelper = new class {
|
||||||
$activeTab.tab('show');
|
$activeTab.tab('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
$('body').on('click', 'a[data-toggle=\'tab\']', function (e) {
|
$('body').on('click', 'a[data-bs-toggle=\'tab\']', function (e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
var tab_name = this.getAttribute('href')
|
var tab_name = this.getAttribute('href')
|
||||||
if (history.replaceState) {
|
if (history.replaceState) {
|
||||||
|
@ -39,8 +43,8 @@ let TabRememberHelper = new class {
|
||||||
$(this).tab('show');
|
$(this).tab('show');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//export default new TabRememberHelper();
|
}
|
||||||
|
|
||||||
|
export default new TabRememberHelper();
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import "./lib/jquery.tristate"
|
import "./lib/jquery.tristate"
|
||||||
|
|
||||||
const TristateHelper = class {
|
class TristateHelper {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.registerTriStateCheckboxes();
|
this.registerTriStateCheckboxes();
|
||||||
this.registerSubmitHandler();
|
this.registerSubmitHandler();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue