commit c60f806bfd425b852eb953e168da1700d681fa55
Author: Silentkiller159 <milanhotovec@seznam.cz>
Date:   Wed May 26 15:22:59 2021 +0200

    Repo update

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 2defae1..d805a5c 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
@@ -3,6 +3,7 @@
 @layout MainLayout
 @inject IJSRuntime JsRuntime
 @inject IMediator _mediator
+@inject IToastService toastService
 @inject NavigationManager _nav
 @inject IStringLocalizer<GoalRanges> T
 
@@ -15,57 +16,58 @@
 </div>
 @if (Ranges is not null)
 {
-<table class="actions" style="width:100%">
-    <tr>
-        <th>@T["Start"]</th>
-        <th>@T["End"]</th>
-        <th>@T["Result"]</th>
-        <th>@T["Actions"]</th>
-    </tr>
-    @foreach (var range in Ranges)
+    <table class="actions" style="width:100%">
+        <tr>
+            <th>@T["Start"]</th>
+            <th>@T["End"]</th>
+            <th>@T["Result"]</th>
+            <th>@T["Actions"]</th>
+        </tr>
+        @foreach (var range in Ranges)
+        {
+            <tr>
+                <td>@range.From.ToShortDateString()</td>
+                <td>@range.To.ToShortDateString()</td>
+                <td>@(range.VariCompanySuccess ?? 0)</td>
+                <td>
+                    <div class="flex">
+                        <div @onclick="() => DownloadAreaFile(range.Id)">
+                            <i class="fal fa-download"></i>
+                            @T["Export"]
+                        </div>
+
+                        <div @onclick='() => _nav.NavigateTo($"/goals/overview/{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="() => RemoveArea(range.Id)">
+                            <i class="fal fa-trash"></i>
+                            @T["Remove"]
+                        </div>
+                    </div>
+                </td>
+            </tr>
+}
+    </table>
+    @if (Ranges.Count > 0)
     {
-<tr>
-    <td>@range.From.ToShortDateString()</td>
-    <td>@range.To.ToShortDateString()</td>
-    <td>@(range.VariCompanySuccess ?? 0)</td>
-    <td>
-        <div class="flex">
-            <div>
-                <i class="fal fa-download"></i>
-                @T["Export"]
+        <!--<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 @onclick='() => _nav.NavigateTo($"/goals/overview/{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="() => RemoveArea(range.Id)">
-                    <i class="fal fa-trash"></i>
-                    @T["Remove"]
-                </div>
-        </div>
-    </td>
-</tr>}
-</table>
-                @if (Ranges.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>}
+            <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.CreateDefinitionRangeAside Show="ShowAside" AsideId="AsideId" LoadAreasInView="LoadAreas" CloseAside="CloseAside" />
 
 <BlazorStyled.Styled>
@@ -180,46 +182,57 @@
 </BlazorStyled.Styled>
 
 @code { [Parameter]
-            public string Id { get; set; } = null!;
+    public string Id { get; set; } = null!;
+
+    private List<GlobalDefinitionArea> Ranges { get; set; } = new() { };
 
-            private List<GlobalDefinitionArea> Ranges { 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 Guid AsideId { get; set; } = default(Guid);
 
-            private Guid AsideId { get; set; } = default(Guid);
+    private bool IsEditMode { get; set; } = false;
 
-            private bool ShowAside { get; set; } = false;
+    private bool ShowAside { get; set; } = false;
 
-            private void OpenAside(Guid id) => (AsideId, ShowAside) = (id, true);
+    private void OpenAside(Guid id, bool editMode) => (AsideId, IsEditMode, ShowAside) = (id, editMode, true);
+
+    private void CloseAside() => (AsideId, ShowAside) = (default(Guid), false);
+
+    private async Task LoadAreas()
+    {
+        var response = await _mediator.Send(new GetAllAreas.Query());
 
-            private void CloseAside() => (AsideId, ShowAside) = (default(Guid), false);
+        if (response.IsSuccess)
+        {
+            Ranges = response.Result.list;
+        }
+    }
 
-            private async Task LoadAreas()
-            {
-                var response = await _mediator.Send(new GetAllAreas.Query());
+    private async Task DownloadAreaFile(Guid id)
+    {
+        // Generate a text file
+        byte[] file = System.Text.Encoding.UTF8.GetBytes("Hello world!");
+        //await JSRuntime.InvokeVoidAsync("BlazorDownloadFile", "file.txt", "text/plain", file);
 
-                if (response.IsSuccess)
-                {
-                    Ranges = response.Result.list;
-                }
-            }
+        toastService.ShowError($"NOT IMPLEMENTED (yet) !");
+    }
 
-            private async Task RemoveArea(Guid id)
-            {
-                bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?");
-                if (confirmed)
-                {
-                    var response = await _mediator.Send(new RemoveArea.Command(id));
-                    await LoadAreas();
-                }
-            }
+    private async Task RemoveArea(Guid id)
+    {
+        bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?");
+        if (confirmed)
+        {
+            var response = await _mediator.Send(new RemoveArea.Command(id));
+            await LoadAreas();
+        }
+    }
 
-            protected async override Task OnInitializedAsync()
-            {
-                await base.OnInitializedAsync();
-                await LoadAreas();
-            } }
+    protected async override Task OnInitializedAsync()
+    {
+        await base.OnInitializedAsync();
+        await LoadAreas();
+    } }
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalDefinition.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalDefinition.cs
index 75c3e04..4f9cb69 100644
--- a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalDefinition.cs
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalDefinition.cs
@@ -78,7 +78,7 @@ namespace Leuze.Modules.Goal.Domain.Domains
             this.SupervisorLocked = true;
         }
 
-        public void ResetLocks()
+        public void LocksReset()
         {
             this.OwnerLocked = false;
             this.SupervisorLocked = false;
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalItem.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalItem.cs
index ba0d780..1111bbe 100644
--- a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalItem.cs
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalItem.cs
@@ -80,7 +80,7 @@ namespace Leuze.Modules.Goal.Domain.Domains
             this.SupervisorLocked = true;
         }
 
-        public void ResetLocks()
+        public void LocksReset()
         {
             this.OwnerLocked = false;
             this.SupervisorLocked = false;
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/ICommentRepository.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/ICommentRepository.cs
index 3d9660b..464c725 100644
--- a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/ICommentRepository.cs
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/ICommentRepository.cs
@@ -21,5 +21,7 @@ namespace Leuze.Modules.Goal.Domain.Repositories
         Task<List<Comment>> GetAllAsync();
 
         Task<bool> EditAsync(Guid id, string text);
+        Task<bool> SetPrivate(Guid id);
+        Task<bool> SetPublic(Guid id);
     }
 }
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 0033b9d..34e8532 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
@@ -27,5 +27,9 @@ namespace Leuze.Modules.Goal.Domain.Repositories
         Task<bool> SetFinanceBaseAsync(Guid id, double financeBase);
 
         Task<bool> SetNameAsync(Guid id, string name);
+
+        Task<bool> LockByOwner(Guid id);
+        Task<bool> LockBySupervisor(Guid id);
+        Task<bool> LocksReset(Guid id);
     }
 }
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalItemRepository.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalItemRepository.cs
index 410f5f7..6302073 100644
--- a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalItemRepository.cs
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalItemRepository.cs
@@ -30,6 +30,9 @@ namespace Leuze.Modules.Goal.Domain.Repositories
         Task<bool> SetPercentileFinalAsync(Guid id, double percentile);
 
         Task<bool> SetGoalDefinitionAsync(Guid id, Guid definitionId);
+        Task<bool> LockByOwner(Guid id);
+        Task<bool> LockBySupervisor(Guid id);
+        Task<bool> LocksReset(Guid id);
 
     }
 }
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/CommentRepository.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/CommentRepository.cs
index 150f3f7..c7d0c7a 100644
--- a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/CommentRepository.cs
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/CommentRepository.cs
@@ -60,5 +60,23 @@ namespace Leuze.Modules.Goal.Infrastructure.Persistence.Repositories
             await storageContext.SaveChangesAsync();
             return true;
         }
+
+        public async Task<bool> SetPrivate(Guid id)
+        {
+            Comment item = await dbSet.FindAsync(id);
+            if (item == null) return false;
+            item.SetPrivate();
+            await storageContext.SaveChangesAsync();
+            return true;
+        }
+
+        public async Task<bool> SetPublic(Guid id)
+        {
+            Comment item = await dbSet.FindAsync(id);
+            if (item == null) return false;
+            item.SetPublic();
+            await storageContext.SaveChangesAsync();
+            return true;
+        }
     }
 }
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 dc3eaa9..74010e7 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
@@ -85,5 +85,32 @@ namespace Leuze.Modules.Goal.Infrastructure.Persistence.Repositories
             await storageContext.SaveChangesAsync();
             return true;
         }
+
+        public async Task<bool> LockByOwner(Guid id)
+        {
+            GoalDefinition item = await dbSet.FindAsync(id);
+            if (item == null) return false;
+            item.LockByOwner();
+            await storageContext.SaveChangesAsync();
+            return true;
+        }
+
+        public async Task<bool> LockBySupervisor(Guid id)
+        {
+            GoalDefinition item = await dbSet.FindAsync(id);
+            if (item == null) return false;
+            item.LockBySupervisor();
+            await storageContext.SaveChangesAsync();
+            return true;
+        }
+
+        public async Task<bool> LocksReset(Guid id)
+        {
+            GoalDefinition item = await dbSet.FindAsync(id);
+            if (item == null) return false;
+            item.LocksReset();
+            await storageContext.SaveChangesAsync();
+            return true;
+        }
     }
 }
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalItemRepository.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalItemRepository.cs
index 564af7b..9229868 100644
--- a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalItemRepository.cs
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalItemRepository.cs
@@ -91,5 +91,32 @@ namespace Leuze.Modules.Goal.Infrastructure.Persistence.Repositories
         {
             return false; //TODO: Not needed now, hope not
         }
+
+        public async Task<bool> LockByOwner(Guid id)
+        {
+            GoalItem item = await dbSet.FindAsync(id);
+            if (item == null) return false;
+            item.LockByOwner();
+            await storageContext.SaveChangesAsync();
+            return true;
+        }
+
+        public async Task<bool> LockBySupervisor(Guid id)
+        {
+            GoalItem item = await dbSet.FindAsync(id);
+            if (item == null) return false;
+            item.LockBySupervisor();
+            await storageContext.SaveChangesAsync();
+            return true;
+        }
+
+        public async Task<bool> LocksReset(Guid id)
+        {
+            GoalItem item = await dbSet.FindAsync(id);
+            if (item == null) return false;
+            item.LocksReset();
+            await storageContext.SaveChangesAsync();
+            return true;
+        }
     }
 }
