From b193209bc32f89c1482b7fba05de728d86bbf59f Mon Sep 17 00:00:00 2001 From: Frede Hundewadt <22748698+fhdk@users.noreply.github.com> Date: Fri, 18 Mar 2022 19:42:05 +0100 Subject: [PATCH] the-good the-bad and the-ugly --- Wonky.Client/AppId.cs | 2 +- Wonky.Client/Components/CompanyTable.razor | 1 + Wonky.Client/Components/CompanyTable.razor.cs | 8 ++ .../Components/RegLookupAddress.razor | 109 ------------------ .../Components/RegLookupAddress.razor.cs | 92 --------------- Wonky.Client/Components/RegLookupVatNo.razor | 101 ---------------- .../Components/RegLookupVatNo.razor.cs | 82 ------------- .../Components/RegStateVatNumber.razor | 4 +- .../Components/RegStateVatNumber.razor.cs | 4 +- .../Components/RegStateVatNumber.razor.css | 5 - .../VatNumberInputComponent.razor.cs | 2 + Wonky.Client/Pages/CompanyCreate.razor.cs | 2 - Wonky.Client/Pages/CompanyUpdate.razor | 73 ++++-------- Wonky.Client/Pages/CompanyUpdate.razor.cs | 102 ++++++++-------- Wonky.Client/Pages/CompanyView.razor | 21 ++-- Wonky.Client/Pages/CompanyView.razor.cs | 20 ++-- Wonky.Client/wwwroot/css/app.css | 14 ++- 17 files changed, 121 insertions(+), 521 deletions(-) delete mode 100644 Wonky.Client/Components/RegLookupAddress.razor delete mode 100644 Wonky.Client/Components/RegLookupAddress.razor.cs delete mode 100644 Wonky.Client/Components/RegLookupVatNo.razor delete mode 100644 Wonky.Client/Components/RegLookupVatNo.razor.cs delete mode 100644 Wonky.Client/Components/RegStateVatNumber.razor.css diff --git a/Wonky.Client/AppId.cs b/Wonky.Client/AppId.cs index f346bc71..99a373e4 100644 --- a/Wonky.Client/AppId.cs +++ b/Wonky.Client/AppId.cs @@ -2,7 +2,7 @@ namespace Wonky.Client; public class AppId { - public string Version { get; set; } = "0.2.6"; + public string Version { get; set; } = "0.2.7"; public string Name { get; set; } = "Wonky Online"; public bool IsBeta { get; set; } = false; diff --git a/Wonky.Client/Components/CompanyTable.razor b/Wonky.Client/Components/CompanyTable.razor index 1d2cda13..52e38f01 100644 --- a/Wonky.Client/Components/CompanyTable.razor +++ b/Wonky.Client/Components/CompanyTable.razor @@ -22,6 +22,7 @@ @foreach (var company in Companies) {
+
@company.Name
@company.Account
@company.City
diff --git a/Wonky.Client/Components/CompanyTable.razor.cs b/Wonky.Client/Components/CompanyTable.razor.cs index a7abc653..7e8e4af0 100644 --- a/Wonky.Client/Components/CompanyTable.razor.cs +++ b/Wonky.Client/Components/CompanyTable.razor.cs @@ -30,6 +30,14 @@ namespace Wonky.Client.Components private Confirmation _confirmation = new (); private string _companyId = string.Empty; + private string VisitState(string nextVisit) + { + var theUgly = DateTime.Parse(nextVisit); + var theBad = theUgly.AddDays(-14); + if (DateTime.Now >= theUgly) + return "the-ugly"; + return DateTime.Now >= theBad ? "the-bad" : "the-good"; + } private void CallConfirmationModal(string companyId) { _companyId = companyId; diff --git a/Wonky.Client/Components/RegLookupAddress.razor b/Wonky.Client/Components/RegLookupAddress.razor deleted file mode 100644 index eb9b4541..00000000 --- a/Wonky.Client/Components/RegLookupAddress.razor +++ /dev/null @@ -1,109 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the Affero GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -
- -
- - -
-
- - -
-
- - -
-
- -
-
-
-
-@if (_adrInfos.Any()) -{ -
- @foreach (var info in _adrInfos) - { - @if(info.Name == "INGEN DATA") - { -
-
@info.Name
-
- } - else - { -
-
-
@info.Name
-
-
-
-
- Reg.nr. -
-
- @info.VatNumber -
-
-
-
- Conavn -
-
- @info.CoName -
-
-
-
- Adresse -
-
- @info.Address -
-
-
-
- Postnr -
-
- @info.ZipCode -
-
-
-
- Bynavn -
-
- @info.City -
-
-
-
- } - } -
-} -else -{ - -} -
diff --git a/Wonky.Client/Components/RegLookupAddress.razor.cs b/Wonky.Client/Components/RegLookupAddress.razor.cs deleted file mode 100644 index b25c3d56..00000000 --- a/Wonky.Client/Components/RegLookupAddress.razor.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the Affero GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using System.ComponentModel.DataAnnotations; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Forms; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.Services; -using Wonky.Entity.Models; -using Wonky.Entity.Requests; - -namespace Wonky.Client.Components; - -public partial class RegLookupAddress : IDisposable -{ - private Query AdrQuery { get; set; } = new(); - private EditContext AdrContext { get; set; } - private List _adrInfos { get; set; } = new(); - private bool ShowAdrResult; - private bool AdrInvalid = true; - [Inject] public VirkRegistryService AdrQueryService { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - - protected override void OnInitialized() - { - ShowAdrResult = false; - AdrContext = new EditContext(AdrQuery); - AdrContext.OnFieldChanged += HandleAdrChanged; - AdrContext.OnValidationStateChanged += AdrValidationChanged; - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - } - - private async Task FetchAddressData() - { - ShowAdrResult = true; - - var query = new VirkParams - { - VatNumber = "", - HouseNumber = AdrQuery.HouseNumber, - StreetName = AdrQuery.StreetName, - ZipCode = AdrQuery.ZipCode - }; - _adrInfos = await AdrQueryService.QueryVirkRegistry(query).ConfigureAwait(true); - } - private void HandleAdrChanged(object sender, FieldChangedEventArgs e) - { - AdrInvalid = !AdrContext.Validate(); - StateHasChanged(); - } - - private void AdrValidationChanged(object sender, ValidationStateChangedEventArgs e) - { - AdrInvalid = true; - AdrContext.OnFieldChanged -= HandleAdrChanged; - AdrContext = new EditContext(AdrQuery); - AdrContext.OnFieldChanged += HandleAdrChanged; - AdrContext.NotifyValidationStateChanged(); - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - AdrContext.OnFieldChanged -= HandleAdrChanged; - AdrContext.OnValidationStateChanged -= AdrValidationChanged; - } - - public class Query - { - [Required(ErrorMessage = "Vejnavn skal udfyldes", AllowEmptyStrings = false)] - public string StreetName { get; set; } = ""; - - [Required(ErrorMessage = "Husnummer skal udfyldes")] - public string HouseNumber { get; set; } = ""; - - [Required(ErrorMessage = "Postnummer skal udfyldes")] - public string ZipCode { get; set; } = ""; - } -} \ No newline at end of file diff --git a/Wonky.Client/Components/RegLookupVatNo.razor b/Wonky.Client/Components/RegLookupVatNo.razor deleted file mode 100644 index cf5fddfd..00000000 --- a/Wonky.Client/Components/RegLookupVatNo.razor +++ /dev/null @@ -1,101 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the Affero GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - - - -
-
- - -
-
- -
-
-
- -
-@if (_vatInfos.Any()) -{ -
- @foreach (var info in _vatInfos) - { - @if(info.Name == "INGEN DATA") - { -
-
@info.Name
-
- } - else - { -
-
-
@info.Name
-
-
-
-
- Reg.nr. -
-
- @info.VatNumber -
-
-
-
- Conavn -
-
- @info.CoName -
-
-
-
- Adresse -
-
- @info.Address -
-
-
-
- Postnr -
-
- @info.ZipCode -
-
-
-
- Bynavn -
-
- @info.City -
-
-
-
- } - } -
-} -else -{ - -} -
diff --git a/Wonky.Client/Components/RegLookupVatNo.razor.cs b/Wonky.Client/Components/RegLookupVatNo.razor.cs deleted file mode 100644 index 4ca83bec..00000000 --- a/Wonky.Client/Components/RegLookupVatNo.razor.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the Affero GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using System.ComponentModel.DataAnnotations; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Forms; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.Services; -using Wonky.Entity.Models; -using Wonky.Entity.Requests; - -namespace Wonky.Client.Components; - -public partial class RegLookupVatNo : IDisposable -{ - private EditContext _regContext { get; set; } - private List _vatInfos { get; set; } = new(); - private bool _showVatResult = true; - private bool _regInvalid = true; - - [Required] private string VatNumber { get; set; } = ""; - [Inject] private VirkRegistryService RegQueryService { get; set; } - [Inject] private HttpInterceptorService Interceptor { get; set; } - - protected override void OnInitialized() - { - _showVatResult = false; - _regContext = new EditContext(VatNumber); - _regContext.OnFieldChanged += HandleRegChanged; - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - } - - private void HandleRegChanged(object sender, FieldChangedEventArgs e) - { - _regInvalid = !_regContext.Validate(); - StateHasChanged(); - } - private async Task FetchRegData() - { - _showVatResult = true; - - var query = new VirkParams - { - VatNumber = VatNumber, - HouseNumber = "", - StreetName = "", - ZipCode = "" - }; - _vatInfos = await RegQueryService.QueryVirkRegistry(query).ConfigureAwait(true); - } - - private void RegValidationChanged(object sender, ValidationStateChangedEventArgs e) - { - _vatInfos.Clear(); - _regInvalid = true; - _regContext.OnFieldChanged -= HandleRegChanged; - _regContext = new EditContext(VatNumber); - _regContext.OnFieldChanged += HandleRegChanged; - _regContext.NotifyValidationStateChanged(); - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - _regContext.OnFieldChanged -= HandleRegChanged; - _regContext.OnValidationStateChanged -= RegValidationChanged; - } - -} \ No newline at end of file diff --git a/Wonky.Client/Components/RegStateVatNumber.razor b/Wonky.Client/Components/RegStateVatNumber.razor index 8089b36f..2a43994e 100644 --- a/Wonky.Client/Components/RegStateVatNumber.razor +++ b/Wonky.Client/Components/RegStateVatNumber.razor @@ -17,9 +17,9 @@ @if (string.IsNullOrEmpty(VatNumber)) { -
+ } else { -
+ } diff --git a/Wonky.Client/Components/RegStateVatNumber.razor.cs b/Wonky.Client/Components/RegStateVatNumber.razor.cs index 376dd792..b5987cda 100644 --- a/Wonky.Client/Components/RegStateVatNumber.razor.cs +++ b/Wonky.Client/Components/RegStateVatNumber.razor.cs @@ -24,18 +24,16 @@ namespace Wonky.Client.Components; public partial class RegStateVatNumber { [Inject] public VirkRegistryService VirkRegistryService { get; set; } - [Parameter] public string VatNumber { get; set; } = ""; - private VirkRegInfo VirkRegInfo { get; set; } = new(); private readonly VirkParams _VirkParams = new(); private string CurrentRegState = "UKENDT"; protected override async Task OnParametersSetAsync() { - _VirkParams.VatNumber = VatNumber; if (!string.IsNullOrEmpty(VatNumber)) { + _VirkParams.VatNumber = VatNumber; var result = await VirkRegistryService.QueryVirkRegistry(_VirkParams); VirkRegInfo = result.Any() ? result[0] : new VirkRegInfo(); if (VirkRegInfo.States.Any()) diff --git a/Wonky.Client/Components/RegStateVatNumber.razor.css b/Wonky.Client/Components/RegStateVatNumber.razor.css deleted file mode 100644 index 39149222..00000000 --- a/Wonky.Client/Components/RegStateVatNumber.razor.css +++ /dev/null @@ -1,5 +0,0 @@ -.state { - max-width: 16px; - max-height: 16px; - float: left; -} \ No newline at end of file diff --git a/Wonky.Client/Components/VatNumberInputComponent.razor.cs b/Wonky.Client/Components/VatNumberInputComponent.razor.cs index 76af8175..ebf587f3 100644 --- a/Wonky.Client/Components/VatNumberInputComponent.razor.cs +++ b/Wonky.Client/Components/VatNumberInputComponent.razor.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; +using Wonky.Client.Models; namespace Wonky.Client.Components; public partial class VatNumberInputComponent : IDisposable @@ -8,6 +9,7 @@ public partial class VatNumberInputComponent : IDisposable private string VatNumber { get; set; } = ""; private EditContext? _editVatNumber; private bool _formInvalid = true; + [Parameter] public EventCallback OnValidSubmit { get; set; } protected override void OnInitialized() { diff --git a/Wonky.Client/Pages/CompanyCreate.razor.cs b/Wonky.Client/Pages/CompanyCreate.razor.cs index 0717b72d..38579d93 100644 --- a/Wonky.Client/Pages/CompanyCreate.razor.cs +++ b/Wonky.Client/Pages/CompanyCreate.razor.cs @@ -38,9 +38,7 @@ namespace Wonky.Client.Pages private VirkRegInfo _virkRegInfo = new(); private EditContext _editContext; private bool _formInvalid = true; - private VirkParams _virkParams = new(); private List VInfos { get; set; } = new(); - [Required] public string VatToLookup { get; set; } = ""; [Inject] public ICompanyHttpRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public IToastService ToastService { get; set; } diff --git a/Wonky.Client/Pages/CompanyUpdate.razor b/Wonky.Client/Pages/CompanyUpdate.razor index 2c507f88..ba294ee0 100644 --- a/Wonky.Client/Pages/CompanyUpdate.razor +++ b/Wonky.Client/Pages/CompanyUpdate.razor @@ -23,45 +23,18 @@ @if (_companyDto != null) { -
-
- -
-
-
-
- - @if (VInfos.Any()) - { - @foreach (var info in VInfos) - { -
-
- @info.VatNumber -
-
- @info.Name -
-
- @info.States[^1].State -
-
- -
-
- } - } -
-
+
+ +
- +
- +
@@ -80,7 +53,7 @@
- +
@@ -94,7 +67,7 @@
- +
@@ -118,22 +91,26 @@
- +
-
- - +
+ +
+ +
-
- - +
+ +
+ +
-
- - +
+ +
+ +
@@ -143,8 +120,8 @@