From a5e915066a21dff4fc05488f9d2fdce722e19df1 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 24 Oct 2019 13:47:30 +0200 Subject: [PATCH] Added FOOTER to tabulator with CSV download and adapted GUI to LA erteilen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New: . tabulator footer with - buttons Alle auswählen/abwählen - display number of selected rows - CSV download . filter buttons - approve-button now initially activated and focused, toggle on click - now as buttongroup in extra row . Lehrauftrag erteilen - button disabled when filter on dummies --- .../lehre/lehrauftrag/approveLehrauftrag.php | 123 +++++++++++++----- .../lehrauftrag/approveLehrauftragData.php | 9 +- 2 files changed, 100 insertions(+), 32 deletions(-) diff --git a/application/views/lehre/lehrauftrag/approveLehrauftrag.php b/application/views/lehre/lehrauftrag/approveLehrauftrag.php index aa914f29a..30dd1d497 100644 --- a/application/views/lehre/lehrauftrag/approveLehrauftrag.php +++ b/application/views/lehre/lehrauftrag/approveLehrauftrag.php @@ -95,21 +95,28 @@ $this->load->view( +
-
+
- - - - - - - - - +
+ + @@ -124,9 +131,9 @@ $this->load->view( * PNG icons used in status- and filter buttons * Setting png icons is a workaround to use font-awsome 5.9.0 icons until system can be updated to newer font awsome version. * */ - const ICON_LEHRAUFTRAG_ORDERED = ''; - const ICON_LEHRAUFTRAG_APPROVED = ''; - const ICON_LEHRAUFTRAG_CHANGED = ''; + const ICON_LEHRAUFTRAG_ORDERED = ''; + const ICON_LEHRAUFTRAG_APPROVED = ''; + const ICON_LEHRAUFTRAG_CHANGED = ''; // ----------------------------------------------------------------------------------------------------------------- // Mutators - setter methods to manipulate table data when entering the tabulator @@ -311,6 +318,65 @@ $this->load->view( } + // Tabulator footer element + // ----------------------------------------------------------------------------------------------------------------- + + // Adds a footer with buttons select all / deselect all / download + function func_footerElement(){ + + var footer_html = '
'; + footer_html += '
'; + + footer_html += ''; + + footer_html += ''; + + footer_html += '
'; + footer_html += '
'; + + return footer_html; + } + + // Performs download CSV + function footer_downloadCSV(){ + $('#filterTabulator').tabulator("download", "csv", "data.csv", {bom:true}); // BOM for correct UTF-8 char output + } + + /* + * Performs select all + * Select all (filtered) rows that are bestellt + */ + function footer_selectAll(){ + $('#filterTabulator').tabulator('getRows', true) + .filter(row => row.getData().personalnummer >= 0 && // NOT dummies + row.getData().bestellt != null && // AND bestellt + row.getData().erteilt == null) // AND NOT erteilt + .forEach((row => row.select())); + } + + /* + * Performs deselect all + * Deselect all (filtered) rows + */ + function footer_deselectAll(){ + $('#filterTabulator').tabulator('deselectRow'); + } + + // Displays number of selected rows on row selection change + function func_rowSelectionChanged(data, rows){ + $('#number-selected').html("Für Erteilung ausgewählt: " + rows.length + ""); + } + // ----------------------------------------------------------------------------------------------------------------- // Tabulator columns format functions // ----------------------------------------------------------------------------------------------------------------- @@ -427,20 +493,6 @@ $this->load->view( } $(function() { - // Select all (filtered) rows, where status bestellt has a value and status erteilt has no value. - $("#select-all").click(function(){ - $('#filterTabulator').tabulator('getRows', true) - .filter(function(row){ - return row.getData().bestellt != null && row.getData().erteilt == null; - }) - .forEach((row => row.select())); - }); - - // Deselect all (filtered) rows - $("#deselect-all").click(function(){ - $('#filterTabulator').tabulator('deselectRow'); - }); - // Show all rows $("#show-all").click(function(){ $('#filterTabulator').tabulator('clearFilter'); @@ -523,10 +575,21 @@ $(function() { } }); - // Focus on clicked button + // De/activate and un/focus on clicked button, En-/Disable 'Lehrauftrag erteilen' $(".btn-lehrauftrag").click(function() { - $(".btn-lehrauftrag").removeClass('focus'); - $(this).addClass('focus'); + + // De/activate and un/focus on clicked button + $(".btn-lehrauftrag").removeClass('focus').removeClass('active'); + $(this).addClass('focus').addClass('active'); + + // Enable button 'Lehrauftrag bestellen' by default + $('#approve-lehrauftraege').attr('disabled', false).attr('title', ''); + + // Disable button Lehrauftrag bestellen for dummies + if (this.id == 'show-dummies') + { + $('#approve-lehrauftraege').attr('disabled', true).attr('title', 'Lehraufträge ohne Lektorzuteilung können nicht bestellt werden.'); + } }); $("#download-cvs").click(function(){ diff --git a/application/views/lehre/lehrauftrag/approveLehrauftragData.php b/application/views/lehre/lehrauftrag/approveLehrauftragData.php index 02f954ab2..301f1de96 100644 --- a/application/views/lehre/lehrauftrag/approveLehrauftragData.php +++ b/application/views/lehre/lehrauftrag/approveLehrauftragData.php @@ -343,10 +343,14 @@ $filterWidgetArray = array( selectablePersistence:false, // deselect previously selected rows when table is filtered, sorted or paginated selectableCheck: function(row){ return func_selectableCheck(row); - }, + }, + footerElement: func_footerElement(), rowUpdated:function(row){ func_rowUpdated(row); }, + rowSelectionChanged:function(data, rows){ + func_rowSelectionChanged(data, rows); + }, rowFormatter:function(row) { func_rowFormatter(row); @@ -362,7 +366,8 @@ $filterWidgetArray = array( // column status is built dynamically in funcTableBuilt(), row_index: {visible:false}, // necessary for row indexing personalnummer: {visible: false}, - lehreinheit_id: {headerFilter:"input", bottomCalc:"count", bottomCalcFormatter:function(cell){return "Anzahl: " + cell.getValue();},}, + lehreinheit_id: {headerFilter:"input", bottomCalc:"count", width: "7%", + bottomCalcFormatter:function(cell){return "Anzahl: " + cell.getValue();},}, lehrveranstaltung_id: {headerFilter:"input"}, lv_bezeichnung: {visible: false}, projektarbeit_id: {visible: false},