mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add machine family details in admin view.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<Version>3.0.99.1182</Version>
|
<Version>3.0.99.1185</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
@@ -103,6 +103,9 @@
|
|||||||
<Content Update="Pages\Admin\Details\License.razor">
|
<Content Update="Pages\Admin\Details\License.razor">
|
||||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Update="Pages\Admin\Details\MachineFamily.razor">
|
||||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" />
|
<_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
@{
|
@{
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// MARECHAI: Master repository of computing history artifacts information
|
// MARECHAI: Master repository of computing history artifacts information
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -29,31 +29,38 @@
|
|||||||
// Copyright © 2003-2020 Natalia Portillo
|
// Copyright © 2003-2020 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
}
|
}
|
||||||
@model Marechai.Database.Models.MachineFamily
|
|
||||||
|
|
||||||
@{
|
@page "/admin/machine_families/details/{Id:int}"
|
||||||
ViewData["Title"] = "Details";
|
@inherits OwningComponentBase<MachineFamiliesService>
|
||||||
|
@inject IStringLocalizer<MachineFamiliesService> L
|
||||||
|
@inject CompaniesService CompaniesService
|
||||||
|
@attribute [Authorize(Roles = "UberAdmin, Admin")]
|
||||||
|
<h3>@L["Machine family details"]</h3>
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
@if (!_loaded)
|
||||||
|
{
|
||||||
|
<p align="center">@L["Loading..."]</p>
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
<h2>Details</h2>
|
|
||||||
<div>
|
<div>
|
||||||
<h4>Machine family</h4>
|
<Field>
|
||||||
<hr />
|
<FieldLabel>@L["Company"]</FieldLabel>
|
||||||
<dl class="dl-horizontal">
|
<Select Disabled="!_editable" TValue="int" @bind-SelectedValue="@_model.CompanyId">
|
||||||
<dt>
|
@foreach (var company in _companies)
|
||||||
@Html.DisplayNameFor(model => model.Company)
|
{
|
||||||
</dt>
|
<SelectItem TValue="int" Value="@company.Id">@company.Name</SelectItem>
|
||||||
<dd>
|
}
|
||||||
@Html.DisplayFor(model => model.Company.Name)
|
</Select>
|
||||||
</dd>
|
</Field>
|
||||||
<dt>
|
<Field>
|
||||||
@Html.DisplayNameFor(model => model.Name)
|
<FieldLabel>@L["Name"]</FieldLabel>
|
||||||
</dt>
|
<TextEdit ReadOnly="!_editable" @bind-Text="@_model.Name"/>
|
||||||
<dd>
|
</Field>
|
||||||
@Html.DisplayFor(model => model.Name)
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">Edit</a>
|
<span class="btn btn-primary">@L["Edit"]</span>
|
||||||
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
|
<a href="/admin/machine_families" class="btn btn-secondary">@L["Back to list"]</a>
|
||||||
</div>
|
</div>
|
||||||
33
Marechai/Pages/Admin/Details/MachineFamily.razor.cs
Normal file
33
Marechai/Pages/Admin/Details/MachineFamily.razor.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Marechai.ViewModels;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace Marechai.Pages.Admin.Details
|
||||||
|
{
|
||||||
|
public partial class MachineFamily
|
||||||
|
{
|
||||||
|
List<CompanyViewModel> _companies;
|
||||||
|
bool _editable;
|
||||||
|
bool _loaded;
|
||||||
|
Database.Models.MachineFamily _model;
|
||||||
|
[Parameter]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if(_loaded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_loaded = true;
|
||||||
|
|
||||||
|
if(Id <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_companies = await CompaniesService.GetAsync();
|
||||||
|
_model = await Service.GetAsync(Id);
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,9 +69,7 @@
|
|||||||
@item.Name
|
@item.Name
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="btn btn-primary">
|
<a class="btn btn-primary" href="/admin/machine_families/details/@item.Id">@L["Details"]</a>
|
||||||
@L["Details"]
|
|
||||||
</span>
|
|
||||||
<span class="btn btn-secondary">
|
<span class="btn btn-secondary">
|
||||||
@L["Edit"]
|
@L["Edit"]
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -162,4 +162,12 @@
|
|||||||
<value>Cancelar</value>
|
<value>Cancelar</value>
|
||||||
<comment>Cancel</comment>
|
<comment>Cancel</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Machine family details" xml:space="preserve">
|
||||||
|
<value>Detalles de familia de máquinas</value>
|
||||||
|
<comment>Machine family details</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Back to list" xml:space="preserve">
|
||||||
|
<value>Volver a la lista</value>
|
||||||
|
<comment>Back to list</comment>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -20,6 +20,8 @@ namespace Marechai.Services
|
|||||||
Id = m.Id, Company = m.Company.Name, Name = m.Name
|
Id = m.Id, Company = m.Company.Name, Name = m.Name
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
|
|
||||||
|
public async Task<MachineFamily> GetAsync(int id) => await _context.MachineFamilies.FindAsync(id);
|
||||||
|
|
||||||
public async Task DeleteAsync(int id)
|
public async Task DeleteAsync(int id)
|
||||||
{
|
{
|
||||||
MachineFamily item = await _context.MachineFamilies.FindAsync(id);
|
MachineFamily item = await _context.MachineFamilies.FindAsync(id);
|
||||||
|
|||||||
Reference in New Issue
Block a user