diff --git a/public/js/components/Cis/Profil/MitarbeiterProfil.js b/public/js/components/Cis/Profil/MitarbeiterProfil.js index b9ebc7dee..4d719fcc1 100644 --- a/public/js/components/Cis/Profil/MitarbeiterProfil.js +++ b/public/js/components/Cis/Profil/MitarbeiterProfil.js @@ -446,6 +446,7 @@ export default { :tabulator-options="funktionen_table_options" tableOnly :sideMenu="false" + :isUsingPresets="true" />
@@ -457,6 +458,7 @@ export default { :tabulator-options="betriebsmittel_table_options" tableOnly :sideMenu="false" + :isUsingPresets="true" />
diff --git a/public/js/components/filter/Filter.js b/public/js/components/filter/Filter.js index 5f0447aea..3027ef377 100644 --- a/public/js/components/filter/Filter.js +++ b/public/js/components/filter/Filter.js @@ -18,6 +18,7 @@ import {CoreFetchCmpt} from '../../components/Fetch.js'; import FilterConfig from './Filter/Config.js'; import FilterColumns from './Filter/Columns.js'; +import TablePresets from './Filter/TablePresets.js'; import TableDownload from './Table/Download.js'; import collapseAutoClose from '../../directives/collapseAutoClose.js'; @@ -45,7 +46,8 @@ export const CoreFilterCmpt = { CoreFetchCmpt, FilterConfig, FilterColumns, - TableDownload + TablePresets, + TableDownload, }, directives: { collapseAutoClose @@ -91,6 +93,10 @@ export const CoreFilterCmpt = { type: Boolean, default: true }, + isUsingPresets: { + Boolean, + default: false, + }, }, inject: ["language"], data: function() { @@ -841,7 +847,7 @@ export const CoreFilterCmpt = { }); }, - template: ` + template: /*html*/ ` + + + + + . + */ + +/** + * + */ +export default { + name: "TablePresets", + props: ["identifier", "tabulator"], + emits: {}, + data: function () { + return { + // todo: remove once actual data is fetched + testDataForUIDev: [ + { + id: null, + name: "Test Preset 1", + displayedColumns: { + testCol1: true, + testCol2: false, + testCol3: true, + testCol4: false, + testCol5: true, + }, + filters: { + testCol3: "adis", + testCol5: "01.06.2026.-31.12.2026.", + }, + columnsOrder: ["testCol3", "testCol5", "testCol1"], + sort: { + column: "testCol1", + direction: "asc", + }, + isUserCustom: false, + }, + { + id: 1, + name: "Test Preset 2", + displayedColumns: { + testCol1: true, + testCol2: true, + testCol3: true, + testCol4: false, + testCol5: false, + }, + filters: { + testCol1: "posko", + }, + columnsOrder: ["testCol1", "testCol3", "testCol2"], + sort: { + column: "testCol3", + direction: "desc", + }, + }, + ], + presetInfo: null, + }; + }, + computed: { + presetInfoFormattedStrings() { + if (!this.presetInfo) return null; + + const displayedColumns = Object.keys(this.presetInfo.displayedColumns).filter((column) => this.presetInfo.displayedColumns[column]); + const filters = Object.keys(this.presetInfo.filters).map((column) => column + ": \"" + this.presetInfo.filters[column] + "\""); + return { + displayedColumns: "Displayed columns: " + displayedColumns.join(", "), + columnsOrder: "Columns ordering: " + this.presetInfo.columnsOrder.join(", "), + filters: "Column filters: " + filters.join(", "), + sort: "Sort: " + this.presetInfo.sort.column + " (" + (this.presetInfo.sort.direction === "asc" ? "ascending" : "descending") + ")", + }; + }, + }, + watch: { + // todo: watch presets, once they change nullify presetInfo and collapse preset info section + }, + methods: { + async showPresetInfo(preset) { + if (preset !== this.presetInfo) { + this.presetInfo = preset; + } + await this.$nextTick(); + if (!this.$refs.presetInfoCollapsible.getAttribute("class").split(" ").includes("show")) { + this.togglePresetInfoCollapsible(); + } + }, + hidePresetInfo() { + this.presetInfo = null; + this.togglePresetInfoCollapsible(); + }, + togglePresetInfoCollapsible() { + new bootstrap.Collapse("#presetInfoCollapsible" + this.$props.identifier, {toggle: true}); + }, + deletePreset(preset) { + // todo + }, + showNewPresetForm() { + // todo + if (!this.$refs.newPresetFormCollapsible.getAttribute("class").split(" ").includes("show")) { + this.toggleNewPresetFormCollapsible(); + } + + }, + toggleNewPresetFormCollapsible() { + new bootstrap.Collapse("#newPresetFormCollapsible" + this.$props.identifier, {toggle: true}); + }, + applyPreset() { + // todo + }, + }, + template: /*html*/ ` +
+
+
Table Presets
+
+
+
+
{{ preset.name }}
+
+
+ + +
+
+
+
+
+ + {{ "Save current configuration" }} +
+
+
+
+
+
+
+
+ {{ presetInfo?.name }} + +
+ {{ presetInfoFormattedStrings?.displayedColumns }} + {{ presetInfoFormattedStrings?.columnsOrder }} + {{ presetInfoFormattedStrings?.filters }} + {{ presetInfoFormattedStrings?.sort }} +
+
+
+
+ +
+
+
+
+ {{ "Save current configuration" }} + +
+ adis +
+
+
+
+
+
+ `, +};