Skip to content

Commit

Permalink
added missing validation output for select element to grid create and…
Browse files Browse the repository at this point in the history
… update component (#328)

added number input type

Co-authored-by: gsuchomski <[email protected]>
  • Loading branch information
omski and gsuchomski authored Jan 20, 2022
1 parent 6022369 commit 7184c70
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
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

0 comments on commit 7184c70

Please sign in to comment.