Localization
This commit is contained in:
@ -0,0 +1,145 @@
|
||||
@inherits Microsoft.Extensions.CodeGeneration.Templating.RazorTemplateBase
|
||||
@using Microsoft.Extensions.CodeGeneration.EntityFramework
|
||||
@@model @Model.ViewDataTypeName
|
||||
|
||||
@{
|
||||
if (Model.IsPartialView)
|
||||
{
|
||||
}
|
||||
else if (Model.IsLayoutPageSelected)
|
||||
{
|
||||
@:@@{
|
||||
@:ViewData["Title"] = @@SR["@Model.ViewName"];
|
||||
if (!string.IsNullOrEmpty(Model.LayoutPageFile))
|
||||
{
|
||||
@:Layout = "@Model.LayoutPageFile";
|
||||
}
|
||||
@:}
|
||||
@:
|
||||
@:<h2>@@SR["@Model.ViewName"]</h2>
|
||||
@:
|
||||
}
|
||||
else
|
||||
{
|
||||
@:@@{
|
||||
@:Layout = null;
|
||||
@:}
|
||||
@:
|
||||
@:<!DOCTYPE html>
|
||||
@:
|
||||
@:<html>
|
||||
@:<head>
|
||||
@:<meta name="viewport" content="width=device-width" />
|
||||
@:<title>@Model.ViewName</title>
|
||||
@:</head>
|
||||
@:<body>
|
||||
@:
|
||||
// PushIndent(" ");
|
||||
}
|
||||
@:<form asp-action="@Model.ViewName">
|
||||
@:<div class="form-horizontal">
|
||||
@:<h4>@@SR["@Model.ViewDataTypeShortName"]</h4>
|
||||
@:<hr />
|
||||
@:<div asp-validation-summary="ValidationSummary.ModelOnly" class="text-danger"></div>
|
||||
foreach (var property in Model.ModelMetadata.Properties)
|
||||
{
|
||||
if (property.Scaffold && !property.IsAutoGenerated && !property.IsReadOnly)
|
||||
{
|
||||
|
||||
// If the property is a primary key and Guid, then the Guid is generated in the controller. Hence, this propery is not displayed on the view.
|
||||
if (property.IsPrimaryKey)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.IsForeignKey)
|
||||
{
|
||||
@:<div class="form-group">
|
||||
@:<label asp-for="@property.PropertyName" class="col-md-2 control-label"></label>
|
||||
@:<div class="col-md-10">
|
||||
@:<select asp-for="@property.PropertyName" class ="form-control"></select>
|
||||
@:</div>
|
||||
@:</div>
|
||||
continue;
|
||||
}
|
||||
|
||||
bool isCheckbox = property.TypeName.Equals("System.Boolean");
|
||||
if (isCheckbox)
|
||||
{
|
||||
@:<div class="form-group">
|
||||
@:<div class="col-md-offset-2 col-md-10">
|
||||
@:<div class="checkbox">
|
||||
@:<input asp-for="@property.PropertyName" />
|
||||
@:<label asp-for="@property.PropertyName"></label>
|
||||
@:</div>
|
||||
@:</div>
|
||||
@:</div>
|
||||
}
|
||||
else if (property.IsEnum && !property.IsEnumFlags)
|
||||
{
|
||||
@:<div class="form-group">
|
||||
@:<label asp-for="@property.PropertyName" class="col-md-2 control-label"></label>
|
||||
@:<div class="col-md-10">
|
||||
@:<select asp-for="@property.PropertyName" class="form-control"></select>
|
||||
@:<span asp-validation-for="@property.PropertyName" class="text-danger" ></span>
|
||||
@:</div>
|
||||
@:</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
@:<div class="form-group">
|
||||
@:<label asp-for="@property.PropertyName" class="col-md-2 control-label"></label>
|
||||
@:<div class="col-md-10">
|
||||
@:<input asp-for="@property.PropertyName" class="form-control" />
|
||||
@:<span asp-validation-for="@property.PropertyName" class="text-danger" ></span>
|
||||
@:</div>
|
||||
@:</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Create" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">@@SR["Back to List"]</a>
|
||||
</div>
|
||||
|
||||
@{
|
||||
if (Model.ReferenceScriptLibraries && (Model.IsLayoutPageSelected || Model.IsPartialView))
|
||||
{
|
||||
@:@@section Scripts {
|
||||
@:<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
@:<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
|
||||
@:<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
|
||||
@:}
|
||||
}
|
||||
// The following code closes the tag used in the case of a view using a layout page and the body and html tags in the case of a regular view page
|
||||
if (!Model.IsPartialView && !Model.IsLayoutPageSelected)
|
||||
{
|
||||
if (Model.ReferenceScriptLibraries)
|
||||
{
|
||||
@:@@section Scripts {
|
||||
@:<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
@:<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
|
||||
@:<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
|
||||
@:}
|
||||
//ClearIndent();
|
||||
}
|
||||
@:</body>
|
||||
@:</html>
|
||||
}
|
||||
}
|
||||
@functions
|
||||
{
|
||||
// Do we need to use this in conjunction with the PrimaryKey check?
|
||||
bool IsPropertyGuid(PropertyMetadata property)
|
||||
{
|
||||
return string.Equals("System.Guid", property.TypeName, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user