forked from btcpayserver/btcpayserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Custom Forms * Update BTCPayServer.Data/Migrations/20230125085242_AddForms.cs * Cleanups * Explain public form * Add store branding * Add form name to POS form * add tests * fix migration * Minor cleanups * Code improvements * Add form validation Closes btcpayserver#4317. * Adapt form validation for Bootstrap 5 * update logic for forms * pr changes * Minor code cleanup * Remove unused parameters * Refactor Form data handling to avoid O(n3) issues * Rename Hidden to Constant * Pre-populate FormView from the query string params * Fix test --------- Co-authored-by: d11n <[email protected]> Co-authored-by: nicolas.dorier <[email protected]>
- Loading branch information
1 parent
60f84d5
commit bbbaacc
Showing
30 changed files
with
1,157 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
|
||
namespace BTCPayServer.Data.Data; | ||
|
||
public class FormData | ||
{ | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
public string Id { get; set; } | ||
public string Name { get; set; } | ||
public string StoreId { get; set; } | ||
public StoreData Store { get; set; } | ||
public string Config { get; set; } | ||
public bool Public { get; set; } | ||
|
||
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade) | ||
{ | ||
builder.Entity<FormData>() | ||
.HasOne(o => o.Store) | ||
.WithMany(o => o.Forms).OnDelete(DeleteBehavior.Cascade); | ||
builder.Entity<FormData>().HasIndex(o => o.StoreId); | ||
|
||
if (databaseFacade.IsNpgsql()) | ||
{ | ||
builder.Entity<FormData>() | ||
.Property(o => o.Config) | ||
.HasColumnType("JSONB"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using BTCPayServer.Data; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; | ||
|
||
#nullable disable | ||
|
||
namespace BTCPayServer.Migrations | ||
{ | ||
[DbContext(typeof(ApplicationDbContext))] | ||
[Migration("20230125085242_AddForms")] | ||
public partial class AddForms : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
int? maxlength = migrationBuilder.IsMySql() ? 255 : null; | ||
migrationBuilder.CreateTable( | ||
name: "Forms", | ||
columns: table => new | ||
{ | ||
Id = table.Column<string>(type: "TEXT", nullable: false, maxLength: maxlength), | ||
Name = table.Column<string>(type: "TEXT", nullable: true, maxLength: maxlength), | ||
StoreId = table.Column<string>(type: "TEXT", nullable: true, maxLength: maxlength), | ||
Config = table.Column<string>(type: migrationBuilder.IsNpgsql() ? "JSONB" : "TEXT", nullable: true), | ||
Public = table.Column<bool>(nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Forms", x => x.Id); | ||
table.ForeignKey( | ||
name: "FK_Forms_Stores_StoreId", | ||
column: x => x.StoreId, | ||
principalTable: "Stores", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Cascade); | ||
}); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_Forms_StoreId", | ||
table: "Forms", | ||
column: "StoreId"); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Forms"); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.