Gremlin/Gremlin_BlazorServer/Pages/Accounts.razor

130 lines
6.7 KiB
Plaintext

@page "/Accounts"
@inject GenericController GenericController
@using Gremlin_BlazorServer.Services
@using Gremlin_BlazorServer.Data.EntityClasses
@inherits LayoutComponentBase
@inject GenericImporter GenericImporter
@inject ILoadingIndicatorService ApplicationLoadingIndicatorService
<AuthorizeView>
<Authorized Context="_">
<Div Margin="Margin.Is3"
Border="Border.Dark.OnAll"
Padding="Padding.Is3"
style="box-shadow: 10px 10px #343A40">
<Heading Size="HeadingSize.Is4">Accounts</Heading>
<Paragraph>
<DataGrid TItem="Account"
Data="@accounts"
SelectedRow="@selectedAccount"
SelectedRowChanged="@OnSelectedAccountChanged"
RowInserted="@OnRowInsertedAsync"
RowUpdated="@OnRowUpdatedAsync"
RowRemoved="@OnRowRemovedAsync"
CommandMode="DataGridCommandMode.ButtonRow"
EditMode="DataGridEditMode.Popup"
UseValidation Narrow Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridColumns>
<DataGridCommandColumn NewCommandAllowed="false" EditCommandAllowed="false" DeleteCommandAllowed="false">
<SaveCommandTemplate>
<Button ElementId="btnSave" PreventDefaultOnSubmit Color="Color.Primary" Clicked="context.Clicked">@context.LocalizationString</Button>
</SaveCommandTemplate>
<CancelCommandTemplate>
<Button ElementId="btnCancel" Color="Color.Secondary" Clicked="context.Clicked">@context.LocalizationString</Button>
</CancelCommandTemplate>
</DataGridCommandColumn>
<DataGridColumn Field="@nameof(Account.AccountId)" Caption="AccountId" Filterable Sortable/>
<DataGridColumn Field="@nameof(Account.AccountName)" Caption="AccountName" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Account.Street)" Caption="Street" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Account.Zip)" Caption="Zip" Filterable Sortable Editable>
<EditTemplate>
<NumericEdit TValue="uint" Value="Convert.ToUInt32(context.CellValue)" ValueChanged="v => context.CellValue = v"/>
</EditTemplate>
</DataGridColumn>
<DataGridColumn Field="@nameof(Account.City)" Caption="City" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Account.PhoneNumber)" Caption="PhoneNumber" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Account.EMail)" Caption="EMail" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Account.FaxNumber)" Caption="FaxNumber" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Account.Webpage)" Caption="Webpage" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Account.SapAccountNumber)" Caption="SapAccountNumber" Filterable Sortable Editable>
<EditTemplate>
<NumericEdit TValue="uint" Value="Convert.ToUInt32(context.CellValue)" ValueChanged="v => context.CellValue = v"/>
</EditTemplate>
</DataGridColumn>
<DataGridColumn Field="@nameof(Account.DataModificationDate)" Caption="DataModificationDate" Filterable Sortable/>
</DataGridColumns>
<ButtonRowTemplate>
<Button Color="Color.Primary" Clicked="context.NewCommand.Clicked">New</Button>
<Button Color="Color.Warning" Disabled="selectedAccount is null" Clicked="context.EditCommand.Clicked">Edit</Button>
<Button Color="Color.Danger" Disabled="selectedAccount is null" Clicked="context.DeleteCommand.Clicked">Delete</Button>
<Button Color="Color.Secondary" Clicked="context.ClearFilterCommand.Clicked">Clear Filter</Button>
</ButtonRowTemplate>
</DataGrid>
</Paragraph>
</Div>
@if (selectedAccount != null) {
<Div Margin="Margin.Is3"
Border="Border.Dark.OnAll"
Padding="Padding.Is3"
style="box-shadow: 10px 10px #343A40">
<Heading Size="HeadingSize.Is5">Contacts in @selectedAccount.AccountName</Heading>
<Paragraph>
<DataGrid TItem="Contact" Data="@selectedAccount.Contacts" UseValidation Narrow FixedHeader ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn/>
<DataGridColumn Field="@nameof(Contact.AccountId)" Caption="AccountId" Filterable Sortable/>
<DataGridColumn Field="@nameof(Contact.LastName)" Caption="LastName" Filterable Sortable/>
<DataGridColumn Field="@nameof(Contact.FirstName)" Caption="FirstName" Filterable Sortable/>
<DataGridColumn Field="@nameof(Contact.Gender)" Caption="Gender" Filterable Sortable/>
<DataGridColumn Field="@nameof(Contact.EMail)" Caption="EMail" Filterable Sortable/>
</DataGrid>
</Paragraph>
</Div>
}
<Div Margin="Margin.Is3"
Border="Border.Dark.OnAll"
Padding="Padding.Is3"
style="box-shadow: 10px 10px #343A40">
<Heading Size="HeadingSize.Is6">Import Accounts from CSV</Heading>
<Paragraph>
<Field>
<FileEdit Filter=".csv" Changed="@OnImportAccounts"/>
</Field>
</Paragraph>
<Paragraph>
<Progress>
<ProgressBar Animated Value="@ImportProgress"/>
</Progress>
</Paragraph>
</Div>
</Authorized>
<NotAuthorized>
<Div Margin="Margin.Is3"
Border="Border.Dark.OnAll"
Padding="Padding.Is3"
style="box-shadow: 10px 10px #343A40">
<Heading Size="HeadingSize.Is3">Authentication Failure!</Heading>
<Paragraph>You're not signed in. Please click on the upper right to either register or log in.</Paragraph>
</Div>
</NotAuthorized>
</AuthorizeView>