commit 08c1fa42f1f285d06ef6e940082ef51345e33346
Author: Silentkiller159 <milanhotovec@seznam.cz>
Date:   Thu May 27 13:36:42 2021 +0200

    UnassignedList add

diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/CreateDefinitionRangeAside.razor b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/CreateDefinitionRangeAside.razor
index 6abdf5c..1de4e51 100644
--- a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/CreateDefinitionRangeAside.razor
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/CreateDefinitionRangeAside.razor
@@ -4,7 +4,7 @@
 
 <aside class="@_aside review_detail">
     <div class="review_detail_header">
-        <div>@T["Title"]</div>
+        <div>@((AsideId != default(Guid)) ? T["TitleEdit"] : T["TitleCreate"] )</div>
         <div>
             <div class="close_button" @onclick="Close">
                 <i class="fal fa-times"></i>
diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/CreateGoalDefinition.razor b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/CreateGoalDefinition.razor
index f3007f6..0a260fe 100644
--- a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/CreateGoalDefinition.razor
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/CreateGoalDefinition.razor
@@ -1,4 +1,6 @@
-﻿@inject IStringLocalizer<CreateGoalDefinition> T
+﻿@inject IMediator _mediator
+@inject IToastService toastService
+@inject IStringLocalizer<CreateGoalDefinition> T
 <aside class="@_aside review_detail">
     <div class="review_detail_header">
         <div>@T["Title"]</div>
@@ -11,25 +13,29 @@
     <div class="review_detail_body">
         <div class="input_row">
             <label class="input_label">@T["Name"]</label>
-            <input type="number" />
+            <input type="text" @bind-value="Name" />
         </div>
         <div class="input_row">
             <label class="input_label">@T["User"]</label>
-            <select>
-                <option value="" disabled>@T["SelectUser"]</option>
+            <select asp-for="SelectedUser">
+                @foreach (var user in UnassignedUsers)
+                {
+                    //<option value="" disabled>@T["SelectUser"]</option>
+                    <option value="@user.Id">@user.Name</option>
+                }
             </select>
         </div>
         <div class="input_row">
             <label class="input_label">@T["Hours"]</label>
-            <input type="number" />
+            <input type="number" @bind-value="Hours" />
         </div>
         <div class="input_row">
             <label class="input_label">@T["Finance"]</label>
-            <input type="number" />
+            <input type="number" @bind-value="FinanceBase"/>
         </div>
     </div>
     <div class="review_detail_footer">
-        <button>@T["Create"]</button>
+        <button @onclick="Create">@T["Create"]</button>
         <button @onclick="Close">@T["Cancel"]</button>
     </div>
 </aside>
@@ -163,12 +169,60 @@
 
     private string _aside;
 
+    private Guid _asideId = default(Guid);
+
+    [Parameter]
+    public Guid AsideId
+    {
+        get { return _asideId; }
+        set
+        {
+            _asideId = value;
+            InitAside();
+        }
+    }
+
     [Parameter]
     public bool Show { get; set; } = false;
 
+    [Parameter]
+    public GlobalDefinitionArea Area { get; set; } = GlobalDefinitionArea.Default();
+
     [Parameter]
     public EventCallback CloseAside { get; set; }
 
+    private string Name { get; set; } = $"";
+    private List<UserShortDto> UnassignedUsers { get; set; } = new();
+    public Guid SelectedUser { get; set; } = default(Guid);
+    private double Hours { get; set; } = 0;
+    private double FinanceBase { get; set; } = 0;
+
+    private async Task InitAside()
+    {
+        var response = await _mediator.Send(new GetAreaById.Query(AsideId));
+
+        if (response.IsSuccess)
+        {
+            //toastService.ShowSuccess("Oblast úspěšně vytvořena");
+            Area = response.Result.area;
+        }
+        else toastService.ShowError($"Oblast se nepodařilo načíst {response.Errors.FirstOrDefault() ?? ""}");
+
+        var response2 = await _mediator.Send(new GetAllUnassignedInArea.Query(AsideId));
+
+        if (response2.IsSuccess)
+        {
+            //toastService.ShowSuccess("Oblast úspěšně vytvořena");
+            UnassignedUsers = response2.Result.list;
+        }
+        else toastService.ShowError($"Seznam nepřiřazených uživatelů se nepodařilo načíst {response2.Errors.FirstOrDefault() ?? ""}");
+    }
+
+    private async Task Create()
+    {
+        toastService.ShowError($"Selected: {SelectedUser}");
+    }
+
     private async Task Close()
     {
         //ResetValues();
diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalRanges.razor b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalRanges.razor
index d805a5c..ce6daa7 100644
--- a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalRanges.razor
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalRanges.razor
@@ -194,11 +194,10 @@ else
 
     private Guid AsideId { get; set; } = default(Guid);
 
-    private bool IsEditMode { get; set; } = false;
 
     private bool ShowAside { get; set; } = false;
 
-    private void OpenAside(Guid id, bool editMode) => (AsideId, IsEditMode, ShowAside) = (id, editMode, true);
+    private void OpenAside(Guid id) => (AsideId, ShowAside) = (id, true);
 
     private void CloseAside() => (AsideId, ShowAside) = (default(Guid), false);
 
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 d73be0a..0f1e239 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
@@ -4,12 +4,13 @@
 @inject IMediator _mediator
 @inject NavigationManager _nav
 @inject IJSRuntime JsRuntime
+@inject IToastService toastService
 @inject IStringLocalizer<GoalsManagement> T
 
 <div class="section_header">
     <h2>@T["Title"]</h2>
     <div class="header_buttons">
-        <button type="button">
+        <button type="button" @onclick="InitAllDefinitions">
             <i class="fal fa-layer-plus"></i>
             <span>@T["InitAll"]</span>
         </button>
@@ -24,55 +25,56 @@
 </div>
 @if (Definitions is not null)
 {
-<table class="actions" style="width:100%">
-    <tr>
-        <th>@T["Name"]</th>
-        <th>@T["User"]</th>
-        <th>@T["CreatedBy"]</th>
-        <th>@T["Actions"]</th>
-    </tr>
-    @foreach (var range in Definitions)
+    <table class="actions" style="width:100%">
+        <tr>
+            <th>@T["Name"]</th>
+            <th>@T["User"]</th>
+            <th>@T["CreatedBy"]</th>
+            <th>@T["Actions"]</th>
+        </tr>
+        @foreach (var range in Definitions)
+        {
+            <tr>
+                <td>@range.Name</td>
+                <td>@range.Owner.Name</td>
+                <td>@range.Creator.Name</td>
+                <td>
+                    <div class="flex">
+                        <AuthorizeView Roles="TL">
+                            <div @onclick='() => _nav.NavigateTo($"/goals/detail/{range.Id}")'>
+                                <i class="fal fa-eye"></i>
+                                @T["Open"]
+                            </div>
+                            <div @onclick="() => OpenAside(range.Id)">
+                                <i class="fal fa-edit"></i>
+                                @T["Edit"]
+                            </div>
+                            <div @onclick="() => RemoveDefinition(range.Id)">
+                                <i class="fal fa-trash"></i>
+                                @T["Remove"]
+                            </div>
+                        </AuthorizeView>
+                    </div>
+                </td>
+            </tr>
+}
+    </table>
+    @if (Definitions.Count > 0)
     {
-<tr>
-    <td>@range.Name</td>
-    <td>@range.Owner.Name</td>
-    <td>@range.Creator.Name</td>
-    <td>
-        <div class="flex">
-            <AuthorizeView Roles="TL">
-                <div @onclick='() => _nav.NavigateTo($"/goals/detail/{range.Id}")'>
-                    <i class="fal fa-eye"></i>
-                    @T["Open"]
-                </div>
-                <div @onclick="() => OpenAside(range.Id)">
-                    <i class="fal fa-edit"></i>
-                    @T["Edit"]
-                </div>
-                <div @onclick="() => RemoveDefinition(range.Id)">
-                    <i class="fal fa-trash"></i>
-                    @T["Remove"]
-                </div>
-            </AuthorizeView>
-        </div>
-    </td>
-</tr>}
-</table>
-                @if (Definitions.Count > 0)
-                {
-<!--<div class="pagination">
-    <div class="left">
-        <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-left.svg" /></button>
-        <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-left.svg" /></button>
-        <input type="number" @bind-value="PageNumber" />
-        <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-right.svg" /></button>
-        <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-right.svg" /></button>
-    </div>
-    <div class="right">@T["Show"] <b>@Ranges.Count @T["From"] @Total</b></div>
-</div>-->} }
-                            else
-                            {
-                <div>Loading...</div>}
-<Leuze.Modules.Goal.Application.UI.Pages.Components.CreateGoalDefinition Show="ShowAside" CloseAside="CloseAside" />
+        <!--<div class="pagination">
+            <div class="left">
+                <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-left.svg" /></button>
+                <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-left.svg" /></button>
+                <input type="number" @bind-value="PageNumber" />
+                <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-right.svg" /></button>
+                <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-right.svg" /></button>
+            </div>
+            <div class="right">@T["Show"] <b>@Ranges.Count @T["From"] @Total</b></div>
+        </div>-->} }
+else
+{
+    <div>Loading...</div>}
+<Leuze.Modules.Goal.Application.UI.Pages.Components.CreateGoalDefinition Show="ShowAside" AsideId="Id" CloseAside="CloseAside" />
 
 <BlazorStyled.Styled>
     .section_header {
@@ -194,44 +196,49 @@
 </BlazorStyled.Styled>
 
 @code { [Parameter]
-            public Guid Id { get; set; } = default(Guid);
+    public Guid Id { get; set; } = default(Guid);
 
-            private List<GoalDefinition> Definitions { get; set; } = new();
+    private List<GoalDefinition> Definitions { get; set; } = new();
 
-            private int PageNumber { get; set; } = 1;
+    private int PageNumber { get; set; } = 1;
 
-            private int PageSize { get; set; } = 12;
+    private int PageSize { get; set; } = 12;
 
-            private int Total { get; set; } = 0;
+    private int Total { get; set; } = 0;
 
-            private bool ShowAside { get; set; } = false;
+    private bool ShowAside { get; set; } = false;
 
-            private void OpenAside(Guid id) => (ShowAside) = (true);
+    private void OpenAside(Guid id) => (ShowAside) = (true);
 
-            private void CloseAside() => (ShowAside) = (false);
+    private void CloseAside() => (ShowAside) = (false);
 
-            private async Task GetMyDefinitions()
-            {
-                var response = await _mediator.Send(new GetAllForArea.Query(Id));
+    private async Task GetMyDefinitions()
+    {
+        var response = await _mediator.Send(new GetAllForArea.Query(Id));
+
+        if (response.IsSuccess)
+        {
+            Definitions = response.Result.list;
+        }
+    }
 
-                if (response.IsSuccess)
-                {
-                    Definitions = response.Result.list;
-                }
-            }
+    private async Task InitAllDefinitions()
+    {
+        toastService.ShowError($"NOT IMPLEMENTED (yet) !");
+    }
 
-            private async Task RemoveDefinition(Guid id)
-            {
-                bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?");
-                if (confirmed)
-                {
-                    var response = await _mediator.Send(new RemoveDefinition.Command(id));
-                    await GetMyDefinitions();
-                }
-            }
+    private async Task RemoveDefinition(Guid id)
+    {
+        bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?");
+        if (confirmed)
+        {
+            var response = await _mediator.Send(new RemoveDefinition.Command(id));
+            await GetMyDefinitions();
+        }
+    }
 
-            protected async override Task OnInitializedAsync()
-            {
-                await base.OnInitializedAsync();
-                await GetMyDefinitions();
-            } }
+    protected async override Task OnInitializedAsync()
+    {
+        await base.OnInitializedAsync();
+        await GetMyDefinitions();
+    } }
diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Resources/Pages/Components/CreateDefinitionRangeAside.cs-CZ.resx b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Resources/Pages/Components/CreateDefinitionRangeAside.cs-CZ.resx
index 81b7a28..1a80ee6 100644
--- a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Resources/Pages/Components/CreateDefinitionRangeAside.cs-CZ.resx
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Resources/Pages/Components/CreateDefinitionRangeAside.cs-CZ.resx
@@ -132,7 +132,10 @@
   <data name="Start" xml:space="preserve">
     <value>Datum začátku oblasti</value>
   </data>
-  <data name="Title" xml:space="preserve">
+  <data name="TitleCreate" xml:space="preserve">
     <value>Vytvořit oblast definic</value>
   </data>
+  <data name="TitleEdit" xml:space="preserve">
+    <value>Editace oblasti definic</value>
+  </data>
 </root>
\ No newline at end of file
diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitionAreas/Commands/EditArea.cs b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitionAreas/Commands/EditArea.cs
index 1d8681a..7dcff80 100644
--- a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitionAreas/Commands/EditArea.cs
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitionAreas/Commands/EditArea.cs
@@ -45,9 +45,9 @@ namespace Leuze.Modules.Goal.Application.CQRS.GoalDefinitionAreas.Commands
                     return RequestResponse<Response>.CreateErrorResponse($"V zadaném rozsahu již existuje oblast!");
                 }
 
-                await _gdAreaRepo.SetFrom(request.id, item.From);;
-                await _gdAreaRepo.SetTo(request.id, item.To);
-                await _gdAreaRepo.SetVariCompanySuccess(request.id, item.VariCompanySuccess);
+                await _gdAreaRepo.SetFrom(request.id, request.from);;
+                await _gdAreaRepo.SetTo(request.id, request.to);
+                await _gdAreaRepo.SetVariCompanySuccess(request.id, request.variCompany);
 
                 return RequestResponse<Response>.CreateSuccessResponse(new(item));
             }
diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitions/Queries/GetAllUnassignedInArea.cs b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitions/Queries/GetAllUnassignedInArea.cs
new file mode 100644
index 0000000..3224037
--- /dev/null
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitions/Queries/GetAllUnassignedInArea.cs
@@ -0,0 +1,61 @@
+﻿using Leuze.Core.Application.CQRS;
+using Leuze.Core.Domain.Domains.Users;
+using Leuze.Core.Domain.Domains.Users.DTOs;
+using Leuze.Core.Domain.Repositories;
+using Leuze.Modules.Goal.Domain.Repositories;
+using Microsoft.AspNetCore.Components.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Application.CQRS.GoalDefinitions.Queries
+{
+    public static class GetAllUnassignedInArea
+    {
+        public record Query(Guid areaId) : IBaseRequest<Response>;
+
+        public record Response(List<UserShortDto> list);
+
+
+        public class Handler : IBaseRequestHandler<Query, Response>
+        {
+            private readonly IGoalDefinitionRepository _goalDefinitionRepo;
+            private readonly AuthenticationStateProvider _authenticationStateProvider;
+            private readonly IDomainUserRepository _domainUserRepo;
+
+            public Handler(IDomainUserRepository domainUserRepo, AuthenticationStateProvider authStateProvider, IGoalDefinitionRepository goalDefinitionRepo)
+            {
+                _goalDefinitionRepo = goalDefinitionRepo;
+                _domainUserRepo = domainUserRepo;
+                _authenticationStateProvider = authStateProvider;
+            }
+
+            public async Task<RequestResponse<Response>> Handle(Query request, CancellationToken cancellationToken)
+            {
+                var state = await _authenticationStateProvider.GetAuthenticationStateAsync();
+                var id = Guid.Parse(state.User!.FindFirst(ClaimTypes.NameIdentifier)!.Value);
+                var user = await _domainUserRepo.GetByIdAsync(id);
+
+                //var goalDefs = await _goalDefinitionRepo.GetAllForAreaAsync(request.areaId);
+                var allUsers = await _domainUserRepo.GetListAsync(id);
+                var areaDefs = await _goalDefinitionRepo.GetAllForAreaAsync(request.areaId);
+                var assignedList = areaDefs.Select(o => new UserShortDto(o.Owner.UserId, o.Owner.Name.FullName)).ToList();
+
+
+                var unassignedUsers = allUsers.Except(assignedList).ToList();
+
+                /*
+                if (goalDefs == null)
+                {
+                    return RequestResponse<Response>.CreateErrorResponse($"Nelze načíst definice pro oblast: {request.areaId}!");
+                }*/
+
+                return RequestResponse<Response>.CreateSuccessResponse(new(unassignedUsers));
+            }
+        }
+    }
+}
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalDefinitionRepository.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalDefinitionRepository.cs
index 34e8532..9842149 100644
--- a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalDefinitionRepository.cs
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalDefinitionRepository.cs
@@ -1,4 +1,6 @@
 ﻿using ExtCore.Data.Abstractions;
+using Leuze.Core.Domain.Domains.Users;
+using Leuze.Core.Domain.Domains.Users.DTOs;
 using Leuze.Modules.Goal.Domain.Domains;
 using System;
 using System.Collections.Generic;
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/DependencyInjection.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/DependencyInjection.cs
index 37f6221..147e8e7 100644
--- a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/DependencyInjection.cs
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/DependencyInjection.cs
@@ -57,7 +57,9 @@ namespace Leuze.Modules.Goal.Infrastructure.Persistence
 
                 //TODO: This is debug delet this
                 var user = context.Set<DomainUser>().Where(item => item.EmailAddress.Email == "ma@test.cz").FirstOrDefault();
-                GoalDefinition gd = new GoalDefinition(user, user, new GlobalDefinitionArea(user, DateTime.Now, DateTime.Now.AddDays(10)) ,"Test Goal definition");
+                GlobalDefinitionArea area = new GlobalDefinitionArea(user, DateTime.Now, DateTime.Now.AddDays(10));
+                context.Add(area);
+                GoalDefinition gd = new GoalDefinition(user, user, area, "Test Goal definition");
                 context.Add(gd);
                 context.SaveChanges();
             }
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs
index 74010e7..bc609c9 100644
--- a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs
@@ -1,5 +1,7 @@
 ﻿using AutoMapper;
 using ExtCore.Data.Abstractions;
+using Leuze.Core.Domain.Domains.Users;
+using Leuze.Core.Domain.Domains.Users.DTOs;
 using Leuze.Core.Infrastructure.Persistence;
 using Leuze.Modules.Goal.Domain.Domains;
 using Leuze.Modules.Goal.Domain.Repositories;
