diff --git a/projects/Infrastructure/Views/Shared/DisplayTemplates/Object.cshtml b/projects/Infrastructure/Views/Shared/DisplayTemplates/Object.cshtml index c25e3abd..ab744cb9 100644 --- a/projects/Infrastructure/Views/Shared/DisplayTemplates/Object.cshtml +++ b/projects/Infrastructure/Views/Shared/DisplayTemplates/Object.cshtml @@ -4,11 +4,18 @@ @foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit && !pm.HideSurroundingHtml)) { var uihit = prop.DataTypeName ?? prop.TemplateHint; -
+
@Html.Label(prop.PropertyName, prop.GetDisplayName() + ":", new { @class = "col-sm-2 col-form-label" })
- @Html.Display(prop.PropertyName, prop.DataTypeName ?? prop.TemplateHint) + @if (prop.UnderlyingOrModelType == typeof(bool)) + { + @Html.CheckBox(prop.PropertyName, new { disabled = "disabled", style = "width:20px;height:20px;margin:2px 0;" }) + } + else + { + @Html.Display(prop.PropertyName, uihit) + }
diff --git a/projects/Infrastructure/Views/Shared/EditorTemplates/Input.cshtml b/projects/Infrastructure/Views/Shared/EditorTemplates/Input.cshtml index bb66c06d..9c8bced7 100644 --- a/projects/Infrastructure/Views/Shared/EditorTemplates/Input.cshtml +++ b/projects/Infrastructure/Views/Shared/EditorTemplates/Input.cshtml @@ -6,7 +6,7 @@ @foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit)) { var metadata = prop as Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata; - object propValue = Model == null ? (prop.ModelType.IsValueType ? Activator.CreateInstance(prop.ModelType) : null) : null; + object propValue = Model == null ? (prop.ModelType.IsValueType ? Activator.CreateInstance(prop.ModelType) : null) : ViewData.ModelMetadata.ModelType.GetProperty(prop.PropertyName).GetValue(ViewData.Model); if (prop.HideSurroundingHtml) { @Html.Hidden(prop.PropertyName) @@ -18,25 +18,13 @@ var htmlClass = "col-sm-2 col-form-label"; htmlClass += isRequired ? " required" : "";
- @if (prop.ModelType != typeof(bool)) - { - @Html.Label(prop.PropertyName, prop.GetDisplayName() + ":", new { @class = htmlClass }) - } - else - { -
- } + @Html.Label(prop.PropertyName, prop.GetDisplayName() + ":", new { @class = htmlClass })
@if (metadata.Attributes.Attributes.Any(o => o.GetType() == typeof(System.ComponentModel.ReadOnlyAttribute))) { -
@Html.Hidden(prop.PropertyName) @Html.Display(prop.PropertyName, prop.DataTypeName ?? prop.TemplateHint) - @if (prop.ModelType == typeof(bool)) - { - @Html.Label(prop.PropertyName, prop.DisplayName + ":", new { @class = "form-check-label" }) - }
} else if (!string.IsNullOrEmpty(uihit) && !(uihit == "EmailAddress" || uihit == "PhoneNumber")) @@ -60,15 +48,13 @@ @Html.TextBox(prop.PropertyName, null, new { @class = inputClass }) } } - else if (prop.ModelType == typeof(bool)) + else if (prop.ModelType == typeof(bool) || prop.UnderlyingOrModelType == typeof(bool)) { -
-
- @Html.CheckBox(prop.PropertyName, new { @class = "form-check-input" }) - @Html.Label(prop.PropertyName, prop.DisplayName, new { @class = "form-check-label" }) -
+
+ @Html.CheckBox(prop.PropertyName, new { style = "width:20px;height:20px;" })
} + else { @Html.TextBox(prop.PropertyName, null, new { @class = inputClass }) diff --git a/projects/Infrastructure/Views/Shared/_Index_Row.cshtml b/projects/Infrastructure/Views/Shared/_Index_Row.cshtml index 8c290e24..50454838 100644 --- a/projects/Infrastructure/Views/Shared/_Index_Row.cshtml +++ b/projects/Infrastructure/Views/Shared/_Index_Row.cshtml @@ -2,6 +2,15 @@ foreach (var prop in props) { var templateName = prop.DataTypeName ?? prop.TemplateHint ?? (prop.ModelType == typeof(string) ? typeof(string).Name : null); - @Html.Display(prop.PropertyName, templateName) + + @if (prop.UnderlyingOrModelType == typeof(bool)) + { + @Html.CheckBox(prop.PropertyName, new { disabled = "disabled", style = "width:20px;height:20px;margin:2px 0;" }) + } + else + { + @Html.Display(prop.PropertyName, templateName) + } + } } \ No newline at end of file diff --git a/projects/WebMVC/appsettings.Development.json b/projects/WebMVC/appsettings.Development.json index 8983e0fc..45fe774a 100644 --- a/projects/WebMVC/appsettings.Development.json +++ b/projects/WebMVC/appsettings.Development.json @@ -6,4 +6,4 @@ "Microsoft.Hosting.Lifetime": "Information" } } -} +} \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/router/shared/edit/boolean.html b/projects/WebMVC/wwwroot/router/shared/edit/boolean.html index 087b58cb..e4b8f332 100644 --- a/projects/WebMVC/wwwroot/router/shared/edit/boolean.html +++ b/projects/WebMVC/wwwroot/router/shared/edit/boolean.html @@ -1,7 +1,7 @@