diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index d3a83a8f9..93603058c 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -724,6 +724,23 @@ namespace BeWoPlanerMobil.Controllers return base.Logout(); } + private List LoadAvailableGoals() + { + var availableGoals = new List(); + + if(Model.IsInGroupBookingMode) + { + var list = GetSelectedGroupBookingSupportConcepts(); + LoadSupportConceptThings(null, false); + list.DoForEach(sc => { availableGoals.AddRangeIfElementsNotIn(sc.Goals); }); + } + else + { + availableGoals = GetAllGoalsForSelectedSupportConcept(); + } + + return availableGoals; + } [Authorize] public string RateSelectedGoal(long? ratingTypeOid, long? goalOid) @@ -735,18 +752,18 @@ namespace BeWoPlanerMobil.Controllers var rating = Model.GoalRatingTypes.FirstOrDefault(ratingType => ratingType.RatingTypeOid == ratingTypeOid); - var allGoals = new List(); + var allGoals = LoadAvailableGoals();//new List(); - if(Model.IsInGroupBookingMode) - { - var list = GetSelectedGroupBookingSupportConcepts(); - LoadSupportConceptThings(null, false); - list.DoForEach(sc => { allGoals.AddRangeIfElementsNotIn(sc.Goals); }); - } - else if(!Model.IsInGroupBookingMode) - { - allGoals = GetAllGoalsForSelectedSupportConcept(); - } + //if(Model.IsInGroupBookingMode) + //{ + // var list = GetSelectedGroupBookingSupportConcepts(); + // LoadSupportConceptThings(null, false); + // list.DoForEach(sc => { allGoals.AddRangeIfElementsNotIn(sc.Goals); }); + //} + //else if(!Model.IsInGroupBookingMode) + //{ + // allGoals = GetAllGoalsForSelectedSupportConcept(); + //} var goal = allGoals.FirstOrDefault(g => g.ValueListEntryOid?.Equals(goalOid.Value) ?? false); @@ -804,7 +821,6 @@ namespace BeWoPlanerMobil.Controllers } } - private void LoadGoals(List infos) { try @@ -984,7 +1000,6 @@ namespace BeWoPlanerMobil.Controllers break; } } - [Authorize] public string LoadStatistics(long oid) @@ -2352,14 +2367,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public string UpdateGoals(string pGoalOids) { - SkipModelInitialization = true; - if (!IsUserLoggedIn()) + if(!IsUserLoggedIn()) { Logout(); return "0"; } - if(string.IsNullOrEmpty(pGoalOids)) { Model.SelectedGoalOids.Clear(); @@ -2370,33 +2383,20 @@ namespace BeWoPlanerMobil.Controllers var splitOids = pGoalOids.Trim(';').Split(';'); var selectedGoalOids = splitOids.Select(long.Parse).ToList(); - //var allGoals = new List(); + var removedGoalOids = Model.SelectedGoalOids.Except(selectedGoalOids).ToList(); - //if(Model.IsInGroupBookingMode || Model.IsInMultiBookingMode) - //{ - // var supportConcepts = GetSelectedGroupBookingSupportConcepts(); - // LoadSupportConceptThings(null, false); - - // supportConcepts.DoForEach(supportConcept => { allGoals.AddRangeIfElementsNotIn(supportConcept.Goals); }); - //} - //else if(!Model.IsInGroupBookingMode) - //{ - // allGoals = sc.Goals; - //} - - //var parents = CustomerService.GetSupportConceptGoalParents(allGoals.Where(w => w.ParentOid.HasValue).Select(s => s.ParentOid.Value).ToList()); - - //allGoals.AddRangeIfElementsNotIn(parents); - - //var goals = allGoals.Where(w => w.ValueListEntryOid.HasValue && selectedGoalOids.Contains(w.ValueListEntryOid.Value)).ToList(); - - //var stillSelectedGoals = Model.SelectedGoals.Where(s => goals.Any(a => a.ValueListEntryOid.HasValue && a.ValueListEntryOid.Value == s.ValueListEntryOid)).ToList(); - - //Model.SelectedGoals = stillSelectedGoals; - //Model.SelectedGoals.AddRangeIfElementsNotIn(DcToMokMapper.CreateZiele(goals)); Model.SelectedGoalOids = selectedGoalOids; - return Model.SelectedGoalOids.Count.ToString() ?? "0"; + var newGoalOids = selectedGoalOids.Where(goalOid => false == (Model.SelectedGoals?.Any(goal => goal.ValueListEntryOid.HasValue && goal.ValueListEntryOid.Value.Equals(goalOid)) ?? false)).ToList(); + + var newGoals = DcToMokMapper.CreateZiele(Model.AllGoals.Where(goal => goal.ValueListEntryOid.HasValue && newGoalOids.Contains(goal.ValueListEntryOid.Value))).ToList(); + var oldGoals = Model.SelectedGoals.Where(goal => goal.ValueListEntryOid.HasValue && selectedGoalOids.Contains(goal.ValueListEntryOid.Value)).ToList(); + + oldGoals.AddRange(newGoals); + + Model.SelectedGoals = oldGoals; + + return string.Join(",", removedGoalOids); } [Authorize] diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/mobileUtils.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/mobileUtils.js index 9e36c13f8..bac0116f9 100644 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/mobileUtils.js +++ b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/mobileUtils.js @@ -105,6 +105,35 @@ function showMessagePopupWithCallback(title, message, callback, executeCallbackB ); } +function showMessagePopupWithOkAndCancelCallback(title, message, okCallback, cancelCallback) { + $("#popupTitle").text(title); + + if(message !== null) { + $("#modal-body").html("

"); + } + + $("#popupMessage").text(message); + + $("#message-popup-ok-btn").off("click"); + + $("#message-popup-ok-btn").on("click", function() { + okCallback(); + }); + + $("#message-popup-close-btn, #message-popup-esc-btn").off("click"); + $("#message-popup-close-btn, #message-popup-esc-btn").on("click", + function() { + cancelCallback(); + }); + + $("#messagePopup").modal( + { + backdrop: "static", + keyboard: false + } + ); +} + function submitForm(submitButton) { if(hasEmptyRequiredFields($(submitButton.form))) { return; diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js index 95789f9bf..46cafe6e3 100644 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js +++ b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js @@ -360,7 +360,8 @@ function showGoalRatingPopup(goalOid) { function hideGoalRatingPopup() { try { $("#goal-rating-popup").modal("hide"); - } catch (error) { + resetGoalRatingPopup(); + } catch(error) { window.showErrorPopup(error); } } diff --git a/BeWoPlanerMobil/Util/DcToMokMapper.cs b/BeWoPlanerMobil/Util/DcToMokMapper.cs index ce78701b2..28e669661 100644 --- a/BeWoPlanerMobil/Util/DcToMokMapper.cs +++ b/BeWoPlanerMobil/Util/DcToMokMapper.cs @@ -33,7 +33,7 @@ namespace BeWoPlanerMobil.Util public static IList CreateZiele(IEnumerable dclist) { - return dclist?.Select(g => CreateZiel(g)).ToList(); + return dclist?.Select(CreateZiel).ToList(); } public static MokServiceRecord CreateServiceRecord(ServiceRecordDC dc, ReportModel model) diff --git a/BeWoPlanerMobil/Views/Main/GoalRatingPopupContentPartial.cshtml b/BeWoPlanerMobil/Views/Main/GoalRatingPopupContentPartial.cshtml index f5e19af42..1c81ba5f6 100644 --- a/BeWoPlanerMobil/Views/Main/GoalRatingPopupContentPartial.cshtml +++ b/BeWoPlanerMobil/Views/Main/GoalRatingPopupContentPartial.cshtml @@ -6,42 +6,47 @@ { } } @if(Model.HasRightToRateGoals) diff --git a/BeWoPlanerMobil/Views/Main/GoalTreePartial.cshtml b/BeWoPlanerMobil/Views/Main/GoalTreePartial.cshtml index daf58ab32..33479ba3c 100644 --- a/BeWoPlanerMobil/Views/Main/GoalTreePartial.cshtml +++ b/BeWoPlanerMobil/Views/Main/GoalTreePartial.cshtml @@ -123,9 +123,28 @@ window.updateGoals2Ratings("@Model.BookingModePrefix", goalsAsMap); - $.get("@Url.Action("UpdateGoals")", {pGoalOids: selectedGoals}, function (numberOfSelectedGoals) { - $("#goals-button").html(`Ziele ${numberOfSelectedGoals}`); - }); + $.get("@Url.Action("UpdateGoals")", {pGoalOids: selectedGoals}, function (removedGoalOids) { + @if(Model.HasAnyRatingTypes) + { + + if(removedGoalOids === null ||removedGoalOids===undefined) { + return; + } + + if(removedGoalOids === "0") { + $(".goal-rating-badge").text("Bewerten"); + return; + } + + const oids = removedGoalOids.split(","); + + $.each(oids, (index, oid) => { + $(`#goal-rating-${oid}`).text("Bewerten"); + }); + + + } + }); } catch(error) { showErrorPopup(error); } diff --git a/BeWoPlanerMobil/Views/Main/SingleSignaturePopupPartial.cshtml b/BeWoPlanerMobil/Views/Main/SingleSignaturePopupPartial.cshtml index 239323f27..48cebc3a4 100644 --- a/BeWoPlanerMobil/Views/Main/SingleSignaturePopupPartial.cshtml +++ b/BeWoPlanerMobil/Views/Main/SingleSignaturePopupPartial.cshtml @@ -188,15 +188,42 @@ Benötigt: Modal-Id *@ function singleSignatureCloseButtonEvent(signaturePad) { - $("#single-signature-modal").modal("hide"); + hideSingleSignaturePopup(); - signaturePad.clear(); - - return; + showMessagePopupWithOkAndCancelCallback( + "Unterschreiben abbrechen", + "Möchten Sie wirklich das Unterschreiben abbrechen?", + () => { + signaturePad.clear(); + }, + () => { + $("#single-signature-modal").modal("show"); + } + ); } function singleSignatureClearButtonEvent(signaturePad) { - signaturePad.clear(); + hideSingleSignaturePopup(); + + showMessagePopupWithOkAndCancelCallback( + "Unterschriftenfeld leeren", + "Möchten Sie wirklich das Unterschriftenfeld leeren?", + () => { + $("#single-signature-modal").modal("show"); + signaturePad.clear(); + }, + () => { + $("#single-signature-modal").modal("show"); + } + ); + } + + function hideSingleSignaturePopup() { + $("#single-signature-modal").modal("hide"); + } + + function showSingleSignaturePopup() { + $("#single-signature-modal").modal("show"); } function signatureFooterClick() { @@ -241,15 +268,15 @@ else
- +
- - - + + +
diff --git a/BeWoPlanerMobil/Views/Shared/_Layout.cshtml b/BeWoPlanerMobil/Views/Shared/_Layout.cshtml index ea1e0a0d0..286b2c545 100644 --- a/BeWoPlanerMobil/Views/Shared/_Layout.cshtml +++ b/BeWoPlanerMobil/Views/Shared/_Layout.cshtml @@ -53,9 +53,9 @@ - + - + @@ -109,6 +109,18 @@ $.get(url, { isOpen: isShown, identifier: id }); } + @if(Html.IsInDebugMode()) + { + + $(window).on("focusout", () => { + + }); + $(window).on("focusin", () => { + + }); + + } + window.addEventListener("error", (event) => { hideSpinner(); @@ -182,27 +194,27 @@ } } - const countdown = new Countdown(parseInt("@AbstractBaseController.TimeoutLimit", 10) * 60, - (remainingSeconds) => { - const remainingMilliseconds = remainingSeconds * 1000; + const countdown = new Countdown(parseInt("@AbstractBaseController.TimeoutLimit", 10) * 60, + (remainingSeconds) => { + const remainingMilliseconds = remainingSeconds * 1000; - const minutes = Math.floor((remainingMilliseconds % (1000 * 60 * 60)) / (1000 * 60)); - const seconds = Math.floor((remainingMilliseconds % (1000 * 60)) / 1000); + const minutes = Math.floor((remainingMilliseconds % (1000 * 60 * 60)) / (1000 * 60)); + const seconds = Math.floor((remainingMilliseconds % (1000 * 60)) / 1000); - var m = minutes.toString().padStart(2, "0"); - var s = seconds.toString().padStart(2, "0"); + var m = minutes.toString().padStart(2, "0"); + var s = seconds.toString().padStart(2, "0"); - const timePart = minutes <= 5 ? ` class="text-danger"` : ""; - $("#countdown").html(`Abmeldung in ${m}:${s}`); - }, - () => { - $("#countdown").html("00:00"); - $("#logout-form").submit(); - } - ); + const timePart = minutes <= 5 ? ` class="text-danger"` : ""; + $("#countdown").html(`Abmeldung in ${m}:${s}`); + }, + () => { + $("#countdown").html("00:00"); + $("#logout-form").submit(); + } + ); - $(document).ready(function() { - countdown?.start(); + $(document).ready(function() { + countdown?.start(); $.each($("canvas"), function(index, canvasElement) { updateCanvasSize($(canvasElement)); @@ -235,15 +247,15 @@ } }); - function toggleRestoreButton() { - const state = false; + function toggleRestoreButton() { + const state = false; - if($(".bewo-restore-btn").length > 0) { - $(".bewo-restore-btn").each(function(index, item) { - $(this).prop("disabled", state); - }); - } - } + 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) { @@ -337,7 +349,7 @@ function getMaxElementHeight(elementClassName) { return Math.max.apply(Math, $(`.${elementClassName}`).map(function () { return $(this).height(); }).get()); - } + }