wip - home change date
This commit is contained in:
parent
5fd50be7b1
commit
0009e912ce
3 changed files with 94 additions and 68 deletions
|
@ -16,46 +16,48 @@
|
||||||
//
|
//
|
||||||
*@
|
*@
|
||||||
|
|
||||||
@attribute [Authorize]
|
|
||||||
|
|
||||||
<PageTitle>Innotec Danmark A/S</PageTitle>
|
<PageTitle>Innotec Danmark A/S</PageTitle>
|
||||||
|
|
||||||
<AuthorizeView>
|
<div class="row mb-1">
|
||||||
<Authorized>
|
<div class="col-md-4">
|
||||||
<h5>@_workDate</h5>
|
<h5>@_workDate.ToLongDateString()</h5>
|
||||||
<hr />
|
</div>
|
||||||
<h5>Dagens aktivitet</h5>
|
<div class="col-md-4">
|
||||||
<table class="table">
|
<input type="date" class="form-control" @bind-Value="_workDate" @bind-Value:event="oninput" @onchange="FetchActivities" />
|
||||||
<thead>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
<h5>Dagens aktivitet</h5>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Kunde</th>
|
||||||
|
<th scope="col">Demo</th>
|
||||||
|
<th scope="col">Salg</th>
|
||||||
|
<th scope="col">Sum</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@if (Activities != null)
|
||||||
|
{
|
||||||
|
foreach (var activity in Activities)
|
||||||
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Kunde</th>
|
<td>
|
||||||
<th scope="col">Demo</th>
|
@activity.Company.Name
|
||||||
<th scope="col">Salg</th>
|
</td>
|
||||||
<th scope="col">Sum</th>
|
<td>
|
||||||
</tr>
|
@activity.Demo
|
||||||
</thead>
|
</td>
|
||||||
<tbody>
|
<td>
|
||||||
@if (Activities != null)
|
@activity.SalesResume
|
||||||
{
|
</td>
|
||||||
foreach (var activity in Activities)
|
<td>
|
||||||
{
|
@activity.OrderAmount
|
||||||
<tr>
|
</td>
|
||||||
<td>
|
</tr>
|
||||||
@activity.ReportVisitDto.Name
|
}
|
||||||
</td>
|
}
|
||||||
<td>
|
</tbody>
|
||||||
@activity.Demo
|
</table>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@activity.SalesResume
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@activity.OrderAmount
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</Authorized>
|
|
||||||
</AuthorizeView>
|
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
|
|
||||||
using Blazored.LocalStorage;
|
using Blazored.LocalStorage;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
using Microsoft.VisualBasic;
|
using Microsoft.VisualBasic;
|
||||||
|
using Wonky.Client.HttpInterceptors;
|
||||||
using Wonky.Client.HttpRepository;
|
using Wonky.Client.HttpRepository;
|
||||||
using Wonky.Client.Services;
|
using Wonky.Client.Services;
|
||||||
using Wonky.Client.Shared;
|
using Wonky.Client.Shared;
|
||||||
|
@ -24,33 +26,59 @@ using Wonky.Entity.DTO;
|
||||||
using Wonky.Entity.Models;
|
using Wonky.Entity.Models;
|
||||||
|
|
||||||
namespace Wonky.Client.Components;
|
namespace Wonky.Client.Components;
|
||||||
public partial class Home
|
public partial class Home : IDisposable
|
||||||
{
|
{
|
||||||
[Inject] public ILocalStorageService Storage { get; set; }
|
[Inject] public ILocalStorageService Storage { get; set; }
|
||||||
[Inject] public ILogger<Home> Logger { get; set; }
|
[Inject] public ILogger<Home> Logger { get; set; }
|
||||||
[Inject] public UserPreferenceService Prefernces { get; set; }
|
[Inject] private HttpInterceptorService Interceptor { get; set; }
|
||||||
|
[Inject] public UserPreferenceService UserPrefs { get; set; }
|
||||||
[Inject] public NavigationManager Navigator { get; set; }
|
[Inject] public NavigationManager Navigator { get; set; }
|
||||||
[Inject] public IActivityHttpRepository ActivityRepo { get; set; }
|
[Inject] public IActivityHttpRepository ActivityRepo { get; set; }
|
||||||
private Preferences _prefs = new();
|
private Preferences _prefs { get; set; } = new();
|
||||||
private string _workDate;
|
private DateTime _workDate { get; set; } = new();
|
||||||
private List<ReportActivityDto> Activities { get; set; }
|
private List<ReportActivityDto> Activities { get; set; }
|
||||||
|
//private EditContext _editContext { get; set; }
|
||||||
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
//_editContext = new EditContext(_workDate);
|
||||||
|
//_editContext.OnFieldChanged += HandleFieldChanged;
|
||||||
|
|
||||||
|
Interceptor.RegisterEvent();
|
||||||
|
Interceptor.RegisterBeforeSendEvent();
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(await Storage.GetItemAsStringAsync("_xa").ConfigureAwait(true)))
|
if (string.IsNullOrWhiteSpace(await Storage.GetItemAsStringAsync("_xa").ConfigureAwait(true)))
|
||||||
Navigator.NavigateTo("/login/home");
|
Navigator.NavigateTo("/login/home");
|
||||||
_prefs = await Prefernces.GetPreferences();
|
|
||||||
if (string.IsNullOrWhiteSpace(_prefs.WorkDate))
|
_prefs = await UserPrefs.GetPreferences();
|
||||||
{
|
_workDate = string.IsNullOrWhiteSpace(_prefs.WorkDate)
|
||||||
await Prefernces.SetWorkDate(DateTime.Now);
|
? DateTime.Now
|
||||||
}
|
: DateTime.Parse(_prefs.WorkDate);
|
||||||
|
|
||||||
_workDate = DateTime.Parse(_prefs.WorkDate).ToLongDateString();
|
await UserPrefs.SetWorkDate(_workDate);
|
||||||
|
|
||||||
Activities = await ActivityRepo.GetActivities(_prefs.WorkDate);
|
|
||||||
|
|
||||||
|
|
||||||
|
await FetchActivities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
|
||||||
|
{
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task FetchActivities()
|
||||||
|
{
|
||||||
|
Activities = new List<ReportActivityDto>();
|
||||||
|
await UserPrefs.SetWorkDate(_workDate);
|
||||||
|
Activities = await ActivityRepo.GetActivities($"{_workDate:yyyy-MM-dd}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Interceptor.DisposeEvent();
|
||||||
|
//_editContext.OnFieldChanged -= HandleFieldChanged;
|
||||||
|
//_editContext.OnValidationStateChanged -= ValidationChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,22 +60,18 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row">
|
<div class="form-group row mb-1">
|
||||||
<div class="form-group row mb-1">
|
<label for="supervisedBy" class="col-form-label col-md-2">Supervisor</label>
|
||||||
<label for="supervisedBy" class="col-form-label col-md-2">Supervisor</label>
|
<div class="col-md-4">
|
||||||
<div class="col-md-4">
|
<InputText id="supervisedBy" class="form-control" @bind-Value="_reportDto.SupervisedBy"/>
|
||||||
<InputText id="supervisedBy" class="form-control" @bind-Value="_reportDto.SupervisedBy"/>
|
<ValidationMessage For="@(() => _reportDto.SupervisedBy)"></ValidationMessage>
|
||||||
<ValidationMessage For="@(() => _reportDto.SupervisedBy)"></ValidationMessage>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="form-group row mb-1">
|
||||||
<div class="form-group row mb-1">
|
<label for="description" class="col-form-label col-md-2">Beskrivelse</label>
|
||||||
<label for="description" class="col-form-label col-md-2">Beskrivelse</label>
|
<div class="col-md-4">
|
||||||
<div class="col-md-4">
|
<InputTextArea id="description" class="form-control" @bind-Value="_reportDto.Description"/>
|
||||||
<InputTextArea id="description" class="form-control" @bind-Value="_reportDto.Description"/>
|
<ValidationMessage For="@(() => _reportDto.Description)"></ValidationMessage>
|
||||||
<ValidationMessage For="@(() => _reportDto.Description)"></ValidationMessage>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -124,7 +120,7 @@
|
||||||
{
|
{
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
@activity.ReportVisitDto.Name @activity.ReportVisitDto.ZipCity
|
@activity.Company.Name - @activity.Company.ZipCity
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
Loading…
Reference in a new issue