wip 0.5.1

This commit is contained in:
Frede Hundewadt 2022-06-11 19:27:29 +02:00
parent 0009e912ce
commit 427ee9195a
9 changed files with 163 additions and 179 deletions

View file

@ -18,14 +18,7 @@
<PageTitle>Innotec Danmark A/S</PageTitle> <PageTitle>Innotec Danmark A/S</PageTitle>
<div class="row mb-1"> <WorkDateComponent OnChanged="FetchActivities"></WorkDateComponent>
<div class="col-md-4">
<h5>@_workDate.ToLongDateString()</h5>
</div>
<div class="col-md-4">
<input type="date" class="form-control" @bind-Value="_workDate" @bind-Value:event="oninput" @onchange="FetchActivities" />
</div>
</div>
<hr /> <hr />
<h5>Dagens aktivitet</h5> <h5>Dagens aktivitet</h5>

View file

@ -35,50 +35,25 @@ public partial class Home : IDisposable
[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 { get; set; } = new(); private Preferences _prefs { get; set; } = new();
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.RegisterEvent();
Interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
if (string.IsNullOrWhiteSpace(await Storage.GetItemAsStringAsync("_xa").ConfigureAwait(true)))
Navigator.NavigateTo("/login/home");
_prefs = await UserPrefs.GetPreferences(); _prefs = await UserPrefs.GetPreferences();
_workDate = string.IsNullOrWhiteSpace(_prefs.WorkDate) await FetchActivities(_prefs.WorkDate);
? DateTime.Now
: DateTime.Parse(_prefs.WorkDate);
await UserPrefs.SetWorkDate(_workDate);
await FetchActivities();
}
private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
{
StateHasChanged();
} }
private async Task FetchActivities() private async Task FetchActivities(string workDate)
{ {
Activities = new List<ReportActivityDto>(); Activities = new List<ReportActivityDto>();
await UserPrefs.SetWorkDate(_workDate); Activities = await ActivityRepo.GetActivities(workDate);
Activities = await ActivityRepo.GetActivities($"{_workDate:yyyy-MM-dd}");
} }
public void Dispose() public void Dispose()
{ {
Interceptor.DisposeEvent(); Interceptor.DisposeEvent();
//_editContext.OnFieldChanged -= HandleFieldChanged;
//_editContext.OnValidationStateChanged -= ValidationChanged;
} }
} }

View file

@ -0,0 +1,13 @@
@using Blazored.LocalStorage
@using Wonky.Client.Services
<div class="row mb-1">
<div class="col-md-4">
<h5 class="fw-bold">@DateTime.Parse(WorkDate).ToLongDateString()</h5>
</div>
<div class="col-md-4">
<input type="date" class="form-control"
@bind-Value="WorkDate" @bind-Value:event="oninput"
@onchange="OnDateChanged" />
</div>
</div>

View file

@ -0,0 +1,39 @@
using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components;
using Wonky.Client.Services;
namespace Wonky.Client.Components;
public partial class WorkDateComponent : IDisposable
{
[Inject] private ILocalStorageService LocalStorage { get; set; }
[Inject] private UserPreferenceService UserPrefs { get; set; }
[Parameter] public EventCallback<string> OnChanged { get; set; }
private Preferences _prefs = new();
private string WorkDate { get; set; }
protected override async Task OnInitializedAsync()
{
UserPrefs.OnChange += ProfileServiceOnOnChange;
_prefs = await UserPrefs.GetPreferences();
WorkDate = _prefs.WorkDate;
}
private async Task OnDateChanged(ChangeEventArgs e)
{
var val = $"{DateOnly.Parse(e.Value?.ToString()!):yyyy-MM-dd}";
await OnChanged.InvokeAsync(val);
await UserPrefs.SetWorkDate(DateTime.Parse(val));
}
private void ProfileServiceOnOnChange(Preferences newPreferences)
{
_prefs = newPreferences;
StateHasChanged();
}
public void Dispose()
{
UserPrefs.OnChange -= ProfileServiceOnOnChange;
}
}

View file

@ -0,0 +1,3 @@
h5 {
font-variant: small-caps;
}

View file

@ -19,11 +19,11 @@
@using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Adviser")] @attribute [Authorize(Roles = "Adviser")]
@using Wonky.Client.Components @using Wonky.Client.Components
<WorkDateComponent OnChanged="SetWorkDate"></WorkDateComponent>
@if (DraftContext != null) @if (DraftContext != null)
{ {
<EditForm EditContext="DraftContext" OnValidSubmit="CreateActivity"> <EditForm EditContext="DraftContext">
<DataAnnotationsValidator/> <DataAnnotationsValidator/>
<div class="accordion-flush" id="crmActivity"> <div class="accordion-flush" id="crmActivity">
<div class="accordion-item"> <div class="accordion-item">
<h2 class="accordion-header" id="activityHeader"> <h2 class="accordion-header" id="activityHeader">
@ -36,26 +36,13 @@
<div id="activityBody" class="accordion-collapse collapse show" <div id="activityBody" class="accordion-collapse collapse show"
aria-labelledby="activityHeader" data-bs-parent="#crmActivity"> aria-labelledby="activityHeader" data-bs-parent="#crmActivity">
<div class="accordion-body"> <div class="accordion-body">
@*
<div class="row mb-1"> <div class="row mb-1">
<label for="account" class="col-md-2 col-form-label">Konto</label> <label for="activityType" class="col-md-2 col-form-label">Ordre Type</label>
<div class="col-md-4"> <div class="col-md-4">
<InputText id="account" class="form-control" @bind-Value="_poDraft.Account" readonly/> <select id="activityType" class="form-select"
<ValidationMessage For="@(() => _poDraft.Account)"></ValidationMessage> @bind-Value="@_poDraft.ActivityTypeEnum" @bind-Value:event="oninput"
</div> @onchange="CheckActivity">
<label for="salesRep" class="col-md-2 col-form-label">Sælger</label> <option value="" selected disabled>- VALG -</option>
<div class="col-md-4">
<InputText id="salesRep" class="form-control" @bind-Value="_poDraft.SalesRep" readonly/>
<ValidationMessage For="@(() => _poDraft.SalesRep)"></ValidationMessage>
</div>
</div>
*@
<div class="row mb-1">
<label for="activityType" class="col-md-2 col-form-label">Kontakt</label>
<div class="col-md-4">
<select id="activityType" class="form-select" @bind-Value="@_poDraft.ActivityTypeEnum" @bind-Value:event="oninput" @onchange="CheckActivity">
<option value="" selected disabled>"IKKE VALGT"</option>
<option value="onSite">Besøg</option> <option value="onSite">Besøg</option>
<option value="phone">Telefon</option> <option value="phone">Telefon</option>
</select> </select>
@ -63,129 +50,69 @@
</div> </div>
<label for="statusType" class="col-md-2 col-form-label">Status</label> <label for="statusType" class="col-md-2 col-form-label">Status</label>
<div class="col-md-4"> <div class="col-md-4">
<select id="statusType" class="form-select" @bind-Value="@_poDraft.ActivityStatusEnum" @bind-Value:event="oninput" @onchange="CheckStatus"> <select id="statusType" class="form-select"
<option value="" selected disabled>"IKKE VALGT"</option> @bind-Value="@_poDraft.ActivityStatusEnum" @bind-Value:event="oninput"
<option value="noSale">Ingen salg</option> @onchange="CheckStatus">
<option value="noSale" selected>Ingen salg</option>
<option value="order">Bestilling</option> <option value="order">Bestilling</option>
<option value="quote">Tilbud</option> @* <option value="quote">Tilbud</option> *@
</select> </select>
<ValidationMessage For="@(() => _poDraft.ActivityStatusEnum)"></ValidationMessage> <ValidationMessage For="@(() => _poDraft.ActivityStatusEnum)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="row mb-1"> <div class="row mb-1">
<label for="vatNumber" class="col-md-2 col-form-label">Momsnr.</label> <label for="demo" class="col-md-2 col-form-label">Demo</label>
<div class="col-md-4"> <div class="col-md-4">
<InputText id="vatNumber" class="form-control" @bind-Value="_poDraft.VatNumber"/> <InputText id="demo" class="form-control"
<ValidationMessage For="@(() => _poDraft.VatNumber)"></ValidationMessage> @bind-Value="_poDraft.Demo"/>
</div> </div>
<label for="email" class="col-md-2 col-form-label">Epost</label> <label for="email" class="col-md-2 col-form-label">Epost</label>
<div class="col-md-4"> <div class="col-md-4">
<InputText id="email" class="form-control" @bind-Value="_poDraft.EMail"/> <InputText id="email" class="form-control"
@bind-Value="_poDraft.EMail"/>
<ValidationMessage For="@(() => _poDraft.EMail)"></ValidationMessage> <ValidationMessage For="@(() => _poDraft.EMail)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="row mb-1">
<label for="activityDate" class="col-md-2 col-form-label">Dato</label>
<div class="col-md-4">
<InputDate id="activityDate" class="form-control" @bind-Value="@(_draftDate)"/>
</div>
<label for="checkDate" class="col-md-2 form-check-label">Dato?</label>
<div class="col-md-4">
<InputCheckbox id="checkDate" class="form-check-input" @bind-Value="@_poDraft.CheckDate" @onclick="CheckDate"/>
</div>
</div>
<div class="row mb-1">
<label for="demo" class="col-md-2 col-form-label">Demo</label>
<div class="col-md-10">
<InputText id="demo" class="form-control" @bind-Value="_poDraft.Demo"/>
</div>
</div>
<div class="row mb-1"> <div class="row mb-1">
<label for="referenceNumber" class="col-md-2 col-form-label">Rekvisition</label> <label for="referenceNumber" class="col-md-2 col-form-label">Rekvisition</label>
<div class="col-md-10"> <div class="col-md-4">
<InputText id="referenceNumber" class="form-control" @bind-Value="_poDraft.ReferenceNumber"v/> <InputText id="referenceNumber" class="form-control"
@bind-Value="_poDraft.ReferenceNumber"v/>
<ValidationMessage For="@(() => _poDraft.ReferenceNumber)"></ValidationMessage> <ValidationMessage For="@(() => _poDraft.ReferenceNumber)"></ValidationMessage>
</div> </div>
</div>
<div class="row mb-1">
<label for="yourRef" class="col-md-2 col-form-label">Indkøber</label> <label for="yourRef" class="col-md-2 col-form-label">Indkøber</label>
<div class="col-md-10"> <div class="col-md-4">
<InputText id="yourRef" class="form-control" @bind-Value="_poDraft.YourRef"/> <InputText id="yourRef" class="form-control"
@bind-Value="_poDraft.YourRef"/>
<ValidationMessage For="@(() => _poDraft.YourRef)"></ValidationMessage> <ValidationMessage For="@(() => _poDraft.YourRef)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="row mb-1"> <div class="row mb-1">
<label for="orderMessage" class="col-md-2 col-form-label">Note /Kontor</label> <label for="orderMessage" class="col-md-2 col-form-label">Note /Kontor</label>
<div class="col-md-10"> <div class="col-md-4">
<InputText id="orderMessage" class="form-control" @bind-Value="_poDraft.OrderMessage"/> <InputTextArea id="orderMessage" class="form-control"
@bind-Value="_poDraft.OrderMessage"/>
<ValidationMessage For="@(() => _poDraft.OrderMessage)"></ValidationMessage> <ValidationMessage For="@(() => _poDraft.OrderMessage)"></ValidationMessage>
</div> </div>
</div>
<div class="row mb-1">
<label for="crmNote" class="col-md-2 col-form-label">Note /Mig</label> <label for="crmNote" class="col-md-2 col-form-label">Note /Mig</label>
<div class="col-md-10"> <div class="col-md-4">
<InputText id="crmNote" class="form-control" @bind-Value="_poDraft.CrmNote"/> <InputTextArea id="crmNote" class="form-control"
@bind-Value="_poDraft.CrmNote"/>
<ValidationMessage For="@(() => _poDraft.CrmNote)"></ValidationMessage> <ValidationMessage For="@(() => _poDraft.CrmNote)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="row mb-1"> <div class="row mb-1">
<label for="attention" class="col-md-2 col-form-label">Att.</label> <label for="attention" class="col-md-2 col-form-label">Att.</label>
<div class="col-md-10"> <div class="col-md-4">
<InputText id="attention" class="form-control" @bind-Value="_poDraft.Attention"/> <InputText id="attention" class="form-control"
@bind-Value="_poDraft.Attention"/>
<ValidationMessage For="@(() => _poDraft.Attention)"></ValidationMessage> <ValidationMessage For="@(() => _poDraft.Attention)"></ValidationMessage>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@* Leverings adresse *@
<div class="accordion-item" style="@(_poDraft.ActivityStatusEnum == "order" ? "display: block" : "display:none")">
<h2 class="accordion-header" id="deliveryHeader">
<button class="accordion-button collapsed bg-light" type="button"
data-bs-toggle="collapse" data-bs-target="#deliveryBody"
aria-expanded="false" aria-controls="deliveryBody">
Leveringsadresse
</button>
</h2>
<div id="deliveryBody" class="accordion-collapse collapse"
aria-labelledby="deliveryHeader" data-bs-parent="#crmActivity">
<div class="accordion-body">
<div class="row mb-1">
<label for="dlvName" class="col-md-2 col-form-label">Lev. Navn</label>
<div class="col-md-10">
<InputText id="dlvName" class="form-control" @bind-Value="_poDraft.DlvName"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvAddress1" class="col-md-2 col-form-label">Lev. Adresse</label>
<div class="col-md-10">
<InputText id="dlvAddress1" class="form-control" @bind-Value="_poDraft.DlvAddress"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvAddress2" class="col-md-2 col-form-label">Lev. Adresse</label>
<div class="col-md-10">
<InputText id="dlvAddress2" class="form-control" @bind-Value="_poDraft.DlvAddress2"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvZipCode" class="col-md-2 col-form-label">Lev. Postnr</label>
<div class="col-md-10">
<InputText id="dlvZipCode" class="form-control" @bind-Value="_poDraft.DlvZipCode"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvCity" class="col-md-2 col-form-label">Lev. Bynavn</label>
<div class="col-md-10">
<InputText id="dlvCity" class="form-control" @bind-Value="_poDraft.DlvCity"/>
</div>
</div>
</div>
</div>
</div>
@* Order lines *@ @* Order lines *@
<div class="accordion-item" style="@(_poDraft.ActivityStatusEnum is "order" or "quote" ? "display: block" : "display:none")"> <div class="accordion-item" style="@(_poDraft.ActivityStatusEnum is "order" or "quote" ? "display: block" : "display:none")">
<h2 class="accordion-header" id="catalogHeader"> <h2 class="accordion-header" id="catalogHeader">
@ -314,7 +241,7 @@
</div> </div>
</div> </div>
} }
@* Ordrekladde *@ @* Order draft lines *@
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
Kladdelinjer <span class="mx-2 draft-expires-msg">Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet)</span> Kladdelinjer <span class="mx-2 draft-expires-msg">Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet)</span>
@ -365,13 +292,67 @@
<div class="card-footer"> <div class="card-footer">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<button type="button" class="btn btn-danger" @onclick="@DeleteDraft" disabled="@(DraftStateProvider.Draft.Items.Count == 0)">Slet kladde</button> <button type="button" class="btn btn-danger"
@onclick="@DeleteDraft"
disabled="@(DraftStateProvider.Draft.Items.Count == 0)">
Slet kladde
</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@* Delivery address *@
<div class="accordion-item" style="@(_poDraft.ActivityStatusEnum == "order" ? "display: block" : "display:none")">
<h2 class="accordion-header" id="deliveryHeader">
<button class="accordion-button collapsed bg-light" type="button"
data-bs-toggle="collapse" data-bs-target="#deliveryBody"
aria-expanded="false" aria-controls="deliveryBody">
Leveringsadresse
</button>
</h2>
<div id="deliveryBody" class="accordion-collapse collapse"
aria-labelledby="deliveryHeader" data-bs-parent="#crmActivity">
<div class="accordion-body">
<div class="row mb-1">
<label for="dlvName" class="col-md-2 col-form-label">Lev. Navn</label>
<div class="col-md-10">
<InputText id="dlvName" class="form-control"
@bind-Value="_poDraft.DlvName"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvAddress1" class="col-md-2 col-form-label">Lev. Adresse</label>
<div class="col-md-10">
<InputText id="dlvAddress1" class="form-control"
@bind-Value="_poDraft.DlvAddress"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvAddress2" class="col-md-2 col-form-label">Lev. Adresse</label>
<div class="col-md-10">
<InputText id="dlvAddress2" class="form-control"
@bind-Value="_poDraft.DlvAddress2"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvZipCode" class="col-md-2 col-form-label">Lev. Postnr</label>
<div class="col-md-10">
<InputText id="dlvZipCode" class="form-control"
@bind-Value="_poDraft.DlvZipCode"/>
</div>
</div>
<div class="row mb-1">
<label for="dlvCity" class="col-md-2 col-form-label">Lev. Bynavn</label>
<div class="col-md-10">
<InputText id="dlvCity" class="form-control"
@bind-Value="_poDraft.DlvCity"/>
</div>
</div>
</div>
</div>
</div>
</div> </div>
<div class="row mt-2 mb-2"> <div class="row mt-2 mb-2">
<div class="col-md-6"></div> <div class="col-md-6"></div>
@ -380,7 +361,7 @@
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
@* <button type="submit" class="btn btn-success" disabled="@InvalidActivity">Gem</button> *@ @* <button type="submit" class="btn btn-success" disabled="@InvalidActivity">Gem</button> *@
<button type="submit" class="btn btn-success">OK</button> <button type="button" class="btn btn-success" @onclick="CreateActivity">OK</button>
</div> </div>
</div> </div>
</EditForm> </EditForm>

View file

@ -61,23 +61,18 @@ public partial class CrmActivityCreate : IDisposable
private bool InvalidStatusType { get; set; } = true; private bool InvalidStatusType { get; set; } = true;
private bool InvalidActivity { get; set; } = true; private bool InvalidActivity { get; set; } = true;
private bool InvalidCanvas { get; set; } = true; private bool InvalidCanvas { get; set; } = true;
private bool InvalidDate { get; set; } = true;
private UserInfoView Ux { get; set; } = new(); private UserInfoView Ux { get; set; } = new();
private DateTime _draftDate { get; set; }
protected override void OnParametersSet()
{
base.OnParametersSet();
}
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
Interceptor.RegisterEvent(); Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
_prefs = await UserPrefs.GetPreferences(); _prefs = await UserPrefs.GetPreferences();
_paging.SearchColumn = _prefs.ItemSearch;
_paging.SearchColumn = _prefs.ItemSearch ?? "name";
_paging.PageSize = Convert.ToInt32(_prefs.PageSize); _paging.PageSize = Convert.ToInt32(_prefs.PageSize);
await GetSalesItems(); await GetSalesItems();
Ux = await StorageService.GetItemAsync<UserInfoView>("_xu"); Ux = await StorageService.GetItemAsync<UserInfoView>("_xu");
NgCompany = await CompanyRepo.GetCompanyById(CompanyId); NgCompany = await CompanyRepo.GetCompanyById(CompanyId);
@ -85,10 +80,7 @@ public partial class CrmActivityCreate : IDisposable
// set up identification // set up identification
_poDraft.SalesHeadId = ""; _poDraft.SalesHeadId = "";
_poDraft.CompanyId = CompanyId; _poDraft.CompanyId = CompanyId;
_draftDate = string.IsNullOrWhiteSpace(_prefs.WorkDate) _poDraft.ActivityDate = _prefs.WorkDate;
? DateTime.Now
: DateTime.Parse(_prefs.WorkDate);
_poDraft.ActivityDate = $"{_draftDate:yyyy-MM-dd}";
// permanent identifications // permanent identifications
_poDraft.SalesRep = Ux.Adviser; _poDraft.SalesRep = Ux.Adviser;
@ -108,18 +100,21 @@ public partial class CrmActivityCreate : IDisposable
_poDraft.DlvAddress2 = NgCompany.Address2; _poDraft.DlvAddress2 = NgCompany.Address2;
_poDraft.DlvZipCode = NgCompany.ZipCode; _poDraft.DlvZipCode = NgCompany.ZipCode;
_poDraft.DlvCity = NgCompany.City; _poDraft.DlvCity = NgCompany.City;
DraftContext = new EditContext(_poDraft); DraftContext = new EditContext(_poDraft);
DraftContext.OnFieldChanged += HandleFieldChanged; DraftContext.OnFieldChanged += HandleFieldChanged;
DraftContext.OnValidationStateChanged += ValidationChanged; DraftContext.OnValidationStateChanged += ValidationChanged;
} }
private void SetWorkDate(string workDate)
{
_poDraft.ActivityDate = workDate;
}
private async Task CreateActivity() private async Task CreateActivity()
{ {
HideButtons = true; HideButtons = true;
// write work date to preference
await UserPrefs.SetWorkDate(_draftDate);
var activityType = _poDraft.ActivityTypeEnum switch var activityType = _poDraft.ActivityTypeEnum switch
{ {
"phone" => "Tlf", "phone" => "Tlf",
@ -127,7 +122,6 @@ public partial class CrmActivityCreate : IDisposable
_ => "" _ => ""
}; };
_poDraft.OurRef = $"{Ux.FullName.Split(" ")[0]} {activityType}"; _poDraft.OurRef = $"{Ux.FullName.Split(" ")[0]} {activityType}";
_poDraft.ActivityDate = $"{_draftDate:yyyy-MM-dd}";
var ln = 0; var ln = 0;
// post to create activity endpoint // post to create activity endpoint
@ -160,19 +154,10 @@ public partial class CrmActivityCreate : IDisposable
private void CheckActivity() private void CheckActivity()
{ {
InvalidActivityType = string.IsNullOrWhiteSpace(_poDraft.ActivityTypeEnum); InvalidActivityType = string.IsNullOrWhiteSpace(_poDraft.ActivityTypeEnum);
Console.WriteLine($"ActivityType => {InvalidActivityType}");
} }
private void CheckStatus() private void CheckStatus()
{ {
InvalidStatusType = string.IsNullOrWhiteSpace(_poDraft.ActivityStatusEnum); InvalidStatusType = string.IsNullOrWhiteSpace(_poDraft.ActivityStatusEnum);
Console.WriteLine($"StatusType => {InvalidStatusType}");
}
private void CheckDate()
{
_poDraft.ActivityDate = $"{_draftDate:yyyy-MM-dd}";
InvalidDate = _poDraft.CheckDate;
Console.WriteLine($"InvalidDate => {InvalidDate}");
} }
private async Task DeleteDraft() private async Task DeleteDraft()
@ -269,11 +254,10 @@ public partial class CrmActivityCreate : IDisposable
private void HandleFieldChanged(object sender, FieldChangedEventArgs e) private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
{ {
InvalidCanvas = InvalidActivityType || InvalidDate; InvalidCanvas = InvalidActivityType;
InvalidActivity = InvalidActivityType InvalidActivity = InvalidActivityType
|| _poFormInvalid || _poFormInvalid
|| DraftStateProvider.Draft.Items.Count == 0 || DraftStateProvider.Draft.Items.Count == 0
|| InvalidDate
|| (_poDraft.ActivityStatusEnum == "offer" && string.IsNullOrWhiteSpace(_poDraft.EMail)); || (_poDraft.ActivityStatusEnum == "offer" && string.IsNullOrWhiteSpace(_poDraft.EMail));
if (InvalidCanvas || InvalidActivity) if (InvalidCanvas || InvalidActivity)
@ -286,14 +270,11 @@ public partial class CrmActivityCreate : IDisposable
} }
private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) private void ValidationChanged(object sender, ValidationStateChangedEventArgs e)
{ {
if (!string.IsNullOrEmpty(_poDraft.VatNumber))
{
if(!VatUtils.ValidateFormat(NgCompany.CountryCode, _poDraft.VatNumber))
ToastService.ShowWarning("CVR / ORG nummer er ikke et gyldigt registreringsnummer");
}
if (string.IsNullOrEmpty(_poDraft.ActivityTypeEnum)) if (string.IsNullOrEmpty(_poDraft.ActivityTypeEnum))
ToastService.ShowWarning("Aktivitet type kan ikke være tom"); ToastService.ShowWarning("Aktivitet type kan ikke være tom");
_poFormInvalid = false; _poFormInvalid = false;
DraftContext.OnFieldChanged -= HandleFieldChanged; DraftContext.OnFieldChanged -= HandleFieldChanged;
DraftContext = new EditContext(_poDraft); DraftContext = new EditContext(_poDraft);
DraftContext.OnFieldChanged += HandleFieldChanged; DraftContext.OnFieldChanged += HandleFieldChanged;

View file

@ -8,7 +8,7 @@
}, },
"appInfo": { "appInfo": {
"name": "Wonky Client", "name": "Wonky Client",
"version": "0.4.3", "version": "0.5.1",
"isBeta": true, "isBeta": true,
"image": "grumpy-coder.png" "image": "grumpy-coder.png"
}, },

View file

@ -36,7 +36,6 @@ namespace Wonky.Entity.DTO
[Required(ErrorMessage = "Vælg aktivitetstype")] public string ActivityTypeEnum { get; set; } = ""; [Required(ErrorMessage = "Vælg aktivitetstype")] public string ActivityTypeEnum { get; set; } = "";
[Required(ErrorMessage = "Vælg status for besøg ")] public string ActivityStatusEnum { get; set; } = ""; [Required(ErrorMessage = "Vælg status for besøg ")] public string ActivityStatusEnum { get; set; } = "";
public string VisitTypeEnum { get; set; } = "recall"; public string VisitTypeEnum { get; set; } = "recall";
public bool CheckDate { get; set; }
[Required] public string ActivityDate { get; set; } = ""; [Required] public string ActivityDate { get; set; } = "";
[MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string Demo { get; set; } = ""; [MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string Demo { get; set; } = "";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string OurRef { get; set; } = ""; [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string OurRef { get; set; } = "";