From f4ba3ef83b630290f027d7e582e95937e96a971a Mon Sep 17 00:00:00 2001 From: Frede Hundewadt <22748698+fhdk@users.noreply.github.com> Date: Mon, 13 Jun 2022 10:52:14 +0200 Subject: [PATCH] wip --- ...archPhrase.razor => SearchComponent.razor} | 3 +- ...rase.razor.cs => SearchComponent.razor.cs} | 17 ++- Wonky.Client/Pages/CrmActivityCreate.razor | 20 ++-- Wonky.Client/Pages/CrmActivityCreate.razor.cs | 37 +++--- Wonky.Client/Pages/SalesReport.razor | 105 ++++++++++++------ Wonky.Client/Pages/SalesReport.razor.cs | 6 +- .../Services/UserPreferenceService.cs | 28 ++--- Wonky.Client/wwwroot/appsettings.json | 6 +- 8 files changed, 140 insertions(+), 82 deletions(-) rename Wonky.Client/Components/{SearchPhrase.razor => SearchComponent.razor} (90%) rename Wonky.Client/Components/{SearchPhrase.razor.cs => SearchComponent.razor.cs} (72%) diff --git a/Wonky.Client/Components/SearchPhrase.razor b/Wonky.Client/Components/SearchComponent.razor similarity index 90% rename from Wonky.Client/Components/SearchPhrase.razor rename to Wonky.Client/Components/SearchComponent.razor index 4c4419e5..9a96f9e8 100644 --- a/Wonky.Client/Components/SearchPhrase.razor +++ b/Wonky.Client/Components/SearchComponent.razor @@ -16,5 +16,4 @@ *@ + @bind-value="@SearchTerm" @bind-value:event="oninput" @onkeyup="OnSearchChanged"/> diff --git a/Wonky.Client/Components/SearchPhrase.razor.cs b/Wonky.Client/Components/SearchComponent.razor.cs similarity index 72% rename from Wonky.Client/Components/SearchPhrase.razor.cs rename to Wonky.Client/Components/SearchComponent.razor.cs index bdfb82f3..e40cc465 100644 --- a/Wonky.Client/Components/SearchPhrase.razor.cs +++ b/Wonky.Client/Components/SearchComponent.razor.cs @@ -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 OnChanged { get; set; } + private string? SearchTerm { get; set; } + [Parameter] public EventCallback 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; diff --git a/Wonky.Client/Pages/CrmActivityCreate.razor b/Wonky.Client/Pages/CrmActivityCreate.razor index 97444f7f..141c81ad 100644 --- a/Wonky.Client/Pages/CrmActivityCreate.razor +++ b/Wonky.Client/Pages/CrmActivityCreate.razor @@ -19,7 +19,15 @@ @using Microsoft.AspNetCore.Authorization @attribute [Authorize(Roles = "Adviser")] @using Wonky.Client.Components - +
+
+
@_workDate.ToLongDateString()
+
+
+ +
+
+ @if (DraftContext != null) { @@ -42,7 +50,7 @@ @@ -51,13 +59,11 @@
-
@@ -133,7 +139,7 @@
- +
diff --git a/Wonky.Client/Pages/CrmActivityCreate.razor.cs b/Wonky.Client/Pages/CrmActivityCreate.razor.cs index 3896677e..5a8e3f68 100644 --- a/Wonky.Client/Pages/CrmActivityCreate.razor.cs +++ b/Wonky.Client/Pages/CrmActivityCreate.razor.cs @@ -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(); } diff --git a/Wonky.Client/Pages/SalesReport.razor b/Wonky.Client/Pages/SalesReport.razor index 897ac654..96bb320c 100644 --- a/Wonky.Client/Pages/SalesReport.razor +++ b/Wonky.Client/Pages/SalesReport.razor @@ -20,10 +20,6 @@ @page "/sales-report" -
workDate: @_workDate
-
checkIn: @_reportDto.CheckIn
-
checkOut: @_reportDto.CheckOut
-
@@ -67,11 +63,11 @@ { + @bind-Value="_leaveBegin" @bind-Value:event="oninput" @onchange="OnLeaveChanged"/> + @bind-Value="_leaveEnd" @bind-Value:event="oninput" @onchange="OnLeaveChanged"/> } else @@ -118,18 +114,18 @@ - + - + - + - + @@ -138,32 +134,77 @@ @if (_reportInit.Activities != null) { -
+ + + + + + + + + + @foreach (var activity in _reportInit.Activities) { -
-
- @activity.Company.Name - @activity.Company.ZipCity -
-
-
-
- @activity.Demo -
-
- @activity.SalesResume -
-
- @activity.OrderAmount -
-
- -
-
+ + + + + + } - + + + + + + + +
BesøgDemoSalgBeløb
@activity.Company.Name - @activity.Company.ZipCity@activity.Demo@activity.SalesResume@activity.OrderAmount
Total@_reportDto.Figures.TotalTurnover
} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Demo @(_reportDto.Figures.NewDemoCount + _reportDto.Figures.RecallDemoCount)ResultatResultat Måned
*BesøgDemoSalgBeløbBesøgDemoSalgBeløb
@_reportDto.Figures.NewVisitCount@_reportDto.Figures.NewDemoCount@_reportDto.Figures.NewSaleCount@_reportDto.Figures.NewTurnover@_reportDto.Figures.NewVisitCountMonth@_reportDto.Figures.NewDemoCountMonth@_reportDto.Figures.NewSaleCountMonth
}
- \ No newline at end of file + + +
workDate: @_workDate
+
tsIn: @_timestampIn
+
tsOut: @_timestampOut
+
checkIn: @_reportDto.CheckIn
+
checkOut: @_reportDto.CheckOut
+
leaveBegin: @_leaveBegin
+
leaveEnd: @_leaveEnd
diff --git a/Wonky.Client/Pages/SalesReport.razor.cs b/Wonky.Client/Pages/SalesReport.razor.cs index 34cdc8eb..57df31fe 100644 --- a/Wonky.Client/Pages/SalesReport.razor.cs +++ b/Wonky.Client/Pages/SalesReport.razor.cs @@ -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,7 +54,9 @@ 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); + } private void HandleFieldChanged(object sender, FieldChangedEventArgs e) @@ -106,6 +109,7 @@ public partial class SalesReport private async Task GetActivities() { + _noFigures = false; _prefs = await UserPrefs.GetPreferences(); _reportInit = await ReportRepo.FetchReportInit(_prefs.WorkDate); diff --git a/Wonky.Client/Services/UserPreferenceService.cs b/Wonky.Client/Services/UserPreferenceService.cs index cfffcbf2..a2e45032 100644 --- a/Wonky.Client/Services/UserPreferenceService.cs +++ b/Wonky.Client/Services/UserPreferenceService.cs @@ -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 GetPreferences() diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 3ba65e7a..bb7b61f0 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -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" },