Make ViewModel bool parameters nullable

This commit is contained in:
2020-08-03 08:26:28 -04:00
parent 803717d9e5
commit b1bff76159
6 changed files with 22 additions and 9 deletions
+4 -4
View File
@@ -57,10 +57,10 @@ namespace LeafWeb.WebCms.Models
public string phips2 { get; set; } public string phips2 { get; set; }
[Display(Name = "Show Only Successfully Completed")] [Display(Name = "Show Only Successfully Completed")]
public bool compl { get; set; } public bool? compl { get; set; }
[Display(Name = "Only my data")] [Display(Name = "Only my data")]
public bool usr { get; set; } public bool? usr { get; set; }
public bool HasExtendedParameters => public bool HasExtendedParameters =>
!( !(
@@ -74,12 +74,12 @@ namespace LeafWeb.WebCms.Models
&& string.IsNullOrEmpty(pari) && string.IsNullOrEmpty(pari)
&& string.IsNullOrEmpty(tleaf) && string.IsNullOrEmpty(tleaf)
&& string.IsNullOrEmpty(phips2) && string.IsNullOrEmpty(phips2)
&& !compl && !(compl.HasValue && compl.Value)
); );
public bool HasParameters => public bool HasParameters =>
HasExtendedParameters HasExtendedParameters
|| !string.IsNullOrEmpty(q) || !string.IsNullOrEmpty(q)
|| usr; || usr.HasValue && usr.Value;
} }
} }
+2 -2
View File
@@ -143,7 +143,7 @@ namespace LeafWeb.WebCms.Utility
select li; select li;
} }
if (query.compl) if (query.compl.HasValue && query.compl.Value)
{ {
resultItems = resultItems =
from li in resultItems from li in resultItems
@@ -154,7 +154,7 @@ namespace LeafWeb.WebCms.Utility
select li; select li;
} }
if (query.usr && !string.IsNullOrEmpty(currentUserEmail)) if (query.usr.HasValue && query.usr.Value && !string.IsNullOrEmpty(currentUserEmail))
{ {
resultItems = resultItems =
from li in resultItems from li in resultItems
+2 -2
View File
@@ -1,12 +1,12 @@
@using System.Web.Mvc.Html @using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc @using ClientDependency.Core.Mvc
@using LeafWeb.WebCms.Utility
@model LeafDataQuery @model LeafDataQuery
@{ @{
Html.RequiresJs("~/scripts/jquery.validate.min.js", 2); Html.RequiresJs("~/scripts/jquery.validate.min.js", 2);
Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.min.js", 2); Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.min.js", 2);
Html.RequiresJs("~/scripts/jquery.validate.custom.js", 2); Html.RequiresJs("~/scripts/jquery.validate.custom.js", 2);
Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.bootstrap.js", 2); Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.bootstrap.js", 2);
Html.RequiresJs("~/scripts/LeafDataQuery.js", 3);
var actionName = string.Empty; var actionName = string.Empty;
var controllerName = string.Empty; var controllerName = string.Empty;
@@ -25,7 +25,7 @@
htmlFormAction = (string)ViewData["htmlFormAction"]; htmlFormAction = (string)ViewData["htmlFormAction"];
} }
} }
@using (Html.BeginUmbracoForm(actionName, controllerName, null, new { action = htmlFormAction })) @using (Html.BeginUmbracoForm(actionName, controllerName, null, new { action = htmlFormAction, id = "leafdataquery" }))
{ {
<div class="row justify-content-end"> <div class="row justify-content-end">
<div class="col text-right pt-2"> <div class="col text-right pt-2">
+1
View File
@@ -1130,6 +1130,7 @@
<Compile Include="Models\QueueViewModel.cs" /> <Compile Include="Models\QueueViewModel.cs" />
<Compile Include="Models\SelectListViewModel.cs" /> <Compile Include="Models\SelectListViewModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="scripts\LeafDataQuery.js" />
<Compile Include="Services\UrlService.cs" /> <Compile Include="Services\UrlService.cs" />
<Compile Include="Services\EmailNotificationService.cs" /> <Compile Include="Services\EmailNotificationService.cs" />
<Compile Include="Services\LeafGasCharter.cs" /> <Compile Include="Services\LeafGasCharter.cs" />
+11
View File
@@ -0,0 +1,11 @@
$(function() {
$("form#leafdataquery .latr input.form-control")
.rules("add",
{
//required: true
required: function ()
{
return !!$(".lat input.form-control").val();
}
});
});
+2 -1
View File
@@ -28,7 +28,8 @@
return false; return false;
}); });
$("form:not(.confirm)").submit(function() { $("form:not(.confirm)").submit(function () {
if (!$(this).valid()) return;
var btn = $(this).find(":submit"); var btn = $(this).find(":submit");
btn.prop("disabled", true); btn.prop("disabled", true);
btn.html( btn.html(