From a3aa99bad1507a41a6caa7f46c4b7eb0412b4855 Mon Sep 17 00:00:00 2001 From: Lyndon Jetten Date: Wed, 30 Dec 2020 12:30:33 +0100 Subject: [PATCH] =?UTF-8?q?CustomerFilterEnum=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DevelopmentController.cs | 133 ++++- BeWoPlanerMobil/Models/DevelopmentModel.cs | 42 +- .../Views/Development/Development.cshtml | 534 +++++++++++------- Shared/Core/CustomerFilterEnum.cs | 58 ++ 4 files changed, 567 insertions(+), 200 deletions(-) create mode 100644 Shared/Core/CustomerFilterEnum.cs diff --git a/BeWoPlanerMobil/Controllers/DevelopmentController.cs b/BeWoPlanerMobil/Controllers/DevelopmentController.cs index 76cb12140..f9720091b 100644 --- a/BeWoPlanerMobil/Controllers/DevelopmentController.cs +++ b/BeWoPlanerMobil/Controllers/DevelopmentController.cs @@ -1,10 +1,14 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Linq; using System.Web.Mvc; using BeWoPlanerMobil.Models; using BeWoPlanerMobil.Service; using BeWoPlanerMobil.Util; using BS.Shared; using BS.Shared.Core; +using BS.Shared.DataContracts; +using BS.Shared.Extensions; using static BS.Shared.UserRightType; namespace BeWoPlanerMobil.Controllers @@ -406,28 +410,149 @@ namespace BeWoPlanerMobil.Controllers Model.UserRightGroups.Add(documentRightGroup); Model.UserRightGroups.Add(sonstigeRightGroup); + Model.UserRightGroups = Model.UserRightGroups.OrderBy(urg => urg.UserRightTypes.Keys.Count).ToList(); + + + // Verfügbare Ressourcen für die Termine + var allResources = KalenderService.GetAllResources().ToList(); + + var categories2Resources = new Dictionary>(); + + foreach(var category in allResources.Select(resource => resource.ResourceCategory)) + { + categories2Resources.AddOrUpdateValueInDictionary(category, allResources.Where(resource => resource.ResourceCategory.Equals(category)).ToList()); + } + + Model.ResourceCategories2Resources = categories2Resources; + + + return View(Model); } [Authorize] - public string UpdateSelectedRights(string indices) + public string UpdateSelectedRights(string indicesString) { // Format: UserRightGroups-Index;Dictionary-Index // Bei alle? UserRightGroup-Index;0 + // Alle ignorieren! Es werden per JavaScript schon alle ausgesucht + + var selectedUserRightTypes = new List(); + + if(!string.IsNullOrWhiteSpace(indicesString)) + { + var ids = indicesString.Split(';'); + + if(ids.Length > 0) + { + foreach(var id in ids) + { + if(!string.IsNullOrWhiteSpace(id)) + { + var splitId = id.Split('-'); + if(splitId.Length > 1) + { + if(Enum.TryParse(splitId[1], out UserRightType userRightType)) + { + selectedUserRightTypes.AddIfNotIn(userRightType); + } + } + } + } + } + } + else // nichts ausgewählt. Soll das gehen oder nicht? Ja, soll gehen. Man braucht ja nicht das Recht, Rechte sich selbst vergeben zu können + { + + } + + var userGroups = MobileSessionFacade.LoggedInUser.UserGroups; + + userGroups?.DoForEach(userGroup => + { + + }); + return _LeerzeichenFuerGetMethoden; } + + [Authorize] + public string UpdateAppointmentResources(string selectedResourceOids) + { +#if !DEBUG + Logout(); + return _LeerzeichenFuerGetMethoden; +#endif + + if(Model == null) + { + Logout(); + } + + var oids = selectedResourceOids.Split(';'); + + Model.SelectedResources.Clear(); + + oids.Where(w => w.Length > 0).DoForEach(oidString => + { + if(long.TryParse(oidString, out var oid)) + { + var resource = Model.AvailableResources.FirstOrDefault(r => r.ResourceOid.HasValue && r.ResourceOid.Value.Equals(oid)); + + Model.SelectedResources.AddIfNotIn(resource); + } + }); + + return _LeerzeichenFuerGetMethoden; + } + + [Authorize] + [HttpPost] + public ActionResult InsertTestAppointments(FormCollection formCollection) + { + + + return View("Development", Model); + } } public class UserRightGroup { public string Title { get; set; } - public Dictionary UserRightTypes { get; set; } + public Dictionary UserRightTypes { get; set; } + + public bool AreAllChecked { get; set; } public UserRightGroup(string title, Dictionary userRightTypes) { Title = title ?? "Unbenannt"; - UserRightTypes = userRightTypes ?? new Dictionary(); + UserRightTypes = new Dictionary(); + + userRightTypes?.DoForEach(rel => + { + var isAssigned = MobileSessionFacade.LoggedInUser.CheckForRight(rel.Key); + var translation = rel.Value; + + UserRightTypes.AddIfNotIn(new KeyValuePair(rel.Key, new UserRightTypeTranslation2IsAssigned(translation, isAssigned))); + }); + + if(userRightTypes != null) + { + AreAllChecked = MobileSessionFacade.LoggedInUser.CheckForRights(userRightTypes.Keys); + } + } + } + + public struct UserRightTypeTranslation2IsAssigned + { + public bool IsAssigned { get; set; } + public string Translation { get; set; } + + public UserRightTypeTranslation2IsAssigned(string translation, bool isAssigned) + { + IsAssigned = isAssigned; + Translation = translation; } } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Models/DevelopmentModel.cs b/BeWoPlanerMobil/Models/DevelopmentModel.cs index d5900d729..447a54988 100644 --- a/BeWoPlanerMobil/Models/DevelopmentModel.cs +++ b/BeWoPlanerMobil/Models/DevelopmentModel.cs @@ -1,13 +1,49 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; -using System.Web; +using System.Web.WebPages.Html; using BeWoPlanerMobil.Controllers; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using BS.Shared.Extensions; namespace BeWoPlanerMobil.Models { public class DevelopmentModel : AbstractModel { public List UserRightGroups { get; set; } = new List(); + + public List AllCustomers { get; set; } = new List(); + public List AllEmployees { get; set; } = new List(); + + [Display(Name = "Ersteller")] + public long? SelectedEmployeeOid { get; set; } + + public List AvailableEmployees { get; set; } = new List(); + + public List AvailableCostbearerRelations { get; set; } = new List(); + + public List SelectedCustomers { get; set; } = new List(); + + public List AvailableCustomers { get; set; } = new List(); + + public List SelectedResources { get; set; } = new List(); + + public Dictionary> ResourceCategories2Resources { get; set; } = new Dictionary>(); + + public List AvailableResources + { + get + { + var result = new List(); + + ResourceCategories2Resources.DoForEach(rc2R => + { + result.AddRangeIfElementsNotIn(rc2R.Value); + }); + + return result; + } + } } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Views/Development/Development.cshtml b/BeWoPlanerMobil/Views/Development/Development.cshtml index 0ec7b9200..c7e9ac51e 100644 --- a/BeWoPlanerMobil/Views/Development/Development.cshtml +++ b/BeWoPlanerMobil/Views/Development/Development.cshtml @@ -7,229 +7,377 @@ } - -
- - @{ - var count = Model.UserRightGroups.Count; - var columnCount = 4; + +
+
+
+ +
+
+ @{ + var count = Model.UserRightGroups.Count; + const int columnCount = 4; - var fullRows = count / columnCount; - var hasRest = (count % columnCount) > 0; - var rest = count % columnCount; + var fullRows = count / columnCount; + var hasRest = (count % columnCount) > 0; + var rest = count % columnCount; - var groupIndex = 0; + var groupIndex = 0; - for(var i = 0; i < fullRows; i++) - { -
- @for(var j = 0; j < columnCount; j++) - { - var group = Model.UserRightGroups.ElementAt(groupIndex); - -
-
-
-
- @group.Title -
-
- @foreach(var right in group.UserRightTypes) + for(var i = 0; i < fullRows; i++) + { +
+ @for(var j = 0; j < columnCount; j++) { -
-
- - + var group = Model.UserRightGroups.ElementAt(groupIndex); + + var areAllCheckedValue = group.AreAllChecked ? "checked=\"checked\"" : ""; + +
+
+
+
+ @group.Title +
+
+ @foreach(var right in group.UserRightTypes) + { + var checkedValue = right.Value.IsAssigned ? "checked=\"checked\"" : ""; + +
+
+ + +
+
+ } +
+
+ + +
+
+ groupIndex++; } -
-
- - -
-
-
- groupIndex++; - } -
- } + } - if(hasRest) - { -
- @for(var i = 0; i < rest; i++) - { - var group = Model.UserRightGroups.ElementAt(groupIndex); - -
-
-
-
- @group.Title -
-
- @foreach(var right in group.UserRightTypes) + if(hasRest) + { +
+ @for(var i = 0; i < rest; i++) { -
-
- - + var group = Model.UserRightGroups.ElementAt(groupIndex); + + var areAllCheckedValue = group.AreAllChecked ? "checked=\"checked\"" : ""; + +
+
+
+
+ @group.Title +
+
+ @foreach(var right in group.UserRightTypes) + { + var checkedValue = right.Value.IsAssigned ? "checked=\"checked\"" : ""; + +
+
+ + +
+
+ } +
+
+ + +
+
+ + groupIndex++; } -
-
- - -
-
+ } + } +
+
+
+
- - groupIndex++; - } -
- } - } - - @*for(var i = 0; i < Model.UserRightGroups.Count; i++) - { - var userRightGroup = Model.UserRightGroups.ElementAt(i); - - if(i == 0 || i % 5 == 0) - { -
-
-
-
-
- @userRightGroup.Title -
-
- - @foreach(var userRightType in userRightGroup.UserRightTypes) +
+
+ @using(Html.BeginForm("InsertTestAppointments", "Development", FormMethod.Post)) { - var relIndex = userRightGroup.UserRightTypes.IndexOf(userRightType); -
-
- - + // Start, Ende, unendliche serientermine?, Mitarbeiter, Ersteller, Klienten, Ressourcen, Titel, Kommentar + + /* + * Was soll passieren? + * + * Es sollen Termine erstellt werden mit dem angemeldeten Mitarbeiter als Originator, private Termine, ganztägige Termine und mehrtägige Termine dieser Konfiguration + * Das ganze dann nochmal mit einem anderen, ausgewählten Mitarbeiter als Originator. + * + * Mögliche Konfigurationen: + * Nur Originator (4): + * Normal + * Privat + * Ganztägig + * Mehrtägig + * + * Originator und Mitarbeiter (4) + * Originator und Ressourcen (4) + * Originator und Klienten (4) + * Originator und Mitarbeiter und Ressourcen (4) + * Originator und Mitarbeiter und Klienten (4) + * Originator und Ressourcen und Klienten (4) + * Originator und Mitarbeiter und Ressourcen und Klienten (4) + * + * Insgesamt also 32 Termine + * + * + * All das nochmal als private Termine + * All das mit einem anderen, ausgewählten Mitarbeiter als Originator als der angemeldete Mitarbeiter. + * + * Serientermine (extrem viele mögliche Kombinationen) [alle realisieren und per Checkboxen konfigurierbar machen] + * + * Täglich, Wöchentlich, Monatlich, Jährlich () + * + * Täglich (6) * 32 + * Alle x Tage + * Kein Ende + * Ende nach x Terminen + * Ende am dd.mm.yyyy + * + * Werktäglich + * Kein Ende + * Ende nach x Terminen + * Ende am dd.mm.yyyy + * + * Wöchentlich (3) * 32 + * Alle x Wochen am: + * Sonntag | Montag | Dienstag | Mittwoch | Donnerstag | Freitag | Samstag + * + * Kein Ende + * Ende nach x Terminen + * Ende am dd.mm.yyyy + * + * Monatlich (6) * 32 + * X-ter Tag jedes x. Monats + * Kein Ende + * Ende nach x Terminen + * Ende am dd.mm.yyyy + * + * Jeden x. [Wochentag] jedes x. Monats + * Kein Ende + * Ende nach x Terminen + * Ende am dd.mm.yyyy + * + * Jährlich (6) * 32 + * Am xx.yy. + * Kein Ende + * Ende nach x Terminen + * Ende am dd.mm.yyyy + * + * Am [ersten, zweiten, dritten, vierten, letzten] [Wochentag] im [Monat] + * Kein Ende + * Ende nach x Terminen + * Ende am dd.mm.yyyy + * + */ +
+
+ Start +
+
+ Ende +
+
+
+
+ Ersteller +
+
+ Titel +
+
+ Kommentar +
+
+
+
+ Mitarbeiter +
+
+ Klienten +
+
+ Ressourcen
} -
-
-
- - -
-
+ Hier kommt gleich die Terminerstellung hin... + + Ressourcen auswählen + Mitarbeiter auswählen + Klienten auswählen + + Zeitraum auswählen + Sollen endlose Serientermine erstellt werden?
-
- } - else - { +
+ Hilfeplanauswahl bzw. CostbearerRelations + Zeitraum + Anzahl Stunden pro Woche (fest, keine andere Auswahl zunächst) - } - }*@ - - @*@foreach(var userRightGroup in Model.UserRightGroups) - { - // TODO: In fünferpacks unterteilen - - var index = Model.UserRightGroups.IndexOf(userRightGroup); - - if(index == 0 || index % 5 == 0) - { -
-
-
-
-
- @userRightGroup.Title -
-
- - @foreach(var userRightType in userRightGroup.UserRightTypes) - { - var relIndex = userRightGroup.UserRightTypes.IndexOf(userRightType); -
-
- - -
-
- } -
-
-
- - -
-
-
-
-
-
- } - else - { - - } - }*@ - - @*
-
-
-
-
- Universalrechte -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- - -
-
-
*@ +
+ + +
+ + \ No newline at end of file diff --git a/Shared/Core/CustomerFilterEnum.cs b/Shared/Core/CustomerFilterEnum.cs new file mode 100644 index 000000000..6bf62ba69 --- /dev/null +++ b/Shared/Core/CustomerFilterEnum.cs @@ -0,0 +1,58 @@ +using System; +using BS.Shared.Translation; + +namespace BeWo.View.Navigation.Filter +{ + public enum CustomerFilterEnum + { + All, + MyCustomer, + TeamCustomer + } + + public class CustomerFilterItem + { + public CustomerFilterItem(CustomerFilterEnum e) + { + CustomerFilter = e; + } + + public CustomerFilterEnum CustomerFilter { get; } + + public string CustomerFilterName + { + get + { + switch (CustomerFilter) + { + case CustomerFilterEnum.All: + return Translator.Translate("Alle Klienten anzeigen"); + case CustomerFilterEnum.MyCustomer: + return Translator.Translate("Nur meine Klienten anzeigen"); + case CustomerFilterEnum.TeamCustomer: + return Translator.Translate("Nur Klienten meiner Teams anzeigen"); + default: + throw new ArgumentOutOfRangeException(); + } + } + + } + + public override string ToString() + { + return CustomerFilterName; + } + + + public override bool Equals(object obj) + { + var item = obj as CustomerFilterItem; + return item != null && item.CustomerFilter == CustomerFilter; + } + + public override int GetHashCode() + { + return CustomerFilter.GetHashCode(); + } + } +} \ No newline at end of file