wip
This commit is contained in:
parent
11f2440c75
commit
f4ba3ef83b
8 changed files with 140 additions and 82 deletions
|
@ -16,5 +16,4 @@
|
|||
*@
|
||||
|
||||
<input id="search-input" type="text" class="form-control" placeholder="Søg ..."
|
||||
@bind-value="@SearchTerm" @bind-value:event="oninput"
|
||||
@onkeyup="SearchChanged"/>
|
||||
@bind-value="@SearchTerm" @bind-value:event="oninput" @onkeyup="OnSearchChanged"/>
|
|
@ -19,13 +19,22 @@ using Timer = System.Timers.Timer;
|
|||
|
||||
namespace Wonky.Client.Components
|
||||
{
|
||||
public partial class SearchPhrase
|
||||
public partial class SearchComponent
|
||||
{
|
||||
private Timer _timer = new();
|
||||
private string SearchTerm { get; set; } = "";
|
||||
[Parameter] public EventCallback<string> OnChanged { get; set; }
|
||||
private string? SearchTerm { get; set; }
|
||||
[Parameter] public EventCallback<string?> OnChanged { get; set; }
|
||||
[Parameter] public string? SavedSearch { get; set; }
|
||||
|
||||
private void SearchChanged()
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(SavedSearch)) return;
|
||||
SearchTerm = SavedSearch;
|
||||
OnChanged.InvokeAsync(SearchTerm);
|
||||
//SearchChanged();
|
||||
}
|
||||
|
||||
private void OnSearchChanged()
|
||||
{
|
||||
_timer = new Timer(500);
|
||||
_timer.Elapsed += OnTimerElapsed;
|
|
@ -19,7 +19,15 @@
|
|||
@using Microsoft.AspNetCore.Authorization
|
||||
@attribute [Authorize(Roles = "Adviser")]
|
||||
@using Wonky.Client.Components
|
||||
<WorkDateComponent OnChanged="SetWorkDate"></WorkDateComponent>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h5 style="font-variant: small-caps">@_workDate.ToLongDateString()</h5>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<WorkDateComponent OnChanged="SetWorkDate"></WorkDateComponent>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (DraftContext != null)
|
||||
{
|
||||
<EditForm EditContext="DraftContext">
|
||||
|
@ -42,7 +50,7 @@
|
|||
<select id="activityType" class="form-select"
|
||||
@bind-Value="@_poDraft.ActivityTypeEnum" @bind-Value:event="oninput"
|
||||
@onchange="CheckActivity">
|
||||
<option value="" selected disabled>- VALG -</option>
|
||||
<option value="">ORDRE TYPE</option>
|
||||
<option value="onSite">Besøg</option>
|
||||
<option value="phone">Telefon</option>
|
||||
</select>
|
||||
|
@ -51,13 +59,11 @@
|
|||
<label for="statusType" class="col-md-2 col-form-label">Status</label>
|
||||
<div class="col-md-4">
|
||||
<select id="statusType" class="form-select"
|
||||
@bind-Value="@_poDraft.ActivityStatusEnum" @bind-Value:event="oninput"
|
||||
@onchange="CheckStatus">
|
||||
@bind-Value="@_poDraft.ActivityStatusEnum" @bind-Value:event="oninput">
|
||||
<option value="noSale" selected>Ingen salg</option>
|
||||
<option value="order">Bestilling</option>
|
||||
@* <option value="quote">Tilbud</option> *@
|
||||
<option value="quote">Tilbud</option>
|
||||
</select>
|
||||
<ValidationMessage For="@(() => _poDraft.ActivityStatusEnum)"></ValidationMessage>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -133,7 +139,7 @@
|
|||
<ItemSearchDropdown OnChanged="SetSearchCol"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<SearchPhrase OnChanged="SetSearchPhrase"/>
|
||||
<SearchComponent OnChanged="SetSearchPhrase"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<ItemSortDropdown OnChanged="SetSortCol"/>
|
||||
|
|
|
@ -67,6 +67,7 @@ public partial class CrmActivityCreate : IDisposable
|
|||
private bool InvalidActivity { get; set; } = true;
|
||||
private bool InvalidCanvas { get; set; } = true;
|
||||
private UserInfoView Ux { get; set; } = new();
|
||||
private DateTime _workDate { get; set; } = DateTime.Now;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
@ -75,6 +76,11 @@ public partial class CrmActivityCreate : IDisposable
|
|||
|
||||
_prefs = await UserPrefs.GetPreferences();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_prefs.WorkDate))
|
||||
_workDate = DateTime.Parse(_prefs.WorkDate);
|
||||
|
||||
_poDraft.ActivityDate = $"{_workDate:yyyy-MM-dd}" ;
|
||||
|
||||
_paging.SearchColumn = _prefs.ItemSearch ?? "name";
|
||||
_paging.PageSize = Convert.ToInt32(_prefs.PageSize);
|
||||
|
||||
|
@ -87,7 +93,7 @@ public partial class CrmActivityCreate : IDisposable
|
|||
_poDraft.CompanyId = NgCompany.CompanyId;
|
||||
_poDraft.BcId = NgCompany.BcId;
|
||||
_poDraft.SalesRepId = Ux.Id;
|
||||
_poDraft.ActivityDate = _prefs.WorkDate;
|
||||
|
||||
_poDraft.ActivityStatusEnum = "noSale";
|
||||
_poDraft.VisitTypeEnum = NgCompany.Account is "" or "NY" ? "new" : "recall";
|
||||
|
||||
|
@ -119,7 +125,7 @@ public partial class CrmActivityCreate : IDisposable
|
|||
|
||||
private void SetWorkDate(string workDate)
|
||||
{
|
||||
_logger.LogInformation("WorkDateComponent.OnChanged() => {workDate}", workDate);
|
||||
_logger.LogInformation("WorkDateComponent.OnChanged(SetWorkDate(workDate)) => {workDate}", workDate);
|
||||
_poDraft.ActivityDate = workDate;
|
||||
}
|
||||
|
||||
|
@ -127,6 +133,7 @@ public partial class CrmActivityCreate : IDisposable
|
|||
{
|
||||
HideButtons = true;
|
||||
_poDraft.ActivityDate = _prefs.WorkDate;
|
||||
|
||||
var activityType = _poDraft.ActivityTypeEnum switch
|
||||
{
|
||||
"phone" => "T",
|
||||
|
@ -165,11 +172,6 @@ public partial class CrmActivityCreate : IDisposable
|
|||
{
|
||||
InvalidActivityType = string.IsNullOrWhiteSpace(_poDraft.ActivityTypeEnum);
|
||||
}
|
||||
private void CheckStatus()
|
||||
{
|
||||
InvalidStatusType = string.IsNullOrWhiteSpace(_poDraft.ActivityStatusEnum);
|
||||
}
|
||||
|
||||
private async Task DeleteDraft()
|
||||
{
|
||||
await DraftStateProvider.DeleteDraftAsync();
|
||||
|
@ -264,17 +266,18 @@ public partial class CrmActivityCreate : IDisposable
|
|||
|
||||
private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
|
||||
{
|
||||
InvalidCanvas = InvalidActivityType;
|
||||
InvalidActivity = InvalidActivityType
|
||||
|| _poFormInvalid
|
||||
|| DraftStateProvider.Draft.Items.Count == 0
|
||||
|| (_poDraft.ActivityStatusEnum == "offer" && string.IsNullOrWhiteSpace(_poDraft.EMail));
|
||||
// InvalidCanvas = InvalidActivityType;
|
||||
// InvalidActivity = InvalidActivityType
|
||||
// || _poFormInvalid
|
||||
// || DraftStateProvider.Draft.Items.Count == 0
|
||||
// || (_poDraft.ActivityStatusEnum == "offer" && string.IsNullOrWhiteSpace(_poDraft.EMail));
|
||||
|
||||
// if (InvalidCanvas || InvalidActivity)
|
||||
// {
|
||||
// _poFormInvalid = true;
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (InvalidCanvas || InvalidActivity)
|
||||
{
|
||||
_poFormInvalid = true;
|
||||
return;
|
||||
}
|
||||
_poFormInvalid = !DraftContext.Validate();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
|
|
@ -20,10 +20,6 @@
|
|||
|
||||
@page "/sales-report"
|
||||
|
||||
<div>workDate: @_workDate</div>
|
||||
<div>checkIn: @_reportDto.CheckIn</div>
|
||||
<div>checkOut: @_reportDto.CheckOut</div>
|
||||
|
||||
<EditForm EditContext="_editContext">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
|
@ -67,11 +63,11 @@
|
|||
{
|
||||
<td>
|
||||
<InputDate class="form-control"
|
||||
@bind-Value="_leaveBegin" @bind-Value:event="oninput" @onchange="OnLeaveChanged"/>
|
||||
@bind-Value="_leaveBegin" @bind-Value:event="oninput" @onchange="OnLeaveChanged"/>
|
||||
</td>
|
||||
<td>
|
||||
<InputDate class="form-control"
|
||||
@bind-Value="_leaveEnd" @bind-Value:event="oninput" @onchange="OnLeaveChanged"/>
|
||||
@bind-Value="_leaveEnd" @bind-Value:event="oninput" @onchange="OnLeaveChanged"/>
|
||||
</td>
|
||||
}
|
||||
else
|
||||
|
@ -118,18 +114,18 @@
|
|||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<InputNumber class="form-control" @bind-Value="_reportDto.Figures.KmMorning"/>
|
||||
<InputNumber class="form-control" @bind-Value="_reportDto.Figures.KmMorning" disabled="@_noFigures" />
|
||||
<ValidationMessage For="@(() => _reportDto.Figures.KmMorning)" />
|
||||
</td>
|
||||
<td>
|
||||
<InputNumber class="form-control" @bind-Value="_reportDto.Figures.KmEvening"/>
|
||||
<InputNumber class="form-control" @bind-Value="_reportDto.Figures.KmEvening" disabled="@_noFigures" />
|
||||
<ValidationMessage For="@(() => _reportDto.Figures.KmEvening)" />
|
||||
</td>
|
||||
<td>
|
||||
<InputNumber class="form-control" @bind-Value="_reportDto.Figures.Distance" readonly=""/>
|
||||
<InputNumber class="form-control" @bind-Value="_reportDto.Figures.Distance" readonly="" />
|
||||
</td>
|
||||
<td>
|
||||
<InputNumber class="form-control" @bind-Value="_reportDto.Figures.DistancePrivate"/>
|
||||
<InputNumber class="form-control" @bind-Value="_reportDto.Figures.DistancePrivate" disabled="@_noFigures"/>
|
||||
<ValidationMessage For="@(() => _reportDto.Figures.DistancePrivate)" />
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -138,32 +134,77 @@
|
|||
|
||||
@if (_reportInit.Activities != null)
|
||||
{
|
||||
<div class="card-list">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Besøg</th>
|
||||
<th scope="col">Demo</th>
|
||||
<th scope="col">Salg</th>
|
||||
<th scope="col">Beløb</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var activity in _reportInit.Activities)
|
||||
{
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
@activity.Company.Name - @activity.Company.ZipCity
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@activity.Demo
|
||||
</div>
|
||||
<div class="col">
|
||||
@activity.SalesResume
|
||||
</div>
|
||||
<div class="col">
|
||||
@activity.OrderAmount
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<tr>
|
||||
<td>@activity.Company.Name - @activity.Company.ZipCity</td>
|
||||
<td>@activity.Demo</td>
|
||||
<td>@activity.SalesResume</td>
|
||||
<td>@activity.OrderAmount</td>
|
||||
</tr>
|
||||
}
|
||||
</div>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Total</td>
|
||||
<td>@_reportDto.Figures.TotalTurnover</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th colspan="2" scope="col">Demo @(_reportDto.Figures.NewDemoCount + _reportDto.Figures.RecallDemoCount)</th>
|
||||
<th colspan="2" scope="col">Resultat</th>
|
||||
<th colspan="4" scope="col">Resultat Måned</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>*</td>
|
||||
<th scope="col">Besøg</th>
|
||||
<th scope="col">Demo</th>
|
||||
<th scope="col">Salg</th>
|
||||
<th scope="col">Beløb</th>
|
||||
<th scope="col">Besøg</th>
|
||||
<th scope="col">Demo</th>
|
||||
<th scope="col">Salg</th>
|
||||
<th scope="col">Beløb</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"></th>
|
||||
<td>@_reportDto.Figures.NewVisitCount</td>
|
||||
<td>@_reportDto.Figures.NewDemoCount</td>
|
||||
<td>@_reportDto.Figures.NewSaleCount</td>
|
||||
<td>@_reportDto.Figures.NewTurnover</td>
|
||||
<td>@_reportDto.Figures.NewVisitCountMonth</td>
|
||||
<td>@_reportDto.Figures.NewDemoCountMonth</td>
|
||||
<td>@_reportDto.Figures.NewSaleCountMonth</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
|
||||
<div>workDate: @_workDate</div>
|
||||
<div>tsIn: @_timestampIn</div>
|
||||
<div>tsOut: @_timestampOut</div>
|
||||
<div>checkIn: @_reportDto.CheckIn</div>
|
||||
<div>checkOut: @_reportDto.CheckOut</div>
|
||||
<div>leaveBegin: @_leaveBegin</div>
|
||||
<div>leaveEnd: @_leaveEnd</div>
|
||||
|
|
|
@ -36,6 +36,7 @@ public partial class SalesReport
|
|||
private NgSalesReportInitDto _reportInit { get; set; } = new();
|
||||
private Preferences _prefs { get; set; } = new();
|
||||
private bool _formInvalid = true;
|
||||
private bool _noFigures = true;
|
||||
private DateTime _workDate { get; set; } = DateTime.Now;
|
||||
private TimeOnly _timestampIn { get; set; } = new(12, 0);
|
||||
private TimeOnly _timestampOut { get; set; } = new(12, 0);
|
||||
|
@ -53,6 +54,8 @@ public partial class SalesReport
|
|||
if (!string.IsNullOrWhiteSpace(_prefs.WorkDate))
|
||||
_workDate = DateTime.Parse(_prefs.WorkDate);
|
||||
_leaveBegin = DateOnly.FromDateTime(_workDate);
|
||||
_reportDto.CheckIn = _workDate.AddHours(12);
|
||||
_reportDto.CheckOut = _workDate.AddHours(12);
|
||||
|
||||
}
|
||||
|
||||
|
@ -106,6 +109,7 @@ public partial class SalesReport
|
|||
|
||||
private async Task GetActivities()
|
||||
{
|
||||
_noFigures = false;
|
||||
_prefs = await UserPrefs.GetPreferences();
|
||||
_reportInit = await ReportRepo.FetchReportInit(_prefs.WorkDate);
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ public record Preferences
|
|||
public string? CompanySort { get; set; } = "name";
|
||||
public string? ItemSearch { get; set; } = "name";
|
||||
public string? ItemSort { get; set; } = "name";
|
||||
public string? CompanyFilterPhrase { get; set; } = "";
|
||||
public string PageSize { get; set; } = "10";
|
||||
public string WorkDate { get; set; } = "";
|
||||
}
|
||||
|
@ -20,6 +21,17 @@ public class UserPreferenceService
|
|||
_localStorageService = localStorageService;
|
||||
}
|
||||
|
||||
public async Task SetCompanyFilterPhrase(string filterPhrase)
|
||||
{
|
||||
var preferences = await GetPreferences();
|
||||
var newPreferences = preferences
|
||||
with
|
||||
{
|
||||
CompanyFilterPhrase = filterPhrase
|
||||
};
|
||||
await _localStorageService.SetItemAsync("preferences", newPreferences);
|
||||
OnChange?.Invoke(newPreferences);
|
||||
}
|
||||
public async Task SetWorkDate(DateTime workDate)
|
||||
{
|
||||
var preferences = await GetPreferences();
|
||||
|
@ -28,9 +40,7 @@ public class UserPreferenceService
|
|||
{
|
||||
WorkDate = $"{workDate:yyyy-MM-dd}"
|
||||
};
|
||||
|
||||
await _localStorageService.SetItemAsync("preferences", newPreferences);
|
||||
|
||||
OnChange?.Invoke(newPreferences);
|
||||
}
|
||||
public async Task SetCompanySearch(string companySearch)
|
||||
|
@ -38,56 +48,42 @@ public class UserPreferenceService
|
|||
var preferences = await GetPreferences();
|
||||
var newPreferences = preferences
|
||||
with { CompanySearch = companySearch };
|
||||
|
||||
await _localStorageService.SetItemAsync("preferences", newPreferences);
|
||||
|
||||
OnChange?.Invoke(newPreferences);
|
||||
}
|
||||
|
||||
public async Task SetCompanySort(string companySort)
|
||||
{
|
||||
var preferences = await GetPreferences();
|
||||
|
||||
var newPreferences = preferences
|
||||
with { CompanySort = companySort };
|
||||
|
||||
await _localStorageService.SetItemAsync("preferences", newPreferences);
|
||||
|
||||
OnChange?.Invoke(newPreferences);
|
||||
}
|
||||
|
||||
public async Task SetItemSearch(string itemSearch)
|
||||
{
|
||||
var preferences = await GetPreferences();
|
||||
|
||||
var newPreferences = preferences
|
||||
with { ItemSearch = itemSearch };
|
||||
|
||||
await _localStorageService.SetItemAsync("preferences", newPreferences);
|
||||
|
||||
OnChange?.Invoke(newPreferences);
|
||||
}
|
||||
|
||||
public async Task SetItemSort(string itemSort)
|
||||
{
|
||||
var preferences = await GetPreferences();
|
||||
|
||||
var newPreferences = preferences
|
||||
with { ItemSort = itemSort };
|
||||
|
||||
await _localStorageService.SetItemAsync("preferences", newPreferences);
|
||||
|
||||
OnChange?.Invoke(newPreferences);
|
||||
}
|
||||
public async Task SetPageSize(string pageSize)
|
||||
{
|
||||
var preferences = await GetPreferences();
|
||||
|
||||
var newPreferences = preferences
|
||||
with { PageSize = pageSize };
|
||||
|
||||
await _localStorageService.SetItemAsync("preferences", newPreferences);
|
||||
|
||||
OnChange?.Invoke(newPreferences);
|
||||
}
|
||||
public async Task<Preferences> GetPreferences()
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "None",
|
||||
"System": "Debug",
|
||||
"System": "Information",
|
||||
"Microsoft": "Information"
|
||||
},
|
||||
"Debug": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug"
|
||||
"Default": "Information"
|
||||
}
|
||||
},
|
||||
"ActivityHttpRepository": {
|
||||
|
@ -18,7 +18,7 @@
|
|||
},
|
||||
"appInfo": {
|
||||
"name": "Wonky Client",
|
||||
"version": "0.6.1",
|
||||
"version": "0.6.2",
|
||||
"isBeta": true,
|
||||
"image": "grumpy-coder.png"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue