From 59449380527aad505a1937af3b97616add273b59 Mon Sep 17 00:00:00 2001 From: KarpAlex Date: Tue, 1 Jun 2021 15:18:54 +0200 Subject: [PATCH] Oehbeitraege GUI: correct table sorting and refreshing of tablesorter --- application/models/codex/Oehbeitrag_model.php | 3 ++- public/css/codex/oehbeitrag.css | 9 +++++-- public/js/codex/oehbeitrag.js | 26 +++++++++++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/application/models/codex/Oehbeitrag_model.php b/application/models/codex/Oehbeitrag_model.php index abc35a663..0df016ba8 100644 --- a/application/models/codex/Oehbeitrag_model.php +++ b/application/models/codex/Oehbeitrag_model.php @@ -36,6 +36,7 @@ class Oehbeitrag_model extends DB_Model /** * Gets all Studiensemester for which no Oehbeitrag value assignment exists. * @param string $start_studiensemester_kurzbz semester before the given semester are ignored + * @param array $excluded_oehbeitrag_id oehbeitraege to be ignored, i.e. which are assigned * @return object */ public function getUnassignedStudiensemester($start_studiensemester_kurzbz, $excluded_oehbeitrag_id = array()) @@ -64,7 +65,7 @@ class Oehbeitrag_model extends DB_Model * Checks if a Ă–hbeitrag can be assigned for a Studiensemester range. * @param string $von_studiensemester_kurzbz * @param string $bis_studiensemester_kurzbz - * @param array $excluded_oehbeitrag_id + * @param array $excluded_oehbeitrag_id oehbeitraege to ignore, i.e. which are assignable * @return object array with true if assignable, with false if not */ public function checkIfStudiensemesterAssignable($von_studiensemester_kurzbz, $bis_studiensemester_kurzbz = null, $excluded_oehbeitrag_id = array()) diff --git a/public/css/codex/oehbeitrag.css b/public/css/codex/oehbeitrag.css index 335489a1b..103c5d367 100644 --- a/public/css/codex/oehbeitrag.css +++ b/public/css/codex/oehbeitrag.css @@ -3,7 +3,12 @@ display: inline; } -.fa-edit, .fa-check { +.fa-edit { cursor: pointer; font-size: 1.2em; -} \ No newline at end of file +} + +.fa-check { + cursor: pointer; + font-size: 1.4em; +} diff --git a/public/js/codex/oehbeitrag.js b/public/js/codex/oehbeitrag.js index 68d39a897..9186c1bf0 100644 --- a/public/js/codex/oehbeitrag.js +++ b/public/js/codex/oehbeitrag.js @@ -154,6 +154,9 @@ var Oehbeitrag = { Oehbeitrag.deleteOehbeitrag(oehbeitrag_id); } ) + + // refresh tablesorter + Oehbeitrag._addTablesorter(); } else { @@ -200,6 +203,8 @@ var Oehbeitrag = { Oehbeitrag._setUpdateEvent($(this).prop("id"), fieldname, inputtype); } ); + + Oehbeitrag._addTablesorter(); } else { @@ -359,8 +364,25 @@ var Oehbeitrag = { }, _addTablesorter: function() { - let headers = {headers: { 0: { sorter: false}, 1: { sorter: false}, 4: { sorter: false}}}; - Tablesort.addTablesorter("oehbeitraegeTbl", [[0,0],[1,0]], ["zebra"], 8, headers); + // add parser through the tablesorter addParser method + $.tablesorter.addParser({ + // set a unique id + id: 'germandatesort', + is: function(s, table, cell, $cell) { + // return false so this parser is not auto detected + return false; + }, + format: function(s, table, cell, cellIndex) { + // format data, should sort by leading german date + return s.substring(0, 10).split(".").reverse().join(""); + }, + // set type, either numeric or text + type: 'numeric' + }); + + let headers = {headers: { 0: {sorter: "germandatesort"}, 1: {sorter: "germandatesort"}, 4: {sorter: false}}}; + + Tablesort.addTablesorter("oehbeitraegeTbl", [[0,1]], ["zebra"], 8, headers); }, /** * Formats a numeric value as a float with two decimals