|
|
|
|
@ -4,6 +4,7 @@ const mins = document.getElementById('minuten');
|
|
|
|
|
const NewEntryButton = document.getElementById('newEntrySubmitButton')
|
|
|
|
|
const SETStudySaveButton = document.getElementById('SETStudySaveButton')
|
|
|
|
|
const SETMonthGoalSaveButton = document.getElementById('SETMonthGoalSaveButton')
|
|
|
|
|
const SETLdcNameSaveButton = document.getElementById('SETLdcNameSaveButton')
|
|
|
|
|
const rule55hCheck = document.getElementById('rule55hCheck')
|
|
|
|
|
const openViewOfEntry = document.getElementById('openViewOfEntry')
|
|
|
|
|
const openViewOfEntryIcon = document.getElementById('openViewOfEntryIcon')
|
|
|
|
|
@ -25,6 +26,9 @@ const currentDate = new Date();
|
|
|
|
|
// live aktualisiert, damit getActualDataAndFillView() sie synchron verwenden kann.
|
|
|
|
|
var rule55Active = false;
|
|
|
|
|
|
|
|
|
|
// Individuell vergebbarer Name für "LDC" (SettingsID 4), überall im UI verwendet statt fest "LDC".
|
|
|
|
|
var ldcLabel = 'LDC';
|
|
|
|
|
|
|
|
|
|
// Sortierung der Aktivitäten-Tabelle: wird aus dem Cache (localStorage) geladen/gespeichert.
|
|
|
|
|
var sortField = 'date';
|
|
|
|
|
var sortDirection = 'asc';
|
|
|
|
|
@ -49,6 +53,9 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|
|
|
|
// 55h-Regel Einstellung laden, bevor die erste Jahresansicht berechnet wird
|
|
|
|
|
await loadRule55Setting();
|
|
|
|
|
|
|
|
|
|
// LDC-Bezeichnung laden, bevor die Tabelle erstmalig gefüllt wird
|
|
|
|
|
await loadLdcLabel();
|
|
|
|
|
|
|
|
|
|
// Gespeicherte Sortierung der Aktivitäten-Tabelle aus dem Cache laden
|
|
|
|
|
loadSortPreference();
|
|
|
|
|
|
|
|
|
|
@ -342,6 +349,56 @@ SETMonthGoalSaveButton.addEventListener('click', () => {
|
|
|
|
|
SETMonthGoalSaveButton.classList.add('d-none')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Lädt die individuelle LDC-Bezeichnung (SettingsID 4) aus der DB, setzt ldcLabel,
|
|
|
|
|
// füllt das Einstellungen-Feld vor und wendet den Namen überall im UI an.
|
|
|
|
|
async function loadLdcLabel() {
|
|
|
|
|
const result = await getAllEntries('settings')
|
|
|
|
|
const setting = result.find(element => element.SettingsID === 4)
|
|
|
|
|
ldcLabel = (setting == undefined || !setting.SettingsValue) ? 'LDC' : setting.SettingsValue
|
|
|
|
|
document.getElementById('ldcNameInput').value = ldcLabel
|
|
|
|
|
applyLdcLabel()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Setzt die aktuelle LDC-Bezeichnung überall dort, wo sie im UI (außerhalb der Tabelle) auftaucht.
|
|
|
|
|
// Die Tabelle selbst bekommt den Namen bei jedem Render über fillTableWithEntries(...).
|
|
|
|
|
function applyLdcLabel() {
|
|
|
|
|
document.getElementById('ldcCheckLabel').innerText = ldcLabel
|
|
|
|
|
document.getElementById('editldcCheckLabel').innerText = ldcLabel
|
|
|
|
|
document.getElementById('monthHourLDCLabel').innerText = ldcLabel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SETLdcNameSaveButton.addEventListener('click', () => {
|
|
|
|
|
getAllEntries('settings')
|
|
|
|
|
.then(function(result) {
|
|
|
|
|
const SETDBData = result.find(element => element.SettingsID === 4)
|
|
|
|
|
actualSettingsEntryID = SETDBData ? SETDBData.id : undefined;
|
|
|
|
|
actualSettings = SETDBData ? SETDBData.SettingsValue : undefined;
|
|
|
|
|
|
|
|
|
|
// AKTUELLE DATEN AUS FELD ÜBERNHEMEN - bei leerem Feld auf "LDC" zurückfallen
|
|
|
|
|
var ActInput = document.getElementById('ldcNameInput').value.trim() || 'LDC'
|
|
|
|
|
document.getElementById('ldcNameInput').value = ActInput
|
|
|
|
|
|
|
|
|
|
const LdcNameSettingsData = {
|
|
|
|
|
SettingsID: 4,
|
|
|
|
|
SettingsValue: ActInput,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ÜBERPRÜFEN OB EIN EINTRAG MTI DER SETTINGS ID VORHANDEN IST - WENN JA DANN UPDATE WENN NEIN DANN NEUEN ERSTELLEN
|
|
|
|
|
if ( actualSettings != undefined ) {
|
|
|
|
|
updateEntry(actualSettingsEntryID, 'settings', LdcNameSettingsData)
|
|
|
|
|
} else {
|
|
|
|
|
addEntry(LdcNameSettingsData, 'settings')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ldcLabel = ActInput
|
|
|
|
|
applyLdcLabel()
|
|
|
|
|
// Tabelle neu füllen, damit die Typ-Spalte den neuen Namen sofort übernimmt
|
|
|
|
|
getActualDataAndFillView(cursorMonth, cursorYear)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
SETLdcNameSaveButton.classList.add('d-none')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function getActualDataAndFillView(monat = currentDate.getMonth(), jahr = currentDate.getFullYear()) {
|
|
|
|
|
try {
|
|
|
|
|
@ -371,7 +428,7 @@ async function getActualDataAndFillView(monat = currentDate.getMonth(), jahr = c
|
|
|
|
|
console.log(jahr)
|
|
|
|
|
|
|
|
|
|
// Tabelle mit den aktuellen informationen füllen (funktion triggern und Daten übergeben)
|
|
|
|
|
fillTableWithEntries(filteredEntries, sortField, sortDirection)
|
|
|
|
|
fillTableWithEntries(filteredEntries, sortField, sortDirection, ldcLabel)
|
|
|
|
|
|
|
|
|
|
// Ausgabe der Daten in den Log für DEV möglich
|
|
|
|
|
// console.log('Gefilterte Einträge für September 2024:', filteredEntries);
|
|
|
|
|
|