From c7e90cd7dff2caf55c2f29e1bf33b79dce9e4354 Mon Sep 17 00:00:00 2001 From: Mario Dian Date: Thu, 13 Dec 2018 21:36:19 +0800 Subject: [PATCH] New PoS design --- BTCPayServer.Tests/UnitTest1.cs | 2 + .../Controllers/AppsController.PointOfSale.cs | 5 + .../Controllers/AppsPublicController.cs | 1 + .../UpdatePointOfSaleViewModel.cs | 5 +- .../AppViewModels/ViewPointOfSaleViewModel.cs | 1 + .../Views/Apps/UpdatePointOfSale.cshtml | 5 + .../Views/AppsPublic/ViewPointOfSale.cshtml | 387 ++++++++++--- BTCPayServer/wwwroot/cart/css/style.css | 128 +++++ BTCPayServer/wwwroot/cart/js/cart.jquery.js | 139 ++++- BTCPayServer/wwwroot/cart/js/cart.js | 515 ++++++++++++++---- .../wwwroot/img/icons/icon-128x128.png | Bin 0 -> 3012 bytes .../wwwroot/img/icons/icon-144x144.png | Bin 0 -> 3361 bytes .../wwwroot/img/icons/icon-152x152.png | Bin 0 -> 3598 bytes .../wwwroot/img/icons/icon-192x192.png | Bin 0 -> 4512 bytes .../wwwroot/img/icons/icon-384x384.png | Bin 0 -> 10427 bytes .../wwwroot/img/icons/icon-512x512.png | Bin 0 -> 6457 bytes BTCPayServer/wwwroot/img/icons/icon-72x72.png | Bin 0 -> 1720 bytes BTCPayServer/wwwroot/img/icons/icon-96x96.png | Bin 0 -> 2239 bytes BTCPayServer/wwwroot/img/splash.png | Bin 0 -> 26224 bytes BTCPayServer/wwwroot/manifest.json | 50 ++ 20 files changed, 1004 insertions(+), 234 deletions(-) create mode 100644 BTCPayServer/wwwroot/cart/css/style.css create mode 100755 BTCPayServer/wwwroot/img/icons/icon-128x128.png create mode 100755 BTCPayServer/wwwroot/img/icons/icon-144x144.png create mode 100755 BTCPayServer/wwwroot/img/icons/icon-152x152.png create mode 100755 BTCPayServer/wwwroot/img/icons/icon-192x192.png create mode 100755 BTCPayServer/wwwroot/img/icons/icon-384x384.png create mode 100755 BTCPayServer/wwwroot/img/icons/icon-512x512.png create mode 100755 BTCPayServer/wwwroot/img/icons/icon-72x72.png create mode 100755 BTCPayServer/wwwroot/img/icons/icon-96x96.png create mode 100644 BTCPayServer/wwwroot/img/splash.png create mode 100644 BTCPayServer/wwwroot/manifest.json diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 1d7e4eaba..b16fb7a4a 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -1429,6 +1429,7 @@ namespace BTCPayServer.Tests vmpos.ButtonText = "{0} Purchase"; vmpos.CustomButtonText = "Nicolas Sexy Hair"; vmpos.CustomTipText = "Wanna tip?"; + vmpos.CustomTipPercentages = "15,18,20"; vmpos.Template = @" apple: price: 5.0 @@ -1454,6 +1455,7 @@ donation: Assert.Equal("{0} Purchase", vmview.ButtonText); Assert.Equal("Nicolas Sexy Hair", vmview.CustomButtonText); Assert.Equal("Wanna tip?", vmview.CustomTipText); + Assert.Equal("15,18,20", vmview.CustomTipPercentages); Assert.IsType(publicApps.ViewPointOfSale(appId, 0, null, null, null, null, "orange").Result); // diff --git a/BTCPayServer/Controllers/AppsController.PointOfSale.cs b/BTCPayServer/Controllers/AppsController.PointOfSale.cs index c0245f7ac..ea89e4dd8 100644 --- a/BTCPayServer/Controllers/AppsController.PointOfSale.cs +++ b/BTCPayServer/Controllers/AppsController.PointOfSale.cs @@ -65,6 +65,9 @@ namespace BTCPayServer.Controllers public string CustomButtonText { get; set; } = CUSTOM_BUTTON_TEXT_DEF; public const string CUSTOM_TIP_TEXT_DEF = "Do you want to leave a tip?"; public string CustomTipText { get; set; } = CUSTOM_TIP_TEXT_DEF; + public const string CUSTOM_TIP_PERCENTAGES = "15,18,20"; + public string CustomTipPercentages { get; set; } = CUSTOM_TIP_PERCENTAGES; + public string CustomCSSLink { get; set; } } @@ -87,6 +90,7 @@ namespace BTCPayServer.Controllers ButtonText = settings.ButtonText ?? PointOfSaleSettings.BUTTON_TEXT_DEF, CustomButtonText = settings.CustomButtonText ?? PointOfSaleSettings.CUSTOM_BUTTON_TEXT_DEF, CustomTipText = settings.CustomTipText ?? PointOfSaleSettings.CUSTOM_TIP_TEXT_DEF, + CustomTipPercentages = settings.CustomTipPercentages, CustomCSSLink = settings.CustomCSSLink }; if (HttpContext?.Request != null) @@ -157,6 +161,7 @@ namespace BTCPayServer.Controllers ButtonText = vm.ButtonText, CustomButtonText = vm.CustomButtonText, CustomTipText = vm.CustomTipText, + CustomTipPercentages = vm.CustomTipPercentages, CustomCSSLink = vm.CustomCSSLink }); await UpdateAppSettings(app); diff --git a/BTCPayServer/Controllers/AppsPublicController.cs b/BTCPayServer/Controllers/AppsPublicController.cs index 344ec39fd..7d132e11a 100644 --- a/BTCPayServer/Controllers/AppsPublicController.cs +++ b/BTCPayServer/Controllers/AppsPublicController.cs @@ -65,6 +65,7 @@ namespace BTCPayServer.Controllers ButtonText = settings.ButtonText, CustomButtonText = settings.CustomButtonText, CustomTipText = settings.CustomTipText, + CustomTipPercentages = settings.CustomTipPercentages, CustomCSSLink = settings.CustomCSSLink }); } diff --git a/BTCPayServer/Models/AppViewModels/UpdatePointOfSaleViewModel.cs b/BTCPayServer/Models/AppViewModels/UpdatePointOfSaleViewModel.cs index 6b9964a7e..5a9a3f8ed 100644 --- a/BTCPayServer/Models/AppViewModels/UpdatePointOfSaleViewModel.cs +++ b/BTCPayServer/Models/AppViewModels/UpdatePointOfSaleViewModel.cs @@ -36,8 +36,11 @@ namespace BTCPayServer.Models.AppViewModels public string CustomButtonText { get; set; } [Required] [MaxLength(30)] - [Display(Name = "Do you want to leave a tip?")] + [Display(Name = "Text to display in the tip input")] public string CustomTipText { get; set; } + [MaxLength(30)] + [Display(Name = "Tip percentage amounts (comma separated)")] + public string CustomTipPercentages { get; set; } [MaxLength(500)] [Display(Name = "Custom bootstrap CSS file")] diff --git a/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs b/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs index 47fc3630d..7593ce637 100644 --- a/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs +++ b/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs @@ -45,6 +45,7 @@ namespace BTCPayServer.Models.AppViewModels public string ButtonText { get; set; } public string CustomButtonText { get; set; } public string CustomTipText { get; set; } + public string CustomTipPercentages { get; set; } public string CustomCSSLink { get; set; } } diff --git a/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml b/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml index be9f81fda..654935726 100644 --- a/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml +++ b/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml @@ -72,6 +72,11 @@ +
+ + + +
diff --git a/BTCPayServer/Views/AppsPublic/ViewPointOfSale.cshtml b/BTCPayServer/Views/AppsPublic/ViewPointOfSale.cshtml index 12735bc3f..ce023695b 100644 --- a/BTCPayServer/Views/AppsPublic/ViewPointOfSale.cshtml +++ b/BTCPayServer/Views/AppsPublic/ViewPointOfSale.cshtml @@ -5,6 +5,7 @@ @{ ViewData["Title"] = Model.Title; Layout = null; + String[] tipPercentages = Model.CustomTipPercentages != null ? Model.CustomTipPercentages.Split(',') : null; } @@ -14,6 +15,11 @@ + + + + + @if (Model.CustomCSSLink != null) { @@ -23,125 +29,332 @@ @if (Model.EnableShoppingCart) { + } + + + + + + + + + + + + + @if (Model.EnableShoppingCart) { -