Refactoring, database structure changed
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
@using Blazorise.Extensions
|
||||
@using WatchIt.DTO.Models.Controllers.Media.Medium.Response
|
||||
@using WatchIt.DTO.Models.Controllers.Roles.Role.Response
|
||||
@using WatchIt.Website.Components.Subcomponents.Common
|
||||
@using Blazorise.Components
|
||||
|
||||
@inherits Component
|
||||
|
||||
|
||||
|
||||
<div class="panel @(Class)">
|
||||
@if (_loaded)
|
||||
{
|
||||
<div class="vstack gap-3">
|
||||
<div class="container-grid">
|
||||
<div class="row gx-2">
|
||||
<div class="col align-self-center">
|
||||
<h4 class="m-0"><strong>Creator roles</strong></h4>
|
||||
</div>
|
||||
@if (!_editingMode)
|
||||
{
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-secondary" disabled="@(Disabled)" @onclick="@(() => ActivateEditData())">Add</button>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-secondary" @onclick="@(CancelEditData)">Cancel</button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-secondary" disabled="@(_saving)" @onclick="@(SaveData)">
|
||||
<LoadingButtonContent IsLoading="@(_saving)" Content="Save" LoadingContent="Saving..."/>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (!_editingMode)
|
||||
{
|
||||
if (_roles.IsNullOrEmpty())
|
||||
{
|
||||
<span class="text-center">No items</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-sm table-transparent">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
Media name
|
||||
</th>
|
||||
<th scope="col">
|
||||
Media type
|
||||
</th>
|
||||
<th scope="col">
|
||||
Role type
|
||||
</th>
|
||||
<th class="table-cell-fit" scope="col">
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="table-group-divider">
|
||||
@foreach (Guid roleId in _roles.Keys)
|
||||
{
|
||||
RoleCreatorResponse role = _roles[roleId].Data;
|
||||
MediumResponse medium = _mediaDict[role.MediumId];
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
@(medium.Title)@(medium.ReleaseDate.HasValue ? $" ({medium.ReleaseDate!.Value.Year})" : string.Empty)
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@(medium.Type == MediumResponseType.Movie ? "Movie" : "TV Series")
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@(_roleTypes[role.TypeId])
|
||||
</td>
|
||||
<td class="align-middle table-cell-fit">
|
||||
<div class="hstack gap-1">
|
||||
<button class="btn btn-outline-secondary btn-sm" type="button" disabled="@(Disabled || _roles[roleId].Deleting)" @onclick="@(() => ActivateEditData(roleId))"><i class="fas fa-edit"></i></button>
|
||||
<button class="btn btn-outline-danger btn-sm" type="button" disabled="@(Disabled || _roles[roleId].Deleting)" @onclick="@(() => DeleteData(roleId))">
|
||||
@if (_roles[roleId].Deleting)
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<EditForm Model="@(_roleRequest)">
|
||||
<AntiforgeryToken/>
|
||||
<div class="container-grid">
|
||||
<div class="row form-group mb-1">
|
||||
<label for="actorFormMedia" class="col-1 col-form-label">Media:</label>
|
||||
<div class="col">
|
||||
<Autocomplete ElementId="actorFormMedia"
|
||||
TItem="MediumResponse"
|
||||
TValue="long"
|
||||
Data="@(_mediaDict.Values)"
|
||||
TextField="@(item => item.ReleaseDate.HasValue ? $"{item.Title} ({item.ReleaseDate.Value.Year})" : item.Title)"
|
||||
ValueField="@(item => item.Id)"
|
||||
@bind-SelectedValue="@(_roleRequest.MediumId)"
|
||||
Placeholder="Search..."
|
||||
Filter="AutocompleteFilter.Contains">
|
||||
<NotFoundContent Context="not_found_context"> Sorry... @not_found_context was not found</NotFoundContent>
|
||||
</Autocomplete>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row form-group my-1">
|
||||
<label for="actorFormType" class="col-1 col-form-label">Type:</label>
|
||||
<div class="col">
|
||||
<InputSelect id="actorFormType" class="form-control" TValue="short" @bind-Value="@(_roleRequest.TypeId)">
|
||||
@foreach (KeyValuePair<short, string> type in _roleTypes)
|
||||
{
|
||||
<option value="@(type.Key)">@(type.Value)</option>
|
||||
}
|
||||
</InputSelect>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Loading Color="@(Loading.Colors.Light)"/>
|
||||
}
|
||||
</div>
|
||||
Reference in New Issue
Block a user