Fix selectable items in company details.

This commit is contained in:
2020-05-25 20:07:38 +01:00
parent 23a127a1e9
commit 1ca77f1692
4 changed files with 18 additions and 33 deletions

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>3.0.99.1159</Version>
<Version>3.0.99.1170</Version>
<Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product>

View File

@@ -31,6 +31,7 @@
}
@page "/admin/companies/details/{Id:int}"
@using Marechai.Database
@inherits OwningComponentBase<CompaniesService>
@inject IStringLocalizer<CompaniesService> L
@inject Iso31661NumericService CountriesService
@@ -52,7 +53,12 @@
</Field>
<Field>
<FieldLabel>@L["Status"]</FieldLabel>
<TextEdit ReadOnly="!_editable" @bind-Text="@CompanyStatus"/>
<Select Disabled="!_editable" TValue="int" @bind-SelectedValue="@Status">
@foreach (int status in Enum.GetValues(typeof(CompanyStatus)))
{
<SelectItem TValue="int" Value="@status">@(((CompanyStatus)status).ToString())</SelectItem>
}
</Select>
</Field>
@if(_editable || _model.Founded.HasValue)
{
@@ -110,25 +116,18 @@
<TextEdit ReadOnly="!_editable" @bind-Text="@_model.PostalCode" />
</Field>
}
@if (_editable)
@if (_editable || _model.CountryId != null)
{
<Field>
<FieldLabel>@L["Country"]</FieldLabel>
<Select ReadOnly="!_editable" TValue="short?" @bind-SelectedValue="@_model.CountryId">
<Select Disabled="!_editable" TValue="short?" @bind-SelectedValue="@_model.CountryId">
@foreach (var country in _countries)
{
<SelectItem Value="@country.Id">@country.Name</SelectItem>
<SelectItem TValue="short?" Value="@country.Id">@country.Name</SelectItem>
}
</Select>
</Field>
}
else if (_model.CountryId != null)
{
<Field>
<FieldLabel>@L["Country"]</FieldLabel>
<TextEdit ReadOnly="!_editable" @bind-Text="@_model.Country.Name" />
</Field>
}
@if (_editable || _model.Sold != null)
{
<Field>
@@ -136,25 +135,18 @@
<DateEdit ReadOnly="!_editable" TValue="DateTime?" @bind-Date="@_model.Sold" />
</Field>
}
@if (_editable)
@if (_editable || _model.SoldToId != null)
{
<Field>
<FieldLabel>@L["Sold to"]</FieldLabel>
<Select ReadOnly="!_editable" TValue="int?" @bind-SelectedValue="@_model.SoldToId">
<Select Disabled="!_editable" TValue="int?" @bind-SelectedValue="@_model.SoldToId">
@foreach (var company in _companies)
{
<SelectItem Value="@company.Id">@company.Name</SelectItem>
<SelectItem TValue="int?" Value="@company.Id">@company.Name</SelectItem>
}
</Select>
</Field>
}
else if (_model.SoldToId != null)
{
<Field>
<FieldLabel>@L["Sold to"]</FieldLabel>
<TextEdit ReadOnly="!_editable" @bind-Text="@_model.SoldTo.Name" />
</Field>
}
</div>
<div>
<span class="btn btn-primary">@L["Edit"]</span>

View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Marechai.Database;
@@ -18,16 +17,10 @@ namespace Marechai.Pages.Admin.Details
[Parameter]
public int Id { get; set; }
public string CompanyStatus
int Status
{
get => _model.Status.ToString();
set
{
if(!Enum.TryParse(value, true, out CompanyStatus parsed))
return;
_model.Status = parsed;
}
get => (int)_model.Status;
set => _model.Status = (CompanyStatus)value;
}
protected override async Task OnAfterRenderAsync(bool firstRender)

View File

@@ -1 +1 @@
{"projectId":"fd3f3857-80b9-4ed7-90f8-c6ebd0ae449f","projectName":"Marechai","neverTrack":false}
{"projectId":"9fc561fc-2850-4b18-8a34-33bab85e34e1","projectName":"Marechai"}