From c4aaeaf45c7856c3ca5f6f143581a8fde57f05c5 Mon Sep 17 00:00:00 2001 From: Lyndon Jetten Date: Thu, 9 Feb 2023 15:17:33 +0100 Subject: [PATCH] Bugfixes im Kalendermodul des MoK --- BeWo/ownChat/ChatView.xaml.cs | 9 +- .../Controllers/ReportController.cs | 4 +- .../Controllers/SchedulerController.cs | 25 +++ BeWoPlanerMobil/Scripts/utils/dateUtils.js | 10 +- BeWoPlanerMobil/Scripts/utils/list-utils.js | 48 ++--- BeWoPlanerMobil/Scripts/utils/logging.js | 10 +- .../Scripts/view-scripts/scheduler.js | 5 +- .../Views/Main/GoalTreePartial.cshtml | 4 +- .../QuittierungsbelegsResultPartial.cshtml | 24 --- .../Scheduler/AppointmentFormPartial.cshtml | 103 +++++----- .../AppointmentIntervalFinderPartial.cshtml | 187 +++++++++++++----- .../Views/Scheduler/Scheduler.cshtml | 7 +- BeWoPlanerMobil/Views/Shared/_Layout.cshtml | 2 +- Data/Access/SearchDAO.cs | 1 - 14 files changed, 253 insertions(+), 186 deletions(-) diff --git a/BeWo/ownChat/ChatView.xaml.cs b/BeWo/ownChat/ChatView.xaml.cs index f4aa5b5ea..7a90dd78d 100644 --- a/BeWo/ownChat/ChatView.xaml.cs +++ b/BeWo/ownChat/ChatView.xaml.cs @@ -153,13 +153,10 @@ namespace BeWo.ownChat stringBuilder.Append($"{m.SendTime:dd.MM.yyyy HH:mm} - {m.Username}: {m.UserMessage}"); } - var utf8 = Encoding.UTF8; - var encodedBytes = utf8.GetBytes(stringBuilder.ToString()); - var convertedBytes = Encoding.Convert(Encoding.UTF8, Encoding.ASCII, encodedBytes); - var ascii = Encoding.ASCII; + var finalString = stringBuilder.ToString(); + + finalString = finalString.Replace("ẞ", "ß"); - var finalString = ascii.GetString(convertedBytes); - var firstTime = messages.Min(r => { var dt = r.SendTime; diff --git a/BeWoPlanerMobil/Controllers/ReportController.cs b/BeWoPlanerMobil/Controllers/ReportController.cs index c8eaa37e6..291fbe3cc 100644 --- a/BeWoPlanerMobil/Controllers/ReportController.cs +++ b/BeWoPlanerMobil/Controllers/ReportController.cs @@ -49,7 +49,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult Report() { - if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !AbstractModel.IsAllowedToSeeScheduler) + if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) { return Logout(); } @@ -71,7 +71,7 @@ namespace BeWoPlanerMobil.Controllers { try { - if (!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !AbstractModel.IsAllowedToSeeScheduler) + if (!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) { return Logout(); } diff --git a/BeWoPlanerMobil/Controllers/SchedulerController.cs b/BeWoPlanerMobil/Controllers/SchedulerController.cs index 58d7c5ec7..4a793ddee 100644 --- a/BeWoPlanerMobil/Controllers/SchedulerController.cs +++ b/BeWoPlanerMobil/Controllers/SchedulerController.cs @@ -878,6 +878,7 @@ namespace BeWoPlanerMobil.Controllers if(long.TryParse(teamOidString, out var teamOid)) { var team = EmployeeService.FindTeamByOid(teamOid, Model.Employee.EmployeeOid.Value); + if(!(team is null)) { Model.SelectedEmployeesForFiltering.AddRangeIfElementsNotIn(team.Member); @@ -981,5 +982,29 @@ namespace BeWoPlanerMobil.Controllers return _LeerzeichenFuerGetMethoden; } + + [Authorize] + public string SelectTeamForIntervalFinder(string teamOidString) + { + if(Model?.Employee?.EmployeeOid is null) + { + Logout(); + return _LeerzeichenFuerGetMethoden; + } + + if(long.TryParse(teamOidString, out var teamOid)) + { + var team = EmployeeService.FindTeamByOid(teamOid, Model.Employee.EmployeeOid.Value); + + if(!(team is null)) + { + var memberOids = team.Member.Select(member => member.EmployeeOid).ToList(); + + return JsonConvert.SerializeObject(memberOids); + } + } + + return _LeerzeichenFuerGetMethoden; + } } } diff --git a/BeWoPlanerMobil/Scripts/utils/dateUtils.js b/BeWoPlanerMobil/Scripts/utils/dateUtils.js index 46cddaf16..b5e69dbd1 100644 --- a/BeWoPlanerMobil/Scripts/utils/dateUtils.js +++ b/BeWoPlanerMobil/Scripts/utils/dateUtils.js @@ -10,15 +10,14 @@ function getDateFromPicker(pickerId) { try { var picker = $("#" + pickerId); - if (picker.length > 0) { + if(picker.length > 0) { picker.datetimepicker("show"); picker.datetimepicker("hide"); var unixTime = picker.datetimepicker("date"); var targetDate = new Date(unixTime); - if (isValidDate(targetDate)) { - logError(dateToShortDateString(targetDate)); + if(isValidDate(targetDate)) { return targetDate; } } @@ -62,6 +61,8 @@ function getTimeFromPicker(pickerId) { function dateToShortDateString(date) { try { + logInfo2("Konvertiere Datum zu kurzem Datum: " + date); + if (isValidDate(date)) { var ddNum = date.getDate(); var mmNum = date.getMonth(); @@ -90,7 +91,7 @@ function dateToShortDateString(date) { return dd + "." + mm + "." + yyyy; } } catch (error) { - logError(error.message); + logError("Fehler in dateToShortDateString:" + error.message); } } @@ -114,6 +115,7 @@ function mergeDateAndTime(date, time) { } } +// ToDo: Löst Exception aus bei einem Wert von z.B. "06.02.2023". function isValidDate(date) { return Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date); } \ No newline at end of file diff --git a/BeWoPlanerMobil/Scripts/utils/list-utils.js b/BeWoPlanerMobil/Scripts/utils/list-utils.js index 070dd96c9..9b9cb1fb6 100644 --- a/BeWoPlanerMobil/Scripts/utils/list-utils.js +++ b/BeWoPlanerMobil/Scripts/utils/list-utils.js @@ -1,54 +1,34 @@ // Wird aufgerufen, wenn sich der Wert der CheckBox ändert. -function changeItemListSelection(url, popupId, listId, itemIdPrefix, isCustomer, checkBoxIdSuffix, filterAppointmentsUrl, allItemsCheckBoxSuffix, teamMemberOids) { +function changeItemListSelection(url, popupId, listId, itemIdPrefix, isCustomer, checkBoxIdSuffix, filterAppointmentsUrl, allItemsCheckBoxSuffix, teamMemberOids, allItemsCheckBoxId) { try { - if (url === undefined || url === null) { + if(url === undefined || url === null) { logError("url ist undefined oder null"); return; } - var oidStr = ""; - var oids = []; - var allChecked = true; - - $("#" + popupId + " input[type=checkbox]").each(function () { - var id = $(this).attr("id").split("-")[1]; - - if($.isNumeric(id) === false) { - return; - } - - if ($(this).prop("checked")) { - oids.push(id); - oidStr += id + ","; - } else { - allChecked = false; - } - }); + var selectedItemOids = $("#" + popupId + " .popup-list-item-container input:checked").map(function () { return $(this).attr("id").split("-")[1]; }).get(); + var allItemOids = $("#" + popupId + " .popup-list-item-container input[type=checkbox]").map(function () { return $(this).attr("id").split("-")[1]; }).get(); if(!isCustomer) { - $("#my-teams-checkbox" + allItemsCheckBoxSuffix).prop("checked", arrayContainsAllItems(oids, teamMemberOids)); + $("#my-teams-checkbox" + allItemsCheckBoxSuffix).prop("checked", arrayContainsAllItems(selectedItemOids, teamMemberOids)); } - if (allChecked === true) { - $("#all-" + (isCustomer ? "customers" : "employees") + "-checkbox" + allItemsCheckBoxSuffix).prop("checked", true); - } else { - $("#all-" + (isCustomer ? "customers" : "employees") + "-checkbox" + allItemsCheckBoxSuffix).prop("checked", false); - } + $("#" + allItemsCheckBoxId).prop("checked", arrayContainsAllItems(selectedItemOids, allItemOids)); - $.get(url, { oidString: oidStr }).done(function (jsonResult) { + $.get(url, { oidString: selectedItemOids.toString() }).done(function (jsonResult) { updateSelectedList(jsonResult, listId, itemIdPrefix, isCustomer, popupId, checkBoxIdSuffix, url, filterAppointmentsUrl, allItemsCheckBoxSuffix, teamMemberOids); $("#one-day-scheduler-partial-container").load(filterAppointmentsUrl); }); } catch(error) { - logError(error.message); + logError("Fehler in changeItemListSelection: " + error.message); } } // Wird aufgerufen, um die Liste mit den ausgewählten Objekten zu aktualisieren -function updateSelectedList(jsonResult, listId, itemIdPrefix, isCustomer, popupId, checkBoxIdSuffix, url, filterAppointmentsUrl, allItemsCheckBoxSuffix, teamMemberOids) { +function updateSelectedList(jsonResult, listId, itemIdPrefix, isCustomer, popupId, checkBoxIdSuffix, url, filterAppointmentsUrl, allItemsCheckBoxSuffix, teamMemberOids, allItemsCheckBoxId) { try { - if (isEmptyOrSpaces(jsonResult)) { + if(isEmptyOrSpaces(jsonResult)) { return; } @@ -98,11 +78,11 @@ function updateSelectedList(jsonResult, listId, itemIdPrefix, isCustomer, popupI list.append(html); }); } catch(error) { - logError(error.message); + logError("Fehler in updateSelectedList: " + error.message); } } -function removeSelectedItem(itemOid, itemSuffix, isCustomer, url, popupId, listId, itemIdPrefix, filterAppointmentsUrl, allItemsCheckBoxSuffix, teamMemberOids) { +function removeSelectedItem(itemOid, itemSuffix, isCustomer, url, popupId, listId, itemIdPrefix, filterAppointmentsUrl, allItemsCheckBoxSuffix, teamMemberOids, allItemsCheckBoxId) { try { var prefix = isCustomer ? "customer-" : "employee-"; @@ -112,8 +92,8 @@ function removeSelectedItem(itemOid, itemSuffix, isCustomer, url, popupId, listI checkBox.prop("checked", false); } - changeItemListSelection(url, popupId, listId, itemIdPrefix, isCustomer, itemSuffix, filterAppointmentsUrl, allItemsCheckBoxSuffix, teamMemberOids); + changeItemListSelection(url, popupId, listId, itemIdPrefix, isCustomer, itemSuffix, filterAppointmentsUrl, allItemsCheckBoxSuffix, teamMemberOids, allItemsCheckBoxId); } catch(error) { - logError(error); + logError("Fehler in removeSelectedItem: " + error); } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Scripts/utils/logging.js b/BeWoPlanerMobil/Scripts/utils/logging.js index eea9a61be..802eede7d 100644 --- a/BeWoPlanerMobil/Scripts/utils/logging.js +++ b/BeWoPlanerMobil/Scripts/utils/logging.js @@ -1,21 +1,21 @@ function logInfo(message) { - logColorfulMessage(message, "purple"); + logColorfulMessage(message, "#FF0094"); } function logWarning(message) { - logColorfulMessage(message, "darkorange"); + logColorfulMessage(message, "#FF5A00"); } function logError(message) { - console.error("%c" + message, "font-size: 16px; font-weight:bold; color: red"); + console.error("%c" + message, "font-size: 14px; font-family: monospace; color: red"); } function logDebug(message) { - logColorfulMessage(message, "green"); + logColorfulMessage(message, "#AAF500"); } function logColorfulMessage(message, color) { - console.log("%c" + message, "font-size: 16px; font-weight: bold; color: " + color); + console.log("%c" + message, "font-size: 14px; font-family: monospace; color: " + color); } function logInfo2(message) { diff --git a/BeWoPlanerMobil/Scripts/view-scripts/scheduler.js b/BeWoPlanerMobil/Scripts/view-scripts/scheduler.js index a9e8e34cf..71582d567 100644 --- a/BeWoPlanerMobil/Scripts/view-scripts/scheduler.js +++ b/BeWoPlanerMobil/Scripts/view-scripts/scheduler.js @@ -199,18 +199,15 @@ function insertOrUpdateAppointment(formattedStartDate, formattedEndDate, formatt } function hideAppointmentForm() { - logDebug("hiding appointment form"); $("#form-container").addClass("d-none d-sm-none"); } function showAppointmentForm() { - logDebug("showing appointment form"); $("#form-container").removeClass("d-none d-sm-none"); + calcPrependTextSizes(); } function toggleAppointmentForm() { - logError("toggling appointment form"); - var isVisible = $("#form-container").css("display") === "block"; if (isVisible) { diff --git a/BeWoPlanerMobil/Views/Main/GoalTreePartial.cshtml b/BeWoPlanerMobil/Views/Main/GoalTreePartial.cshtml index 73c2b3551..726cedd44 100644 --- a/BeWoPlanerMobil/Views/Main/GoalTreePartial.cshtml +++ b/BeWoPlanerMobil/Views/Main/GoalTreePartial.cshtml @@ -38,12 +38,14 @@ var isLeaf = $(item).parent().prop("class").includes("goal-text"); + // ToDo: Auch die Ziele beachten! + if(goalText.toLowerCase().includes(text)) { $.each($($(item).parents(".goal-card")), function(cardIndex, card) { $(card).show(); $(card).find(".collapse").collapse("show"); }); - } else if (isLeaf) { + } else if(isLeaf) { var parent1 = $($(item).parent()); if(parent1 !== undefined && parent1 !== null) { diff --git a/BeWoPlanerMobil/Views/Report/QuittierungsbelegsResultPartial.cshtml b/BeWoPlanerMobil/Views/Report/QuittierungsbelegsResultPartial.cshtml index c8c5f3336..70d52a507 100644 --- a/BeWoPlanerMobil/Views/Report/QuittierungsbelegsResultPartial.cshtml +++ b/BeWoPlanerMobil/Views/Report/QuittierungsbelegsResultPartial.cshtml @@ -136,31 +136,7 @@ break; } } - - -
diff --git a/BeWoPlanerMobil/Views/Scheduler/AppointmentFormPartial.cshtml b/BeWoPlanerMobil/Views/Scheduler/AppointmentFormPartial.cshtml index 8e3fd9e3a..39b22833c 100644 --- a/BeWoPlanerMobil/Views/Scheduler/AppointmentFormPartial.cshtml +++ b/BeWoPlanerMobil/Views/Scheduler/AppointmentFormPartial.cshtml @@ -11,9 +11,22 @@ } $("#insert-appointment-form").ready(function() { - var width = getMaxWidth("scheduler-form-prepend-text"); - $(".scheduler-form-prepend-text").width(width); + calcPrependTextSizes(); }); + + function calcPrependTextSizes() { + try { + var width = getMaxWidth("scheduler-form-prepend-text"); + + if(width <= 0) { + return; + } + + $(".scheduler-form-prepend-text").width(width); + } catch(error) { + logError(error); + } + } @using(Html.BeginForm("InsertOrUpdateAppointment", "Scheduler", FormMethod.Post, new { id = "insert-appointment-form" })) { @@ -373,30 +386,22 @@ $.each(entries, function (index, item) { var employee = $(item); - if (employee.find(".employee-name-label").text().toLowerCase().includes(text)) { + if(employee.find(".employee-name-label").text().toLowerCase().includes(text)) { employee.show(); } else { employee.hide(); } }); - } catch (error) { + } catch(error) { logError(error.message); } } function selectAllEmployeesOnChange() { try { - var value = $("#all-employees-checkbox").prop("checked"); + var allChecked = $("#all-employees-checkbox").prop("checked"); - $("#employees-popup input[type=checkbox]").each(function() { - var id = $(this).attr("id").split("-")[1]; - - if($.isNumeric(id) === false) { - return; - } - - $(this).prop("checked", value); - }); + $("#employees-popup .employee-input-container input[type=checkbox]").map(function() { $(this).prop("checked", allChecked); }); changeEmployeeListSelection(); } catch(error) { @@ -406,32 +411,17 @@ function changeEmployeeListSelection() { try { - var oidStr = ""; - var oids = []; - var allChecked = true; + var selectedEmployeeOids = $("#employees-popup .employee-input-container input:checked").map(function() { return $(this).attr("id").split("-")[1]; }).get(); + var allEmployeesCount = $("#employees-popup .employee-input-container input[type=checkbox]").map(function () { return $(this).attr("id").split("-")[1]; }).get().length; + var selectedEmployeesCount = selectedEmployeeOids.length; - $("#employees-popup input[type=checkbox]").each(function () { - var id = $(this).attr("id").split("-")[1]; + $("#all-employees-checkbox").prop("checked", (allEmployeesCount === selectedEmployeesCount)); - if ($.isNumeric(id) === false) { - return; - } - - if ($(this).prop("checked")) { - oids.push(id); - oidStr += id + ","; - } else { - allChecked = false; - } - }); - - $("#all-employees-checkbox").prop("checked", allChecked); - - $.get('@Url.Action("SelectEmployeesForAppointment")', {oidString: oidStr}).done(function(jsonResult) { + $.get('@Url.Action("SelectEmployeesForAppointment")', { oidString: selectedEmployeeOids.toString()}).done(function(jsonResult) { updateSelectedEmployees(jsonResult); $("#one-day-scheduler-partial-container").load('@Url.Action("FetchAppointments", "Scheduler")'); }); - } catch (error) { + } catch(error) { logError(error); } } @@ -494,7 +484,7 @@ $.get('@Url.Action("SelectTeamForAppointment")', { teamOidString: teamOid }).done(function(jsonResult) { var oids = $.parseJSON(jsonResult); - $("#employees-popup input[type=checkbox]").each(function () { + $("#employees-popup .employee-input-container input[type=checkbox]").each(function () { var id = $(this).attr("id").split("-")[1]; if ($.isNumeric(id) === false) { @@ -569,16 +559,18 @@
} + +
+ @foreach(var employee in Model.AllEmployees) + { + var checkedValue = Model.SelectedEmployees.Contains(employee) ? "checked" : string.Empty; - @foreach(var employee in Model.AllEmployees) - { - var checkedValue = Model.SelectedEmployees.Contains(employee) ? "checked" : string.Empty; - -
- - -
- } +
+ + +
+ } +
+ + +