mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 11:04:25 +00:00
Add legal name for companies.
This commit is contained in:
6855
Marechai.Database/Migrations/20200806002515_AddCompanyLegalName.Designer.cs
generated
Normal file
6855
Marechai.Database/Migrations/20200806002515_AddCompanyLegalName.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Marechai.Database.Migrations
|
||||
{
|
||||
public partial class AddCompanyLegalName : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder) =>
|
||||
migrationBuilder.AddColumn<string>("LegalName", "companies", nullable: true);
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder) =>
|
||||
migrationBuilder.DropColumn("LegalName", "companies");
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace Marechai.Database.Migrations
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "3.1.4").HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
modelBuilder.HasAnnotation("ProductVersion", "3.1.6").HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("Marechai.Database.Models.ApplicationRole", b =>
|
||||
{
|
||||
@@ -453,6 +453,8 @@ namespace Marechai.Database.Migrations
|
||||
|
||||
b.Property<bool>("FoundedMonthIsUnknown").HasColumnType("bit(1)");
|
||||
|
||||
b.Property<string>("LegalName").HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
|
||||
b.Property<string>("Name").IsRequired().ValueGeneratedOnAdd().HasColumnName("name").
|
||||
HasColumnType("varchar(128)").HasDefaultValueSql("''");
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ namespace Marechai.Database.Models
|
||||
public bool SoldMonthIsUnknown { get; set; }
|
||||
[DefaultValue(false)]
|
||||
public bool SoldDayIsUnknown { get; set; }
|
||||
public string LegalName { get; set; }
|
||||
|
||||
public virtual Iso31661Numeric Country { get; set; }
|
||||
[DisplayName("Sold to")]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Version>4.0.0.1787</Version>
|
||||
<Version>4.0.0.1790</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
<div>
|
||||
<Field>
|
||||
<FieldLabel>@L["Name"]</FieldLabel>
|
||||
<FieldLabel>@L["Common name (as usually displayed publicly)"]</FieldLabel>
|
||||
<Validation Validator="@ValidateName">
|
||||
<TextEdit ReadOnly="!_editing" @bind-Text="@_model.Name">
|
||||
<Feedback>
|
||||
@@ -64,6 +64,27 @@
|
||||
</TextEdit>
|
||||
</Validation>
|
||||
</Field>
|
||||
@if (_editing || _model.LegalName != null)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Legal name (as shown in governmental registries including \"Inc.\", \"Corp.\", \"gmbH\", etc...)"]</FieldLabel>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownLegalName">@L["Unknown (legal name)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownLegalName)
|
||||
{
|
||||
<Validation Validator="@ValidateLegalName">
|
||||
<TextEdit Disabled="!_editing" @bind-Text="@_model.LegalName">
|
||||
<Feedback>
|
||||
<ValidationError>@L["Please enter a valid legal name."]</ValidationError>
|
||||
</Feedback>
|
||||
</TextEdit>
|
||||
</Validation>
|
||||
}
|
||||
</Field>
|
||||
}
|
||||
<Field>
|
||||
<FieldLabel>@L["Status"]</FieldLabel>
|
||||
<Select Disabled="!_editing" TValue="int" @bind-SelectedValue="@Status">
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace Marechai.Pages.Admin.Details
|
||||
bool _unknownCountry;
|
||||
bool _unknownFacebook;
|
||||
bool _unknownFounded;
|
||||
bool _unknownLegalName;
|
||||
bool _unknownLogoYear;
|
||||
bool _unknownPostalCode;
|
||||
bool _unknownProvince;
|
||||
@@ -159,6 +160,7 @@ namespace Marechai.Pages.Admin.Details
|
||||
_unknownPostalCode = string.IsNullOrWhiteSpace(_model.PostalCode);
|
||||
_unknownSold = !_model.Sold.HasValue;
|
||||
_unknownSoldTo = !_model.SoldToId.HasValue;
|
||||
_unknownLegalName = string.IsNullOrWhiteSpace(_model.LegalName);
|
||||
}
|
||||
|
||||
void OnEditClicked()
|
||||
@@ -249,6 +251,11 @@ namespace Marechai.Pages.Admin.Details
|
||||
else if(_model.Sold?.Date >= DateTime.UtcNow.Date)
|
||||
return;
|
||||
|
||||
if(_unknownLegalName)
|
||||
_model.LegalName = null;
|
||||
else if(string.IsNullOrWhiteSpace(_model.LegalName))
|
||||
return;
|
||||
|
||||
if(_creating)
|
||||
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
|
||||
else
|
||||
@@ -283,6 +290,9 @@ namespace Marechai.Pages.Admin.Details
|
||||
void ValidateWebsite(ValidatorEventArgs e) =>
|
||||
Validators.ValidateUrl(e, L["Webpage must be smaller than 255 characters."], 255);
|
||||
|
||||
void ValidateLegalName(ValidatorEventArgs e) =>
|
||||
Validators.ValidateString(e, L["Legal name must be smaller than 256 characters."], 256);
|
||||
|
||||
void ValidateTwitter(ValidatorEventArgs e)
|
||||
{
|
||||
if(!(e.Value is string twitter))
|
||||
|
||||
@@ -118,6 +118,13 @@
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
@if(!string.IsNullOrEmpty(_company.LegalName))
|
||||
{
|
||||
<tr>
|
||||
<th class="text-right">@L["Legal name"]</th>
|
||||
<td>@_company.LegalName</td>
|
||||
</tr>
|
||||
}
|
||||
<tr>
|
||||
<th class="text-right">@L["Country"]</th>
|
||||
<td>
|
||||
|
||||
@@ -166,4 +166,7 @@
|
||||
<value>Unknown</value>
|
||||
<comment>Unknown, referring to a company logo year</comment>
|
||||
</data>
|
||||
<data name="Unknown (legal name)" xml:space="preserve">
|
||||
<value>Unknown</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -533,4 +533,22 @@
|
||||
<data name="in use since {0}" xml:space="preserve">
|
||||
<value>en uso desde el {0}</value>
|
||||
</data>
|
||||
<data name="Legal name must be smaller than 256 characters." xml:space="preserve">
|
||||
<value>El nombre legal debe contener menos de 256 caracteres.</value>
|
||||
</data>
|
||||
<data name="Common name (as usually displayed publicly)" xml:space="preserve">
|
||||
<value>Nombre común (como se muestra en público usualmente)</value>
|
||||
</data>
|
||||
<data name="Legal name (as shown in governmental registries including "Inc.", "Corp.", "gmbH", etc...)" xml:space="preserve">
|
||||
<value>Nombre legal (como aparece en registros gubernamentales incluyendo "Inc.", "Corp.", "gmbH", etc...)</value>
|
||||
</data>
|
||||
<data name="Unknown (legal name)" xml:space="preserve">
|
||||
<value>Desconocido</value>
|
||||
</data>
|
||||
<data name="Please enter a valid legal name." xml:space="preserve">
|
||||
<value>Por favor introduce un nombre legal válido.</value>
|
||||
</data>
|
||||
<data name="Legal name" xml:space="preserve">
|
||||
<value>Nombre legal</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -71,7 +71,8 @@ namespace Marechai.Services
|
||||
FoundedMonthIsUnknown =
|
||||
c.FoundedMonthIsUnknown,
|
||||
SoldDayIsUnknown = c.SoldDayIsUnknown,
|
||||
SoldMonthIsUnknown = c.SoldMonthIsUnknown
|
||||
SoldMonthIsUnknown = c.SoldMonthIsUnknown,
|
||||
LegalName = c.LegalName
|
||||
}).ToListAsync();
|
||||
|
||||
public async Task<CompanyViewModel> GetAsync(int id) => await _context.Companies.Where(c => c.Id == id).
|
||||
@@ -102,7 +103,8 @@ namespace Marechai.Services
|
||||
SoldDayIsUnknown =
|
||||
c.SoldDayIsUnknown,
|
||||
SoldMonthIsUnknown =
|
||||
c.SoldMonthIsUnknown
|
||||
c.SoldMonthIsUnknown,
|
||||
LegalName = c.LegalName
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
public async Task UpdateAsync(CompanyViewModel viewModel, string userId)
|
||||
@@ -129,6 +131,7 @@ namespace Marechai.Services
|
||||
model.FoundedMonthIsUnknown = viewModel.FoundedMonthIsUnknown;
|
||||
model.SoldDayIsUnknown = viewModel.SoldDayIsUnknown;
|
||||
model.SoldMonthIsUnknown = viewModel.SoldMonthIsUnknown;
|
||||
model.LegalName = viewModel.LegalName;
|
||||
await _context.SaveChangesWithUserAsync(userId);
|
||||
}
|
||||
|
||||
@@ -152,7 +155,8 @@ namespace Marechai.Services
|
||||
FoundedDayIsUnknown = viewModel.FoundedDayIsUnknown,
|
||||
FoundedMonthIsUnknown = viewModel.FoundedMonthIsUnknown,
|
||||
SoldDayIsUnknown = viewModel.SoldDayIsUnknown,
|
||||
SoldMonthIsUnknown = viewModel.SoldMonthIsUnknown
|
||||
SoldMonthIsUnknown = viewModel.SoldMonthIsUnknown,
|
||||
LegalName = viewModel.LegalName
|
||||
};
|
||||
|
||||
await _context.Companies.AddAsync(model);
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace Marechai.ViewModels
|
||||
public bool FoundedMonthIsUnknown { get; set; }
|
||||
public bool SoldDayIsUnknown { get; set; }
|
||||
public bool SoldMonthIsUnknown { get; set; }
|
||||
public string LegalName { get; set; }
|
||||
|
||||
public string SoldView => Status != CompanyStatus.Active && Status != CompanyStatus.Unknown
|
||||
? Sold?.ToShortDateString() ?? "Unknown"
|
||||
|
||||
Reference in New Issue
Block a user