From 5cc98562e30d35e0aba304fa21ff6ca1f51906a1 Mon Sep 17 00:00:00 2001 From: cris-technikum Date: Thu, 10 Jun 2021 09:37:16 +0200 Subject: [PATCH] Added focus on filterbutton, if table starts with stored filter Because tabulators persistentFilter = true, the table is initialized with the stored filter. Therfore probably less data was shown, but was not clear, because the corresponding filterbutton was not focused. Now the button is focused depending on the filter detected. Signed-off-by: cris-technikum --- .../anrechnung/approveAnrechnungUebersicht.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js b/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js index 7f00d20a6..60a890ce1 100644 --- a/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js +++ b/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js @@ -50,6 +50,7 @@ function hf_filterTrueFalse(headerValue, rowValue){ } // Adds column details +// Sets focus on filterbutton, if table starts with stored filter. function func_tableBuilt(table) { table.addColumn( { @@ -67,6 +68,12 @@ function func_tableBuilt(table) { } }, false, "status" // place column after status ); + + // Set focus on filterbutton + let filters = table.getFilters(); + if (filters.length > 0){ + approveAnrechnung.focusFilterbuttonIfTableStartsWithStoredFilter(filters); + } } // Formats the rows @@ -507,5 +514,40 @@ var approveAnrechnung = { // Copy begruendung into textarea textarea.val($.trim($(elem).parent().text())); + }, + focusFilterbuttonIfTableStartsWithStoredFilter(filters){ + switch (filters[0].value) { + case ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR: + $("#show-inProgressLektor").addClass('active'); + break; + case ANRECHNUNGSTATUS_APPROVED: + $("#show-approved").addClass('active'); + break; + case ANRECHNUNGSTATUS_REJECTED: + $("#show-rejected").addClass('active'); + break; + case ANRECHNUNGSTATUS_PROGRESSED_BY_STGL: + if (filters.length > 1) + { + if (filters[1].field == 'empfehlung_anrechnung') + { + if (filters[1].value === 'true') + { + $("#show-recommended").addClass('active'); + } + else + { + $("#show-not-recommended").addClass('active'); + } + } + } + else + { + $("#show-inProgressDP").addClass('active'); + } + + break; + + } } } \ No newline at end of file