diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index b7a6f59eb..7dfec4e75 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -1156,12 +1156,13 @@ namespace BTCPayServer.Tests s.Driver.FindElement(By.Id("ArchivePaymentRequest")).Click(); Assert.Contains("The payment request has been archived", s.FindAlertMessage().Text); Assert.DoesNotContain("Pay123", s.Driver.PageSource); - s.Driver.FindElement(By.Id("SearchDropdownToggle")).Click(); - s.Driver.FindElement(By.Id("SearchIncludeArchived")).Click(); + s.Driver.FindElement(By.Id("StatusOptionsToggle")).Click(); + s.Driver.WaitForElement(By.Id("StatusOptionsIncludeArchived")).Click(); Assert.Contains("Pay123", s.Driver.PageSource); // unarchive (from list) - s.Driver.FindElement(By.Id($"ToggleArchival-{payReqId}")).Click(); + s.Driver.FindElement(By.Id($"ToggleActions-{payReqId}")).Click(); + s.Driver.WaitForElement(By.Id($"ToggleArchival-{payReqId}")).Click(); Assert.Contains("The payment request has been unarchived", s.FindAlertMessage().Text); Assert.Contains("Pay123", s.Driver.PageSource); } diff --git a/BTCPayServer/Controllers/UIPaymentRequestController.cs b/BTCPayServer/Controllers/UIPaymentRequestController.cs index 0a9022a71..79c587f04 100644 --- a/BTCPayServer/Controllers/UIPaymentRequestController.cs +++ b/BTCPayServer/Controllers/UIPaymentRequestController.cs @@ -78,16 +78,20 @@ namespace BTCPayServer.Controllers model = this.ParseListQuery(model ?? new ListPaymentRequestsViewModel()); var store = GetCurrentStore(); - var includeArchived = new SearchString(model.SearchTerm, model.TimezoneOffset ?? 0).GetFilterBool("includearchived") == true; + var fs = new SearchString(model.SearchTerm, model.TimezoneOffset ?? 0); var result = await _PaymentRequestRepository.FindPaymentRequests(new PaymentRequestQuery { UserId = GetUserId(), StoreId = store.Id, Skip = model.Skip, Count = model.Count, - IncludeArchived = includeArchived + Status = fs.GetFilterArray("status")?.Select(s => Enum.Parse(s, true)).ToArray(), + IncludeArchived = fs.GetFilterBool("includearchived") ?? false }); - + + model.Search = fs; + model.SearchText = fs.TextSearch; + model.Items = result.Select(data => { var blob = data.GetBlob(); diff --git a/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs b/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs index ae8da65ea..405afa842 100644 --- a/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs +++ b/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs @@ -18,6 +18,9 @@ namespace BTCPayServer.Models.PaymentRequestViewModels { public List Items { get; set; } public override int CurrentPageCount => Items.Count; + + public SearchString Search { get; set; } + public string SearchText { get; set; } } public class UpdatePaymentRequestViewModel diff --git a/BTCPayServer/Views/UIInvoice/ListInvoices.cshtml b/BTCPayServer/Views/UIInvoice/ListInvoices.cshtml index 35e698382..6368fa529 100644 --- a/BTCPayServer/Views/UIInvoice/ListInvoices.cshtml +++ b/BTCPayServer/Views/UIInvoice/ListInvoices.cshtml @@ -5,7 +5,6 @@ @model InvoicesModel @{ ViewData.SetActivePage(InvoiceNavPages.Index, "Invoices"); - var statusFilterCount = CountArrayFilter("status") + CountArrayFilter("exceptionstatus") + (HasBooleanFilter("includearchived") ? 1 : 0) + (HasBooleanFilter("unusual") ? 1 : 0); var hasDateFilter = HasArrayFilter("startdate") || HasArrayFilter("enddate"); var appFilterCount = Model.Apps.Count(app => HasArrayFilter("orderid", app.AppOrderId)); diff --git a/BTCPayServer/Views/UIPaymentRequest/GetPaymentRequests.cshtml b/BTCPayServer/Views/UIPaymentRequest/GetPaymentRequests.cshtml index 75a2b7c74..24191d69b 100644 --- a/BTCPayServer/Views/UIPaymentRequest/GetPaymentRequests.cshtml +++ b/BTCPayServer/Views/UIPaymentRequest/GetPaymentRequests.cshtml @@ -6,6 +6,20 @@ @{ Layout = "_Layout"; ViewData["Title"] = "Payment Requests"; + var storeId = Context.GetStoreData().Id; + var statusFilterCount = CountArrayFilter("status") + (HasBooleanFilter("includearchived") ? 1 : 0); +} + +@functions +{ + private int CountArrayFilter(string type) => + Model.Search.ContainsFilter(type) ? Model.Search.GetFilterArray(type).Length : 0; + + private bool HasArrayFilter(string type, string key = null) => + Model.Search.ContainsFilter(type) && (key is null || Model.Search.GetFilterArray(type).Contains(key)); + + private bool HasBooleanFilter(string key) => + Model.Search.ContainsFilter(key) && Model.Search.GetFilterBool(key) is true; }
@@ -16,9 +30,8 @@ - - - Create Payment Request + + Create Request @@ -37,86 +50,91 @@ -
-
-
- - -
- - - - -
- -
+
+ + + + + -
+ -
-
- @if (Model.Items.Count > 0) - { - - - - - + } + +
Title -
- Expiry - +@if (Model.Items.Any()) +{ + + + + + + + + + + + + @foreach (var item in Model.Items) + { + + + + + + - - - - - - @foreach (var item in Model.Items) - { - - - - - - - - } - -
Title +
+ Expiry + +
+
PriceStatusActions
+ @item.Title + + @(item.ExpiryDate?.ToBrowserDate() ?? new HtmlString("No Expiry")) + + @item.AmountFormatted + + @item.Status + + StatusAmountActions
- @item.Title - - @(item.ExpiryDate?.ToBrowserDate() ?? new HtmlString($"No Expiry")) - - @item.Status - - @item.AmountFormatted - - Invoices - - - Clone - - - @(item.Archived ? "Unarchive" : "Archive") - - - View -
+
+ +
- - } - else - { -

- There are no payment requests matching your criteria. -

- } -
-
+ +} +else +{ +

+ There are no payment requests matching your criteria. +

+}