Files
marechai/Marechai/Pages/Admin/Details/Person.razor

258 lines
9.1 KiB
Plaintext
Raw Normal View History

2020-05-26 03:02:50 +01:00
@{
2020-12-20 21:34:13 +00:00
/******************************************************************************
2020-05-26 03:02:50 +01:00
// 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/people/details/{Id:int}"
2020-05-27 13:38:05 +01:00
@page "/admin/people/edit/{Id:int}"
2020-05-28 03:05:21 +01:00
@page "/admin/people/create"
@using Marechai.Database.Models
2020-05-26 03:02:50 +01:00
@inherits OwningComponentBase<PeopleService>
@inject IStringLocalizer<PeopleService> L
@inject Iso31661NumericService CountriesService
2020-05-27 13:38:05 +01:00
@inject NavigationManager NavigationManager
2020-12-20 21:34:13 +00:00
@inject UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
2020-05-26 03:02:50 +01:00
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Person details"]</h3>
<hr />
2020-12-20 21:34:13 +00:00
@if(!_loaded)
2020-05-26 03:02:50 +01:00
{
<p align="center">@L["Loading..."]</p>
return;
}
<div>
2020-12-20 21:34:13 +00:00
@if(_editing || _model.Name != null)
2020-05-26 03:02:50 +01:00
{
<Field>
<FieldLabel>@L["Name"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownName" @TValue="bool">@L["Unknown (name)"]</Check>
}
@if(!_editing ||
!_unknownName)
2020-05-27 13:38:05 +01:00
{
<Validation Validator="@ValidateName">
2020-12-20 21:34:13 +00:00
<TextEdit @bind-Text="@_model.Name" ReadOnly="!_editing">
2020-05-27 13:38:05 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid name."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-26 03:02:50 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
@if(_editing || _model.Surname != null)
2020-05-26 03:02:50 +01:00
{
<Field>
<FieldLabel>@L["Surname"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownSurname" @TValue="bool">@L["Unknown (surname)"]</Check>
}
@if(!_editing ||
!_unknownSurname)
2020-05-27 13:38:05 +01:00
{
<Validation Validator="@ValidateSurname">
2020-12-20 21:34:13 +00:00
<TextEdit @bind-Text="@_model.Surname" ReadOnly="!_editing">
2020-05-27 13:38:05 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid surname."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-26 03:02:50 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
@if(_editing || _model.Alias != null)
2020-05-26 03:02:50 +01:00
{
<Field>
<FieldLabel>@L["Alias"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownAlias" @TValue="bool">@L["Unknown (alias)"]</Check>
}
@if(!_editing ||
!_unknownAlias)
2020-05-27 13:38:05 +01:00
{
<Validation Validator="@ValidateAlias">
2020-12-20 21:34:13 +00:00
<TextEdit @bind-Text="@_model.Alias" ReadOnly="!_editing">
2020-05-27 13:38:05 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid alias."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-26 03:02:50 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
@if(_editing || _model.DisplayName != null)
2020-05-26 03:02:50 +01:00
{
<Field>
<FieldLabel>@L["Display name"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownDisplayName" @TValue="bool">@L["Unknown (display name)"]</Check>
}
@if(!_editing ||
!_unknownDisplayName)
2020-05-27 13:38:05 +01:00
{
<Validation Validator="@ValidateDisplayName">
2020-12-20 21:34:13 +00:00
<TextEdit @bind-Text="@_model.DisplayName" ReadOnly="!_editing">
2020-05-27 13:38:05 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid display name."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-26 03:02:50 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
@if(_editing || _model.CountryOfBirthId != null)
2020-05-26 03:02:50 +01:00
{
<Field>
<FieldLabel>@L["Country of birth"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownCountry" @TValue="bool">@L["Unknown (country of birth)"]</Check>
}
@if(!_editing ||
!_unknownCountry)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<Select @bind-SelectedValue="@_model.CountryOfBirthId" Disabled="!_editing" @TValue="short?">
@foreach(var country in _countries)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<SelectItem @TValue="short?" Value="@country.Id">@country.Name</SelectItem>
}
2020-05-27 13:38:05 +01:00
</Select>
2020-12-20 21:34:13 +00:00
}
2020-05-26 03:02:50 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
2020-05-26 03:02:50 +01:00
<Field>
<FieldLabel>@L["Birth date"]</FieldLabel>
2020-05-27 13:38:05 +01:00
<Validation Validator="@ValidateBirthDate">
2020-12-20 21:34:13 +00:00
<DateEdit @bind-Date="@_model.BirthDate" ReadOnly="!_editing" @TValue="DateTime">
2020-05-27 13:38:05 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid birth date."]</ValidationError>
</Feedback>
</DateEdit>
</Validation>
2020-05-26 03:02:50 +01:00
</Field>
2020-12-20 21:34:13 +00:00
@if(_editing || _model.DeathDate != null)
2020-05-26 03:02:50 +01:00
{
<Field>
<FieldLabel>@L["Date of death"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownDeathDate" @TValue="bool">@L["Unknown (death date)"]</Check>
}
@if(!_editing ||
!_unknownDeathDate)
2020-05-27 13:38:05 +01:00
{
<Validation Validator="@ValidateDeathDate">
2020-12-20 21:34:13 +00:00
<DateEdit @bind-Date="@_model.DeathDate" ReadOnly="!_editing" @TValue="DateTime?">
2020-05-27 13:38:05 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid death date."]</ValidationError>
</Feedback>
</DateEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-26 03:02:50 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
@if(_editing || _model.Webpage != null)
2020-05-26 03:02:50 +01:00
{
<Field>
<FieldLabel>@L["Webpage"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownWebpage" @TValue="bool">@L["Unknown (webpage)"]</Check>
}
@if(!_editing ||
!_unknownWebpage)
2020-05-27 13:38:05 +01:00
{
<Validation Validator="@ValidateWebpage">
2020-12-20 21:34:13 +00:00
<TextEdit @bind-Text="@_model.Webpage" ReadOnly="!_editing">
2020-05-27 13:38:05 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid webpage."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-26 03:02:50 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
@if(_editing || _model.Twitter != null)
2020-05-26 03:02:50 +01:00
{
<Field>
<FieldLabel>@L["Twitter"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownTwitter" @TValue="bool">@L["Unknown (twitter)"]</Check>
}
@if(!_editing ||
!_unknownTwitter)
2020-05-27 13:38:05 +01:00
{
<Validation Validator="@ValidateTwitter">
2020-12-20 21:34:13 +00:00
<TextEdit @bind-Text="@_model.Twitter" ReadOnly="!_editing">
2020-05-27 13:38:05 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid Twitter handle."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-26 03:02:50 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
@if(_editing || _model.Facebook != null)
2020-05-26 03:02:50 +01:00
{
<Field>
2020-05-27 22:30:06 +01:00
<FieldLabel>@L["Facebook"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownFacebook" @TValue="bool">@L["Unknown (facebook)"]</Check>
}
@if(!_editing ||
!_unknownFacebook)
2020-05-27 13:38:05 +01:00
{
<Validation Validator="@ValidateFacebook">
2020-12-20 21:34:13 +00:00
<TextEdit @bind-Text="@_model.Facebook" ReadOnly="!_editing">
2020-05-27 13:38:05 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid Facebook user name."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-26 03:02:50 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
2020-05-26 03:02:50 +01:00
</div>
<div>
2020-12-20 21:34:13 +00:00
@if(!_editing)
2020-05-27 13:38:05 +01:00
{
2020-12-20 21:34:13 +00:00
<Button Clicked="@OnEditClicked" Color="Color.Primary">@L["Edit"]</Button>
}
2020-05-27 13:38:05 +01:00
else
{
2020-12-20 21:34:13 +00:00
<Button Clicked="@OnSaveClicked" Color="Color.Success">@L["Save"]</Button>
<Button Clicked="@OnCancelClicked" Color="Color.Danger">@L["Cancel"]</Button>
}
<a class="btn btn-secondary" href="/admin/people">@L["Back to list"]</a>
2020-05-26 03:02:50 +01:00
</div>