mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-01 19:09:27 +00:00
Code refactoring of Dynamic ECTS Summen
. now build with tabulators column formatter. . rows are reinitialized instead of using the updateData. . format of cell background-color has moved out from row formatter to cell formatter
This commit is contained in:
@@ -127,7 +127,8 @@ $this->load->view(
|
||||
<td colspan="3"><span id="ects"><?php echo $antragData->ects ?></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="col-xs-4">Bisher angerechnete ECTS
|
||||
<th class="col-xs-4">
|
||||
<?php echo $this->p->t('anrechnung', 'bisherAngerechneteEcts'); ?>
|
||||
<span class="approveAnrechnungDetail-anrechnungEctsTooltip"
|
||||
data-toggle="tooltip" data-placement="right"
|
||||
title="<?php echo $this->p->t('anrechnung', 'anrechnungEctsTooltipText'); ?>">
|
||||
@@ -139,6 +140,7 @@ $this->load->view(
|
||||
[Schulisch: <span id="sumEctsSchulisch"><?php echo $antragData->sumEctsSchulisch ?></span> /
|
||||
Beruflich: <span id="sumEctsBeruflich"><?php echo $antragData->sumEctsBeruflich ?></span> ]
|
||||
<span id="sumEctsMsg"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="col-xs-4"><?php echo $this->p->t('lehre', 'lektorInnen'); ?></th>
|
||||
|
||||
@@ -79,8 +79,6 @@ $query = '
|
||||
anrechnungen.lv_bezeichnung,
|
||||
anrechnungen.ects::float4 AS ects,
|
||||
NULL AS "ectsSumBisherUndNeu",
|
||||
anrechnungen.ectsSumSchulisch::float4 AS "ectsSumBisherUndNeuSchulisch",
|
||||
anrechnungen.ectsSumBeruflich::float4 AS "ectsSumBisherUndNeuBeruflich",
|
||||
anrechnungen.ectsSumSchulisch::float4 AS "ectsSumSchulisch",
|
||||
anrechnungen.ectsSumBeruflich::float4 AS "ectsSumBeruflich",
|
||||
anrechnungen.begruendung,
|
||||
@@ -151,8 +149,6 @@ $filterWidgetArray = array(
|
||||
ucfirst($this->p->t('lehre', 'lehrveranstaltung')),
|
||||
'ECTS (LV)',
|
||||
'ECTS (LV + Bisher)',
|
||||
'ECTS (LV + Schule)',
|
||||
'ECTS (LV + Beruf)',
|
||||
'ECTS (Bisher schulisch)',
|
||||
'ECTS (Bisher beruflich',
|
||||
ucfirst($this->p->t('global', 'begruendung')),
|
||||
@@ -178,7 +174,7 @@ $filterWidgetArray = array(
|
||||
headerFilterPlaceholder: " ",
|
||||
index: "anrechnung_id", // assign specific column as unique id (important for row indexing)
|
||||
selectable: true, // allow row selection
|
||||
selectableRangeMode: "click", // allow range selection using shift end click on end of range -- TODO: check, löst rowSelectionChanged 2* aus
|
||||
selectableRangeMode: "click", // allow range selection using shift end click on end of range
|
||||
selectablePersistence:false, // deselect previously selected rows when table is filtered, sorted or paginated
|
||||
tableBuilt: function(){
|
||||
func_tableBuilt(this);
|
||||
@@ -214,9 +210,7 @@ $filterWidgetArray = array(
|
||||
ausbildungssemester: {headerFilter:"input"},
|
||||
lv_bezeichnung: {headerFilter:"input"},
|
||||
ects: {headerFilter:"input", align:"center"},
|
||||
ectsSumBisherUndNeu: {mutator: mut_getEctsSumBisherUndNeu, formatter:"html"},
|
||||
ectsSumBisherUndNeuSchulisch: {headerFilter: "input", visible: false},
|
||||
ectsSumBisherUndNeuBeruflich: {headerFilter: "input", visible: false},
|
||||
ectsSumBisherUndNeu: {formatter: format_ectsSumBisherUndNeu},
|
||||
ectsSumSchulisch: {visible: true, headerFilter:"input", align:"right"},
|
||||
ectsSumBeruflich: {visible: true, headerFilter:"input", align:"right"},
|
||||
begruendung: {headerFilter:"input", visible: true},
|
||||
|
||||
@@ -568,7 +568,6 @@ var approveAnrechnungDetail = {
|
||||
(parseFloat($('#ects').text()) + parseFloat($('#sumEctsSchulisch').text()) + parseFloat($('#sumEctsBeruflich').text())) > 90
|
||||
)
|
||||
{
|
||||
console.log('inside');
|
||||
$('#sumEctsMsg').html("<br><b>ACHTUNG! Bei Anrechnung von LV: Maximale ECTS überschritten.</b></br>").css('backgroundColor', COLOR_DANGER);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -11,7 +11,9 @@ const COLOR_LIGHTGREY = "#f5f5f5";
|
||||
const COLOR_DANGER = '#f2dede';
|
||||
|
||||
var tabulator = null; // Set in tableBuilt function.
|
||||
var rowSelectionChanged = false; // Set in rowSelectionChanged function. Useful in rowUpdate to differ update behaviour.
|
||||
|
||||
// Array with accumulated LV ECTS by Prestudent. Used to find out if max ECTS are exceeded.
|
||||
var selectedPrestudentWithAccumulatedLvEcts = [];
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Mutators - setter methods to manipulate table data when entering the tabulator
|
||||
@@ -27,20 +29,6 @@ var mut_formatStringDate = function(value, data, type, params, component) {
|
||||
}
|
||||
}
|
||||
|
||||
var mut_getEctsSumBisherUndNeu = function(value, data, type, params, component){
|
||||
|
||||
let ectsSumBisherUndNeuTotal = (data.ectsSumBisherUndNeuSchulisch + data.ectsSumBisherUndNeuBeruflich);
|
||||
let ectsSumBisherUndNeuSchulisch = data.ectsSumBisherUndNeuSchulisch;
|
||||
let ectsSumBisherUndNeuBeruflich = data.ectsSumBisherUndNeuBeruflich;
|
||||
|
||||
// Format text
|
||||
ectsSumBisherUndNeuTotal = (ectsSumBisherUndNeuTotal > 90) ? "<span class='text-danger'><b><u>" + ectsSumBisherUndNeuTotal + "</u></b></span>" : ectsSumBisherUndNeuTotal;
|
||||
ectsSumBisherUndNeuSchulisch = (ectsSumBisherUndNeuSchulisch > 60) ? "<span class='text-danger'><b><u>" + ectsSumBisherUndNeuSchulisch + "</u></b></span>" : ectsSumBisherUndNeuSchulisch;
|
||||
ectsSumBisherUndNeuBeruflich = (ectsSumBisherUndNeuBeruflich > 60) ? "<span class='text-danger'><b><u>" + ectsSumBisherUndNeuBeruflich + "</u></b></span>" : ectsSumBisherUndNeuBeruflich;
|
||||
|
||||
return "T: " + ectsSumBisherUndNeuTotal + " [ S: " + ectsSumBisherUndNeuSchulisch + " | B: " + ectsSumBisherUndNeuBeruflich + " ]";
|
||||
}
|
||||
|
||||
// TABULATOR FUNCTIONS
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// Returns relative height (depending on screen size)
|
||||
@@ -98,34 +86,65 @@ function func_tableBuilt(table) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats column ECTS (LV + Bisher).
|
||||
*/
|
||||
var format_ectsSumBisherUndNeu = function(cell, formatterParams, onRendered){
|
||||
let row = cell.getRow();
|
||||
let rowData = row.getData();
|
||||
|
||||
let begruendung_id = (rowData.begruendung_id);
|
||||
let ectsSumBisherUndNeuTotal = (rowData.ectsSumSchulisch + rowData.ectsSumBeruflich);
|
||||
let ectsSumBisherUndNeuSchulisch = rowData.ectsSumSchulisch;
|
||||
let ectsSumBisherUndNeuBeruflich = rowData.ectsSumBeruflich;
|
||||
|
||||
// If exists, add accumulated LV ECTS to bisherige ECTS
|
||||
if (selectedPrestudentWithAccumulatedLvEcts.length > 0)
|
||||
{
|
||||
let selectedPrestudent = selectedPrestudentWithAccumulatedLvEcts.find(x => x.prestudent_id === rowData.prestudent_id);
|
||||
|
||||
if (selectedPrestudent != undefined)
|
||||
{
|
||||
ectsSumBisherUndNeuTotal = (rowData.ectsSumSchulisch + rowData.ectsSumBeruflich) + selectedPrestudent.ectsSumAnzurechnendeLvsSchulisch;
|
||||
ectsSumBisherUndNeuSchulisch = rowData.ectsSumSchulisch + selectedPrestudent.ectsSumAnzurechnendeLvsSchulisch;
|
||||
ectsSumBisherUndNeuBeruflich = rowData.ectsSumBeruflich + selectedPrestudent.ectsSumAnzurechnendeLvsBeruflich;
|
||||
}
|
||||
|
||||
// Color column if maximum ECTS exceeded
|
||||
if (begruendung_id != 5 && row.isSelected())
|
||||
{
|
||||
|
||||
if (
|
||||
(ectsSumBisherUndNeuSchulisch + ectsSumBisherUndNeuBeruflich) > 90 ||
|
||||
ectsSumBisherUndNeuSchulisch > 60 ||
|
||||
ectsSumBisherUndNeuBeruflich > 60
|
||||
)
|
||||
{
|
||||
cell.getElement().style["background-color"] = COLOR_DANGER;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cell.getElement().style.removeProperty('background-color');
|
||||
}
|
||||
}
|
||||
|
||||
// If max ECTS is exceeded, format font color / weight
|
||||
ectsSumBisherUndNeuTotal = (ectsSumBisherUndNeuTotal > 90) ? "<span class='text-danger'><b><u>" + ectsSumBisherUndNeuTotal + "</u></b></span>" : ectsSumBisherUndNeuTotal;
|
||||
ectsSumBisherUndNeuSchulisch = (ectsSumBisherUndNeuSchulisch > 60) ? "<span class='text-danger'><b><u>" + ectsSumBisherUndNeuSchulisch + "</u></b></span>" : ectsSumBisherUndNeuSchulisch;
|
||||
ectsSumBisherUndNeuBeruflich = (ectsSumBisherUndNeuBeruflich > 60) ? "<span class='text-danger'><b><u>" + ectsSumBisherUndNeuBeruflich + "</u></b></span>" : ectsSumBisherUndNeuBeruflich;
|
||||
|
||||
return "T: " + ectsSumBisherUndNeuTotal + " [ S: " + ectsSumBisherUndNeuSchulisch + " | B: " + ectsSumBisherUndNeuBeruflich + " ]";
|
||||
}
|
||||
|
||||
// Formats the rows
|
||||
function func_rowFormatter(row){
|
||||
let status_kurzbz = row.getData().status_kurzbz;
|
||||
let begruendung_id = row.getData().begruendung_id;
|
||||
let ectsSumBisherUndNeuSchulisch = row.getData().ectsSumBisherUndNeuSchulisch;
|
||||
let ectsSumBisherUndNeuBeruflich = row.getData().ectsSumBisherUndNeuBeruflich;
|
||||
|
||||
if (status_kurzbz != ANRECHNUNGSTATUS_PROGRESSED_BY_STGL)
|
||||
{
|
||||
row.getElement().style["background-color"] = COLOR_LIGHTGREY; // default
|
||||
}
|
||||
|
||||
// Color column if maximum ECTS exceeded
|
||||
if (begruendung_id != 5 && row.isSelected())
|
||||
{
|
||||
if (
|
||||
(ectsSumBisherUndNeuSchulisch + ectsSumBisherUndNeuBeruflich) > 90 ||
|
||||
ectsSumBisherUndNeuSchulisch > 60 ||
|
||||
ectsSumBisherUndNeuBeruflich > 60
|
||||
)
|
||||
{
|
||||
row.getCell('ectsSumBisherUndNeu').getElement().style["background-color"] = COLOR_DANGER;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
row.getCell('ectsSumBisherUndNeu').getElement().style.removeProperty('background-color');
|
||||
}
|
||||
}
|
||||
|
||||
// Formats row selectable/unselectable
|
||||
@@ -139,57 +158,28 @@ function func_selectableCheck(row){
|
||||
);
|
||||
}
|
||||
|
||||
// Format rows when maximum ECTS are exceeded.
|
||||
// Calculate dynamically sum of all LV ECTS by Student and display, when maximum ECTS are exceeded.
|
||||
// data = selected data, rows = selected rows
|
||||
function func_rowSelectionChanged(data, rows){
|
||||
|
||||
var selectedData = data;
|
||||
var selectedRows = rows;
|
||||
var tableData = tabulator.getData(true); // only the filtered / sorted table rows
|
||||
|
||||
rowSelectionChanged = true;
|
||||
|
||||
// Sum up over all anzurechnenden LV-ECTS by Prestudent
|
||||
var selectedPrestudentWithAccumulatedLvEcts = [];
|
||||
selectedPrestudentWithAccumulatedLvEcts = approveAnrechnung.getSumLvEctsByPreStudent(selectedData);
|
||||
selectedPrestudentWithAccumulatedLvEcts = approveAnrechnung.getSumLvEctsByPreStudent(data);
|
||||
|
||||
// Loop through table rows
|
||||
tableData.forEach(function(td){
|
||||
// Loop through all active rows
|
||||
var rowManager = tabulator.rowManager;
|
||||
for (var i = 0; i < rowManager.activeRows.length; i++) {
|
||||
|
||||
let selectedPrestudent = selectedPrestudentWithAccumulatedLvEcts.find(x => x.prestudent_id === td.prestudent_id);
|
||||
|
||||
// Add accumulated LV ECTS to bisherige ECTS in ECTS 'controlling column', if Prestudent is selected at least once
|
||||
if (selectedPrestudent != undefined)
|
||||
{
|
||||
td.ectsSumBisherUndNeuSchulisch = td.ectsSumSchulisch + selectedPrestudent.ectsSumAnzurechnendeLvsSchulisch;
|
||||
td.ectsSumBisherUndNeuBeruflich = td.ectsSumBeruflich + selectedPrestudent.ectsSumAnzurechnendeLvsBeruflich;
|
||||
|
||||
}
|
||||
// ..else reset to bisherige ECTS
|
||||
else
|
||||
{
|
||||
td.ectsSumBisherUndNeuSchulisch = td.ectsSumSchulisch;
|
||||
td.ectsSumBisherUndNeuBeruflich = td.ectsSumBeruflich;
|
||||
}
|
||||
});
|
||||
|
||||
// Update ECTS columns
|
||||
tabulator.updateData(tableData);
|
||||
// Reinitialize row -> triggers formatters.
|
||||
rowManager.activeRows[i].reinitialize();
|
||||
}
|
||||
|
||||
// Show number of selected rows.
|
||||
approveAnrechnung.showNumberSelectedRows(selectedRows);
|
||||
|
||||
rowSelectionChanged = false;
|
||||
approveAnrechnung.showNumberSelectedRows(rows);
|
||||
}
|
||||
|
||||
// Performes after row was updated
|
||||
function func_rowUpdated(row){
|
||||
|
||||
// If rowUpdate is called on row selection change, return to avoid following row deselection and formatting.
|
||||
if (rowSelectionChanged)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Deselect and disable new selection of updated rows
|
||||
row.deselect();
|
||||
row.getElement().style["pointerEvents"] = "none";
|
||||
|
||||
Reference in New Issue
Block a user