Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added missing validation output for select element to grid create and… #328

Merged
merged 1 commit into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions GridBlazor/Pages/GridCreateComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
else
{
var selectedValue = column.GetFormatedValue(value);
<select id="@column.FieldName" name="@column.FieldName" class="form-control" value="@selectedValue" @onchange="(e) => ChangeValue(e, column)">
<select id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" value="@selectedValue" @onchange="(e) => ChangeValue(e, column)">
<option value="">@Strings.SelectItem</option>
@foreach (var selectItem in ((IGridColumn<T>)column).SelectItems)
{
Expand All @@ -66,6 +66,9 @@
}
}
</select>
<span class="field-validation-error">
<span>@ColumnErrors.Get(column.FieldName)</span>
</span>
}
}
else if (((IGridColumn<T>)column).IsSelectColumn.IsSelectKey)
Expand All @@ -78,7 +81,7 @@
else
{
var selectedValue = column.GetFormatedValue(value);
<select id="@column.FieldName" name="@column.FieldName" class="form-control" value="@selectedValue" @onchange="(e) => ChangeValue(e, column)">
<select id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" value="@selectedValue" @onchange="(e) => ChangeValue(e, column)">
<option value="">@Strings.SelectItem</option>
@{
var selectItems = SelectItems.Get(column.Name);
Expand All @@ -98,6 +101,9 @@
}
}
</select>
<span class="field-validation-error">
<span>@ColumnErrors.Get(column.FieldName)</span>
</span>
}
}
else
Expand Down Expand Up @@ -275,6 +281,10 @@
}
}
}
else if (((IGridColumn<T>)column).InputType == InputType.Number)
{
<input type="@(InputType.Number.ToTypeAttr())" id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" value="@column.GetFormatedValue(value)" @onchange="(e) => ChangeValue(e, column)" />
}
else
{
<input id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" value="@column.GetFormatedValue(value)" @onchange="(e) => ChangeValue(e, column)" />
Expand Down
14 changes: 12 additions & 2 deletions GridBlazor/Pages/GridUpdateComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
else
{
var selectedValue = column.GetFormatedValue(value);
<select id="@column.FieldName" name="@column.FieldName" class="form-control" value="@selectedValue" @onchange="(e) => ChangeValue(e, column)">
<select id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" value="@selectedValue" @onchange="(e) => ChangeValue(e, column)">
<option value="">@Strings.SelectItem</option>
@foreach (var selectItem in ((IGridColumn<T>)column).SelectItems)
{
Expand All @@ -70,6 +70,9 @@
}
}
</select>
<span class="field-validation-error">
<span>@ColumnErrors.Get(column.FieldName)</span>
</span>
}
}
else if (((IGridColumn<T>)column).IsSelectColumn.IsSelectKey)
Expand All @@ -82,7 +85,7 @@
else
{
var selectedValue = column.GetFormatedValue(value);
<select id="@column.FieldName" name="@column.FieldName" class="form-control" value="@selectedValue" @onchange="(e) => ChangeValue(e, column)">
<select id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" value="@selectedValue" @onchange="(e) => ChangeValue(e, column)">
<option value="">@Strings.SelectItem</option>
@{
var selectItems = SelectItems.Get(column.Name);
Expand All @@ -102,6 +105,9 @@
}
}
</select>
<span class="field-validation-error">
<span>@ColumnErrors.Get(column.FieldName)</span>
</span>
}
}
else
Expand Down Expand Up @@ -274,6 +280,10 @@
}
}
}
else if (((IGridColumn<T>)column).InputType == InputType.Number)
{
<input type="@(InputType.Number.ToTypeAttr())" id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" value="@column.GetFormatedValue(value)" @onchange="(e) => ChangeValue(e, column)" />
}
else
{
<input id="@column.FieldName" name="@column.FieldName" class="form-control @(ColumnErrors.ContainsKey(@column.FieldName) ? "input-validation-error" : "")" value="@column.GetFormatedValue(value)" @onchange="(e) => ChangeValue(e, column)" />
Expand Down
5 changes: 4 additions & 1 deletion GridShared/Columns/InputType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public enum InputType
DateTimeLocal,
Week,
Month,
File
File,
Number
}

public static class InputTypeExtensions
Expand All @@ -33,6 +34,8 @@ public static string ToTypeAttr(this InputType me)
return "month";
case InputType.File:
return "file";
case InputType.Number:
return "number";
default:
return "";
}
Expand Down