CustomerFilterEnum hinzugefügt

This commit is contained in:
Lyndon Jetten
2020-12-30 12:30:33 +01:00
parent 79452aa505
commit a3aa99bad1
4 changed files with 567 additions and 200 deletions

View File

@@ -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<ValueListEntryDC, List<ResourceDC>>();
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<UserRightType>();
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<UserRightType, string> UserRightTypes { get; set; }
public Dictionary<UserRightType, UserRightTypeTranslation2IsAssigned> UserRightTypes { get; set; }
public bool AreAllChecked { get; set; }
public UserRightGroup(string title, Dictionary<UserRightType, string> userRightTypes)
{
Title = title ?? "Unbenannt";
UserRightTypes = userRightTypes ?? new Dictionary<UserRightType, string>();
UserRightTypes = new Dictionary<UserRightType, UserRightTypeTranslation2IsAssigned>();
userRightTypes?.DoForEach(rel =>
{
var isAssigned = MobileSessionFacade.LoggedInUser.CheckForRight(rel.Key);
var translation = rel.Value;
UserRightTypes.AddIfNotIn(new KeyValuePair<UserRightType, UserRightTypeTranslation2IsAssigned>(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;
}
}
}

View File

@@ -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<UserRightGroup> UserRightGroups { get; set; } = new List<UserRightGroup>();
public List<CompactCustomerDC> AllCustomers { get; set; } = new List<CompactCustomerDC>();
public List<CompactEmployeeDC> AllEmployees { get; set; } = new List<CompactEmployeeDC>();
[Display(Name = "Ersteller")]
public long? SelectedEmployeeOid { get; set; }
public List<SelectListItem> AvailableEmployees { get; set; } = new List<SelectListItem>();
public List<SelectListItem> AvailableCostbearerRelations { get; set; } = new List<SelectListItem>();
public List<CompactCustomerDC> SelectedCustomers { get; set; } = new List<CompactCustomerDC>();
public List<SelectListItem> AvailableCustomers { get; set; } = new List<SelectListItem>();
public List<ResourceDC> SelectedResources { get; set; } = new List<ResourceDC>();
public Dictionary<ValueListEntryDC, List<ResourceDC>> ResourceCategories2Resources { get; set; } = new Dictionary<ValueListEntryDC, List<ResourceDC>>();
public List<ResourceDC> AvailableResources
{
get
{
var result = new List<ResourceDC>();
ResourceCategories2Resources.DoForEach(rc2R =>
{
result.AddRangeIfElementsNotIn(rc2R.Value);
});
return result;
}
}
}
}

View File

@@ -7,19 +7,108 @@
}
<script>
function changeRightSelection(indecesString) {
function changeRightSelection(checkbox) {
// TODO: Methode aufrufen.
// Don't try.
var rootElement = $("#rightsContainer");
var selectedRights = "";
var boxxxy = $(checkbox);
var boxxxyId = boxxxy.attr("id");
if (boxxxyId.includes("all-")) {
var groupName = boxxxyId.split("-")[1];
checkWholeRightGroupCheckBoxes(groupName);
}
var cbs = rootElement.find("input");
$.each(cbs, function(index, checkbox) {
var box = $(checkbox);
var id = box.attr("id");
if (!id.includes("all-") && box.prop("checked") === true) {
selectedRights += id + ";";
}
});
$.get("@Url.Action("UpdateSelectedRights")", { indicesString: selectedRights });
}
function checkWholeRightGroupCheckBoxes(groupContainerId) {
var allCheckBoxes = $("#" + groupContainerId + "-container").find("input");
var allCheckBox = $("#all-" + groupContainerId);
var isChecked = allCheckBox.prop("checked");
logDebug("is checked: " + isChecked + "; type of value: " + typeof isChecked);
$.each(allCheckBoxes,
function(index, checkBox) {
var id = $(checkBox).prop("id");
if (!id.includes("all-")) {
$(checkBox).prop("checked", isChecked);
}
});
}
function updateAppointmentResources() {
var container = $("#resource-container");
var selectedResources = "";
var checkboxes = container.find("input");
$.each(checkboxes, function(index, checkbox) {
var isChecked = $(checkbox).prop("checked") === true;
if(isChecked) {
var id = $(checkbox).attr("id");// -> 17-checkbox
var splitId = id.split("-");
if(splitId.length === 2) {
selectedResources += splitId[0] + ";";
}
}
});
$.get("@Url.Action("UpdateAppointmentResources")", { selectedResourceOids: selectedResources });
}
</script>
<!-- TODO: Liste mit Rechtegruppenobjekten, die jeweils eine Liste für die UserRightTypes haben -->
<div class="container-fluid mt-3">
<!--
TODO: Liste mit Rechtegruppenobjekten, die jeweils eine Liste für die UserRightTypes haben
TODO: Zugewiesene Rechte anhaken!
-->
<div class="container-fluid mt-3" id="rightsContainer">
<div class="form-row">
<div class="col-md-12">
<ul class="nav nav-tabs" role="tab-list">
<li class="nav-item">
<a href="#rights-tab" data-toggle="tab" role="tab" class="nav-link">
Rechte
</a>
</li>
<li class="nav-item">
<a href="#scheduler-tab" data-toggle="tab" role="tab" class="nav-link active">
Kalender
</a>
</li>
<li class="nav-item">
<a href="#service-records-tab" data-toggle="tab" role="tab" class="nav-link">
Zeiterfassung
</a>
</li>
</ul>
<div class="tab-content mt-3">
<div class="tab-pane show" id="rights-tab" role="tabpanel">
@{
var count = Model.UserRightGroups.Count;
var columnCount = 4;
const int columnCount = 4;
var fullRows = count / columnCount;
var hasRest = (count % columnCount) > 0;
@@ -34,25 +123,29 @@
{
var group = Model.UserRightGroups.ElementAt(groupIndex);
var areAllCheckedValue = group.AreAllChecked ? "checked=\"checked\"" : "";
<div class="col-md-3">
<div class="card">
<div class="card-body">
<div class="card-body" id="@group.Title-container">
<div class="card-title text-bewo-customer-card-header">
@group.Title
</div>
<hr />
@foreach(var right in group.UserRightTypes)
{
var checkedValue = right.Value.IsAssigned ? "checked=\"checked\"" : "";
<div class="row ml-1">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="cb-@right.Key" />
<label class="custom-control-label" for="cb-@right.Key">@right.Value</label>
<input type="checkbox" class="custom-control-input" id="cb-@right.Key" onchange="changeRightSelection(this)" @checkedValue />
<label class="custom-control-label" for="cb-@right.Key">@right.Value.Translation</label>
</div>
</div>
}
<hr />
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="all-@group.Title" />
<input type="checkbox" class="custom-control-input" id="all-@group.Title" onchange="changeRightSelection(this)" @areAllCheckedValue />
<label class="custom-control-label" for="all-@group.Title">Alle</label>
</div>
</div>
@@ -70,25 +163,29 @@
{
var group = Model.UserRightGroups.ElementAt(groupIndex);
var areAllCheckedValue = group.AreAllChecked ? "checked=\"checked\"" : "";
<div class="col-md-3">
<div class="card">
<div class="card-body">
<div class="card-title text-bewo-customer-card-header">
@group.Title
</div>
<hr/>
<hr />
@foreach(var right in group.UserRightTypes)
{
var checkedValue = right.Value.IsAssigned ? "checked=\"checked\"" : "";
<div class="row ml-1">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="cb-@right.Key"/>
<label class="custom-control-label" for="cb-@right.Key">@right.Value</label>
<input type="checkbox" class="custom-control-input" id="cb-@right.Key" onchange="changeRightSelection(this)" @checkedValue />
<label class="custom-control-label" for="cb-@right.Key">@right.Value.Translation</label>
</div>
</div>
}
<hr/>
<hr />
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="all-@group.Title"/>
<input type="checkbox" class="custom-control-input" id="all-@group.Title" onchange="changeRightSelection(this)" @areAllCheckedValue />
<label class="custom-control-label" for="all-@group.Title">Alle</label>
</div>
</div>
@@ -100,136 +197,187 @@
</div>
}
}
@*for(var i = 0; i < Model.UserRightGroups.Count; i++)
{
var userRightGroup = Model.UserRightGroups.ElementAt(i);
if(i == 0 || i % 5 == 0)
{
<div class="row my-3">
</div>
<div class="tab-pane show active" id="scheduler-tab" role="tabpanel">
<div class="col-md-2">
<div class="card">
<div class="card-body">
<div class="card-title text-bewo-customer-card-header">
@userRightGroup.Title
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#resources-popup">Ressourcen hinzufügen</button>
</div>
<hr/>
@foreach(var userRightType in userRightGroup.UserRightTypes)
<div class="row">
<div class="col col-12">
@using(Html.BeginForm("InsertTestAppointments", "Development", FormMethod.Post))
{
var relIndex = userRightGroup.UserRightTypes.IndexOf(userRightType);
<div class="row ml-1">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="cb-@i-@relIndex" onchange="changeRightSelection()"/>
<label for="cb-@i-@relIndex" class="custom-control-label">@userRightType.Value</label>
// 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
*
*/
<div class="row">
<div class="col-md-6">
Start
</div>
<div class="col-md-6">
Ende
</div>
</div>
<div class="row">
<div class="col-md-4">
Ersteller
</div>
<div class="col-md-4">
Titel
</div>
<div class="col-md-4">
Kommentar
</div>
</div>
<div class="row">
<div class="col-md-4">
Mitarbeiter
</div>
<div class="col-md-4">
Klienten
</div>
<div class="col-md-4">
Ressourcen
</div>
</div>
}
<hr/>
<div class="row ml-1">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="all-@i" onchange="changeRightSelection()"/>
<label for="all-@i" class="custom-control-label">Alle</label>
</div>
</div>
</div>
</div>
</div>
</div>
}
else
{
Hier kommt gleich die Terminerstellung hin...
}
}*@
Ressourcen auswählen
Mitarbeiter auswählen
Klienten auswählen
@*@foreach(var userRightGroup in Model.UserRightGroups)
{
// TODO: In fünferpacks unterteilen
Zeitraum auswählen
Sollen endlose Serientermine erstellt werden?
</div>
<div class="tab-pane show" id="service-records-tab" role="tabpanel">
Hilfeplanauswahl bzw. CostbearerRelations
Zeitraum
Anzahl Stunden pro Woche (fest, keine andere Auswahl zunächst)
var index = Model.UserRightGroups.IndexOf(userRightGroup);
</div>
</div>
</div>
</div>
if(index == 0 || index % 5 == 0)
{
<div class="row my-3">
<div class="col-md-2">
<div class="card">
<div class="card-body">
<div class="card-title text-bewo-customer-card-header">
@userRightGroup.Title
</div>
<hr/>
@foreach(var userRightType in userRightGroup.UserRightTypes)
{
var relIndex = userRightGroup.UserRightTypes.IndexOf(userRightType);
<div class="row ml-1">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="cb-@index-@relIndex" onchange="changeRightSelection('@index;@relIndex')"/>
<label for="cb-@index-@relIndex" class="custom-control-label">@userRightType.Value</label>
</div>
</div>
}
<hr/>
<div class="row ml-1">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="all-@index" onchange="changeRightSelection('0;@index')"/>
<label for="all-@index" class="custom-control-label">Alle</label>
</div>
</div>
</div>
</div>
</div>
</div>
}
else
{
}
}*@
@*<div class="row my-3">
<div class="col-md-2">
<div class="card">
<div class="card-body">
<div class="card-title text-bewo-customer-card-header">
Universalrechte
</div>
<hr/>
<div class="row ml-1">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="checkbox-view-all-universal-rights"/>
<label for="checkbox-view-all-universal-rights" class="custom-control-label">Alles ansehen</label>
</div>
</div>
<div class="row ml-1">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="checkbox-create-all-universal-rights"/>
<label for="checkbox-create-all-universal-rights" class="custom-control-label">Alles anlegen</label>
</div>
</div>
<div class="row ml-1">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="checkbox-edit-all-universal-rights"/>
<label for="checkbox-edit-all-universal-rights" class="custom-control-label">Alles ändern</label>
</div>
</div>
<div class="row ml-1">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="checkbox-delete-all-universal-rights"/>
<label for="checkbox-delete-all-universal-rights" class="custom-control-label">Alles löschen</label>
</div>
</div>
<hr/>
<div class="row ml-1">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="checkbox-all-universal-rights"/>
<label for="checkbox-all-universal-rights" class="custom-control-label">Alle</label>
</div>
</div>
</div>
</div>
</div>
</div>*@
</div>
<div class="modal" tabindex="-1" role="dialog" id="resources-popup">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title">Ressourcen</h6>
<button type="button" class="close" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<div class="modal-body">
<div class="container-fluid" id="resource-container">
@foreach(var category2Resources in Model.ResourceCategories2Resources)
{
<div class="card w-100 mb-3" id="resource-category-@category2Resources.Key.ValueListEntryOid">
<div class="card-header" data-toggle="collapse" data-target="#collapsable-resource-category-@category2Resources.Key.ValueListEntryOid">
<div class="d-flex align-items-center">
<h5 class="mr-auto">@category2Resources.Key.DisplayName</h5>
<div class="btn-group" role="group">
<span class="fas fa-chevron-down text-primary"></span>
</div>
</div>
</div>
<div class="collapse" id="collapsable-resource-category-@category2Resources.Key.ValueListEntryOid">
<div class="card-body">
@foreach(var resource in category2Resources.Value)
{
var checkedValue = Model.SelectedResources.Contains(resource) ? "checked" : string.Empty;
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="@resource.ResourceOid-checkbox" @checkedValue onchange="updateAppointmentResources()" />
<label class="custom-control-label" for="@resource.ResourceOid-checkbox">@resource.Name</label>
</div>
}
</div>
</div>
</div>
}
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Übernehmen</button>
</div>
</div>
</div>
</div>

View File

@@ -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();
}
}
}