Revize 08c1fa42
Přidáno uživatelem Milan Hotovec před téměř 4 roky(ů)
src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/CreateDefinitionRangeAside.razor | ||
---|---|---|
4 | 4 |
|
5 | 5 |
<aside class="@_aside review_detail"> |
6 | 6 |
<div class="review_detail_header"> |
7 |
<div>@T["Title"]</div>
|
|
7 |
<div>@((AsideId != default(Guid)) ? T["TitleEdit"] : T["TitleCreate"] )</div>
|
|
8 | 8 |
<div> |
9 | 9 |
<div class="close_button" @onclick="Close"> |
10 | 10 |
<i class="fal fa-times"></i> |
src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/Components/CreateGoalDefinition.razor | ||
---|---|---|
1 |
@inject IStringLocalizer<CreateGoalDefinition> T |
|
1 |
@inject IMediator _mediator |
|
2 |
@inject IToastService toastService |
|
3 |
@inject IStringLocalizer<CreateGoalDefinition> T |
|
2 | 4 |
<aside class="@_aside review_detail"> |
3 | 5 |
<div class="review_detail_header"> |
4 | 6 |
<div>@T["Title"]</div> |
... | ... | |
11 | 13 |
<div class="review_detail_body"> |
12 | 14 |
<div class="input_row"> |
13 | 15 |
<label class="input_label">@T["Name"]</label> |
14 |
<input type="number" />
|
|
16 |
<input type="text" @bind-value="Name" />
|
|
15 | 17 |
</div> |
16 | 18 |
<div class="input_row"> |
17 | 19 |
<label class="input_label">@T["User"]</label> |
18 |
<select> |
|
19 |
<option value="" disabled>@T["SelectUser"]</option> |
|
20 |
<select asp-for="SelectedUser"> |
|
21 |
@foreach (var user in UnassignedUsers) |
|
22 |
{ |
|
23 |
//<option value="" disabled>@T["SelectUser"]</option> |
|
24 |
<option value="@user.Id">@user.Name</option> |
|
25 |
} |
|
20 | 26 |
</select> |
21 | 27 |
</div> |
22 | 28 |
<div class="input_row"> |
23 | 29 |
<label class="input_label">@T["Hours"]</label> |
24 |
<input type="number" /> |
|
30 |
<input type="number" @bind-value="Hours" />
|
|
25 | 31 |
</div> |
26 | 32 |
<div class="input_row"> |
27 | 33 |
<label class="input_label">@T["Finance"]</label> |
28 |
<input type="number" /> |
|
34 |
<input type="number" @bind-value="FinanceBase"/>
|
|
29 | 35 |
</div> |
30 | 36 |
</div> |
31 | 37 |
<div class="review_detail_footer"> |
32 |
<button>@T["Create"]</button> |
|
38 |
<button @onclick="Create">@T["Create"]</button>
|
|
33 | 39 |
<button @onclick="Close">@T["Cancel"]</button> |
34 | 40 |
</div> |
35 | 41 |
</aside> |
... | ... | |
163 | 169 |
|
164 | 170 |
private string _aside; |
165 | 171 |
|
172 |
private Guid _asideId = default(Guid); |
|
173 |
|
|
174 |
[Parameter] |
|
175 |
public Guid AsideId |
|
176 |
{ |
|
177 |
get { return _asideId; } |
|
178 |
set |
|
179 |
{ |
|
180 |
_asideId = value; |
|
181 |
InitAside(); |
|
182 |
} |
|
183 |
} |
|
184 |
|
|
166 | 185 |
[Parameter] |
167 | 186 |
public bool Show { get; set; } = false; |
168 | 187 |
|
188 |
[Parameter] |
|
189 |
public GlobalDefinitionArea Area { get; set; } = GlobalDefinitionArea.Default(); |
|
190 |
|
|
169 | 191 |
[Parameter] |
170 | 192 |
public EventCallback CloseAside { get; set; } |
171 | 193 |
|
194 |
private string Name { get; set; } = $""; |
|
195 |
private List<UserShortDto> UnassignedUsers { get; set; } = new(); |
|
196 |
public Guid SelectedUser { get; set; } = default(Guid); |
|
197 |
private double Hours { get; set; } = 0; |
|
198 |
private double FinanceBase { get; set; } = 0; |
|
199 |
|
|
200 |
private async Task InitAside() |
|
201 |
{ |
|
202 |
var response = await _mediator.Send(new GetAreaById.Query(AsideId)); |
|
203 |
|
|
204 |
if (response.IsSuccess) |
|
205 |
{ |
|
206 |
//toastService.ShowSuccess("Oblast úspěšně vytvořena"); |
|
207 |
Area = response.Result.area; |
|
208 |
} |
|
209 |
else toastService.ShowError($"Oblast se nepodařilo načíst {response.Errors.FirstOrDefault() ?? ""}"); |
|
210 |
|
|
211 |
var response2 = await _mediator.Send(new GetAllUnassignedInArea.Query(AsideId)); |
|
212 |
|
|
213 |
if (response2.IsSuccess) |
|
214 |
{ |
|
215 |
//toastService.ShowSuccess("Oblast úspěšně vytvořena"); |
|
216 |
UnassignedUsers = response2.Result.list; |
|
217 |
} |
|
218 |
else toastService.ShowError($"Seznam nepřiřazených uživatelů se nepodařilo načíst {response2.Errors.FirstOrDefault() ?? ""}"); |
|
219 |
} |
|
220 |
|
|
221 |
private async Task Create() |
|
222 |
{ |
|
223 |
toastService.ShowError($"Selected: {SelectedUser}"); |
|
224 |
} |
|
225 |
|
|
172 | 226 |
private async Task Close() |
173 | 227 |
{ |
174 | 228 |
//ResetValues(); |
src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalRanges.razor | ||
---|---|---|
194 | 194 |
|
195 | 195 |
private Guid AsideId { get; set; } = default(Guid); |
196 | 196 |
|
197 |
private bool IsEditMode { get; set; } = false; |
|
198 | 197 |
|
199 | 198 |
private bool ShowAside { get; set; } = false; |
200 | 199 |
|
201 |
private void OpenAside(Guid id, bool editMode) => (AsideId, IsEditMode, ShowAside) = (id, editMode, true);
|
|
200 |
private void OpenAside(Guid id) => (AsideId, ShowAside) = (id, true);
|
|
202 | 201 |
|
203 | 202 |
private void CloseAside() => (AsideId, ShowAside) = (default(Guid), false); |
204 | 203 |
|
src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalsManagement.razor | ||
---|---|---|
4 | 4 |
@inject IMediator _mediator |
5 | 5 |
@inject NavigationManager _nav |
6 | 6 |
@inject IJSRuntime JsRuntime |
7 |
@inject IToastService toastService |
|
7 | 8 |
@inject IStringLocalizer<GoalsManagement> T |
8 | 9 |
|
9 | 10 |
<div class="section_header"> |
10 | 11 |
<h2>@T["Title"]</h2> |
11 | 12 |
<div class="header_buttons"> |
12 |
<button type="button"> |
|
13 |
<button type="button" @onclick="InitAllDefinitions">
|
|
13 | 14 |
<i class="fal fa-layer-plus"></i> |
14 | 15 |
<span>@T["InitAll"]</span> |
15 | 16 |
</button> |
... | ... | |
24 | 25 |
</div> |
25 | 26 |
@if (Definitions is not null) |
26 | 27 |
{ |
27 |
<table class="actions" style="width:100%"> |
|
28 |
<tr> |
|
29 |
<th>@T["Name"]</th> |
|
30 |
<th>@T["User"]</th> |
|
31 |
<th>@T["CreatedBy"]</th> |
|
32 |
<th>@T["Actions"]</th> |
|
33 |
</tr> |
|
34 |
@foreach (var range in Definitions) |
|
28 |
<table class="actions" style="width:100%"> |
|
29 |
<tr> |
|
30 |
<th>@T["Name"]</th> |
|
31 |
<th>@T["User"]</th> |
|
32 |
<th>@T["CreatedBy"]</th> |
|
33 |
<th>@T["Actions"]</th> |
|
34 |
</tr> |
|
35 |
@foreach (var range in Definitions) |
|
36 |
{ |
|
37 |
<tr> |
|
38 |
<td>@range.Name</td> |
|
39 |
<td>@range.Owner.Name</td> |
|
40 |
<td>@range.Creator.Name</td> |
|
41 |
<td> |
|
42 |
<div class="flex"> |
|
43 |
<AuthorizeView Roles="TL"> |
|
44 |
<div @onclick='() => _nav.NavigateTo($"/goals/detail/{range.Id}")'> |
|
45 |
<i class="fal fa-eye"></i> |
|
46 |
@T["Open"] |
|
47 |
</div> |
|
48 |
<div @onclick="() => OpenAside(range.Id)"> |
|
49 |
<i class="fal fa-edit"></i> |
|
50 |
@T["Edit"] |
|
51 |
</div> |
|
52 |
<div @onclick="() => RemoveDefinition(range.Id)"> |
|
53 |
<i class="fal fa-trash"></i> |
|
54 |
@T["Remove"] |
|
55 |
</div> |
|
56 |
</AuthorizeView> |
|
57 |
</div> |
|
58 |
</td> |
|
59 |
</tr> |
|
60 |
} |
|
61 |
</table> |
|
62 |
@if (Definitions.Count > 0) |
|
35 | 63 |
{ |
36 |
<tr> |
|
37 |
<td>@range.Name</td> |
|
38 |
<td>@range.Owner.Name</td> |
|
39 |
<td>@range.Creator.Name</td> |
|
40 |
<td> |
|
41 |
<div class="flex"> |
|
42 |
<AuthorizeView Roles="TL"> |
|
43 |
<div @onclick='() => _nav.NavigateTo($"/goals/detail/{range.Id}")'> |
|
44 |
<i class="fal fa-eye"></i> |
|
45 |
@T["Open"] |
|
46 |
</div> |
|
47 |
<div @onclick="() => OpenAside(range.Id)"> |
|
48 |
<i class="fal fa-edit"></i> |
|
49 |
@T["Edit"] |
|
50 |
</div> |
|
51 |
<div @onclick="() => RemoveDefinition(range.Id)"> |
|
52 |
<i class="fal fa-trash"></i> |
|
53 |
@T["Remove"] |
|
54 |
</div> |
|
55 |
</AuthorizeView> |
|
56 |
</div> |
|
57 |
</td> |
|
58 |
</tr>} |
|
59 |
</table> |
|
60 |
@if (Definitions.Count > 0) |
|
61 |
{ |
|
62 |
<!--<div class="pagination"> |
|
63 |
<div class="left"> |
|
64 |
<button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-left.svg" /></button> |
|
65 |
<button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-left.svg" /></button> |
|
66 |
<input type="number" @bind-value="PageNumber" /> |
|
67 |
<button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-right.svg" /></button> |
|
68 |
<button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-right.svg" /></button> |
|
69 |
</div> |
|
70 |
<div class="right">@T["Show"] <b>@Ranges.Count @T["From"] @Total</b></div> |
|
71 |
</div>-->} } |
|
72 |
else |
|
73 |
{ |
|
74 |
<div>Loading...</div>} |
|
75 |
<Leuze.Modules.Goal.Application.UI.Pages.Components.CreateGoalDefinition Show="ShowAside" CloseAside="CloseAside" /> |
|
64 |
<!--<div class="pagination"> |
|
65 |
<div class="left"> |
|
66 |
<button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-left.svg" /></button> |
|
67 |
<button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-left.svg" /></button> |
|
68 |
<input type="number" @bind-value="PageNumber" /> |
|
69 |
<button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-right.svg" /></button> |
|
70 |
<button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-right.svg" /></button> |
|
71 |
</div> |
|
72 |
<div class="right">@T["Show"] <b>@Ranges.Count @T["From"] @Total</b></div> |
|
73 |
</div>-->} } |
|
74 |
else |
|
75 |
{ |
|
76 |
<div>Loading...</div>} |
|
77 |
<Leuze.Modules.Goal.Application.UI.Pages.Components.CreateGoalDefinition Show="ShowAside" AsideId="Id" CloseAside="CloseAside" /> |
|
76 | 78 |
|
77 | 79 |
<BlazorStyled.Styled> |
78 | 80 |
.section_header { |
... | ... | |
194 | 196 |
</BlazorStyled.Styled> |
195 | 197 |
|
196 | 198 |
@code { [Parameter] |
197 |
public Guid Id { get; set; } = default(Guid);
|
|
199 |
public Guid Id { get; set; } = default(Guid); |
|
198 | 200 |
|
199 |
private List<GoalDefinition> Definitions { get; set; } = new();
|
|
201 |
private List<GoalDefinition> Definitions { get; set; } = new(); |
|
200 | 202 |
|
201 |
private int PageNumber { get; set; } = 1;
|
|
203 |
private int PageNumber { get; set; } = 1; |
|
202 | 204 |
|
203 |
private int PageSize { get; set; } = 12;
|
|
205 |
private int PageSize { get; set; } = 12; |
|
204 | 206 |
|
205 |
private int Total { get; set; } = 0;
|
|
207 |
private int Total { get; set; } = 0; |
|
206 | 208 |
|
207 |
private bool ShowAside { get; set; } = false;
|
|
209 |
private bool ShowAside { get; set; } = false; |
|
208 | 210 |
|
209 |
private void OpenAside(Guid id) => (ShowAside) = (true);
|
|
211 |
private void OpenAside(Guid id) => (ShowAside) = (true); |
|
210 | 212 |
|
211 |
private void CloseAside() => (ShowAside) = (false);
|
|
213 |
private void CloseAside() => (ShowAside) = (false); |
|
212 | 214 |
|
213 |
private async Task GetMyDefinitions() |
|
214 |
{ |
|
215 |
var response = await _mediator.Send(new GetAllForArea.Query(Id)); |
|
215 |
private async Task GetMyDefinitions() |
|
216 |
{ |
|
217 |
var response = await _mediator.Send(new GetAllForArea.Query(Id)); |
|
218 |
|
|
219 |
if (response.IsSuccess) |
|
220 |
{ |
|
221 |
Definitions = response.Result.list; |
|
222 |
} |
|
223 |
} |
|
216 | 224 |
|
217 |
if (response.IsSuccess) |
|
218 |
{ |
|
219 |
Definitions = response.Result.list; |
|
220 |
} |
|
221 |
} |
|
225 |
private async Task InitAllDefinitions() |
|
226 |
{ |
|
227 |
toastService.ShowError($"NOT IMPLEMENTED (yet) !"); |
|
228 |
} |
|
222 | 229 |
|
223 |
private async Task RemoveDefinition(Guid id)
|
|
224 |
{
|
|
225 |
bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?");
|
|
226 |
if (confirmed)
|
|
227 |
{
|
|
228 |
var response = await _mediator.Send(new RemoveDefinition.Command(id));
|
|
229 |
await GetMyDefinitions();
|
|
230 |
}
|
|
231 |
}
|
|
230 |
private async Task RemoveDefinition(Guid id) |
|
231 |
{ |
|
232 |
bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?"); |
|
233 |
if (confirmed) |
|
234 |
{ |
|
235 |
var response = await _mediator.Send(new RemoveDefinition.Command(id)); |
|
236 |
await GetMyDefinitions(); |
|
237 |
} |
|
238 |
} |
|
232 | 239 |
|
233 |
protected async override Task OnInitializedAsync() |
|
234 |
{ |
|
235 |
await base.OnInitializedAsync(); |
|
236 |
await GetMyDefinitions(); |
|
237 |
} } |
|
240 |
protected async override Task OnInitializedAsync() |
|
241 |
{ |
|
242 |
await base.OnInitializedAsync(); |
|
243 |
await GetMyDefinitions(); |
|
244 |
} } |
src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Resources/Pages/Components/CreateDefinitionRangeAside.cs-CZ.resx | ||
---|---|---|
132 | 132 |
<data name="Start" xml:space="preserve"> |
133 | 133 |
<value>Datum začátku oblasti</value> |
134 | 134 |
</data> |
135 |
<data name="Title" xml:space="preserve"> |
|
135 |
<data name="TitleCreate" xml:space="preserve">
|
|
136 | 136 |
<value>Vytvořit oblast definic</value> |
137 | 137 |
</data> |
138 |
<data name="TitleEdit" xml:space="preserve"> |
|
139 |
<value>Editace oblasti definic</value> |
|
140 |
</data> |
|
138 | 141 |
</root> |
src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitionAreas/Commands/EditArea.cs | ||
---|---|---|
45 | 45 |
return RequestResponse<Response>.CreateErrorResponse($"V zadaném rozsahu již existuje oblast!"); |
46 | 46 |
} |
47 | 47 |
|
48 |
await _gdAreaRepo.SetFrom(request.id, item.From);;
|
|
49 |
await _gdAreaRepo.SetTo(request.id, item.To);
|
|
50 |
await _gdAreaRepo.SetVariCompanySuccess(request.id, item.VariCompanySuccess);
|
|
48 |
await _gdAreaRepo.SetFrom(request.id, request.from);;
|
|
49 |
await _gdAreaRepo.SetTo(request.id, request.to);
|
|
50 |
await _gdAreaRepo.SetVariCompanySuccess(request.id, request.variCompany);
|
|
51 | 51 |
|
52 | 52 |
return RequestResponse<Response>.CreateSuccessResponse(new(item)); |
53 | 53 |
} |
src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitions/Queries/GetAllUnassignedInArea.cs | ||
---|---|---|
1 |
using Leuze.Core.Application.CQRS; |
|
2 |
using Leuze.Core.Domain.Domains.Users; |
|
3 |
using Leuze.Core.Domain.Domains.Users.DTOs; |
|
4 |
using Leuze.Core.Domain.Repositories; |
|
5 |
using Leuze.Modules.Goal.Domain.Repositories; |
|
6 |
using Microsoft.AspNetCore.Components.Authorization; |
|
7 |
using System; |
|
8 |
using System.Collections.Generic; |
|
9 |
using System.Linq; |
|
10 |
using System.Security.Claims; |
|
11 |
using System.Text; |
|
12 |
using System.Threading; |
|
13 |
using System.Threading.Tasks; |
|
14 |
|
|
15 |
namespace Leuze.Modules.Goal.Application.CQRS.GoalDefinitions.Queries |
|
16 |
{ |
|
17 |
public static class GetAllUnassignedInArea |
|
18 |
{ |
|
19 |
public record Query(Guid areaId) : IBaseRequest<Response>; |
|
20 |
|
|
21 |
public record Response(List<UserShortDto> list); |
|
22 |
|
|
23 |
|
|
24 |
public class Handler : IBaseRequestHandler<Query, Response> |
|
25 |
{ |
|
26 |
private readonly IGoalDefinitionRepository _goalDefinitionRepo; |
|
27 |
private readonly AuthenticationStateProvider _authenticationStateProvider; |
|
28 |
private readonly IDomainUserRepository _domainUserRepo; |
|
29 |
|
|
30 |
public Handler(IDomainUserRepository domainUserRepo, AuthenticationStateProvider authStateProvider, IGoalDefinitionRepository goalDefinitionRepo) |
|
31 |
{ |
|
32 |
_goalDefinitionRepo = goalDefinitionRepo; |
|
33 |
_domainUserRepo = domainUserRepo; |
|
34 |
_authenticationStateProvider = authStateProvider; |
|
35 |
} |
|
36 |
|
|
37 |
public async Task<RequestResponse<Response>> Handle(Query request, CancellationToken cancellationToken) |
|
38 |
{ |
|
39 |
var state = await _authenticationStateProvider.GetAuthenticationStateAsync(); |
|
40 |
var id = Guid.Parse(state.User!.FindFirst(ClaimTypes.NameIdentifier)!.Value); |
|
41 |
var user = await _domainUserRepo.GetByIdAsync(id); |
|
42 |
|
|
43 |
//var goalDefs = await _goalDefinitionRepo.GetAllForAreaAsync(request.areaId); |
|
44 |
var allUsers = await _domainUserRepo.GetListAsync(id); |
|
45 |
var areaDefs = await _goalDefinitionRepo.GetAllForAreaAsync(request.areaId); |
|
46 |
var assignedList = areaDefs.Select(o => new UserShortDto(o.Owner.UserId, o.Owner.Name.FullName)).ToList(); |
|
47 |
|
|
48 |
|
|
49 |
var unassignedUsers = allUsers.Except(assignedList).ToList(); |
|
50 |
|
|
51 |
/* |
|
52 |
if (goalDefs == null) |
|
53 |
{ |
|
54 |
return RequestResponse<Response>.CreateErrorResponse($"Nelze načíst definice pro oblast: {request.areaId}!"); |
|
55 |
}*/ |
|
56 |
|
|
57 |
return RequestResponse<Response>.CreateSuccessResponse(new(unassignedUsers)); |
|
58 |
} |
|
59 |
} |
|
60 |
} |
|
61 |
} |
src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalDefinitionRepository.cs | ||
---|---|---|
1 | 1 |
using ExtCore.Data.Abstractions; |
2 |
using Leuze.Core.Domain.Domains.Users; |
|
3 |
using Leuze.Core.Domain.Domains.Users.DTOs; |
|
2 | 4 |
using Leuze.Modules.Goal.Domain.Domains; |
3 | 5 |
using System; |
4 | 6 |
using System.Collections.Generic; |
src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/DependencyInjection.cs | ||
---|---|---|
57 | 57 |
|
58 | 58 |
//TODO: This is debug delet this |
59 | 59 |
var user = context.Set<DomainUser>().Where(item => item.EmailAddress.Email == "ma@test.cz").FirstOrDefault(); |
60 |
GoalDefinition gd = new GoalDefinition(user, user, new GlobalDefinitionArea(user, DateTime.Now, DateTime.Now.AddDays(10)) ,"Test Goal definition"); |
|
60 |
GlobalDefinitionArea area = new GlobalDefinitionArea(user, DateTime.Now, DateTime.Now.AddDays(10)); |
|
61 |
context.Add(area); |
|
62 |
GoalDefinition gd = new GoalDefinition(user, user, area, "Test Goal definition"); |
|
61 | 63 |
context.Add(gd); |
62 | 64 |
context.SaveChanges(); |
63 | 65 |
} |
src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs | ||
---|---|---|
1 | 1 |
using AutoMapper; |
2 | 2 |
using ExtCore.Data.Abstractions; |
3 |
using Leuze.Core.Domain.Domains.Users; |
|
4 |
using Leuze.Core.Domain.Domains.Users.DTOs; |
|
3 | 5 |
using Leuze.Core.Infrastructure.Persistence; |
4 | 6 |
using Leuze.Modules.Goal.Domain.Domains; |
5 | 7 |
using Leuze.Modules.Goal.Domain.Repositories; |
Také k dispozici: Unified diff
UnassignedList add