commit e75c5129139bebf16572dda99e962f802e98195e
Author: Dominik Chlouba <dchlouba@students.zcu.cz>
Date:   Thu May 27 20:14:20 2021 +0200

    Updated UserShortDto, methods in DomainUserRepository for fetching users with different roles, UI fixes

diff --git a/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/Components/UserAside.razor b/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/Components/UserAside.razor
index 526919f..f2e219a 100644
--- a/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/Components/UserAside.razor
+++ b/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/Components/UserAside.razor
@@ -312,7 +312,7 @@
 
     private async Task FetchUsers()
     {
-        var result = await _mediator.Send(new GetUsersList.Query(false, Role));
+        var result = await _mediator.Send(new GetUsersList.Query(false, "TL"));
         if (result.IsSuccess && result.Result is not null)
         {
             if (UserId == default(Guid)) Users = result.Result.List;
diff --git a/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/List.razor b/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/List.razor
index 8a8935b..082e05c 100644
--- a/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/List.razor
+++ b/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/List.razor
@@ -19,22 +19,24 @@
             <th>@T["Email"]</th>
             <th>@T["Role"]</th>
             <th>@T["Type"]</th>
+            <th>@T["Senior"]</th>
             <th>@T["Actions"]</th>
         </tr>
         @foreach (var user in Users)
         {
-            <tr>
-                <td>@user.Name</td>
-                <td>@user.Email</td>
-                <td>@user.Role</td>
-                <td>@(user.IsAdUser ? "AD" : "Lokální")</td>
-                <td>
-                    <div class="button-ui" @onclick="() => SetUserAsideId(user.Id)">
-                        <i class="fal fa-edit"></i>
-                        @T["Edit"]
-                    </div>
-                </td>
-            </tr>
+    <tr>
+        <td>@user.Name</td>
+        <td>@user.Email</td>
+        <td>@user.Role</td>
+        <td>@(user.IsAdUser ? "AD" : "Lokální")</td>
+        <td>@(user.SeniorName is not null ? user.SeniorName : "Bez nadřízeného")</td>
+        <td>
+            <div class="button-ui" @onclick="() => SetUserAsideId(user.Id)">
+                <i class="fal fa-edit"></i>
+                @T["Edit"]
+            </div>
+        </td>
+    </tr>
         }
     </table>
     @if (Users.Count > 0)
diff --git a/src/Core/Application/Leuze.Core.Application/CQRS/Users/Queries/GetUsersList.cs b/src/Core/Application/Leuze.Core.Application/CQRS/Users/Queries/GetUsersList.cs
index 4156c9c..ab1df69 100644
--- a/src/Core/Application/Leuze.Core.Application/CQRS/Users/Queries/GetUsersList.cs
+++ b/src/Core/Application/Leuze.Core.Application/CQRS/Users/Queries/GetUsersList.cs
@@ -1,10 +1,7 @@
 ﻿using Leuze.Core.Domain.Domains.Users.DTOs;
 using Leuze.Core.Domain.Repositories;
-using Microsoft.AspNetCore.Components.Authorization;
-using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Security.Claims;
 using System.Threading;
 using System.Threading.Tasks;
 using Leuze.Core.Application.Authentication;
@@ -19,7 +16,7 @@ namespace Leuze.Core.Application.CQRS.Users.Queries
         /// <summary>
         /// 
         /// </summary>
-        public record Query(bool ExcludeMyself, Guid LimitForRole) : IBaseRequest<Response>;
+        public record Query(bool ExcludeMyself, string? LimitForRole) : IBaseRequest<Response>;
 
         /// <summary>
         /// 
diff --git a/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserDto.cs b/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserDto.cs
index 7f3aa24..cce02d1 100644
--- a/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserDto.cs
+++ b/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserDto.cs
@@ -5,5 +5,5 @@ namespace Leuze.Core.Domain.Domains.Users.DTOs
     /// <summary>
     /// 
     /// </summary>
-    public record UserDto(Guid Id, string Name, string Email, string Role, bool IsAdUser);
+    public record UserDto(Guid Id, string Name, string? SeniorName, string Email, string Role, bool IsAdUser);
 }
diff --git a/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserShortDto.cs b/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserShortDto.cs
index cb6ede3..a961eb5 100644
--- a/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserShortDto.cs
+++ b/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserShortDto.cs
@@ -5,5 +5,5 @@ namespace Leuze.Core.Domain.Domains.Users.DTOs
     /// <summary>
     /// 
     /// </summary>
-    public record UserShortDto(Guid Id, string Name);
+    public record UserShortDto(Guid Id, string Name, Guid? SeniorId, Guid RoleId, string RoleName);
 }
diff --git a/src/Core/Domain/Leuze.Core.Domain/Repositories/IDomainUserRepository.cs b/src/Core/Domain/Leuze.Core.Domain/Repositories/IDomainUserRepository.cs
index 10d9c4f..8d83827 100644
--- a/src/Core/Domain/Leuze.Core.Domain/Repositories/IDomainUserRepository.cs
+++ b/src/Core/Domain/Leuze.Core.Domain/Repositories/IDomainUserRepository.cs
@@ -52,7 +52,7 @@ namespace Leuze.Core.Domain.Repositories
         /// 
         /// </summary>
         /// <returns></returns>
-        Task<List<UserShortDto>> GetListAsync(Guid limitForRole);
+        Task<List<UserShortDto>> GetListAsync(string? limitForRole);
 
         /// <summary>
         /// 
@@ -60,5 +60,25 @@ namespace Leuze.Core.Domain.Repositories
         /// <param name="id"></param>
         /// <returns></returns>
         Task<UserDetailDto> GetDetailByIdAsync(Guid id);
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        Task<List<UserShortDto>> GetAllNonAdminUsers();
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        Task<List<UserShortDto>> GetAllTLUsers();
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        Task<List<UserShortDto>> GetAllMAUsersFromTL(Guid id);
+
     }
 }
diff --git a/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs b/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs
index fdf83c1..8e85ef1 100644
--- a/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs
+++ b/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs
@@ -45,11 +45,11 @@ namespace Leuze.Core.Infrastructure.Persistence.Repository
         /// <inheritdoc/>
         public async Task<(List<UserDto> List, int Total)> GetFilteredListAsync(int pageNumber, int pageSize)
         {
-            var query = dbSet.Include(o => o.User).ThenInclude(o => o.Roles).AsNoTracking().AsQueryable();
+            var query = dbSet.Include(o => o.SeniorUser).Include(o => o.User).ThenInclude(o => o.Roles).AsNoTracking().AsQueryable();
 
             var total = await query.CountAsync();
 
-            var list = await query.Select(o => new UserDto(o.UserId, o.Name.FullName, o.EmailAddress.Email, o.User.Roles.Single().Name, o.User.IsAdUser))
+            var list = await query.Select(o => new UserDto(o.UserId, o.Name.FullName, o.SeniorUser != null ? o.SeniorUser.Name.FullName : null!, o.EmailAddress.Email, o.User.Roles.Single().Name, o.User.IsAdUser))
                     .Skip((pageNumber - 1) * pageSize)
                     .Take(pageSize)
                     .ToListAsync();
@@ -71,11 +71,31 @@ namespace Leuze.Core.Infrastructure.Persistence.Repository
                 .SingleOrDefaultAsync();
 
         /// <inheritdoc/>
-        public async Task<List<UserShortDto>> GetListAsync(Guid limitForRole)
+        public async Task<List<UserShortDto>> GetListAsync(string? limitForRole)
         {
-            var query = dbSet.AsQueryable();
+            var query = dbSet.Include(o => o.User).ThenInclude(o => o.Roles).AsQueryable();
 
-            return await query.Select(o => new UserShortDto(o.UserId, o.Name.FullName)).ToListAsync();
+            if (limitForRole is not null) query = query.Where(o => o.User.Roles.Any(a => a.NormalizedName == limitForRole.ToUpper()));
+
+            return await query.Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
         }
+
+        /// <inheritdoc/>
+        public async Task<List<UserShortDto>> GetAllNonAdminUsers()
+            => await dbSet.Include(o => o.User).ThenInclude(o => o.Roles)
+                .Where(o => o.User.Roles.Any(a => a.NormalizedName != "ADMIN"))
+                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
+
+        /// <inheritdoc/>
+        public async Task<List<UserShortDto>> GetAllTLUsers()
+            => await dbSet.Include(o => o.User).ThenInclude(o => o.Roles)
+                .Where(o => o.User.Roles.Any(a => a.NormalizedName == "TL"))
+                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
+
+        /// <inheritdoc/>
+        public async Task<List<UserShortDto>> GetAllMAUsersFromTL(Guid id)
+            => await dbSet.Include(o => o.User).ThenInclude(o => o.Roles)
+                .Where(o => o.SeniorUserId.HasValue && o.SeniorUserId.Value == id && o.User.Roles.Any(a => a.NormalizedName == "MA"))
+                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
     }
 }
diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalDefinitionDetail.razor b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalDefinitionDetail.razor
index 8ced194..2a73cd2 100644
--- a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalDefinitionDetail.razor
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalDefinitionDetail.razor
@@ -39,6 +39,7 @@
     <td>@range.PercentileFinal</td>
     <td>
         <div class="flex">
+            <div></div>
             <div></div>
             <div class="button-ui" @onclick='() => SetDetailId(range.Id)'>
                 <i class="fal fa-eye"></i>
@@ -165,7 +166,7 @@
     .flex{
     display: grid;
     align-items: center;
-    grid-template-columns: repeat(3, 100px);
+    grid-template-columns: repeat(4, 120px);
     justify-content: right;
     }
     .flex > div:not(:last-child) {
diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalsManagement.razor b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalsManagement.razor
index 196c861..925d726 100644
--- a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalsManagement.razor
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalsManagement.razor
@@ -40,6 +40,7 @@
     <td>
         <div class="flex">
             <AuthorizeView Roles="TL">
+                <div></div>
                 <div class="button-ui" @onclick='() => _nav.NavigateTo($"/goals/detail/{range.Id}")'>
                     <i class="fal fa-eye"></i>
                     @T["Open"]
@@ -145,7 +146,7 @@
     .flex{
     display: grid;
     align-items: center;
-    grid-template-columns: repeat(3, 100px);
+    grid-template-columns: repeat(4, 120px);
     justify-content: right;
     }
     .flex > div:not(:last-child) {
