Skip to content

Commit 4dbfe61

Browse files
authored
Add * by required field (#8328)
* add an * to required fields
1 parent efc81b0 commit 4dbfe61

8 files changed

Lines changed: 43 additions & 9 deletions

File tree

src/Bootstrap/dist/css/bootstrap-theme.css

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Bootstrap/less/theme/page-manage-organizations.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
display: inline-block;
4343
width: 100%;
4444
}
45+
46+
.required:after {
47+
color: red;
48+
content: " *";
49+
}
4550
}
4651

4752
.manage-members-listing tbody:first-child {

src/Bootstrap/less/theme/page-sign-in.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@
2727
.or-row {
2828
margin: 20px;
2929
}
30+
31+
.required:after{
32+
color: red;
33+
content: " *";
34+
}
3035
}

src/NuGetGallery/ExtensionMethods.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,34 @@ public static HtmlString HasErrorFor<TModel, TProperty>(this HtmlHelper<TModel>
106106

107107
public static HtmlString ShowLabelFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression)
108108
{
109-
return ShowLabelFor(html, expression, labelText: null);
109+
return ShowLabelFor(html, expression, labelText: null, isrequired: false);
110110
}
111111

112-
public static HtmlString ShowLabelFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, string labelText)
112+
public static HtmlString ShowLabelFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, bool isrequired)
113+
{
114+
return ShowLabelFor(html, expression, labelText: null, isrequired);
115+
}
116+
117+
public static HtmlString ShowLabelFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, string labelText, bool isrequired)
113118
{
114119
var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
115120
var propertyName = metadata.PropertyName.ToLower();
116121

117-
return html.LabelFor(expression, labelText, new
122+
if (isrequired)
118123
{
119-
id = $"{propertyName}-label"
120-
});
124+
return html.LabelFor(expression, labelText, new
125+
{
126+
id = $"{propertyName}-label",
127+
@class = "required"
128+
});
129+
}
130+
else
131+
{
132+
return html.LabelFor(expression, labelText, new
133+
{
134+
id = $"{propertyName}-label"
135+
});
136+
}
121137
}
122138

123139
public static HtmlString ShowPasswordFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression)

src/NuGetGallery/Views/Authentication/_Register.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</div>
2020

2121
<div class="form-group @Html.HasErrorFor(m => m.Register.Username)">
22-
@Html.ShowLabelFor(m => m.Register.Username)
22+
@Html.ShowLabelFor(m => m.Register.Username, isrequired: true)
2323
@Html.ShowTextBoxFor(m => m.Register.Username)
2424
@Html.ShowValidationMessagesFor(m => m.Register.Username)
2525
</div>

src/NuGetGallery/Views/Packages/_ManageListing.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
@Html.Hidden("version", @Model.Version, new { id = "input-list-package" })
5353
<div class="form-group @Html.HasErrorFor(package => package.Listed)">
5454
@Html.ShowCheckboxFor(package => package.Listed)
55-
@Html.ShowLabelFor(package => package.Listed, "List in search results.")
55+
@Html.ShowLabelFor(package => package.Listed, "List in search results.", isrequired: false)
5656
@Html.ShowValidationMessagesFor(package => package.Listed)
5757

5858
<p>Unlisted packages cannot be installed directly and do not show up in search results.</p>

src/NuGetGallery/Views/Shared/_AccountChangeEmail.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</div>
4343
}
4444
<div class="form-group @Html.HasErrorFor(m => m.ChangeEmail.NewEmail)">
45-
@Html.ShowLabelFor(m => m.ChangeEmail.NewEmail)
45+
@Html.ShowLabelFor(m => m.ChangeEmail.NewEmail, isrequired: true)
4646
@Html.ShowTextBoxFor(m => m.ChangeEmail.NewEmail)
4747
@Html.ShowValidationMessagesFor(m => m.ChangeEmail.NewEmail)
4848
</div>

src/NuGetGallery/Views/Users/ApiKeys.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@
319319

320320
<div class="row">
321321
<div class="col-sm-7 form-group">
322-
<label data-bind="attr: { for: PackageOwnerId,
322+
<label class="required" data-bind="attr: { for: PackageOwnerId,
323323
id: PackageOwnerId() + '-label' }">Package Owner</label>
324324
<select class="form-control"
325325
data-bind="attr: { id: PackageOwnerId,

0 commit comments

Comments
 (0)