You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/projects/Infrastructure/Views/Shared/Search.cshtml

45 lines
1.8 KiB

@using System.Reflection
@using Microsoft.AspNetCore.Mvc.Controllers
@using Infrastructure.Web.Mvc
@using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
@{
var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute<ControllerScopeAttribute>()?.Scope;
var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit).ToList();
}
@foreach (var prop in props)
{
var uihit = prop.TemplateHint ?? prop.DataTypeName;
var name = "query." + prop.PropertyName;
if (scope != null && scope == ControllerScopeType.Organ && prop.PropertyName == "OrganId")
{
Html.Hidden(prop.PropertyName);
continue;
}
if ((prop as DefaultModelMetadata).Attributes.Attributes.Any(o => o.GetType() == typeof(SkipSearchAttribute)))
{
continue;
}
if (prop.PropertyName == "Id" || prop.PropertyName == "Order" || prop.PropertyName == "Cron" || uihit == "ImageUrl" || uihit == "MultiSelectList" || uihit == "ImageUrl")
{
continue;
}
else
{
if (prop.IsNullableValueType && prop.UnderlyingOrModelType == typeof(bool))
{
uihit = "SearchTemplates/Boolean.cshtml";
}
if (uihit == "MultilineText")
{
uihit = "String";
}
<div class="col-12 col-sm-6 col-md-4 col-lg-3">
<div class="form-group row">
<label class="col-sm-3 col-form-label" title="@prop.GetDisplayName()" for="@prop.PropertyName" data-ui="@uihit @prop.UnderlyingOrModelType" style="text-align:right;overflow:hidden;">@prop.GetDisplayName():</label>
<div class="col-sm-9">
@Html.Editor(prop.PropertyName, uihit, prop.AdditionalValues)
</div>
</div>
</div>
}
}