From 4701783329e5f41aaa54c5cef3ad0c678ca4e09f Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Tue, 30 May 2023 15:28:51 +0200 Subject: [PATCH] FIX: dlvAddress block closing when changing input field. FIX: deleteDraft and deleteItem on ActivityCreage page did not trigger correct --- Wonky.Client/Helpers/Utils.cs | 11 +- .../HttpRepository/CrmWorkplaceRepository.cs | 21 ++- .../HttpRepository/ICrmWorkplaceRepository.cs | 18 +- Wonky.Client/Models/DocRevision.cs | 11 ++ Wonky.Client/Models/DocView.cs | 4 + Wonky.Client/Models/WorkplaceDocDto.cs | 33 ---- .../ProductSelectionOverlay.razor | 70 ++++---- .../ProductSelectionOverlay.razor.cs | 59 +++++-- .../Pages/AdvisorActivityCreatePage.razor | 57 +++++- .../Pages/AdvisorActivityCreatePage.razor.cs | 6 + .../AdvisorCustomerWorkplaceNewPage.razor.cs | 2 +- ...AdvisorCustomerWorkplaceRevisionPage.razor | 164 ++++++++--------- ...isorCustomerWorkplaceRevisionPage.razor.cs | 166 ++++++++++++------ ...AdvisorCustomerWorkplaceViewEditPage.razor | 8 +- ...isorCustomerWorkplaceViewEditPage.razor.cs | 35 +++- Wonky.Client/wwwroot/appsettings.json | 2 +- .../{WorkplaceDocumentDto.cs => BucketDto.cs} | 2 +- Wonky.Entity/DTO/UpdateDocHeaderDto.cs | 12 -- Wonky.Entity/Views/BucketResultView.cs | 21 +++ 19 files changed, 432 insertions(+), 270 deletions(-) create mode 100644 Wonky.Client/Models/DocRevision.cs delete mode 100644 Wonky.Client/Models/WorkplaceDocDto.cs rename Wonky.Entity/DTO/{WorkplaceDocumentDto.cs => BucketDto.cs} (97%) delete mode 100644 Wonky.Entity/DTO/UpdateDocHeaderDto.cs create mode 100644 Wonky.Entity/Views/BucketResultView.cs diff --git a/Wonky.Client/Helpers/Utils.cs b/Wonky.Client/Helpers/Utils.cs index b9e33a3e..c6037ddc 100644 --- a/Wonky.Client/Helpers/Utils.cs +++ b/Wonky.Client/Helpers/Utils.cs @@ -27,9 +27,14 @@ namespace Wonky.Client.Helpers; /// public static class Utils { - public static List GenerateRevListView(IEnumerable products) + public static List GenerateVariantListDto(IEnumerable items) { - var result = new List(); + return items.Select(item => new ProductVariant { VariantId = item.VariantId, S5A = item.S5A, S9A = item.S9A }).ToList(); + } + + public static List GenerateRevListView(IEnumerable products) + { + var result = new List(); var docProducts = products.OrderBy(x => x.TradingName).ToList(); @@ -37,7 +42,7 @@ public static class Utils { foreach (var variant in product.Variants) { - var newDoc = new WorkplaceDocItemDto + var newDoc = new DocView { ProductId = product.ProductId, VariantId = variant.VariantId, diff --git a/Wonky.Client/HttpRepository/CrmWorkplaceRepository.cs b/Wonky.Client/HttpRepository/CrmWorkplaceRepository.cs index d08b6be9..94aba345 100644 --- a/Wonky.Client/HttpRepository/CrmWorkplaceRepository.cs +++ b/Wonky.Client/HttpRepository/CrmWorkplaceRepository.cs @@ -86,6 +86,7 @@ public class CrmWorkplaceRepository : ICrmWorkplaceRepository return JsonSerializer.Deserialize(content, _options) ?? new WorkplaceDocInfo(); } + public async Task GetRevisionList(string companyId, string workplaceId) { var result = await _client.GetAsync( @@ -97,8 +98,9 @@ public class CrmWorkplaceRepository : ICrmWorkplaceRepository } return JsonSerializer.Deserialize(content, _options) ?? new WorkplaceDocInfo(); } + - public async Task CreateWorkplace(string companyId, WorkplaceDto workplace) + public async Task PostWorkplace(string companyId, WorkplaceDto workplace) { var result = await _client.PostAsJsonAsync( $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}", workplace, _options); @@ -110,13 +112,26 @@ public class CrmWorkplaceRepository : ICrmWorkplaceRepository return content; } + + public async Task PostWorkplaceDocuments(string companyId, string workplaceId, BucketDto bucketDto) + { + var result = await _client.PostAsJsonAsync( + $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}/{workplaceId}/documents/bop", bucketDto, _options); + var content = await result.Content.ReadAsStringAsync(); + if (!result.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { + return new BucketResultView(); + } + return JsonSerializer.Deserialize(content) ?? new BucketResultView(); + } + - public async Task UpdateWorkplace(string companyId, WorkplaceDto workplace) + public async Task PutWorkplace(string companyId, WorkplaceDto workplace) { await _client.PutAsJsonAsync( $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}/{workplace.WorkplaceId}", workplace, _options); } - + public async Task DeleteWorkplace(string companyId, string workplaceId) { diff --git a/Wonky.Client/HttpRepository/ICrmWorkplaceRepository.cs b/Wonky.Client/HttpRepository/ICrmWorkplaceRepository.cs index 76ef5735..2b5e37bf 100644 --- a/Wonky.Client/HttpRepository/ICrmWorkplaceRepository.cs +++ b/Wonky.Client/HttpRepository/ICrmWorkplaceRepository.cs @@ -21,20 +21,22 @@ namespace Wonky.Client.HttpRepository; public interface ICrmWorkplaceRepository { Task> GetWorkplaces(string companyId); - - + Task GetWorkplace(string companyId, string workplaceId); - Task CreateWorkplace(string companyId, WorkplaceDto workplace); - - Task UpdateWorkplace(string companyId, WorkplaceDto workplace); - - Task DeleteWorkplace(string companyId, string workplaceId); - Task GetDocuments(string companyId, string workplaceId); Task GetRevisionList(string companyId, string workplaceId); + Task PostWorkplace(string companyId, WorkplaceDto workplace); + + Task PostWorkplaceDocuments(string companyId, string workplaceId, BucketDto bucketDto); + + Task PutWorkplace(string companyId, WorkplaceDto workplace); + + Task DeleteWorkplace(string companyId, string workplaceId); + + Task DeleteDocument(string companyId, string workplaceId, string documentId); Task DeleteVariantDocuments(string companyId, string workplaceId, string apbDocumentId, string apvDocumentId); diff --git a/Wonky.Client/Models/DocRevision.cs b/Wonky.Client/Models/DocRevision.cs new file mode 100644 index 00000000..9e83f3b5 --- /dev/null +++ b/Wonky.Client/Models/DocRevision.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace Wonky.Client.Models; + +public class DocRevision +{ + public string ApprovedBy { get; set; } = ""; + public string ApprovedDate { get; set; } = ""; + public string AuthoredBy { get; set; } = ""; + public string FollowupDate { get; set; } = ""; +} \ No newline at end of file diff --git a/Wonky.Client/Models/DocView.cs b/Wonky.Client/Models/DocView.cs index e040a42e..cc44f6d1 100644 --- a/Wonky.Client/Models/DocView.cs +++ b/Wonky.Client/Models/DocView.cs @@ -4,6 +4,7 @@ namespace Wonky.Client.Models; public class DocView { + public bool Added { get; set; } public string ApbDocId { get; set; } = ""; public string ApbDocLink { get; set; } = ""; public string ApvDocId { get; set; } = ""; @@ -12,4 +13,7 @@ public class DocView public string ProductId { get; set; } = ""; public string VariantId { get; set; } = ""; public string VariantName { get; set; } = ""; + public string S5A { get; set; } = ""; + public string S9A { get; set; } = ""; + public bool Selected { get; set; } } \ No newline at end of file diff --git a/Wonky.Client/Models/WorkplaceDocDto.cs b/Wonky.Client/Models/WorkplaceDocDto.cs deleted file mode 100644 index 52b53ec8..00000000 --- a/Wonky.Client/Models/WorkplaceDocDto.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Wonky.Entity.DTO; - -namespace Wonky.Client.Models; - -public class WorkplaceDocDto -{ - [Required] public string EyeCleanerLocation { get; set; } = ""; - [Required]public string FirstAidLocation { get; set; } = ""; - [Required]public string GlovesStorage { get; set; } = ""; - [Required]public string GogglesStorage { get; set; } = ""; - [Required]public string MaskStorage { get; set; } = ""; - [Required]public string ProductStorage { get; set; } = ""; - [Required]public string WasteDeposit { get; set; } = ""; - [Required]public string AuthoredBy { get; set; } = ""; - [Required]public string ApprovedBy { get; set; } = ""; - [Required]public string ApprovedDate { get; set; } = ""; - [Required]public string FollowupDate { get; set; } = ""; - - public List Items { get; set; } = new(); -} - -public class WorkplaceDocItemDto -{ - public string ApbDocId { get; set; } = ""; - public string ApvDocId { get; set; } = ""; - public string ProductId { get; set; } = ""; - public string S5A { get; set; } = ""; - public string S9A { get; set; } = ""; - public bool Selected { get; set; } - public string VariantId { get; set; } = ""; - public string VariantName { get; set; } = ""; -} diff --git a/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor b/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor index eac4e6c0..6f93dc37 100644 --- a/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor +++ b/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor @@ -13,52 +13,46 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] *@ +@using Wonky.Client.Components