parent
bcaee8df4e
commit
bb07119b4a
|
|
@ -36,6 +36,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
{ "DateTime-local", "datetime-local" },
|
{ "DateTime-local", "datetime-local" },
|
||||||
{ nameof(DateTimeOffset), "text" },
|
{ nameof(DateTimeOffset), "text" },
|
||||||
{ "Time", "time" },
|
{ "Time", "time" },
|
||||||
|
{ "Month", "month" },
|
||||||
{ nameof(Byte), "number" },
|
{ nameof(Byte), "number" },
|
||||||
{ nameof(SByte), "number" },
|
{ nameof(SByte), "number" },
|
||||||
{ nameof(Int16), "number" },
|
{ nameof(Int16), "number" },
|
||||||
|
|
@ -378,7 +379,12 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
private string GetFormat(ModelExplorer modelExplorer, string inputTypeHint, string inputType)
|
private string GetFormat(ModelExplorer modelExplorer, string inputTypeHint, string inputType)
|
||||||
{
|
{
|
||||||
string format;
|
string format;
|
||||||
if (string.Equals("decimal", inputTypeHint, StringComparison.OrdinalIgnoreCase) &&
|
if (string.Equals("month", inputType, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// A new HTML5 input type that only will be rendered in Rfc3339 mode
|
||||||
|
format = "{0:yyyy-MM}";
|
||||||
|
}
|
||||||
|
else if (string.Equals("decimal", inputTypeHint, StringComparison.OrdinalIgnoreCase) &&
|
||||||
string.Equals("text", inputType, StringComparison.Ordinal) &&
|
string.Equals("text", inputType, StringComparison.Ordinal) &&
|
||||||
string.IsNullOrEmpty(modelExplorer.Metadata.EditFormatString))
|
string.IsNullOrEmpty(modelExplorer.Metadata.EditFormatString))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -370,6 +370,14 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
return GenerateTextBox(htmlHelper, inputType: "time");
|
return GenerateTextBox(htmlHelper, inputType: "time");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IHtmlContent MonthInputTemplate(IHtmlHelper htmlHelper)
|
||||||
|
{
|
||||||
|
// A new HTML5 input type that only will be rendered in Rfc3339 mode
|
||||||
|
htmlHelper.Html5DateRenderingMode = Html5DateRenderingMode.Rfc3339;
|
||||||
|
ApplyRfc3339DateFormattingIfNeeded(htmlHelper, "{0:yyyy-MM}");
|
||||||
|
return GenerateTextBox(htmlHelper, inputType: "month");
|
||||||
|
}
|
||||||
|
|
||||||
public static IHtmlContent NumberInputTemplate(IHtmlHelper htmlHelper)
|
public static IHtmlContent NumberInputTemplate(IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
return GenerateTextBox(htmlHelper, inputType: "number");
|
return GenerateTextBox(htmlHelper, inputType: "number");
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
{ "DateTime-local", DefaultEditorTemplates.DateTimeLocalInputTemplate },
|
{ "DateTime-local", DefaultEditorTemplates.DateTimeLocalInputTemplate },
|
||||||
{ nameof(DateTimeOffset), DefaultEditorTemplates.DateTimeOffsetTemplate },
|
{ nameof(DateTimeOffset), DefaultEditorTemplates.DateTimeOffsetTemplate },
|
||||||
{ "Time", DefaultEditorTemplates.TimeInputTemplate },
|
{ "Time", DefaultEditorTemplates.TimeInputTemplate },
|
||||||
|
{ "Month", DefaultEditorTemplates.MonthInputTemplate },
|
||||||
{ typeof(byte).Name, DefaultEditorTemplates.NumberInputTemplate },
|
{ typeof(byte).Name, DefaultEditorTemplates.NumberInputTemplate },
|
||||||
{ typeof(sbyte).Name, DefaultEditorTemplates.NumberInputTemplate },
|
{ typeof(sbyte).Name, DefaultEditorTemplates.NumberInputTemplate },
|
||||||
{ typeof(short).Name, DefaultEditorTemplates.NumberInputTemplate },
|
{ typeof(short).Name, DefaultEditorTemplates.NumberInputTemplate },
|
||||||
|
|
|
||||||
|
|
@ -1052,6 +1052,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
{ "text", null, "text" },
|
{ "text", null, "text" },
|
||||||
{ "TEXT", null, "text" },
|
{ "TEXT", null, "text" },
|
||||||
{ "time", null, "time" },
|
{ "time", null, "time" },
|
||||||
|
{ "month", "{0:yyyy-MM}", "month" },
|
||||||
{ "UInt16", null, "number" },
|
{ "UInt16", null, "number" },
|
||||||
{ "uint16", null, "number" },
|
{ "uint16", null, "number" },
|
||||||
{ "UInt32", null, "number" },
|
{ "UInt32", null, "number" },
|
||||||
|
|
@ -1217,6 +1218,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
[InlineData("DateTimeLocal", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-ddTHH:mm:ss.fff}", "datetime-local")]
|
[InlineData("DateTimeLocal", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-ddTHH:mm:ss.fff}", "datetime-local")]
|
||||||
[InlineData("Time", Html5DateRenderingMode.CurrentCulture, "{0:t}", "time")] // Format from [DataType].
|
[InlineData("Time", Html5DateRenderingMode.CurrentCulture, "{0:t}", "time")] // Format from [DataType].
|
||||||
[InlineData("Time", Html5DateRenderingMode.Rfc3339, "{0:HH:mm:ss.fff}", "time")]
|
[InlineData("Time", Html5DateRenderingMode.Rfc3339, "{0:HH:mm:ss.fff}", "time")]
|
||||||
|
[InlineData("Month", Html5DateRenderingMode.CurrentCulture, "{0:yyyy-MM}", "month")]
|
||||||
|
[InlineData("Month", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM}", "month")]
|
||||||
[InlineData("NullableDate", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-dd}", "date")]
|
[InlineData("NullableDate", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-dd}", "date")]
|
||||||
[InlineData("NullableDateTime", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-ddTHH:mm:ss.fff}", "datetime-local")]
|
[InlineData("NullableDateTime", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-ddTHH:mm:ss.fff}", "datetime-local")]
|
||||||
[InlineData("NullableDateTimeOffset", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-ddTHH:mm:ss.fffK}", "text")]
|
[InlineData("NullableDateTimeOffset", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-ddTHH:mm:ss.fffK}", "text")]
|
||||||
|
|
@ -1377,6 +1380,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
|
||||||
[DataType(DataType.Time)]
|
[DataType(DataType.Time)]
|
||||||
public DateTimeOffset Time { get; set; }
|
public DateTimeOffset Time { get; set; }
|
||||||
|
|
||||||
|
[DataType("month")]
|
||||||
|
public DateTimeOffset Month { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NestedModel
|
private class NestedModel
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
{ "DateTimeOffset", "__TextBox__ class='text-box single-line' type='text'" },
|
{ "DateTimeOffset", "__TextBox__ class='text-box single-line' type='text'" },
|
||||||
{ "Time", "__TextBox__ class='text-box single-line' type='time'" },
|
{ "Time", "__TextBox__ class='text-box single-line' type='time'" },
|
||||||
{ "time", "__TextBox__ class='text-box single-line' type='time'" },
|
{ "time", "__TextBox__ class='text-box single-line' type='time'" },
|
||||||
|
{ "Month", "__TextBox__ class='text-box single-line' type='month'" },
|
||||||
|
{ "month", "__TextBox__ class='text-box single-line' type='month'" },
|
||||||
{ "Byte", "__TextBox__ class='text-box single-line' type='number'" },
|
{ "Byte", "__TextBox__ class='text-box single-line' type='number'" },
|
||||||
{ "BYTE", "__TextBox__ class='text-box single-line' type='number'" },
|
{ "BYTE", "__TextBox__ class='text-box single-line' type='number'" },
|
||||||
{ "SByte", "__TextBox__ class='text-box single-line' type='number'" },
|
{ "SByte", "__TextBox__ class='text-box single-line' type='number'" },
|
||||||
|
|
@ -825,6 +827,7 @@ Environment.NewLine;
|
||||||
[InlineData("datetime-local", null, "2000-01-02T03:04:05.060", "datetime-local")]
|
[InlineData("datetime-local", null, "2000-01-02T03:04:05.060", "datetime-local")]
|
||||||
[InlineData("DateTimeOffset", "{0:o}", "2000-01-02T03:04:05.060-05:00", "text")]
|
[InlineData("DateTimeOffset", "{0:o}", "2000-01-02T03:04:05.060-05:00", "text")]
|
||||||
[InlineData("time", "{0:t}", "03:04:05.060", "time")]
|
[InlineData("time", "{0:t}", "03:04:05.060", "time")]
|
||||||
|
[InlineData("month", "{0:yyyy-MM}", "2000-01", "month")]
|
||||||
public void Editor_FindsCorrectDateOrTimeTemplate(
|
public void Editor_FindsCorrectDateOrTimeTemplate(
|
||||||
string dataTypeName,
|
string dataTypeName,
|
||||||
string editFormatString,
|
string editFormatString,
|
||||||
|
|
@ -886,6 +889,7 @@ Environment.NewLine;
|
||||||
[InlineData("datetime-local", null, "02/01/2000 03:04:05 -05:00", "datetime-local")]
|
[InlineData("datetime-local", null, "02/01/2000 03:04:05 -05:00", "datetime-local")]
|
||||||
[InlineData("DateTimeOffset", "{0:o}", "2000-01-02T03:04:05.0600000-05:00", "text")]
|
[InlineData("DateTimeOffset", "{0:o}", "2000-01-02T03:04:05.0600000-05:00", "text")]
|
||||||
[InlineData("time", "{0:t}", "03:04", "time")]
|
[InlineData("time", "{0:t}", "03:04", "time")]
|
||||||
|
[InlineData("month", "{0:yyyy-MM}", "2000-01", "month")]
|
||||||
[ReplaceCulture]
|
[ReplaceCulture]
|
||||||
public void Editor_FindsCorrectDateOrTimeTemplate_NotRfc3339(
|
public void Editor_FindsCorrectDateOrTimeTemplate_NotRfc3339(
|
||||||
string dataTypeName,
|
string dataTypeName,
|
||||||
|
|
@ -950,6 +954,7 @@ Environment.NewLine;
|
||||||
[InlineData("datetime-local", null, "2000-01-02T03:04:05.060", "datetime-local")]
|
[InlineData("datetime-local", null, "2000-01-02T03:04:05.060", "datetime-local")]
|
||||||
[InlineData("DateTimeOffset", "{0:o}", "2000-01-02T03:04:05.060Z", "text")]
|
[InlineData("DateTimeOffset", "{0:o}", "2000-01-02T03:04:05.060Z", "text")]
|
||||||
[InlineData("time", "{0:t}", "03:04:05.060", "time")]
|
[InlineData("time", "{0:t}", "03:04:05.060", "time")]
|
||||||
|
[InlineData("month", "{0:yyyy-MM}", "2000-01", "month")]
|
||||||
public void Editor_FindsCorrectDateOrTimeTemplate_ForDateTime(
|
public void Editor_FindsCorrectDateOrTimeTemplate_ForDateTime(
|
||||||
string dataTypeName,
|
string dataTypeName,
|
||||||
string editFormatString,
|
string editFormatString,
|
||||||
|
|
@ -1010,6 +1015,7 @@ Environment.NewLine;
|
||||||
[InlineData("datetime-local", null, "02/01/2000 03:04:05", "datetime-local")]
|
[InlineData("datetime-local", null, "02/01/2000 03:04:05", "datetime-local")]
|
||||||
[InlineData("DateTimeOffset", "{0:o}", "2000-01-02T03:04:05.0600000Z", "text")]
|
[InlineData("DateTimeOffset", "{0:o}", "2000-01-02T03:04:05.0600000Z", "text")]
|
||||||
[InlineData("time", "{0:t}", "03:04", "time")]
|
[InlineData("time", "{0:t}", "03:04", "time")]
|
||||||
|
[InlineData("month", "{0:yyyy-MM}", "2000-01", "month")]
|
||||||
[ReplaceCulture]
|
[ReplaceCulture]
|
||||||
public void Editor_FindsCorrectDateOrTimeTemplate_ForDateTimeNotRfc3339(
|
public void Editor_FindsCorrectDateOrTimeTemplate_ForDateTimeNotRfc3339(
|
||||||
string dataTypeName,
|
string dataTypeName,
|
||||||
|
|
@ -1076,6 +1082,8 @@ Environment.NewLine;
|
||||||
[InlineData("datetime-local", Html5DateRenderingMode.Rfc3339, "datetime-local")]
|
[InlineData("datetime-local", Html5DateRenderingMode.Rfc3339, "datetime-local")]
|
||||||
[InlineData("time", Html5DateRenderingMode.CurrentCulture, "time")]
|
[InlineData("time", Html5DateRenderingMode.CurrentCulture, "time")]
|
||||||
[InlineData("time", Html5DateRenderingMode.Rfc3339, "time")]
|
[InlineData("time", Html5DateRenderingMode.Rfc3339, "time")]
|
||||||
|
[InlineData("month", Html5DateRenderingMode.CurrentCulture, "month")]
|
||||||
|
[InlineData("month", Html5DateRenderingMode.Rfc3339, "month")]
|
||||||
public void Editor_AppliesNonDefaultEditFormat(string dataTypeName, Html5DateRenderingMode renderingMode, string expectedType)
|
public void Editor_AppliesNonDefaultEditFormat(string dataTypeName, Html5DateRenderingMode renderingMode, string expectedType)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue