From 96569ae4aad03a7f43dd774942081a58d896f270 Mon Sep 17 00:00:00 2001 From: d11n Date: Mon, 13 Nov 2023 13:59:14 +0100 Subject: [PATCH 1/2] POS Cart: Add options for search and categories display (#5438) --- .../Models/CreateAppRequest.cs | 2 ++ .../Models/PointOfSaleAppData.cs | 2 ++ .../GreenField/GreenfieldAppsController.cs | 6 ++++- .../Controllers/UIPointOfSaleController.cs | 6 +++++ .../Models/UpdatePointOfSaleViewModel.cs | 4 +++ .../Models/ViewPointOfSaleViewModel.cs | 2 ++ .../Services/Apps/PointOfSaleSettings.cs | 4 +++ .../Shared/PointOfSale/Public/Cart.cshtml | 26 ++++++++++++------- .../PointOfSale/UpdatePointOfSale.cshtml | 13 ++++++++++ BTCPayServer/wwwroot/pos/admin.js | 4 +++ .../swagger/v1/swagger.template.apps.json | 12 +++++++++ 11 files changed, 70 insertions(+), 11 deletions(-) diff --git a/BTCPayServer.Client/Models/CreateAppRequest.cs b/BTCPayServer.Client/Models/CreateAppRequest.cs index e4ed12173d..bdb1a62d7f 100644 --- a/BTCPayServer.Client/Models/CreateAppRequest.cs +++ b/BTCPayServer.Client/Models/CreateAppRequest.cs @@ -28,6 +28,8 @@ public class CreatePointOfSaleAppRequest : CreateAppRequest public PosViewType DefaultView { get; set; } public bool ShowCustomAmount { get; set; } = false; public bool ShowDiscount { get; set; } = true; + public bool ShowSearch { get; set; } = true; + public bool ShowCategories { get; set; } = true; public bool EnableTips { get; set; } = true; public string CustomAmountPayButtonText { get; set; } = null; public string FixedAmountPayButtonText { get; set; } = null; diff --git a/BTCPayServer.Client/Models/PointOfSaleAppData.cs b/BTCPayServer.Client/Models/PointOfSaleAppData.cs index 3008dda56e..f2eba42fef 100644 --- a/BTCPayServer.Client/Models/PointOfSaleAppData.cs +++ b/BTCPayServer.Client/Models/PointOfSaleAppData.cs @@ -21,6 +21,8 @@ public class PointOfSaleAppData : AppDataBase public string DefaultView { get; set; } public bool ShowCustomAmount { get; set; } public bool ShowDiscount { get; set; } + public bool ShowSearch { get; set; } + public bool ShowCategories { get; set; } public bool EnableTips { get; set; } public string Currency { get; set; } public object Items { get; set; } diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs index c246aa7c83..db60ef1eb5 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs @@ -270,12 +270,14 @@ private CrowdfundSettings ToCrowdfundSettings(CreateCrowdfundAppRequest request) private PointOfSaleSettings ToPointOfSaleSettings(CreatePointOfSaleAppRequest request) { - return new PointOfSaleSettings() + return new PointOfSaleSettings { Title = request.Title, DefaultView = (PosViewType)request.DefaultView, ShowCustomAmount = request.ShowCustomAmount, ShowDiscount = request.ShowDiscount, + ShowSearch = request.ShowSearch, + ShowCategories = request.ShowCategories, EnableTips = request.EnableTips, Currency = request.Currency, Template = request.Template != null ? AppService.SerializeTemplate(AppService.Parse(request.Template)) : null, @@ -336,6 +338,8 @@ private PointOfSaleAppData ToPointOfSaleModel(AppData appData) DefaultView = settings.DefaultView.ToString(), ShowCustomAmount = settings.ShowCustomAmount, ShowDiscount = settings.ShowDiscount, + ShowSearch = settings.ShowSearch, + ShowCategories = settings.ShowCategories, EnableTips = settings.EnableTips, Currency = settings.Currency, Items = JsonConvert.DeserializeObject( diff --git a/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs b/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs index 265a8f6222..eee430a7a7 100644 --- a/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs +++ b/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs @@ -95,6 +95,8 @@ public async Task ViewPointOfSale(string appId, PosViewType? view ViewType = (PosViewType)viewType, ShowCustomAmount = settings.ShowCustomAmount, ShowDiscount = settings.ShowDiscount, + ShowSearch = settings.ShowSearch, + ShowCategories = settings.ShowCategories, EnableTips = settings.EnableTips, CurrencyCode = settings.Currency, CurrencySymbol = numberFormatInfo.CurrencySymbol, @@ -543,6 +545,8 @@ public async Task UpdatePointOfSale(string appId) DefaultView = settings.DefaultView, ShowCustomAmount = settings.ShowCustomAmount, ShowDiscount = settings.ShowDiscount, + ShowSearch = settings.ShowSearch, + ShowCategories = settings.ShowCategories, EnableTips = settings.EnableTips, Currency = settings.Currency, Template = settings.Template, @@ -631,6 +635,8 @@ public async Task UpdatePointOfSale(string appId, UpdatePointOfSa DefaultView = vm.DefaultView, ShowCustomAmount = vm.ShowCustomAmount, ShowDiscount = vm.ShowDiscount, + ShowSearch = vm.ShowSearch, + ShowCategories = vm.ShowCategories, EnableTips = vm.EnableTips, Currency = vm.Currency, Template = vm.Template, diff --git a/BTCPayServer/Plugins/PointOfSale/Models/UpdatePointOfSaleViewModel.cs b/BTCPayServer/Plugins/PointOfSale/Models/UpdatePointOfSaleViewModel.cs index b75514f363..95f9cc56de 100644 --- a/BTCPayServer/Plugins/PointOfSale/Models/UpdatePointOfSaleViewModel.cs +++ b/BTCPayServer/Plugins/PointOfSale/Models/UpdatePointOfSaleViewModel.cs @@ -31,6 +31,10 @@ public class UpdatePointOfSaleViewModel public bool ShowCustomAmount { get; set; } [Display(Name = "User can input discount in %")] public bool ShowDiscount { get; set; } + [Display(Name = "Display the search bar")] + public bool ShowSearch { get; set; } + [Display(Name = "Display the category list")] + public bool ShowCategories { get; set; } [Display(Name = "Enable tips")] public bool EnableTips { get; set; } public string Example1 { get; internal set; } diff --git a/BTCPayServer/Plugins/PointOfSale/Models/ViewPointOfSaleViewModel.cs b/BTCPayServer/Plugins/PointOfSale/Models/ViewPointOfSaleViewModel.cs index 267771156d..afa0c737c2 100644 --- a/BTCPayServer/Plugins/PointOfSale/Models/ViewPointOfSaleViewModel.cs +++ b/BTCPayServer/Plugins/PointOfSale/Models/ViewPointOfSaleViewModel.cs @@ -65,6 +65,8 @@ public class CurrencyInfoData public PosViewType ViewType { get; set; } public bool ShowCustomAmount { get; set; } public bool ShowDiscount { get; set; } + public bool ShowSearch { get; set; } = true; + public bool ShowCategories { get; set; } = true; public bool EnableTips { get; set; } public string Step { get; set; } public string Title { get; set; } diff --git a/BTCPayServer/Services/Apps/PointOfSaleSettings.cs b/BTCPayServer/Services/Apps/PointOfSaleSettings.cs index e028909a57..397d250075 100644 --- a/BTCPayServer/Services/Apps/PointOfSaleSettings.cs +++ b/BTCPayServer/Services/Apps/PointOfSaleSettings.cs @@ -77,6 +77,8 @@ public PointOfSaleSettings() DefaultView = PosViewType.Static; ShowCustomAmount = false; ShowDiscount = true; + ShowSearch = true; + ShowCategories = true; EnableTips = true; RequiresRefundEmail = RequiresRefundEmail.InheritFromStore; } @@ -87,6 +89,8 @@ public PointOfSaleSettings() public PosViewType DefaultView { get; set; } public bool ShowCustomAmount { get; set; } public bool ShowDiscount { get; set; } + public bool ShowSearch { get; set; } = true; + public bool ShowCategories { get; set; } = true; public bool EnableTips { get; set; } public RequiresRefundEmail RequiresRefundEmail { get; set; } diff --git a/BTCPayServer/Views/Shared/PointOfSale/Public/Cart.cshtml b/BTCPayServer/Views/Shared/PointOfSale/Public/Cart.cshtml index 6a03c630e4..3561422a57 100644 --- a/BTCPayServer/Views/Shared/PointOfSale/Public/Cart.cshtml +++ b/BTCPayServer/Views/Shared/PointOfSale/Public/Cart.cshtml @@ -31,22 +31,28 @@
-
+

@(string.IsNullOrEmpty(Model.Title) ? Model.StoreName : Model.Title)

- -
- -
+ @if (Model.ShowSearch) + { + + } + @if (Model.ShowCategories) + { +
+ +
+ }
diff --git a/BTCPayServer/Views/Shared/PointOfSale/UpdatePointOfSale.cshtml b/BTCPayServer/Views/Shared/PointOfSale/UpdatePointOfSale.cshtml index c72a5bdc3a..b74c86e54a 100644 --- a/BTCPayServer/Views/Shared/PointOfSale/UpdatePointOfSale.cshtml +++ b/BTCPayServer/Views/Shared/PointOfSale/UpdatePointOfSale.cshtml @@ -113,6 +113,19 @@
+
+ Cart +
+ + + +
+
+ + + +
+
Tips
diff --git a/BTCPayServer/wwwroot/pos/admin.js b/BTCPayServer/wwwroot/pos/admin.js index 7c5e160d6c..0126cef431 100644 --- a/BTCPayServer/wwwroot/pos/admin.js +++ b/BTCPayServer/wwwroot/pos/admin.js @@ -1,6 +1,7 @@ const description = document.getElementById('description'); const products = document.getElementById('products'); const tips = document.getElementById('tips'); +const cart = document.getElementById('cart-display'); const discounts = document.getElementById('discounts'); const buttonPriceText = document.getElementById('button-price-text'); const customPayments = document.getElementById('custom-payments'); @@ -16,6 +17,7 @@ function updateFormForDefaultView(type) { case 'Static': case 'Print': hide(tips); + hide(cart); hide(discounts); hide(buttonPriceText); show(description); @@ -23,6 +25,7 @@ function updateFormForDefaultView(type) { show(customPayments); break; case 'Cart': + show(cart); show(tips); show(products); show(discounts); @@ -33,6 +36,7 @@ function updateFormForDefaultView(type) { case 'Light': show(tips); show(discounts); + hide(cart); hide(products); hide(description); hide(buttonPriceText); diff --git a/BTCPayServer/wwwroot/swagger/v1/swagger.template.apps.json b/BTCPayServer/wwwroot/swagger/v1/swagger.template.apps.json index c04f828a7f..82ede0e4c2 100644 --- a/BTCPayServer/wwwroot/swagger/v1/swagger.template.apps.json +++ b/BTCPayServer/wwwroot/swagger/v1/swagger.template.apps.json @@ -470,6 +470,18 @@ "description": "Whether the option to enter a discount is shown", "example": false }, + "showSearch": { + "type": "boolean", + "description": "Display the search bar", + "example": false, + "default": true + }, + "showCategories": { + "type": "boolean", + "description": "Display the list of categories", + "example": false, + "default": true + }, "enableTips": { "type": "boolean", "description": "Whether the option to enter a tip is shown", From 46f0818765003de1fea5d455d8ae43962f4a8a6a Mon Sep 17 00:00:00 2001 From: rockstardev <5191402+rockstardev@users.noreply.github.com> Date: Tue, 14 Nov 2023 20:59:51 -0600 Subject: [PATCH 2/2] Bumping LND to 0.17.1-beta --- BTCPayServer.Tests/docker-compose.altcoins.yml | 4 ++-- BTCPayServer.Tests/docker-compose.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BTCPayServer.Tests/docker-compose.altcoins.yml b/BTCPayServer.Tests/docker-compose.altcoins.yml index a890d06c60..d8d05755ba 100644 --- a/BTCPayServer.Tests/docker-compose.altcoins.yml +++ b/BTCPayServer.Tests/docker-compose.altcoins.yml @@ -224,7 +224,7 @@ services: - "5432" merchant_lnd: - image: btcpayserver/lnd:v0.17.0-beta + image: btcpayserver/lnd:v0.17.1-beta restart: unless-stopped environment: LND_CHAIN: "btc" @@ -259,7 +259,7 @@ services: - bitcoind customer_lnd: - image: btcpayserver/lnd:v0.17.0-beta + image: btcpayserver/lnd:v0.17.1-beta restart: unless-stopped environment: LND_CHAIN: "btc" diff --git a/BTCPayServer.Tests/docker-compose.yml b/BTCPayServer.Tests/docker-compose.yml index d0afe390cd..0acd1dee29 100644 --- a/BTCPayServer.Tests/docker-compose.yml +++ b/BTCPayServer.Tests/docker-compose.yml @@ -211,7 +211,7 @@ services: - "5432" merchant_lnd: - image: btcpayserver/lnd:v0.17.0-beta + image: btcpayserver/lnd:v0.17.1-beta restart: unless-stopped environment: LND_CHAIN: "btc" @@ -248,7 +248,7 @@ services: - bitcoind customer_lnd: - image: btcpayserver/lnd:v0.17.0-beta + image: btcpayserver/lnd:v0.17.1-beta restart: unless-stopped environment: LND_CHAIN: "btc"