Skip to content

Instantly share code, notes, and snippets.

@explorer14
Last active January 10, 2021 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save explorer14/06e396238fae8e90b47a4f9d1e576992 to your computer and use it in GitHub Desktop.
Save explorer14/06e396238fae8e90b47a4f9d1e576992 to your computer and use it in GitHub Desktop.
<MatDialog @bind-IsOpen="@IsDialogOpen">
<MatDialogTitle>Create expense for <b>@SelectedPot.PotName</b></MatDialogTitle>
<MatDialogContent>
<MatDatePicker Label="Expense Date"
Required="true"
@bind-Value="@Expense.Date"
Format="dd/MM/yyyy"></MatDatePicker>
<MatTextField Label="Description"
Required="true"
@bind-Value="@Expense.Description"></MatTextField>
<MatTextField Label="Spend"
Required="true"
@bind-Value="@Expense.Spend"></MatTextField>
</MatDialogContent>
<MatDialogActions>
<MatButton OnClick="@(async e =>
{
await OnDialogClosing.InvokeAsync();
CloseDialog();
})">Cancel</MatButton>
<MatButton OnClick="@(async e =>
{
Expense.PotId = SelectedPot.PotId;
await OnAddNewExpense.InvokeAsync(
new NewExpenseEventArgs(Expense));
})">Save</MatButton>
</MatDialogActions>
</MatDialog>
@code {
[Parameter]
public bool IsDialogOpen { get; set; }
[Parameter]
public SelectedPot SelectedPot { get; set; }
[Parameter]
public EventCallback<NewExpenseEventArgs> OnAddNewExpense { get; set; }
[Parameter]
public EventCallback OnDialogClosing { get; set; }
private NewExpense Expense { get; set; }
= new NewExpense();
private void CloseDialog() => IsDialogOpen = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment