-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* updates for razor pages crud and blazor crud templates (#3086) * updates for razor pages crud and blazor crud templates * PR fixes * minor fix, reverting
- Loading branch information
1 parent
51866dd
commit 6a4b3cc
Showing
14 changed files
with
85 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,14 +48,15 @@ | |
foreach (var property in Model.ModelMetadata.Properties) | ||
{ | ||
var sixteenWhitespace = new string(' ', 16); | ||
var propertyRequiredText = property.IsRequired ? $"\n{sixteenWhitespace}<span class=\"text-danger\">*</span>" : string.Empty; | ||
var propertyRequiredText = property.IsRequired ? $"\r\n{sixteenWhitespace}<span class=\"text-danger\">*</span>" : string.Empty; | ||
var ariaRequiredAttributeHtml = property.IsRequired ? "aria-required=\"true\"" : string.Empty; | ||
if (property.Scaffold && !property.IsAutoGenerated && !property.IsReadOnly) | ||
{ | ||
if (property.IsForeignKey) | ||
{ | ||
@:<div class="form-group">@propertyRequiredText | ||
@:<label asp-for="@(Model.ModelTypeName)[email protected]" class="control-label"></label> | ||
@:<select asp-for="@(Model.ModelTypeName)[email protected]" class ="form-control" asp-items="[email protected]"></select> | ||
@:<select asp-for="@(Model.ModelTypeName)[email protected]" class ="form-control" asp-items="[email protected]" @ariaRequiredAttributeHtml></select> | ||
@:</div> | ||
continue; | ||
} | ||
|
@@ -65,31 +66,31 @@ | |
{ | ||
@:<div class="form-group form-check">@propertyRequiredText | ||
@:<label class="form-check-label"> | ||
@:<input class="form-check-input" asp-for="@(Model.ModelTypeName)[email protected]" /> @@Html.DisplayNameFor(model => model.@(Model.ModelTypeName).@GetValueExpression(property)) | ||
@:<input class="form-check-input" asp-for="@(Model.ModelTypeName)[email protected]" @ariaRequiredAttributeHtml/> @@Html.DisplayNameFor(model => model.@(Model.ModelTypeName).@GetValueExpression(property)) | ||
@:</label> | ||
@:</div> | ||
} | ||
else if (property.IsEnum && !property.IsEnumFlags) | ||
{ | ||
@:<div class="form-group">@propertyRequiredText | ||
@:<label asp-for="@(Model.ModelTypeName)[email protected]" class="control-label"></label> | ||
@:<select asp-for="@(Model.ModelTypeName)[email protected]" class="form-control"></select> | ||
@:<select asp-for="@(Model.ModelTypeName)[email protected]" class="form-control" @ariaRequiredAttributeHtml></select> | ||
@:<span asp-validation-for="@(Model.ModelTypeName)[email protected]" class="text-danger"></span> | ||
@:</div> | ||
} | ||
else if (property.IsMultilineText) | ||
{ | ||
@:<div class="form-group">@propertyRequiredText | ||
@:<label asp-for="@(Model.ModelTypeName)[email protected]" class="control-label"></label> | ||
@:<textarea asp-for="@(Model.ModelTypeName)[email protected]" class="form-control"></textarea> | ||
@:<textarea asp-for="@(Model.ModelTypeName)[email protected]" class="form-control" @ariaRequiredAttributeHtml></textarea> | ||
@:<span asp-validation-for="@(Model.ModelTypeName)[email protected]" class="text-danger"></span> | ||
@:</div> | ||
} | ||
else | ||
{ | ||
@:<div class="form-group">@propertyRequiredText | ||
@:<label asp-for="@(Model.ModelTypeName)[email protected]" class="control-label"></label> | ||
@:<input asp-for="@(Model.ModelTypeName)[email protected]" class="form-control" /> | ||
@:<input asp-for="@(Model.ModelTypeName)[email protected]" class="form-control" @ariaRequiredAttributeHtml/> | ||
@:<span asp-validation-for="@(Model.ModelTypeName)[email protected]" class="text-danger"></span> | ||
@:</div> | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,8 @@ | |
@:<div asp-validation-summary="ModelOnly" class="text-danger"></div> | ||
foreach (PropertyMetadata property in Model.ModelMetadata.Properties) | ||
{ | ||
var propertyRequiredText = property.IsRequired ? "<span class=\"text-danger\">*</span>" : string.Empty; | ||
var propertyRequiredText = property.IsRequired ? "\r\n<span class=\"text-danger\">*</span>" : string.Empty; | ||
var ariaRequiredAttributeHtml = property.IsRequired ? "aria-required=\"true\"" : string.Empty; | ||
if (property.IsPrimaryKey) | ||
{ | ||
@:<input type="hidden" asp-for="@(Model.ModelTypeName)[email protected]" /> | ||
|
@@ -63,10 +64,9 @@ | |
|
||
if (property.IsForeignKey) | ||
{ | ||
@:<div class="form-group"> | ||
@:@propertyRequiredText | ||
@:<div class="form-group">@propertyRequiredText | ||
@:<label asp-for="@(Model.ModelTypeName)[email protected]" class="control-label"></label> | ||
@:<select asp-for="@(Model.ModelTypeName)[email protected]" class="form-control" asp-items="[email protected]"></select> | ||
@:<select asp-for="@(Model.ModelTypeName)[email protected]" class="form-control" asp-items="[email protected]" @ariaRequiredAttributeHtml></select> | ||
@:<span asp-validation-for="@(Model.ModelTypeName)[email protected]" class="text-danger"></span> | ||
@:</div> | ||
continue; | ||
|
@@ -75,37 +75,33 @@ | |
bool isCheckbox = property.TypeName.Equals("System.Boolean"); | ||
if (isCheckbox) | ||
{ | ||
@:<div class="form-group form-check"> | ||
@:@propertyRequiredText | ||
@:<div class="form-group form-check">@propertyRequiredText | ||
@:<label class="form-check-label"> | ||
@:<input class="form-check-input" asp-for="@(Model.ModelTypeName)[email protected]" /> @@Html.DisplayNameFor(model => model.@(Model.ModelTypeName).@GetValueExpression(property)) | ||
@:<input class="form-check-input" asp-for="@(Model.ModelTypeName)[email protected]" @ariaRequiredAttributeHtml/> @@Html.DisplayNameFor(model => model.@(Model.ModelTypeName).@GetValueExpression(property)) | ||
@:</label> | ||
@:</div> | ||
} | ||
else if (property.IsEnum && !property.IsEnumFlags) | ||
{ | ||
@:<div class="form-group"> | ||
@:@propertyRequiredText | ||
@:<div class="form-group">@propertyRequiredText | ||
@:<label asp-for="@(Model.ModelTypeName)[email protected]" class="control-label"></label> | ||
@:<select asp-for="@(Model.ModelTypeName)[email protected]" class="form-control"></select> | ||
@:<select asp-for="@(Model.ModelTypeName)[email protected]" class="form-control" @ariaRequiredAttributeHtml></select> | ||
@:<span asp-validation-for="@(Model.ModelTypeName)[email protected]" class="text-danger"></span> | ||
@:</div> | ||
} | ||
else if (property.IsMultilineText) | ||
{ | ||
@:<div class="form-group"> | ||
@:@propertyRequiredText | ||
@:<div class="form-group">@propertyRequiredText | ||
@:<label asp-for="@(Model.ModelTypeName)[email protected]" class="control-label"></label> | ||
@:<textarea asp-for="@(Model.ModelTypeName)[email protected]" class="form-control"></textarea> | ||
@:<textarea asp-for="@(Model.ModelTypeName)[email protected]" class="form-control" @ariaRequiredAttributeHtml></textarea> | ||
@:<span asp-validation-for="@(Model.ModelTypeName)[email protected]" class="text-danger"></span> | ||
@:</div> | ||
} | ||
else | ||
{ | ||
@:<div class="form-group"> | ||
@:@propertyRequiredText | ||
@:<div class="form-group">@propertyRequiredText | ||
@:<label asp-for="@(Model.ModelTypeName)[email protected]" class="control-label"></label> | ||
@:<input asp-for="@(Model.ModelTypeName)[email protected]" class="form-control" /> | ||
@:<input asp-for="@(Model.ModelTypeName)[email protected]" class="form-control" @ariaRequiredAttributeHtml/> | ||
@:<span asp-validation-for="@(Model.ModelTypeName)[email protected]" class="text-danger"></span> | ||
@:</div> | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.