mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-10-12 06:54:04 +00:00
Merge branch 'feature/76688-general-tabulator-issues_77080-persistence' into studvw_lvvw_2026_08_rc_77973_76688
This commit is contained in:
@@ -26,6 +26,7 @@ import moduleLayoutFitDataStretchFrozen from "../../tabulator/layouts/fitDataStr
|
||||
import InternalToExternalEventBroadcastModule from "../../tabulator/customModules/InternalToExternalEventBroadcastModule.js";
|
||||
import MenuExtensionModule from "../../tabulator/customModules/MenuExtensionModule.js";
|
||||
import ResponsiveLayoutExtensionModule from "../../tabulator/customModules/ResponsiveLayoutExtensionModule.js";
|
||||
import TablePresetsModule from "../../tabulator/customModules/TablePresetsModule.js";
|
||||
|
||||
import { debounce } from "../../helpers/DebounceHelper.js";
|
||||
|
||||
@@ -1057,6 +1058,7 @@ export const CoreFilterCmpt = {
|
||||
Tabulator.registerModule(InternalToExternalEventBroadcastModule);
|
||||
Tabulator.registerModule(MenuExtensionModule);
|
||||
Tabulator.registerModule(ResponsiveLayoutExtensionModule);
|
||||
Tabulator.registerModule(TablePresetsModule);
|
||||
},
|
||||
mounted() {
|
||||
this.initTabulator().then(() => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2022 fhcomplete.org
|
||||
* Copyright (C) 2026 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -172,7 +172,7 @@ export default {
|
||||
}
|
||||
|
||||
if (shouldUpdatePresetInfo) {
|
||||
this.presetInfo = {...preset};
|
||||
this.presetInfo = { ...preset };
|
||||
}
|
||||
|
||||
this.hideNewPresetForm();
|
||||
@@ -398,45 +398,8 @@ export default {
|
||||
window.localStorage["tabulatorPreset-" + this.$props.presetsId] =
|
||||
preset.id ? "custom:" + preset.id : "general:" + preset.name;
|
||||
|
||||
let columns = this.$props.tabulator
|
||||
.getColumnDefinitions()
|
||||
.filter((column) => column.field !== "collapse");
|
||||
columns.forEach((column) =>
|
||||
this.$props.tabulator.hideColumn(column.field),
|
||||
);
|
||||
|
||||
preset.displayedColumns?.forEach(
|
||||
(columnField, index, displayedColumns) => {
|
||||
this.$props.tabulator.showColumn(columnField);
|
||||
if (index === 0) return;
|
||||
this.$props.tabulator.moveColumn(
|
||||
columnField,
|
||||
displayedColumns[index - 1],
|
||||
true,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
this.$props.tabulator.clearHeaderFilter();
|
||||
if (preset.headerFilters) {
|
||||
Object.entries(preset.headerFilters).forEach(
|
||||
([columnField, filterValue]) => {
|
||||
this.$props.tabulator.setHeaderFilterValue(
|
||||
columnField,
|
||||
filterValue,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
this.$props.tabulator.clearSort();
|
||||
if (preset.sort?.column) {
|
||||
this.$props.tabulator.setSort(
|
||||
preset.sort.column,
|
||||
preset.sort.direction ?? "asc",
|
||||
);
|
||||
}
|
||||
|
||||
this.$props.tabulator.modules.tablePresets.applyPreset(preset);
|
||||
|
||||
this.$emit("tablePresetApplied", { preset });
|
||||
},
|
||||
async fetchCustomUserTabulatorPresets() {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import Module from "../../../../vendor/olifolkerd/tabulator5/src/js/core/Module.js";
|
||||
|
||||
export default class TablePresetsModule extends Module {
|
||||
static moduleName = "tablePresets";
|
||||
static moduleInitNumber = 1;
|
||||
|
||||
constructor(table) {
|
||||
super(table);
|
||||
}
|
||||
|
||||
applyPreset(preset) {
|
||||
let columnsConfig = this.table.options.columns;
|
||||
let reorderedColumnsConfig = [];
|
||||
preset.displayedColumns.forEach((columnField) => {
|
||||
let columnConfig = columnsConfig.find(
|
||||
(column) => column.field === columnField,
|
||||
);
|
||||
if (!columnConfig) return;
|
||||
columnConfig.visible = true;
|
||||
reorderedColumnsConfig.push(columnConfig);
|
||||
});
|
||||
|
||||
let hiddenColumnsConfig = columnsConfig
|
||||
.filter((column) => !preset.displayedColumns.includes(column.field))
|
||||
.map((column) => {
|
||||
column.visible = false;
|
||||
return column;
|
||||
});
|
||||
this.table.setColumns(
|
||||
reorderedColumnsConfig.concat(hiddenColumnsConfig),
|
||||
);
|
||||
|
||||
this.table.clearHeaderFilter();
|
||||
if (preset.headerFilters) {
|
||||
Object.entries(preset.headerFilters).forEach(
|
||||
([columnField, filterValue]) => {
|
||||
this.table.setHeaderFilterValue(
|
||||
columnField,
|
||||
filterValue,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
this.table.clearSort();
|
||||
if (preset.sort?.column) {
|
||||
this.table.setSort(
|
||||
preset.sort.column,
|
||||
preset.sort.direction ?? "asc",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user