mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 09:54:30 +01:00
POS: Replace EnableShoppingCart with DefaultView
This commit is contained in:
parent
5b4fec11ed
commit
fad53a9fa2
@ -378,7 +378,7 @@ namespace BTCPayServer.Tests
|
||||
s.Driver.FindElement(By.Id("SelectedAppType")).SendKeys("PointOfSale" + Keys.Enter);
|
||||
s.Driver.FindElement(By.Id("SelectedStore")).SendKeys(store + Keys.Enter);
|
||||
s.Driver.FindElement(By.Id("Create")).Click();
|
||||
s.Driver.FindElement(By.Id("EnableShoppingCart")).Click();
|
||||
s.Driver.FindElement(By.Id("DefaultView")).SendKeys("Cart" + Keys.Enter);
|
||||
s.Driver.FindElement(By.Id("SaveSettings")).ForceClick();
|
||||
s.Driver.FindElement(By.Id("ViewApp")).ForceClick();
|
||||
s.Driver.SwitchTo().Window(s.Driver.WindowHandles.Last());
|
||||
|
@ -4,12 +4,9 @@ using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Data;
|
||||
using BTCPayServer.Models.AppViewModels;
|
||||
using BTCPayServer.Services.Apps;
|
||||
using BTCPayServer.Services.Mails;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BTCPayServer.Controllers
|
||||
{
|
||||
@ -55,7 +52,7 @@ namespace BTCPayServer.Controllers
|
||||
" image: https://cdn.pixabay.com/photo/2016/09/16/11/24/darts-1673812__480.jpg\n" +
|
||||
" inventory: 5\n" +
|
||||
" custom: true";
|
||||
EnableShoppingCart = false;
|
||||
DefaultView = PosViewType.Static;
|
||||
ShowCustomAmount = true;
|
||||
ShowDiscount = true;
|
||||
EnableTips = true;
|
||||
@ -63,7 +60,7 @@ namespace BTCPayServer.Controllers
|
||||
public string Title { get; set; }
|
||||
public string Currency { get; set; }
|
||||
public string Template { get; set; }
|
||||
public bool EnableShoppingCart { get; set; }
|
||||
public PosViewType DefaultView { get; set; }
|
||||
public bool ShowCustomAmount { get; set; }
|
||||
public bool ShowDiscount { get; set; }
|
||||
public bool EnableTips { get; set; }
|
||||
@ -101,7 +98,7 @@ namespace BTCPayServer.Controllers
|
||||
Id = appId,
|
||||
StoreId = app.StoreDataId,
|
||||
Title = settings.Title,
|
||||
EnableShoppingCart = settings.EnableShoppingCart,
|
||||
DefaultView = settings.DefaultView,
|
||||
ShowCustomAmount = settings.ShowCustomAmount,
|
||||
ShowDiscount = settings.ShowDiscount,
|
||||
EnableTips = settings.EnableTips,
|
||||
@ -179,7 +176,7 @@ namespace BTCPayServer.Controllers
|
||||
app.SetSettings(new PointOfSaleSettings()
|
||||
{
|
||||
Title = vm.Title,
|
||||
EnableShoppingCart = vm.EnableShoppingCart,
|
||||
DefaultView = vm.DefaultView,
|
||||
ShowCustomAmount = vm.ShowCustomAmount,
|
||||
ShowDiscount = vm.ShowDiscount,
|
||||
EnableTips = vm.EnableTips,
|
||||
|
@ -57,7 +57,7 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
Title = settings.Title,
|
||||
Step = step.ToString(CultureInfo.InvariantCulture),
|
||||
EnableShoppingCart = settings.EnableShoppingCart,
|
||||
DefaultView = settings.DefaultView,
|
||||
ShowCustomAmount = settings.ShowCustomAmount,
|
||||
ShowDiscount = settings.ShowDiscount,
|
||||
EnableTips = settings.EnableTips,
|
||||
@ -106,7 +106,7 @@ namespace BTCPayServer.Controllers
|
||||
if (app == null)
|
||||
return NotFound();
|
||||
var settings = app.GetSettings<PointOfSaleSettings>();
|
||||
if (string.IsNullOrEmpty(choiceKey) && !settings.ShowCustomAmount && !settings.EnableShoppingCart)
|
||||
if (string.IsNullOrEmpty(choiceKey) && !settings.ShowCustomAmount && settings.DefaultView != PosViewType.Cart)
|
||||
{
|
||||
return RedirectToAction(nameof(ViewPointOfSale), new { appId = appId });
|
||||
}
|
||||
@ -141,14 +141,14 @@ namespace BTCPayServer.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!settings.ShowCustomAmount && !settings.EnableShoppingCart)
|
||||
if (!settings.ShowCustomAmount && settings.DefaultView != PosViewType.Cart)
|
||||
return NotFound();
|
||||
price = amount;
|
||||
title = settings.Title;
|
||||
|
||||
//if cart IS enabled and we detect posdata that matches the cart system's, check inventory for the items
|
||||
if (!string.IsNullOrEmpty(posData) &&
|
||||
settings.EnableShoppingCart &&
|
||||
settings.DefaultView == PosViewType.Cart &&
|
||||
AppService.TryParsePosCartItems(posData, out var cartItems))
|
||||
{
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using BTCPayServer.Services.Apps;
|
||||
using BTCPayServer.Validation;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
@ -16,8 +17,8 @@ namespace BTCPayServer.Models.AppViewModels
|
||||
public string Currency { get; set; }
|
||||
public string Template { get; set; }
|
||||
|
||||
[Display(Name = "Enable shopping cart")]
|
||||
public bool EnableShoppingCart { get; set; }
|
||||
[Display(Name = "Default view")]
|
||||
public PosViewType DefaultView { get; set; }
|
||||
[Display(Name = "User can input custom amount")]
|
||||
public bool ShowCustomAmount { get; set; }
|
||||
[Display(Name = "User can input discount in %")]
|
||||
|
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Services.Apps;
|
||||
|
||||
namespace BTCPayServer.Models.AppViewModels
|
||||
{
|
||||
@ -36,7 +33,9 @@ namespace BTCPayServer.Models.AppViewModels
|
||||
|
||||
public CurrencyInfoData CurrencyInfo { get; set; }
|
||||
|
||||
public bool EnableShoppingCart { get; set; }
|
||||
public PosViewType DefaultView { get; set; }
|
||||
|
||||
public bool IsCartView { get { return DefaultView == PosViewType.Cart; } }
|
||||
public bool ShowCustomAmount { get; set; }
|
||||
public bool ShowDiscount { get; set; }
|
||||
public bool EnableTips { get; set; }
|
||||
|
@ -10,4 +10,10 @@ namespace BTCPayServer.Services.Apps
|
||||
PointOfSale,
|
||||
Crowdfund
|
||||
}
|
||||
|
||||
public enum PosViewType
|
||||
{
|
||||
Static,
|
||||
Cart
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
@addTagHelper *, BundlerMinifier.TagHelpers
|
||||
@using BTCPayServer.Services.Apps
|
||||
@addTagHelper *, BundlerMinifier.TagHelpers
|
||||
@model UpdatePointOfSaleViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Update Point of Sale";
|
||||
@ -35,10 +36,10 @@
|
||||
<span asp-validation-for="Currency" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-check">
|
||||
<input asp-for="EnableShoppingCart" type="checkbox" class="form-check-input" />
|
||||
<label asp-for="EnableShoppingCart" class="form-check-label"></label>
|
||||
<span asp-validation-for="EnableShoppingCart" class="text-danger"></span>
|
||||
<div class="form-group">
|
||||
<label asp-for="DefaultView" class="control-label"></label>*
|
||||
<select asp-for="DefaultView" asp-items="@Html.GetEnumSelectList<PosViewType>()" class="form-control"></select>
|
||||
<span asp-validation-for="DefaultView" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input asp-for="ShowCustomAmount" type="checkbox" class="form-check-input" />
|
||||
|
@ -1,4 +1,5 @@
|
||||
@addTagHelper *, BundlerMinifier.TagHelpers
|
||||
@using BTCPayServer.Services.Apps
|
||||
@addTagHelper *, BundlerMinifier.TagHelpers
|
||||
@inject BTCPayServer.HostedServices.CssThemeManager themeManager
|
||||
|
||||
@model BTCPayServer.Models.AppViewModels.ViewPointOfSaleViewModel
|
||||
@ -29,7 +30,7 @@
|
||||
}
|
||||
<link href="~/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" asp-append-version="true" />
|
||||
|
||||
@if (Model.EnableShoppingCart)
|
||||
@if (Model.IsCartView)
|
||||
{
|
||||
<link rel="stylesheet" href="~/cart/css/style.css" asp-append-version="true">
|
||||
<script type="text/javascript">
|
||||
@ -206,7 +207,7 @@
|
||||
<partial name="_StatusMessage" />
|
||||
}
|
||||
|
||||
@if (Model.EnableShoppingCart)
|
||||
@if (Model.IsCartView)
|
||||
{
|
||||
<div id="cartModal" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
|
Loading…
Reference in New Issue
Block a user