mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
* re-ordering * adds section header * updates label on "products" * changes button to primary * moves description * updates partial * re-ordering + section headers * more section heads and ordering * redorders * Toggle custom amount and tips settings * Use display name for point of sale app type * Use switches for enabling options * Add space before required indicator * Set and consolidate view model display names * Move redirects and custom CSS to additional options * Revert to checkbox for discounts * adds padding * removes bs-parent for multiple open elements on accordion * adds helper text to discount checkbox * updates "default view" label text * wording cleanup * more wording adjustments * updates * Add display names for app types * Extract template editor inline styles * updates helper text * Display names for app types * Typo fix * Move template back to editor * Fix selenium test Co-authored-by: Dennis Reimann <mail@dennisreimann.de>
59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using BTCPayServer.Data;
|
|
using BTCPayServer.Services.Apps;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
namespace BTCPayServer.Models.AppViewModels
|
|
{
|
|
public class CreateAppViewModel
|
|
{
|
|
public CreateAppViewModel()
|
|
{
|
|
SetApps();
|
|
}
|
|
class Format
|
|
{
|
|
public string Name { get; set; }
|
|
public string Value { get; set; }
|
|
}
|
|
[Required]
|
|
[MaxLength(50)]
|
|
[MinLength(1)]
|
|
public string Name { get; set; }
|
|
|
|
[Display(Name = "Store")]
|
|
public string SelectedStore { get; set; }
|
|
|
|
public void SetStores(StoreData[] stores)
|
|
{
|
|
var defaultStore = stores[0].Id;
|
|
var choices = stores.Select(o => new Format() { Name = o.StoreName, Value = o.Id }).ToArray();
|
|
var chosen = choices.FirstOrDefault(f => f.Value == defaultStore) ?? choices.FirstOrDefault();
|
|
Stores = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen);
|
|
SelectedStore = chosen.Value;
|
|
}
|
|
|
|
public SelectList Stores { get; set; }
|
|
|
|
[Display(Name = "App type")]
|
|
public string SelectedAppType { get; set; }
|
|
|
|
public SelectList AppTypes { get; set; }
|
|
|
|
void SetApps()
|
|
{
|
|
var defaultAppType = AppType.PointOfSale.ToString();
|
|
var choices = typeof(AppType).GetEnumNames().Select(o => new Format
|
|
{
|
|
Name = typeof(AppType).DisplayName(o),
|
|
Value = o
|
|
}).ToArray();
|
|
var chosen = choices.FirstOrDefault(f => f.Value == defaultAppType) ?? choices.FirstOrDefault();
|
|
AppTypes = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen);
|
|
SelectedAppType = chosen.Value;
|
|
}
|
|
|
|
}
|
|
}
|