mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-19 06:54:19 +01:00
* Renamed "WithdrawAsync" to "WithdrawToStoreWalletAsync" * WIP * WIP withdrawal + Refactored Form saving to JObject * WIP * Form to fix bad values during withdrawing appears correctly * WIP * Lots of cleanup and refactoring + Password field and toggle password view * Cleanup + Finishing touches on withdrawals * Added "Destination" dummy text as this is always the destination. * Fixed broken test * Added support for withdrawing using qty as a percentage if it ends with "%". Needs more testing. * Fixed broken build * Fixed broken build (2) * Update BTCPayServer/wwwroot/swagger/v1/swagger.template.custodians.json Co-authored-by: d11n <mail@dennisreimann.de> * Update BTCPayServer/wwwroot/swagger/v1/swagger.template.custodians.json Co-authored-by: d11n <mail@dennisreimann.de> * Improved unit tests * Fixed swagger bug * Test improvements Make string conversion of quantity explicitely. * Fix build warnings * Swagger: Add missing operationId * Made change Dennis requested * Removed unused file * Removed incorrect comment * Extra contructor * Renamed client methods * Cleanup config before saving * Fixed broken controller * Refactor custodian * Fix build * Make decimal fields strings to match the rest of Greenfield * Improve parsing of % quantities --------- Co-authored-by: d11n <mail@dennisreimann.de> Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
65 lines
2.1 KiB
C#
65 lines
2.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace BTCPayServer.Abstractions.Form;
|
|
|
|
public class Field
|
|
{
|
|
public static Field Create(string label, string name, string value, bool required, string helpText, string type = "text")
|
|
{
|
|
return new Field
|
|
{
|
|
Label = label,
|
|
Name = name,
|
|
Value = value,
|
|
OriginalValue = value,
|
|
Required = required,
|
|
HelpText = helpText,
|
|
Type = type
|
|
};
|
|
}
|
|
// The name of the HTML5 node. Should be used as the key for the posted data.
|
|
public string Name;
|
|
|
|
public bool Constant;
|
|
|
|
// HTML5 compatible type string like "text", "textarea", "email", "password", etc.
|
|
public string Type;
|
|
|
|
public static Field CreateFieldset()
|
|
{
|
|
return new Field { Type = "fieldset" };
|
|
}
|
|
|
|
// The value field is what is currently in the DB or what the user entered, but possibly not saved yet due to validation errors.
|
|
// If this is the first the user sees the form, then value and original value are the same. Value changes as the user starts interacting with the form.
|
|
public string Value;
|
|
|
|
public bool Required;
|
|
|
|
// The translated label of the field.
|
|
public string Label;
|
|
|
|
// The original value is the value that is currently saved in the backend. A "reset" button can be used to revert back to this. Should only be set from the constructor.
|
|
public string OriginalValue;
|
|
|
|
// A useful note shown below the field or via a tooltip / info icon. Should be translated for the user.
|
|
public string HelpText;
|
|
|
|
[JsonExtensionData] public IDictionary<string, JToken> AdditionalData { get; set; }
|
|
public List<Field> Fields { get; set; } = new ();
|
|
|
|
// The field is considered "valid" if there are no validation errors
|
|
public List<string> ValidationErrors = new ();
|
|
|
|
public virtual bool IsValid()
|
|
{
|
|
return ValidationErrors.Count == 0 && Fields.All(field => field.IsValid());
|
|
}
|
|
}
|