From 62fe86c4035f728a47681441c3e6a5d01c4c84f5 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt <22748698+fhdk@users.noreply.github.com> Date: Wed, 13 Apr 2022 18:18:01 +0200 Subject: [PATCH] wip --- Wonky.Client/Models/PurchaseOrder.cs | 38 +++--- Wonky.Client/Pages/CompanyUpdate.razor | 4 +- Wonky.Client/Pages/CompanyUpdate.razor.cs | 5 - Wonky.Client/Pages/CrmActivityCreate.razor | 108 +++++++++--------- Wonky.Client/Pages/CrmActivityCreate.razor.cs | 14 ++- Wonky.Entity/DTO/CompanyDto.cs | 20 ++-- 6 files changed, 94 insertions(+), 95 deletions(-) diff --git a/Wonky.Client/Models/PurchaseOrder.cs b/Wonky.Client/Models/PurchaseOrder.cs index 288fcb66..e72ef170 100644 --- a/Wonky.Client/Models/PurchaseOrder.cs +++ b/Wonky.Client/Models/PurchaseOrder.cs @@ -24,31 +24,31 @@ namespace Wonky.Client.Models public string ActivityId { get; set; } = ""; public string CrmCompanyKey { get; set; } = ""; public string SalesRep { get; set; } = ""; - public string Account { get; set; } = ""; - public string Name { get; set; } = ""; - public string City { get; set; }= ""; - public string ZipCode { get; set; } = ""; + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string Account { get; set; } = ""; + [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Name { get; set; } = ""; + [MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string City { get; set; }= ""; + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string ZipCode { get; set; } = ""; [Required(ErrorMessage = "Vælg aktivitet")] public string ActivityType { get; set; } = ""; - public string OurRef { get; set; } = ""; - public string Address { get; set; } = ""; - public string Address2 { get; set; } = ""; - public string Phone { get; set; } = ""; - public string EMail { get; set; } = ""; + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string OurRef { get; set; } = ""; + [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Address { get; set; } = ""; + [MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string Address2 { get; set; } = ""; + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string Phone { get; set; } = ""; + [MaxLength(80, ErrorMessage = "Du kan højst bruge 80 tegn")] public string EMail { get; set; } = ""; // Form entries public bool CheckDate { get; set; } public DateTime ActivityDate { get; set; } - public string Demo { get; set; } = ""; - public string VatNumber { get; set; } = ""; - public string ReferenceNumber { get; set; } = ""; - [MaxLength(255, ErrorMessage = "Du kan højst bruge 255 tegn")]public string YourRef { 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 VatNumber { get; set; } = ""; + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string ReferenceNumber { get; set; } = ""; + [MaxLength(35, ErrorMessage = "Du kan højst bruge 35 tegn")] public string YourRef { get; set; } = ""; [MaxLength(255, ErrorMessage = "Du kan højst bruge 255 tegn")] public string OrderMessage { get; set; } = ""; - public string CrmNote { get; set; } = ""; + [MaxLength(255, ErrorMessage = "Du kan højst bruge 255 tegn")] public string CrmNote { get; set; } = ""; // Delivery address form entries - public string DlvName { get; set; } = ""; - public string DlvAddress1 { get; set; } = ""; - public string DlvAddress2 { get; set; } = ""; - public string DlvZipCode { get; set; } = ""; - public string DlvCity { get; set; } = ""; + [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string DlvName { get; set; } = ""; + [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string DlvAddress1 { get; set; } = ""; + [MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string DlvAddress2 { get; set; } = ""; + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string DlvZipCode { get; set; } = ""; + [MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string DlvCity { get; set; } = ""; // Lines public List Lines { get; set; } = new(); } diff --git a/Wonky.Client/Pages/CompanyUpdate.razor b/Wonky.Client/Pages/CompanyUpdate.razor index 12740285..811a4390 100644 --- a/Wonky.Client/Pages/CompanyUpdate.razor +++ b/Wonky.Client/Pages/CompanyUpdate.razor @@ -27,10 +27,10 @@
@_company.Account - @_company.Name
- +
- +
@if (VInfos.Any()) { diff --git a/Wonky.Client/Pages/CompanyUpdate.razor.cs b/Wonky.Client/Pages/CompanyUpdate.razor.cs index a71cf0dd..43f4c0fb 100644 --- a/Wonky.Client/Pages/CompanyUpdate.razor.cs +++ b/Wonky.Client/Pages/CompanyUpdate.razor.cs @@ -45,7 +45,6 @@ public partial class CompanyUpdate : IDisposable private VirkRegInfo _virkRegInfo { get; set; } = new(); private DateTime LastVisit { get; set; } private DateTime NextVisit { get; set; } - private VatAddress _address { get; set; } = new(); private string _vatState { get; set; } = "the-ugly"; protected override async Task OnInitializedAsync() @@ -58,8 +57,6 @@ public partial class CompanyUpdate : IDisposable NextVisit = DateTime.Parse(_company.NextVisit); _editContext = new EditContext(_company); - Console.WriteLine(JsonSerializer.Serialize(_company)); - if(_company.HasFolded == 1) { _vatState = "the-dead"; @@ -68,8 +65,6 @@ public partial class CompanyUpdate : IDisposable { _vatState = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? "the-good" : "the-draw"; } - - _address.ZipCode = _company.ZipCode; } private async Task Update() diff --git a/Wonky.Client/Pages/CrmActivityCreate.razor b/Wonky.Client/Pages/CrmActivityCreate.razor index 8e1004ba..c93aaaeb 100644 --- a/Wonky.Client/Pages/CrmActivityCreate.razor +++ b/Wonky.Client/Pages/CrmActivityCreate.razor @@ -40,16 +40,16 @@
- -
-
- +
+
+ +
@@ -104,51 +104,6 @@
- @* Section for delivery address *@ -
-

- -

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
@* Catalog selection for draft *@

@@ -274,7 +229,7 @@ @* Draft lines *@

-

+ @* Section for delivery address *@ +
+

+ +

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
@* ---------------------------------------------- *@ @* Display action buttons *@
Tilbage - - - + + +
diff --git a/Wonky.Client/Pages/CrmActivityCreate.razor.cs b/Wonky.Client/Pages/CrmActivityCreate.razor.cs index 0bcf03b9..1c5aa776 100644 --- a/Wonky.Client/Pages/CrmActivityCreate.razor.cs +++ b/Wonky.Client/Pages/CrmActivityCreate.razor.cs @@ -46,15 +46,17 @@ public partial class CrmActivityCreate : IDisposable private Preferences _prefs { get; set; } = new(); private PurchaseOrder _purchaseOrder = new (); private CompanyDto _company = new(); - private EditContext _editContext; - private bool _poFormInvalid = true; + private EditContext _editContext { get; set; } private MetaData? MetaData { get; set; } = new(); private CatalogPagingParams _paging = new(); - private bool ShowItem; - private bool ShowSearchView; + private bool _poFormInvalid { get; set; } = true; + private bool ShowItem { get; set; } + private bool ShowSearchView { get; set; } private string Quantity = "1"; private string Price = "0"; private string Discount = "0"; + private bool InvalidActivity { get; set; } = true; + private bool InvalidCanvas { get; set; } = true; protected override async Task OnInitializedAsync() { @@ -71,7 +73,7 @@ public partial class CrmActivityCreate : IDisposable // set up indexdb identification _purchaseOrder.ActivityId = CompanyId; _purchaseOrder.CrmCompanyKey = CompanyId; - + _purchaseOrder.ActivityDate = DateTime.Now; // permanent identifications _purchaseOrder.SalesRep = ux.Adviser; _purchaseOrder.Account = _company.Account; @@ -192,6 +194,8 @@ public partial class CrmActivityCreate : IDisposable private void HandleFieldChanged(object sender, FieldChangedEventArgs e) { _poFormInvalid = !_editContext.Validate(); + InvalidActivity = string.IsNullOrWhiteSpace(_purchaseOrder.ActivityType) || _poFormInvalid || DraftStateProvider.Draft.Items.Count == 0 || !_purchaseOrder.CheckDate; + InvalidCanvas = string.IsNullOrWhiteSpace(_purchaseOrder.ActivityType) || _poFormInvalid || !_purchaseOrder.CheckDate; StateHasChanged(); } private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) diff --git a/Wonky.Entity/DTO/CompanyDto.cs b/Wonky.Entity/DTO/CompanyDto.cs index b598465e..5e684bc9 100644 --- a/Wonky.Entity/DTO/CompanyDto.cs +++ b/Wonky.Entity/DTO/CompanyDto.cs @@ -21,20 +21,20 @@ namespace Wonky.Entity.DTO; public class CompanyDto { - [Required(ErrorMessage = "Navn skal udyldes")] public string Name { get; set; } - [Required(ErrorMessage = "Postnummer skal udfyldes")] public string ZipCode { get; set; } - [Required(ErrorMessage = "Bynavn skal udfyldes")] public string City { get; set; } + [Required(ErrorMessage = "Navn skal udyldes")] [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Name { get; set; } + [Required(ErrorMessage = "Postnummer skal udfyldes")] [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string ZipCode { get; set; } + [Required(ErrorMessage = "Bynavn skal udfyldes")] [MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string City { get; set; } [Required(ErrorMessage = "ORG/VAT/CVR er ikke et gyldigt nummer")] public string VatNumber { get; set; } public string CompanyId { get; set; } = ""; public string SalesRepId { get; set; } = ""; public string BcId { get; set; } = ""; - public string Address1 { get; set; } = ""; - public string Address2 { get; set; } = ""; - public string Account { get; set; } = ""; - public string Phone { get; set; } = ""; - public string Mobile { get; set; } = ""; - public string Email { get; set; } = ""; - public string Attention { get; set; } = ""; + [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Address1 { get; set; } = ""; + [MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string Address2 { get; set; } = ""; + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string Account { get; set; } = ""; + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string Phone { get; set; } = ""; + [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string Mobile { get; set; } = ""; + [MaxLength(80, ErrorMessage = "Du kan højst bruge 80 tegn")] public string Email { get; set; } = ""; + [MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string Attention { get; set; } = ""; public string LastVisit { get; set; } = ""; public string NextVisit { get; set; } = ""; public int Interval { get; set; } = 8;