mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add document company details in admin view.
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
@model Marechai.ViewModels.DocumentCompanyViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
}
|
||||
<h1>Details</h1>
|
||||
<div>
|
||||
<h4>Document company</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Name)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
<a asp-action="Details" asp-route-id="@Model.CompanyId" asp-controller="Companies">
|
||||
@Html.DisplayFor(modelItem => Model.Company)</a>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">
|
||||
Edit
|
||||
</a>
|
||||
<a asp-action="Index" class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</div>
|
||||
@@ -85,6 +85,9 @@
|
||||
<Content Update="Pages\Admin\Details\Company.razor">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
</Content>
|
||||
<Content Update="Pages\Admin\Details\DocumentCompany.razor">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" />
|
||||
|
||||
69
Marechai/Pages/Admin/Details/DocumentCompany.razor
Normal file
69
Marechai/Pages/Admin/Details/DocumentCompany.razor
Normal file
@@ -0,0 +1,69 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Details.cshtml
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Admin view details
|
||||
//
|
||||
// --[ 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/document_companies/details/{Id:int}"
|
||||
@inherits OwningComponentBase<DocumentCompaniesService>
|
||||
@inject IStringLocalizer<DocumentCompaniesService> L
|
||||
@inject CompaniesService CompaniesService
|
||||
@attribute [Authorize(Roles = "UberAdmin, Admin")]
|
||||
<h3>@L["Document company details"]</h3>
|
||||
<hr />
|
||||
|
||||
@if (!_loaded)
|
||||
{
|
||||
<p align="center">@L["Loading..."]</p>
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
<div>
|
||||
<Field>
|
||||
<FieldLabel>@L["Name"]</FieldLabel>
|
||||
<TextEdit ReadOnly="!_editable" @bind-Text="@_model.Name"/>
|
||||
</Field>
|
||||
@if (_editable || _model.CompanyId != null)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Linked company"]</FieldLabel>
|
||||
<Select Disabled="!_editable" TValue="int?" @bind-SelectedValue="@_model.CompanyId">
|
||||
@foreach (var company in _companies)
|
||||
{
|
||||
<SelectItem TValue="int?" Value="@company.Id">@company.Name</SelectItem>
|
||||
}
|
||||
</Select>
|
||||
</Field>
|
||||
}
|
||||
</div>
|
||||
<div>
|
||||
<span class="btn btn-primary">@L["Edit"]</span>
|
||||
<a href="/admin/companies" class="btn btn-secondary">@L["Back to list"]</a>
|
||||
</div>
|
||||
33
Marechai/Pages/Admin/Details/DocumentCompany.razor.cs
Normal file
33
Marechai/Pages/Admin/Details/DocumentCompany.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 DocumentCompany
|
||||
{
|
||||
List<CompanyViewModel> _companies;
|
||||
bool _editable;
|
||||
bool _loaded;
|
||||
Database.Models.DocumentCompany _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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,9 +71,7 @@
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<span class="btn btn-primary">
|
||||
@L["Details"]
|
||||
</span>
|
||||
<a class="btn btn-primary" href="/admin/document_companies/details/@item.Id">@L["Details"]</a>
|
||||
<span class="btn btn-secondary">
|
||||
@L["Edit"]
|
||||
</span>
|
||||
|
||||
@@ -162,4 +162,12 @@
|
||||
<value>Cancelar</value>
|
||||
<comment>Cancel</comment>
|
||||
</data>
|
||||
<data name="Document company details" xml:space="preserve">
|
||||
<value>Detalles de compañía de documentos</value>
|
||||
<comment>Document company details</comment>
|
||||
</data>
|
||||
<data name="Back to list" xml:space="preserve">
|
||||
<value>Volver a la lista</value>
|
||||
<comment>Back to list</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -22,6 +22,8 @@ namespace Marechai.Services
|
||||
CompanyId = d.CompanyId
|
||||
}).ToListAsync();
|
||||
|
||||
public async Task<DocumentCompany> GetAsync(int id) => await _context.DocumentCompanies.FindAsync(id);
|
||||
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
DocumentCompany item = await _context.DocumentCompanies.FindAsync(id);
|
||||
|
||||
Reference in New Issue
Block a user