mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-23 12:08:32 +00:00
Add opening form CreateToken
This commit is contained in:
parent
4853c3387a
commit
b529f55ea9
10
NftFaucetRadzen/Models/NewFileModel.cs
Normal file
10
NftFaucetRadzen/Models/NewFileModel.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace NftFaucetRadzen.Models;
|
||||
|
||||
public class NewFileModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string FileData { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public long? FileSize { get; set; }
|
||||
}
|
@ -2,5 +2,16 @@
|
||||
|
||||
<PageTitle>Create token</PageTitle>
|
||||
<RadzenContent Container="main">
|
||||
<RadzenHeading Size="H1" Text="Create new token" />
|
||||
<h4 class="mb-4">Image</h4>
|
||||
<RadzenFileInput @bind-Value=@Model.FileData @bind-FileName=@Model.FileName @bind-FileSize=@Model.FileSize TValue="string" Class="w-100"/>
|
||||
<h4 class="mb-4">Name</h4>
|
||||
<RadzenTextBox Placeholder="Name..." MaxLength="50" @bind-Value="@Model.Name" Class="w-100" />
|
||||
<h4 class="mb-4">Description</h4>
|
||||
<RadzenTextArea MaxLength="250" @bind-Value="@Model.Description" Class="w-100"/>
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<RadzenButton Click="@((args) => DialogService.Close())" ButtonStyle="ButtonStyle.Secondary" Text="Cancel" Style="width: 120px" Class="mr-1" />
|
||||
<RadzenButton Click="@((args) => OnSavePressed())" Disabled="!ModelIsValid" Text="Save" Style="width: 120px" />
|
||||
</div>
|
||||
</div>
|
||||
</RadzenContent>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Microsoft.JSInterop;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using NftFaucetRadzen.Models;
|
||||
using Radzen;
|
||||
|
||||
namespace NftFaucetRadzen.Pages;
|
||||
@ -23,4 +24,35 @@ public partial class CreateTokenPage
|
||||
|
||||
[Inject]
|
||||
protected NotificationService NotificationService { get; set; }
|
||||
|
||||
private NewFileModel Model { get; set; } = new NewFileModel();
|
||||
private bool ModelIsValid => IsValid();
|
||||
|
||||
private void OnSavePressed()
|
||||
{
|
||||
if (!IsValid())
|
||||
return;
|
||||
|
||||
DialogService.Close(Model);
|
||||
}
|
||||
|
||||
private bool IsValid()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Model.Name))
|
||||
return false;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Model.Description))
|
||||
return false;
|
||||
|
||||
if (string.IsNullOrEmpty(Model.FileData))
|
||||
return false;
|
||||
|
||||
if (string.IsNullOrEmpty(Model.FileName))
|
||||
return false;
|
||||
|
||||
if (Model.FileSize is null or 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
<RadzenHeading Size="H1" Text="Select or create a token to mint" />
|
||||
<div style="width: 100%; display: flex; flex-direction: row; justify-content: end;">
|
||||
<RadzenButton Text="Create New" Icon="add_circle_outline" ButtonStyle="ButtonStyle.Secondary"
|
||||
Click="@(() => NotificationService.Notify(NotificationSeverity.Warning, "NOT IMPLEMENTED", "Will be implemented later"))" />
|
||||
Click="@OpenCreateTokenDialog" />
|
||||
</div>
|
||||
<CardList Data="@Data" @bind-SelectedItems="@AppState.Storage.SelectedTokens" />
|
||||
</RadzenContent>
|
||||
|
@ -68,4 +68,11 @@ public partial class TokensPage : BasicComponent
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
private async Task OpenCreateTokenDialog()
|
||||
{
|
||||
await DialogService.OpenAsync<CreateTokenPage>("Create new token",
|
||||
new Dictionary<string, object>(),
|
||||
new DialogOptions() { Width = "700px", Height = "570px", Resizable = true, Draggable = true });
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user