commit c4ecb32e1fdb6c4f4650bfe1066539a47c89b503
Author: Dominik Chlouba <dchlouba@students.zcu.cz>
Date:   Tue Jun 1 23:11:08 2021 +0200

    Updating and removing comments, button for accepting and declining goals

diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/GoalDetailAside.razor b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/GoalDetailAside.razor
index 8836892..a75f19e 100644
--- a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/GoalDetailAside.razor
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/GoalDetailAside.razor
@@ -1,10 +1,31 @@
 ﻿@inject IMediator _mediator
 @inject IToastService toastService
+@inject AuthenticatedUserProvider _provider
 
 <aside class="@_aside goal_detail">
     <div class="goal_detail_header">
         <div>
-            <button class="authorize_button accepted">Schválit</button>
+            @if (DetailItem.SupervisorLocked && DetailItem.OwnerLocked)
+            {
+                <button class="authorize_button accepted">Schváleno</button>
+            }
+            else if (_provider.RequiredUserId == DetailItem.GoalDefinition.CreatorId && !DetailItem.OwnerLocked)
+            {
+                <button class="authorize_button">Odeslat ke schválení</button>
+            }
+            else if (_provider.RequiredUserId == DetailItem.GoalDefinition.CreatorId && DetailItem.OwnerLocked)
+            {
+                <button class="authorize_button">Čeká na schválení</button>
+            }
+            else if (_provider.RequiredUserId != DetailItem.GoalDefinition.CreatorId && DetailItem.OwnerLocked && !DetailItem.SupervisorLocked)
+            {
+                <button class="authorize_button accepted">Schválit</button>
+                <button class="authorize_button">Zamítnout</button>
+            }
+            else
+            {
+                <button class="authorize_button accepted">Schváleno</button>
+            }
             <div class="review_button accepted" @onclick="() =>SetReviewId(Guid.NewGuid())">
                 1 <i class="fal fa-trophy"></i>
             </div>
@@ -28,7 +49,7 @@
             <div class="goal_description_title">Popis cíle</div>
             <textarea oninput='this.style.height = "";this.style.height = this.scrollHeight + "px"'
                       class="goal_description" placeholder="Vyplňte popis cíle" @bind="Description"></textarea>
-            <button @onclick="EditGoal">Uložit změny</button>
+            <button class="edit_goal_desc" @onclick="EditGoal">Uložit změny</button>
         </div>
         <div class="goal_communication_area">
             @foreach (var comment in Comments)
@@ -36,31 +57,44 @@
                 if (comment.IsSystem)
                 {
                     <div class="goal_communication_item">
-                        System: Uživatel @comment.Creator.Name.FullName @comment.type.GetStringValue() z @comment.OldText na @comment.Text <span class="date">@comment.CreatedAt.ToShortDateString() @comment.CreatedAt.ToShortTimeString()</span>
+                        Uživatel @comment.Creator.Name.FullName @comment.type.GetStringValue() z @comment.OldText na @comment.Text <span class="date">@comment.CreatedAt.ToShortDateString() @comment.CreatedAt.ToShortTimeString()</span>
                     </div>
                 }
                 else
                 {
-                    <div class="goal_communication_item">
-                        <div class="item_tool">
-                            <div>
-                                @comment.Creator.Name.FullName: @comment.Text <span class="date">>@comment.CreatedAt.ToShortDateString() @comment.CreatedAt.ToShortTimeString()</span>
-                            </div>
-                            <div>
-                                <div class="action_buttons" style="display: none">
-                                    <i class="fal fa-edit"></i>
-                                    <i class="fal fa-trash"></i>
-                                </div>
-                                <div class="action_buttons" style="display: block">
-                                    <i class="green fal fa-check"></i>
-                                    <i class="red fal fa-times"></i>
-                                </div>
-                            </div>
+        <div class="goal_communication_item">
+            <div class="item_tool">
+                <div>
+                    @comment.Creator.Name.FullName: @comment.Text <span class="date">>@comment.CreatedAt.ToShortDateString() @comment.CreatedAt.ToShortTimeString()</span>
+                </div>
+                <div>
+                    @if (CommentEditId != comment.Id)
+                    {
+                        <div class="action_buttons">
+                            <span @onclick="() => OpenCommentEdit(comment.Id, comment.Text)"><i class="fal fa-edit"></i></span>
+                            <span @onclick="() => DeleteComment(comment.Id)"><i class="fal fa-trash"></i></span>
                         </div>
-                        <textarea class="comment-textarea noedit"
-                                  oninput='this.style.height = "";this.style.height = this.scrollHeight + "px"'
-                                  placeholder="Upravte komentář"></textarea>
-                    </div>
+                    }
+                    else
+                    {
+                        <div class="action_buttons">
+                            <span @onclick="UpdateComment"><i class="green fal fa-check"></i></span>
+                            <span @onclick="DiscardComment"><i class="red fal fa-times"></i></span>
+                        </div>
+                    }
+                </div>
+            </div>
+            @if (CommentEditId != comment.Id)
+            {
+                <div>@comment.Text</div>
+            }
+            else
+            {
+                <textarea class="comment-textarea noedit"
+                          oninput='this.style.height = "";this.style.height = this.scrollHeight + "px"'
+                          placeholder="Upravte komentář" @bind="CommentEditText"></textarea>
+            }
+        </div>
                 }
             }
         </div>
@@ -82,6 +116,26 @@
     right: @(Show ? "0" : "-615")px;
 </BlazorStyled.Styled>
 <BlazorStyled.Styled>
+    .action_buttons span {
+    cursor: pointer;
+    }
+    .action_buttons span:hover {
+    color:red;
+    }
+    .edit_goal_desc{
+    left: calc(100% - 220px);
+    margin: 0 0 20px 0;
+    width: 200px;
+    background: rgb(227, 6, 19);
+    color: white;
+    font-weight: 500;
+    font-size: 14px;
+    padding: 12px;
+    border: none;
+    border-radius: 4px;
+    position: relative;
+    cursor: pointer;
+    }
     .goal_detail {
     width: 600px;
     height: 100%;
@@ -334,6 +388,9 @@
 
     private string CommentVisibility { get; set; } = "public";
 
+    private Guid CommentEditId { get; set; } = default(Guid);
+
+    private string CommentEditText { get; set; } = "";
 
 
     private Guid _detailId;
@@ -362,6 +419,20 @@
 
     public void CloseReview() => ReviewId = default(Guid);
 
+    public void OpenCommentEdit(Guid id, string text) => (CommentEditId, CommentEditText) = (id, text);
+
+    public void DeleteComment(Guid id)
+    {
+
+    }
+
+    public void UpdateComment()
+    {
+
+    }
+
+    public void DiscardComment() => (CommentEditId, CommentEditText) = (default(Guid), "");
+
     private async Task GetDetails()
     {
         var response = await _mediator.Send(new GetGoalById.Query(DetailId));
@@ -401,8 +472,10 @@
         {
             //toastService.ShowSuccess("Komentář úspěšně přidán");
             await GetDetails(); //Refresh
+            CommentText = "";
+            CommentVisibility = "public";
         }
-        else toastService.ShowError($"Komentář se nepodařil opřidat {response.Errors.FirstOrDefault() ?? ""}");
+        else toastService.ShowError($"Komentář se nepodařilo přidat {response.Errors.FirstOrDefault() ?? ""}");
     }
 
     private async Task Close()
diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/_Imports.razor b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/_Imports.razor
index 42383d1..d17b230 100644
--- a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/_Imports.razor
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/_Imports.razor
@@ -35,4 +35,5 @@
 @using Leuze.Modules.Goal.Domain.Domains
 @using Leuze.Modules.Goal.Domain.Domains.DTOs
 @using Microsoft.Extensions.Localization
-@using Microsoft.AspNetCore.Localization
\ No newline at end of file
+@using Microsoft.AspNetCore.Localization
+@using Leuze.Core.Application.Authentication
\ No newline at end of file
