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);
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
@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(" ");
|
||||
}
|
||||
}
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>@Model.ViewDataTypeShortName</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
@{
|
||||
foreach (var property in Model.ModelMetadata.Properties)
|
||||
{
|
||||
if (property.Scaffold && !property.IsPrimaryKey && !property.IsForeignKey)
|
||||
{
|
||||
<dt>
|
||||
@@Html.DisplayNameFor(model => model.@GetValueExpression(property))
|
||||
</dt>
|
||||
<dd>
|
||||
@@Html.DisplayFor(model => model.@GetValueExpression(property))
|
||||
</dd>
|
||||
}
|
||||
}
|
||||
@:</dl>
|
||||
@:
|
||||
@:<form asp-action="@Model.ViewName">
|
||||
@:<div class="form-actions no-color">
|
||||
@:<input type="submit" value="Delete" class="btn btn-default" /> |
|
||||
@:<a asp-action="Index">@@SR["Back to List"]</a>
|
||||
@:</div>
|
||||
@:</form>
|
||||
@:</div>
|
||||
if (!Model.IsPartialView && !Model.IsLayoutPageSelected)
|
||||
{
|
||||
//ClearIndent();
|
||||
@:</body>
|
||||
@:</html>
|
||||
}
|
||||
}
|
||||
@functions
|
||||
{
|
||||
string GetValueExpression(PropertyMetadata property)
|
||||
{
|
||||
//Todo: Get the association for the property and use that.
|
||||
return property.PropertyName;
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
@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(" ");
|
||||
}
|
||||
}
|
||||
<div>
|
||||
<h4>@Model.ViewDataTypeShortName</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
@{
|
||||
foreach (var property in Model.ModelMetadata.Properties)
|
||||
{
|
||||
if (property.Scaffold && !property.IsPrimaryKey && !property.IsForeignKey)
|
||||
{
|
||||
<dt>
|
||||
@@Html.DisplayNameFor(model => model.@GetValueExpression(property))
|
||||
</dt>
|
||||
<dd>
|
||||
@@Html.DisplayFor(model => model.@GetValueExpression(property))
|
||||
</dd>
|
||||
}
|
||||
}
|
||||
} </dl>
|
||||
</div>
|
||||
<p>
|
||||
@{
|
||||
string pkName = GetPrimaryKeyName();
|
||||
if (pkName != null)
|
||||
{
|
||||
@:<a asp-action="Edit" asp-route-id="@@Model.@pkName">@@SR["Edit"]</a> |
|
||||
@:<a asp-action="Index">@@SR["Back to List"]</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
@:@@Html.ActionLink("Edit", "Edit", new { /* id = Model.PrimaryKey */ }) |
|
||||
@:<a asp-action="Index">@@SR["Back to List"]</a>
|
||||
}
|
||||
}</p>
|
||||
@{
|
||||
if (!Model.IsPartialView && !Model.IsLayoutPageSelected)
|
||||
{
|
||||
//ClearIndent();
|
||||
@:</body>
|
||||
@:</html>
|
||||
}
|
||||
}
|
||||
@functions
|
||||
{
|
||||
string GetPrimaryKeyName()
|
||||
{
|
||||
return (Model.ModelMetadata.PrimaryKeys != null && Model.ModelMetadata.PrimaryKeys.Length == 1)
|
||||
? Model.ModelMetadata.PrimaryKeys[0].PropertyName
|
||||
: null;
|
||||
}
|
||||
|
||||
string GetValueExpression(PropertyMetadata property)
|
||||
{
|
||||
//Todo: Get the association for the property and use that.
|
||||
return property.PropertyName;
|
||||
}
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
@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>@@SR["@Model.ViewName"]</title>
|
||||
@:</head>
|
||||
@:<body>
|
||||
@:
|
||||
// PushIndent(" ");
|
||||
}
|
||||
@:<form asp-action="@Model.ViewName">
|
||||
@:<div class="form-horizontal">
|
||||
@:<h4>@Model.ViewDataTypeShortName</h4>
|
||||
@:<hr />
|
||||
@:<div asp-validation-summary="ValidationSummary.ModelOnly" class="text-danger"></div>
|
||||
foreach (PropertyMetadata property in Model.ModelMetadata.Properties)
|
||||
{
|
||||
if (property.Scaffold)
|
||||
{
|
||||
if (property.IsPrimaryKey)
|
||||
{
|
||||
@:<input type="hidden" asp-for="@property.PropertyName" />
|
||||
continue;
|
||||
}
|
||||
if (property.IsReadOnly)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.IsForeignKey)
|
||||
{
|
||||
@:<div class="form-group">
|
||||
@:<label asp-for="@property.PropertyName" class="control-label col-md-2">@GetAssociationName(property)</label>
|
||||
@:<div class="col-md-10">
|
||||
@:<select asp-for="@property.PropertyName" class="form-control" />
|
||||
@:<span asp-validation-for="@property.PropertyName" class="text-danger" />
|
||||
@:</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="Save" 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
|
||||
{
|
||||
string GetAssociationName(PropertyMetadata property)
|
||||
{
|
||||
//Todo: Implement properly.
|
||||
return property.PropertyName;
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
@inherits Microsoft.Extensions.CodeGeneration.Templating.RazorTemplateBase
|
||||
@using Microsoft.Extensions.CodeGeneration.EntityFramework
|
||||
@@model @GetEnumerableTypeExpression(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>@@SR["@Model.ViewName"]</title>
|
||||
@:</head>
|
||||
@:<body>
|
||||
// PushIndent(" ");
|
||||
}
|
||||
@:<p>
|
||||
@:<a asp-action="Create">@@SR["Create New"]</a>
|
||||
@:</p>
|
||||
@:<table class="table">
|
||||
@:<tr>
|
||||
IEnumerable<PropertyMetadata> properties = Model.ModelMetadata.Properties;
|
||||
foreach (var property in properties)
|
||||
{
|
||||
if (property.Scaffold && !property.IsPrimaryKey && !property.IsForeignKey)
|
||||
{
|
||||
<th>
|
||||
@@Html.DisplayNameFor(model => model.@GetValueExpression(property))
|
||||
</th>
|
||||
}
|
||||
}
|
||||
@:<th></th>
|
||||
@:</tr>
|
||||
@:
|
||||
@:@@foreach (var item in Model) {
|
||||
@:<tr>
|
||||
foreach (PropertyMetadata property in properties)
|
||||
{
|
||||
if (property.Scaffold && !property.IsPrimaryKey && !property.IsForeignKey)
|
||||
{
|
||||
<td>
|
||||
@@Html.DisplayFor(modelItem => item.@GetValueExpression(property))
|
||||
</td>
|
||||
}
|
||||
}
|
||||
|
||||
string pkName = GetPrimaryKeyName();
|
||||
if (pkName != null)
|
||||
{
|
||||
@:<td>
|
||||
@:<a asp-action="Edit" asp-route-id="@@item.@pkName">@@SR["Edit"]</a> |
|
||||
@:<a asp-action="Details" asp-route-id="@@item.@pkName">@@SR["Details"]</a> |
|
||||
@:<a asp-action="Delete" asp-route-id="@@item.@pkName">@@SR["Delete"]</a>
|
||||
@:</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>
|
||||
@@Html.ActionLink("Edit", SR["Edit"], new { /* id=item.PrimaryKey */ }) |
|
||||
@@Html.ActionLink("Details", SR["Details"], new { /* id=item.PrimaryKey */ }) |
|
||||
@@Html.ActionLink("Delete", SR["Delete"], new { /* id=item.PrimaryKey */ })
|
||||
</td>
|
||||
}
|
||||
@:</tr>
|
||||
@:}
|
||||
|
||||
@:</table>
|
||||
if(!Model.IsPartialView && !Model.IsLayoutPageSelected)
|
||||
{
|
||||
//ClearIndent();
|
||||
@:</body>
|
||||
@:</html>
|
||||
}
|
||||
}
|
||||
@functions
|
||||
{
|
||||
string GetPrimaryKeyName()
|
||||
{
|
||||
return (Model.ModelMetadata.PrimaryKeys != null && Model.ModelMetadata.PrimaryKeys.Length == 1)
|
||||
? Model.ModelMetadata.PrimaryKeys[0].PropertyName
|
||||
: null;
|
||||
}
|
||||
|
||||
string GetValueExpression(PropertyMetadata property)
|
||||
{
|
||||
//Todo: Get the association for the property and use that.
|
||||
return property.PropertyName;
|
||||
}
|
||||
|
||||
string GetEnumerableTypeExpression(string typeName)
|
||||
{
|
||||
return "IEnumerable<" + typeName + ">";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user