From f93f6f737a3fb4e21dcb34e8ab6732728e8b5936 Mon Sep 17 00:00:00 2001 From: Lyndon Date: Fri, 25 Jul 2025 18:37:07 +0200 Subject: [PATCH] Bugs behoben --- .../ownSoft-Scripts/view-scripts/main.js | 66 +++++++++++++-- .../Views/Main/GroupBookingFormPartial.cshtml | 82 ++++++------------- BeWoPlanerMobil/Views/Main/Main.cshtml | 79 ++++++------------ .../Views/Main/MultiBookingFormPartial.cshtml | 41 ++++------ .../Views/Main/MultiBookingPartial.cshtml | 2 - .../Views/Main/SingleBookingPartial.cshtml | 25 ++---- BeWoPlanerMobil/Views/Shared/_Layout.cshtml | 77 +++++++++++++---- 7 files changed, 194 insertions(+), 178 deletions(-) diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js index b805d28fe..f27b11e50 100644 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js +++ b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js @@ -61,10 +61,33 @@ function submitGroupBookingForm() { function toggleGroupBookingForm() { const isEnabled = $("#selected-cb2sc-list").children().length > 0; - + + changeGroupBookingFormEnableState(!isEnabled); +} + +function changeMultiBookingFormEnableState(enableState) { + $( + "#multi-booking-employees-button, " + + "#category-select, " + + "#leistung-select, " + + "#mb-start-date-input, " + + "#mb-end-date-input, " + + "#mb-start-time-input, " + + "#mb-end-time-input, " + + "#mb-duration-input, " + + "#mb-distance-input, " + + "textarea, " + + "#mb-reset-btn, " + + "#mb-create-btn, " + + "#mb-betrag," + + "#mb-textbausteine-btn, " + + "#mb-hours-minutes-dropdown-btn, " + + "#mb-marker-cb, " + + ".bewo-restore-btn").prop("disabled", enableState); +} + +function changeGroupBookingFormEnableState(enableState) { $( - "#betrag, " + - ".gb-restore-btn," + "#employees-button, " + "#category-select, " + "#leistung-select, " + @@ -72,15 +95,42 @@ function toggleGroupBookingForm() { "#gb-end-date-input, " + "#gb-start-time-input, " + "#gb-end-time-input, " + - "#db-duration-input, " + + "#gb-duration-input, " + "#gb-distance-input, " + "textarea, " + "#reset-button, " + "#create-button, " + - "#textbausteine-button, " + + "#gb-textbausteine-btn, " + "#gb-hours-minutes-dropdown-btn, " + - "#marker-cb" - ).prop("disabled", isEnabled ? false : true); + "#gb-marker-cb, " + + "#gb-betrag, " + + ".bewo-restore-btn" + ).prop("disabled", enableState); +} + +function changeSingleBookingFormEnableState(enableState) { + $( + "#employeesDropDown, " + + "#category-select, " + + "#leistung-select, " + + "#sb-start-date-input, " + + "#sb-end-date-input, " + + "#sb-start-time-input, " + + "#sb-end-time-input, " + + "#sb-duration-input, " + + "#sb-hours-minutes-dropdown-btn, " + + "#sb-distance-input, " + + "#sb-textbausteine-btn, " + + "#goals-button, " + + "textarea, " + + "#reset-button, " + + "#create-button, " + + "#statistics-button, " + + "#timeFrameSelect, " + + "#sb-marker-cb, " + + "#sb-betrag, " + + ".bewo-restore-btn" + ).prop("disabled", enableState); } function deleteServiceRecord(serviceRecordOid) { @@ -240,7 +290,7 @@ function validateForm(form, prefix) { $("#srv-marker").val($(`#${prefix}-marker-cb`).is(":checked") ? "on" : "off"); $("#srv-service-description").val($(`#${prefix}-leistung-select`).find(":selected").val()); $("#srv-duration").val($(`#${prefix}-duration-input`).val()); - $("#srv-betrag").val($("#betrag").val()); + $("#srv-betrag").val($(`#${prefix}-betrag`).val()); showSpinner(); $("#service-record-validation-form").submit(); diff --git a/BeWoPlanerMobil/Views/Main/GroupBookingFormPartial.cshtml b/BeWoPlanerMobil/Views/Main/GroupBookingFormPartial.cshtml index 86a431b2b..8f2a16604 100644 --- a/BeWoPlanerMobil/Views/Main/GroupBookingFormPartial.cshtml +++ b/BeWoPlanerMobil/Views/Main/GroupBookingFormPartial.cshtml @@ -15,28 +15,6 @@ } } - if(TempData[TempDataConstants.DoLogoutKey] is bool doLogout && doLogout) + if(TempData[TempDataConstants.DoLogoutKey] is true) {
- +
} @@ -469,9 +469,6 @@ {
-
} @@ -485,11 +482,7 @@ } @@ -528,12 +521,12 @@ } else { - - } + + } - + *@ } diff --git a/BeWoPlanerMobil/Views/Shared/_Layout.cshtml b/BeWoPlanerMobil/Views/Shared/_Layout.cshtml index 8db8004a8..f687dd143 100644 --- a/BeWoPlanerMobil/Views/Shared/_Layout.cshtml +++ b/BeWoPlanerMobil/Views/Shared/_Layout.cshtml @@ -54,7 +54,7 @@ - + @@ -109,6 +109,16 @@ this.inputList = inputList; } + clearInputList() { + if(this.inputList === null || this.inputList === undefined) { + this.inputList = []; + } + + this.inputList.length = 0; + + localStorage.setItem(this.id, JSON.stringify(this)); + } + removeItemById(id) { const newInputList = []; @@ -162,7 +172,11 @@ } getItemById(id) { - return this.inputList.find((element) => element.inputId === id); + const item = this.inputList.find((element) => element.inputId === id); + + logInfo3(`Element: ${id}; Wert: ${item.inputValue}; Typ: ${item.inputType}`); + + return item; } getItemsByName(name) { @@ -329,6 +343,16 @@ } }); + function toggleRestoreButton() { + const state = !window.getRestoreButtonState(); + + if($(".bewo-restore-btn").length > 0) { + $(".bewo-restore-btn").each(function(index, item) { + $(this).prop("disabled", state); + }); + } + } + $(window).resize(function () { $.each($("canvas"), function(index, canvasElement) { updateCanvasSize($(canvasElement)); @@ -423,14 +447,6 @@ return Math.max.apply(Math, $(`.${elementClassName}`).map(function () { return $(this).height(); }).get()); } - function toggleMultiBookingForm(shouldDisable) { - $("#multi-booking-employees-button, #category-select, #leistung-select, " + - "#mb-start-date-input, #mb-end-date-input, #mb-start-time-input, #mb-end-time-input, #mb-duration-input, " + - "#mb-distance-input, textarea, #mb-reset-button, #mb-create-button, " + - ".mb-restore-btn, " + - "#mb-textbausteine-button, #mb-hours-minutes-dropdown-btn, #mb-marker-cb").prop("disabled", shouldDisable); - } - @* Eingabenwiederherstellung *@ function getLocalStorageKey() { @@ -455,23 +471,43 @@ return beWoStorage; } - window.addEventListener("load", function() { - $("textarea, select, input").on("change", function() { + function clearLocalBeWoStorage() { + const beWoStorage = getBeWoStorage(); + + beWoStorage.clearInputList(); + } + + function getRestoreButtonState() { + const beWoStorage = getBeWoStorage(); + + return beWoStorage.inputList.length > 0; + } + + window.addEventListener("load", function() { + $(".booking-form-container").find("textarea, select, input").on("change", function() { const item = $(this); const id = item.attr("id"); const type = item.prop("type"); const value = type === "checkbox" ? item.is(":checked").toString() : item.val(); - if(value === undefined || value === null || value.length === 0) { + if((value === null || value === undefined) || value.length === 0) { + logInfo2(`Element mit Id "${id}" hat ${(value !== null ? "einen leeren" : " keinen")} Wert.`); return; } + logInfo3(`${id}: ${value}`); + const name = item.prop("name"); const beWoStorage = getBeWoStorage(); - beWoStorage.addInputValue(id, name, type, value, new Date()); - }); + beWoStorage.addInputValue(id, name, type, value, new Date()); + + // ToDo: Auch Hilfeplan- und Mitarbeiterauswahl berücksichtigen + // ToDo: 28.07.2025: Hilefplan einbauen und dabei dann ein Flag setzen in TempData und dann gegebenenfalls alle anderen Felder wiederherstellen + + toggleRestoreButton(); + }); }); function restoreField(id) { @@ -490,8 +526,13 @@ function restoreAllFields() { const beWoStorage = getBeWoStorage(); - $.each(beWoStorage.inputList, (index, item) => { - $(`#${item.inputId}`).val(item.inputValue); + $.each(beWoStorage.inputList, (index, item) => { + if (item.inputType === "checkbox") { + $(`#${item.inputId}`).prop("checked", item.inputValue); + } else { + $(`#${item.inputId}`).val(item.inputValue); + } + $(`#${item.inputId}`).trigger("change"); }); } @@ -532,7 +573,7 @@ {