Add contribution payment options to registries

- Added support for single and amount-specific QR codes.
- Updated `RegistrySettings` model and database schema.
- Enhanced `RegistryAdmin` to configure payment options.
- Introduced `RegistryContributionAmount` for partial fulfillment.
- Updated `RegistryPublic` to display contribution progress.
- Added new models for payment methods and QR code handling.
- Improved privacy by limiting contributor visibility.
This commit is contained in:
Arne Moerman
2026-05-18 23:33:06 +02:00
parent 7dd7b0342f
commit c36e04029b
14 changed files with 1211 additions and 21 deletions
@@ -39,6 +39,9 @@ public partial class RegistryAdmin : ComponentBase
builder.AddMarkupContent(3, "<span class='ql-formats'><button class='ql-link'></button><button class='ql-clean'></button></span>");
};
private bool _pendingEditorLoad;
private string? _lastLoadedHeaderContentHtml;
protected override async Task OnParametersSetAsync()
{
var userId = await RegistryUserContext.GetUserIdAsync(CancellationToken.None).ConfigureAwait(false);
@@ -60,14 +63,16 @@ public partial class RegistryAdmin : ComponentBase
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender || TextEditor is null || string.IsNullOrWhiteSpace(SettingsModel.HeaderContentHtml))
if (TextEditor is null || !_pendingEditorLoad)
{
return;
}
try
{
await TextEditor.LoadHTMLContent(SettingsModel.HeaderContentHtml).ConfigureAwait(false);
await TextEditor.LoadHTMLContent(SettingsModel.HeaderContentHtml ?? string.Empty).ConfigureAwait(false);
_lastLoadedHeaderContentHtml = SettingsModel.HeaderContentHtml ?? string.Empty;
_pendingEditorLoad = false;
}
catch (JSException)
{
@@ -229,6 +234,17 @@ public partial class RegistryAdmin : ComponentBase
Admins = await RegistryService.GetRegistryAdminsAsync(RegistryId, CancellationToken.None).ConfigureAwait(false);
}
protected void AddContributionAmountQrCode()
{
SettingsModel.ContributionAmountQrCodes.Add(new ContributionAmountQrCodeModel());
}
protected void RemoveContributionAmountQrCode(ContributionAmountQrCodeModel model)
{
ArgumentNullException.ThrowIfNull(model);
SettingsModel.ContributionAmountQrCodes.Remove(model);
}
private async Task LoadAsync()
{
var settings = await RegistryService.GetRegistrySettingsAsync(RegistryId, CancellationToken.None).ConfigureAwait(false);
@@ -244,6 +260,11 @@ public partial class RegistryAdmin : ComponentBase
SettingsModel.BankAccountIban = settings.BankAccountIban;
SettingsModel.BankAccountBic = settings.BankAccountBic;
SettingsModel.ShowBankAccountName = settings.ShowBankAccountName;
SettingsModel.ContributionQrCodeUrl = settings.ContributionQrCodeUrl;
SettingsModel.ContributionAmountQrCodes = settings.ContributionAmountQrCodes;
var currentHeaderContent = SettingsModel.HeaderContentHtml ?? string.Empty;
_pendingEditorLoad = currentHeaderContent != _lastLoadedHeaderContentHtml;
}
Admins = await RegistryService.GetRegistryAdminsAsync(RegistryId, CancellationToken.None).ConfigureAwait(false);