From 70418b8ff68d6ac8c3f3387e1c10251bb6c4a019 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 12 Mar 2024 14:28:01 +0100 Subject: [PATCH] updates TableWidget.js functions that are no longer valid in tabulator5 --- .../approveAnrechnungUebersichtData.php | 14 ++-- public/js/TableWidget.js | 77 +++++++++++++------ 2 files changed, 59 insertions(+), 32 deletions(-) diff --git a/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php b/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php index 1948f847b..754bf7ccb 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php +++ b/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php @@ -238,7 +238,7 @@ $filterWidgetArray = array( begruendung_id: {visible: false, headerFilter:"input"}, dms_id: {visible: false, headerFilter:"input"}, schreibberechtigt: { - formatter:"tickCross", align:"center", + formatter:"tickCross", hozAlign:"center", headerFilter:"tickCross", headerFilterParams:{tristate: true}, headerFilterFunc: hf_schreibberechtigt }, studiensemester_kurzbz: {visible: false, headerFilter:"input"}, @@ -247,22 +247,22 @@ $filterWidgetArray = array( orgform_kurzbz: {headerFilter:"input"}, ausbildungssemester: {headerFilter:"input"}, lv_bezeichnung: {headerFilter:"input"}, - ects: {headerFilter:"input", align:"center"}, + ects: {headerFilter:"input", hozAlign:"center"}, ectsSumBisherUndNeu: {formatter: format_ectsSumBisherUndNeu}, - ectsSumSchulisch: {visible: false, headerFilter:"input", align:"right"}, - ectsSumBeruflich: {visible: false, headerFilter:"input", align:"right"}, + ectsSumSchulisch: {visible: false, headerFilter:"input", hozAlign:"right"}, + ectsSumBeruflich: {visible: false, headerFilter:"input", hozAlign:"right"}, begruendung: {headerFilter:"input", visible: true}, student: {headerFilter:"input"}, zgv: {headerFilter:"input"}, dokument_bezeichnung: {headerFilter:"input", formatter:"link", formatterParams: paramLookup_dokBez}, anmerkung_student: {headerFilter:"input"}, - antragsdatum: {align:"center", headerFilter:"input", mutator: mut_formatStringDate}, - empfehlung_anrechnung: {headerFilter:"input", align:"center", formatter: format_empfehlung_anrechnung, headerFilterFunc: hf_filterTrueFalse}, + antragsdatum: {hozAlign:"center", headerFilter:"input", mutator: mut_formatStringDate}, + empfehlung_anrechnung: {headerFilter:"input", hozAlign:"center", formatter: format_empfehlung_anrechnung, headerFilterFunc: hf_filterTrueFalse}, status_kurzbz: {visible: false, headerFilter:"input"}, status_bezeichnung: {headerFilter:"input"}, prestudent_id: {visible: false, headerFilter:"input"}, - empfehlungsanfrageAm: {visible: false, align:"center", headerFilter:"input", mutator: mut_formatStringDate}, + empfehlungsanfrageAm: {visible: false, hozAlign:"center", headerFilter:"input", mutator: mut_formatStringDate}, empfehlungsanfrageAn: {visible: false, headerFilter:"input"} }', // col properties ); diff --git a/public/js/TableWidget.js b/public/js/TableWidget.js index 0a1166bf8..36bbf6288 100644 --- a/public/js/TableWidget.js +++ b/public/js/TableWidget.js @@ -161,6 +161,42 @@ var FHC_TableWidget = { FHC_TableWidget._renderDataset(tableWidgetDiv, data); FHC_TableWidget._turnOnEvents(tableWidgetDiv); // turns all the events off + + FHC_TableWidget._onTableBuilt(tableWidgetDiv, data); + }, + + + _onTableBuilt: function(tableWidgetDiv, data) { + var options = FHC_TableWidget._getRepresentationOptions(data); + + tableWidgetDiv.find("#tableWidgetTabulator").tabulator("on","tableBuilt",()=>{ + + if (typeof options.tableWidgetHeader == 'undefined' || + (typeof options.tableWidgetHeader != 'undefined' && options.tableWidgetHeader != false)) + { + // renders the table headers + var tabulatorHeaderCollapseHTML = _renderTabulatorHeaderCollapseHTML(tableWidgetDiv); + tableWidgetDiv.find('#tableWidgetHeader').after(tabulatorHeaderCollapseHTML); + } + + + // makes the table headers toggle visibility when clicking on them + tableWidgetDiv.find('.btn-select-col').on('click', function() + { + var selected = this.value; + + tableWidgetDiv.find("#tableWidgetTabulator").tabulator('toggleColumn', selected); + + // toggle class to color button as selected / deselected + $(this).toggleClass('btn-select-col-selected').blur(); // blur removes automatic focus + }) + + + + + + + }) }, /** @@ -263,18 +299,7 @@ var FHC_TableWidget = { }) // Click-Event to toggle column-picker columns - //! was changed to be added when the table was built first - tableWidgetDiv.find("#tableWidgetTabulator").tabulator("on","tableBuilt",()=>{ - tableWidgetDiv.find('.btn-select-col').on('click', function() - { - var selected = this.value; - - tableWidgetDiv.find("#tableWidgetTabulator").tabulator('toggleColumn', selected); - - // toggle class to color button as selected / deselected - $(this).toggleClass('btn-select-col-selected').blur(); // blur removes automatic focus - }) - }); + //! this event was moved to the _onTableBuilt function } }, @@ -298,6 +323,8 @@ var FHC_TableWidget = { { FHC_TableWidget._renderDatasetTabulator(tableWidgetDiv, data); // ...render the tabulator GUI } + + }, /** @@ -545,13 +572,18 @@ var FHC_TableWidget = { if (data.hasOwnProperty("dataset") && $.isArray(data.dataset)) { if (options == null) options = {}; - + + options.columnDefaults={ + // set header tooltip with column title + //! the old keyword is tooltipsHeader, the new keyword for the option is headerTooltip + headerTooltip: (typeof options.columnDefaults.tooltipsHeader == 'undefined') ? true : options.columnDefaults.tooltipsHeader + } options.columns = arrayTabulatorColumns; options.data = data.dataset; options.persistence = (typeof options.persistence == 'undefined') ? true : options.persistence; // enables persistence (default store in localStorage if available, else in cookie) options.persistenceID = (typeof options.persistenceID == 'undefined') ? data.tableUniqueId : options.persistenceID; // persistenceID to store persistence data seperately for multiple tables options.movableColumns = (typeof options.movableColumns == 'undefined') ? true : options.movableColumns; // allows changing column order - options.tooltipsHeader = (typeof options.tooltipsHeader == 'undefined') ? true : options.tooltipsHeader; // set header tooltip with column title + options.placeholder = _func_placeholder(); // display text when table is empty // OLD tabulator v4 @@ -569,14 +601,11 @@ var FHC_TableWidget = { // Renders the tabulator tableWidgetDiv.find("#tableWidgetTabulator").tabulator(options); + + //! the following callbacks need to be attached after the table has built in tabulator version 5+ tableWidgetDiv.find("#tableWidgetTabulator").tabulator("on","rowSelectionChanged",_func_rowSelectionChanged); tableWidgetDiv.find("#tableWidgetTabulator").tabulator("on","columnVisibilityChanged",_func_columnVisibilityChanged); - // notify other js files that work on the tabulator instance that the tabulator is initialized by triggering the event tableInit - - - - } } @@ -593,12 +622,10 @@ var FHC_TableWidget = { var tabulatorHeaderHTML = _renderTabulatorHeaderHTML(tableWidgetDiv); tableWidgetDiv.find('#tableWidgetHeader').append(tabulatorHeaderHTML); - tableWidgetDiv.find("#tableWidgetTabulator").tabulator("on","tableBuilt",()=>{ - - // Render the collapsable div triggered by button in tableWidgetHeader - var tabulatorHeaderCollapseHTML = _renderTabulatorHeaderCollapseHTML(tableWidgetDiv); - tableWidgetDiv.find('#tableWidgetHeader').after(tabulatorHeaderCollapseHTML); - }); + + // Render the collapsable div triggered by button in tableWidgetHeader + //! this rendering was moved to the _onTableBuilt function + }