mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add books admin page.
This commit is contained in:
211
Marechai/Pages/Admin/Details/Book.razor
Normal file
211
Marechai/Pages/Admin/Details/Book.razor
Normal file
@@ -0,0 +1,211 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
}
|
||||
|
||||
@page "/admin/books/details/{Id:long}"
|
||||
@page "/admin/books/edit/{Id:long}"
|
||||
@page "/admin/books/create"
|
||||
@using Marechai.Database
|
||||
@using Marechai.Database.Models
|
||||
@inherits OwningComponentBase<BooksService>
|
||||
@inject IStringLocalizer<BooksService> L
|
||||
@inject Iso31661NumericService CountriesService
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IWebHostEnvironment Host
|
||||
@inject IJSRuntime JSRuntime
|
||||
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
|
||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||
@attribute [Authorize(Roles = "UberAdmin, Admin")]
|
||||
|
||||
|
||||
<h3>@L["Book details"]</h3>
|
||||
<hr />
|
||||
|
||||
@if (!_loaded)
|
||||
{
|
||||
<p align="center">@L["Loading..."]</p>
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
<div>
|
||||
<Field>
|
||||
<FieldLabel>@L["Title using latin script"]</FieldLabel>
|
||||
<Validation Validator="@ValidateTitle">
|
||||
<TextEdit ReadOnly="!_editing" @bind-Text="@_model.Title">
|
||||
<Feedback>
|
||||
<ValidationError>@L["Please enter a valid title."]</ValidationError>
|
||||
</Feedback>
|
||||
</TextEdit>
|
||||
</Validation>
|
||||
</Field>
|
||||
@if (_editing || _model.NativeTitle != null)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Native title, that is, title using native script (cyrillic, chinese, etc)"]</FieldLabel>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownNativeTitle">@L["Unknown (native title)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownNativeTitle)
|
||||
{
|
||||
<Validation Validator="@ValidateNativeTitle">
|
||||
<TextEdit Disabled="!_editing" @bind-Text="@_model.NativeTitle">
|
||||
<Feedback>
|
||||
<ValidationError>@L["Please enter a valid native title."]</ValidationError>
|
||||
</Feedback>
|
||||
</TextEdit>
|
||||
</Validation>
|
||||
}
|
||||
</Field>
|
||||
}
|
||||
@if (_editing || _model.Published != null)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Published"]</FieldLabel>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownPublished">@L["Unknown (publication date)"]</Check>
|
||||
}
|
||||
@if (!_editing || !_unknownPublished)
|
||||
{
|
||||
<Validation Validator="@ValidatePublished">
|
||||
<DateEdit TValue="DateTime?" ReadOnly="!_editing" @bind-Date="@_model.Published" >
|
||||
<Feedback>
|
||||
<ValidationError>@L["Please enter a valid publication date."]</ValidationError>
|
||||
</Feedback>
|
||||
</DateEdit>
|
||||
</Validation>
|
||||
}
|
||||
</Field>
|
||||
}
|
||||
@if (_editing || _model.CountryId != null)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Country of publication"]</FieldLabel>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownCountry">@L["Unknown (country of publication)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownCountry)
|
||||
{
|
||||
<Select Disabled="!_editing" TValue="short?" @bind-SelectedValue="@_model.CountryId">
|
||||
@foreach (var country in _countries)
|
||||
{
|
||||
<SelectItem TValue="short?" Value="@country.Id">@country.Name</SelectItem>
|
||||
}
|
||||
</Select>
|
||||
}
|
||||
</Field>
|
||||
}
|
||||
@if (_editing || _model.Isbn != null)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["ISBN"]</FieldLabel>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownIsbn">@L["Unknown (ISBN)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownIsbn)
|
||||
{
|
||||
<Validation Validator="@ValidateIsbn">
|
||||
<TextEdit ReadOnly="!_editing" @bind-Text="@_model.Isbn">
|
||||
<Feedback>
|
||||
<ValidationError>@L["Please enter a valid ISBN."]</ValidationError>
|
||||
</Feedback>
|
||||
</TextEdit>
|
||||
</Validation>
|
||||
}
|
||||
</Field>
|
||||
}
|
||||
@if (_editing || _model.Pages.HasValue)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Pages"]</FieldLabel>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownPages">@L["Unknown (pages)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownPages)
|
||||
{
|
||||
<Validation Validator="@ValidatePages">
|
||||
<NumericEdit Disabled="!_editing" TValue="short?" Decimals="0" @bind-Value="@_model.Pages">
|
||||
<Feedback>
|
||||
<ValidationError>@L["Please enter a valid number of pages."]</ValidationError>
|
||||
</Feedback>
|
||||
</NumericEdit>
|
||||
</Validation>
|
||||
}
|
||||
</Field>
|
||||
}
|
||||
@if (_editing || _model.Edition.HasValue)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Edition"]</FieldLabel>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownEdition">@L["Unknown (edition)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownEdition)
|
||||
{
|
||||
<Validation Validator="@ValidateEdition">
|
||||
<NumericEdit Disabled="!_editing" TValue="int?" Decimals="0" @bind-Value="@_model.Edition">
|
||||
<Feedback>
|
||||
<ValidationError>@L["Please enter a valid edition number."]</ValidationError>
|
||||
</Feedback>
|
||||
</NumericEdit>
|
||||
</Validation>
|
||||
}
|
||||
</Field>
|
||||
}
|
||||
@{
|
||||
// TODO: Source book
|
||||
}
|
||||
@{
|
||||
// TODO: Link to previous edition
|
||||
}
|
||||
</div>
|
||||
<div>
|
||||
@if (!_editing)
|
||||
{
|
||||
<Button Color="Color.Primary" Clicked="@OnEditClicked">@L["Edit"]</Button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Button Color="Color.Success" Clicked="@OnSaveClicked">@L["Save"]</Button>
|
||||
<Button Color="Color.Danger" Clicked="@OnCancelClicked">@L["Cancel"]</Button>
|
||||
}
|
||||
<a href="/admin/books" class="btn btn-secondary">@L["Back to list"]</a>
|
||||
</div>
|
||||
|
||||
@{
|
||||
// TODO: Book synopsis
|
||||
}
|
||||
Reference in New Issue
Block a user