WIP: v.127 KRV functionality
This commit is contained in:
parent
a4d245f7a7
commit
98110da4ca
11 changed files with 566 additions and 0 deletions
28
Wonky.Client/HttpRepository/IWorkplaceHttpRepository.cs
Normal file
28
Wonky.Client/HttpRepository/IWorkplaceHttpRepository.cs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
|
||||||
|
using Wonky.Entity.DTO;
|
||||||
|
using Wonky.Entity.Views;
|
||||||
|
|
||||||
|
namespace Wonky.Client.HttpRepository;
|
||||||
|
|
||||||
|
public interface IWorkplaceHttpRepository
|
||||||
|
{
|
||||||
|
Task<List<WorkplaceListView>> GetWorkplaces(string companyId);
|
||||||
|
Task<WorkplaceDto> GetWorkplace(string companyId, string workplaceId);
|
||||||
|
Task CreateWorkplace(string companyId, WorkplaceDto workplace);
|
||||||
|
Task UpdateWorkplace(string companyId, WorkplaceDto workplace);
|
||||||
|
Task DeleteWorkplace(string companyId, string workplaceId);
|
||||||
|
}
|
80
Wonky.Client/HttpRepository/WorkplaceHttpRepository.cs
Normal file
80
Wonky.Client/HttpRepository/WorkplaceHttpRepository.cs
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
|
||||||
|
using System.Net.Http.Json;
|
||||||
|
using System.Text.Json;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Wonky.Entity.Configuration;
|
||||||
|
using Wonky.Entity.DTO;
|
||||||
|
using Wonky.Entity.Views;
|
||||||
|
|
||||||
|
namespace Wonky.Client.HttpRepository;
|
||||||
|
|
||||||
|
public class WorkplaceHttpRepository : IWorkplaceHttpRepository
|
||||||
|
{
|
||||||
|
private readonly JsonSerializerOptions? _options = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly NavigationManager _navigation;
|
||||||
|
private ILogger<WorkplaceHttpRepository> _logger;
|
||||||
|
private readonly HttpClient _client;
|
||||||
|
private readonly ApiConfig _api;
|
||||||
|
|
||||||
|
public WorkplaceHttpRepository(HttpClient client,
|
||||||
|
ILogger<WorkplaceHttpRepository> logger,
|
||||||
|
NavigationManager navigation,
|
||||||
|
IOptions<ApiConfig> configuration)
|
||||||
|
{
|
||||||
|
_client = client;
|
||||||
|
_logger = logger;
|
||||||
|
_navigation = navigation;
|
||||||
|
_api = configuration.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<WorkplaceListView>> GetWorkplaces(string companyId)
|
||||||
|
{
|
||||||
|
var result = await _client.GetFromJsonAsync<List<WorkplaceListView>>(
|
||||||
|
$"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}", _options);
|
||||||
|
return result ?? new List<WorkplaceListView>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<WorkplaceDto> GetWorkplace(string companyId, string workplaceId)
|
||||||
|
{
|
||||||
|
var result = await _client.GetFromJsonAsync<WorkplaceDto>(
|
||||||
|
$"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}/{workplaceId}", _options);
|
||||||
|
return result ?? new WorkplaceDto();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task CreateWorkplace(string companyId, WorkplaceDto workplace)
|
||||||
|
{
|
||||||
|
await _client.PostAsJsonAsync(
|
||||||
|
$"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}", workplace, _options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateWorkplace(string companyId, WorkplaceDto workplace)
|
||||||
|
{
|
||||||
|
await _client.PutAsJsonAsync(
|
||||||
|
$"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}/{workplace.WorkplaceId}", workplace, _options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteWorkplace(string companyId, string workplaceId)
|
||||||
|
{
|
||||||
|
await _client.DeleteAsync(
|
||||||
|
$"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}/{workplaceId}");
|
||||||
|
}
|
||||||
|
}
|
68
Wonky.Client/Pages/KrvItemViewPage.razor
Normal file
68
Wonky.Client/Pages/KrvItemViewPage.razor
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
@*
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
*@
|
||||||
|
|
||||||
|
@page "/krv/{CountryCode}/items/{salesItemId}"
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@attribute [Authorize(Roles = "Advisor,Advisor")]
|
||||||
|
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h1>@_item.Name</h1>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<table class="table table-striped table-bordered">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Navn</th>
|
||||||
|
<td>@_item.Name</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Varenr</th>
|
||||||
|
<td>@_item.Sku</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row"></th>
|
||||||
|
<td>@_item.ProductGroup</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Kort Navn</th>
|
||||||
|
<td>@_item.ShortName</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="table table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col" rowspan="2">Priser</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var rate in _item.Rates)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<th scope="row">@rate.Quantity</th>
|
||||||
|
<td>@rate.Rate</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer">
|
||||||
|
<a href="/krvVariants" class="btn btn-success">Tilbage</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
53
Wonky.Client/Pages/KrvItemViewPage.razor.cs
Normal file
53
Wonky.Client/Pages/KrvItemViewPage.razor.cs
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
|
||||||
|
using Wonky.Client.HttpInterceptors;
|
||||||
|
using Wonky.Client.HttpRepository;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Wonky.Entity.Views;
|
||||||
|
|
||||||
|
#pragma warning disable CS8618
|
||||||
|
namespace Wonky.Client.Pages;
|
||||||
|
|
||||||
|
public partial class KrvItemViewPage : IDisposable
|
||||||
|
{
|
||||||
|
// ##################################################################
|
||||||
|
[Inject] private ICountryCatalogRepository _itemRepo { get; set; }
|
||||||
|
[Inject] private HttpInterceptorService _interceptor { get; set; }
|
||||||
|
|
||||||
|
// ##################################################################
|
||||||
|
[Parameter] public string SalesItemId { get; set; } = "";
|
||||||
|
[Parameter] public string CountryCode { get; set; } = "";
|
||||||
|
|
||||||
|
// ##################################################################
|
||||||
|
private SalesItemView _item { get; set; } = new ();
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_interceptor.RegisterEvent();
|
||||||
|
_interceptor.RegisterBeforeSendEvent();
|
||||||
|
_item = await _itemRepo.GetSalesItemId(CountryCode, SalesItemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_interceptor!.DisposeEvent();
|
||||||
|
}
|
||||||
|
}
|
10
Wonky.Client/Pages/KrvItemViewPage.razor.css
Normal file
10
Wonky.Client/Pages/KrvItemViewPage.razor.css
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/* item image preview */
|
||||||
|
.image-name {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
.image-preview {
|
||||||
|
width: auto;
|
||||||
|
max-width: 200px;
|
||||||
|
height: 100px;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
6
Wonky.Client/Pages/WorkplaceDocumentListPage.razor
Normal file
6
Wonky.Client/Pages/WorkplaceDocumentListPage.razor
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@using Wonky.Client.Components
|
||||||
|
@attribute [Authorize(Roles = "Advisor")]
|
||||||
|
@page "/advisor/customers//{CompanyId}/workplaces/{WorkplaceId}/documents"
|
||||||
|
|
||||||
|
<h2>Dokumenter</h2>
|
35
Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs
Normal file
35
Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Wonky.Client.HttpInterceptors;
|
||||||
|
using Wonky.Client.HttpRepository;
|
||||||
|
using Wonky.Entity.DTO;
|
||||||
|
|
||||||
|
#pragma warning disable CS8618
|
||||||
|
|
||||||
|
namespace Wonky.Client.Pages;
|
||||||
|
|
||||||
|
public partial class WorkplaceDocumentListPage : IDisposable
|
||||||
|
{
|
||||||
|
// ##############################################################
|
||||||
|
[Inject] private HttpInterceptorService Interceptor { get; set; }
|
||||||
|
[Inject] private IWorkplaceHttpRepository WorkplaceRepo { get; set; }
|
||||||
|
|
||||||
|
// ##############################################################
|
||||||
|
[Parameter] public string CompanyId { get; set; } = "";
|
||||||
|
[Parameter] public string WorkplaceId { get; set; } = "";
|
||||||
|
|
||||||
|
// ##############################################################
|
||||||
|
private WorkplaceDto Workplace { get; set; } = new();
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
Interceptor.RegisterEvent();
|
||||||
|
Interceptor.RegisterBeforeSendEvent();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Interceptor.DisposeEvent();
|
||||||
|
}
|
||||||
|
}
|
30
Wonky.Client/Pages/WorkplaceListPage.razor
Normal file
30
Wonky.Client/Pages/WorkplaceListPage.razor
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
@*
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
*@
|
||||||
|
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@using Wonky.Client.Components
|
||||||
|
@attribute [Authorize(Roles = "Advisor")]
|
||||||
|
@page "/advisor/customers/{CompanyId}/workplaces"
|
||||||
|
|
||||||
|
<div class="row bg-light border border-1 rounded-2">
|
||||||
|
<div class="col">
|
||||||
|
<h2>@Customer.Name</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<WorkplaceListComponent CompanyId="@CompanyId" Workplaces="@Workplaces" />
|
||||||
|
</div>
|
60
Wonky.Client/Pages/WorkplaceListPage.razor.cs
Normal file
60
Wonky.Client/Pages/WorkplaceListPage.razor.cs
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Wonky.Client.HttpInterceptors;
|
||||||
|
using Wonky.Client.HttpRepository;
|
||||||
|
using Wonky.Entity.DTO;
|
||||||
|
using Wonky.Entity.Views;
|
||||||
|
|
||||||
|
#pragma warning disable CS8618
|
||||||
|
namespace Wonky.Client.Pages;
|
||||||
|
|
||||||
|
public partial class WorkplaceListPage : IDisposable
|
||||||
|
{
|
||||||
|
// ##############################################################
|
||||||
|
[Inject] private IWorkplaceHttpRepository WorkplaceRepo { get; set; }
|
||||||
|
[Inject] private IAdvisorCustomerRepository CustomerRepo { get; set; }
|
||||||
|
[Inject] private HttpInterceptorService Interceptor { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
// ##############################################################
|
||||||
|
[Parameter] public string CompanyId { get; set; } = "";
|
||||||
|
|
||||||
|
// ##############################################################
|
||||||
|
private List<WorkplaceListView> Workplaces { get; set; } = new();
|
||||||
|
private CompanyDto Customer { get; set; } = new();
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
Interceptor.RegisterEvent();
|
||||||
|
Interceptor.RegisterBeforeSendEvent();
|
||||||
|
Customer = await CustomerRepo.GetCompanyById(CompanyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
Workplaces = await WorkplaceRepo.GetWorkplaces(CompanyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Interceptor.DisposeEvent();
|
||||||
|
}
|
||||||
|
}
|
121
Wonky.Client/Pages/WorkplaceViewPage.razor
Normal file
121
Wonky.Client/Pages/WorkplaceViewPage.razor
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
@*
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
*@
|
||||||
|
|
||||||
|
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@attribute [Authorize(Roles = "Advisor")]
|
||||||
|
@page "/advisor/customers/{CompanyId}/workplaces/{WorkplaceId}"
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="card-title">
|
||||||
|
<h2>@Workplace.CompanyName</h2>
|
||||||
|
<h3>@Workplace.Name @(!string.IsNullOrWhiteSpace(Workplace.Description) ? $"- {Workplace.Description}" : "")</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<EditForm EditContext="WorkplaceContext" OnValidSubmit="SubmitUpdate">
|
||||||
|
<DataAnnotationsValidator/>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="4">
|
||||||
|
Stamdata
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="align-middle">Navn</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<InputText id="name" class="form-control" @bind-Value="Workplace.Name"/>
|
||||||
|
<ValidationMessage For="@(() => Workplace.Name)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
<td class="align-middle">Beskrivelse</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<InputText id="description" class="form-control" @bind-Value="Workplace.Description"/>
|
||||||
|
<ValidationMessage For="@(() => Workplace.Description)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="align-middle text-center" colspan="4">Placering og Opbevaring</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="align-middle">Produkter</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<InputText id="productStorage" class="form-control" @bind-Value="Workplace.ProductStorage"/>
|
||||||
|
<ValidationMessage For="@(() => Workplace.ProductStorage)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
<td class="align-middle" colspan="2"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="align-middle">Masker</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<InputText id="maskStorage" class="form-control" @bind-Value="Workplace.MaskStorage"/>
|
||||||
|
<ValidationMessage For="@(() => Workplace.MaskStorage)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
<td class="align-middle">Øjenskylleflaske</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<InputText id="eyeCleanerLocation" class="form-control" @bind-Value="Workplace.EyeCleanerLocation"/>
|
||||||
|
<ValidationMessage For="@(() => Workplace.EyeCleanerLocation)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="align-middle">Handsker</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<InputText id="glovesStorage" class="form-control" @bind-Value="Workplace.GlovesStorage"/>
|
||||||
|
<ValidationMessage For="@(() => Workplace.GlovesStorage)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
<td class="align-middle">Førstehjælp</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<InputText id="firstAidStorage" class="form-control" @bind-Value="Workplace.FirstAidStorage"/>
|
||||||
|
<ValidationMessage For="@(() => Workplace.FirstAidStorage)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="align-middle">Sikkerhedsbriller</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<InputText id="gogglesStorage" class="form-control" @bind-Value="Workplace.GogglesStorage"/>
|
||||||
|
<ValidationMessage For="@(() => Workplace.GogglesStorage)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
<td class="align-middle" colspan="2"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="align-middle">Affald</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<InputText id="masteDeposit" class="form-control" @bind-Value="Workplace.WasteDeposit"/>
|
||||||
|
<ValidationMessage For="@(() => Workplace.WasteDeposit)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
<td class="align-middle" colspan="2"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<button type="button" class="btn btn-danger" @onclick="DeleteWorkplace">Slet</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<button type="submit" class="btn btn-success">Gem</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<a class="btn btn-primary" href="/companies/@CompanyId/workplaces/@WorkplaceId/documents">Dokumenter</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</EditForm>
|
||||||
|
</div>
|
||||||
|
</div>
|
75
Wonky.Client/Pages/WorkplaceViewPage.razor.cs
Normal file
75
Wonky.Client/Pages/WorkplaceViewPage.razor.cs
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
|
using Wonky.Client.HttpInterceptors;
|
||||||
|
using Wonky.Client.HttpRepository;
|
||||||
|
using Wonky.Entity.DTO;
|
||||||
|
|
||||||
|
#pragma warning disable CS8618
|
||||||
|
|
||||||
|
namespace Wonky.Client.Pages;
|
||||||
|
|
||||||
|
public partial class WorkplaceViewPage : IDisposable
|
||||||
|
{
|
||||||
|
// ##############################################################33333
|
||||||
|
[Inject] private IWorkplaceHttpRepository WorkplaceRepo { get; set; }
|
||||||
|
[Inject] private IAdvisorCustomerRepository CustomerRepo { get; set; }
|
||||||
|
[Inject] private HttpInterceptorService Interceptor { get; set; }
|
||||||
|
[Inject] private NavigationManager Navigator { get; set; }
|
||||||
|
|
||||||
|
// ##############################################################33333
|
||||||
|
[Parameter] public string CompanyId { get; set; } = "";
|
||||||
|
[Parameter] public string WorkplaceId { get; set; } = "";
|
||||||
|
|
||||||
|
// ##############################################################33333
|
||||||
|
private WorkplaceDto Workplace { get; set; } = new();
|
||||||
|
private EditContext WorkplaceContext { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
Interceptor.RegisterEvent();
|
||||||
|
Interceptor.RegisterBeforeSendEvent();
|
||||||
|
Workplace = await WorkplaceRepo.GetWorkplace(CompanyId, WorkplaceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
WorkplaceContext = new EditContext(Workplace);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task SubmitUpdate()
|
||||||
|
{
|
||||||
|
await WorkplaceRepo.UpdateWorkplace(CompanyId, Workplace);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task DeleteWorkplace()
|
||||||
|
{
|
||||||
|
await WorkplaceRepo.DeleteWorkplace(CompanyId, Workplace.WorkplaceId);
|
||||||
|
Navigator.NavigateTo($"/companies/{CompanyId}/workplaces");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Interceptor.DisposeEvent();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue