public WaterQualityManagementPlanVerificationGridSpec(Person currentPerson) { // Reusing permissions checks from WQMPs for WQMP Verifications var waterQualityManagementPlanManageFeature = new WaterQualityManagementPlanManageFeature(); var waterQualityManagementPlanDeleteFeature = new WaterQualityManagementPlanDeleteFeature(); var currentUserCanManage = waterQualityManagementPlanManageFeature.HasPermissionByPerson(currentPerson); ObjectNameSingular = "Water Quality Management Plan O&M Verification"; ObjectNamePlural = "Water Quality Management Plan O&M Verifications"; SaveFiltersInCookie = true; var isAnonymousOrUnassigned = currentPerson.IsAnonymousOrUnassigned(); if (currentUserCanManage) { Add(string.Empty, x => { var userHasDeletePermission = waterQualityManagementPlanDeleteFeature .HasPermission(currentPerson, x.WaterQualityManagementPlan).HasPermission; return(DhtmlxGridHtmlHelpers.MakeDeleteIconAndLinkBootstrap(x.GetDeleteUrl(), userHasDeletePermission)); }, 26, DhtmlxGridColumnFilterType.None); } if (!isAnonymousOrUnassigned) { Add(string.Empty, x => UrlTemplate.MakeHrefString(x.GetDetailUrl(), "View", new Dictionary <string, string> { { "class", "gridButton" } }), 60, DhtmlxGridColumnFilterType.None); } Add("WQMP Name", x => x.WaterQualityManagementPlan.GetDisplayNameAsUrl(), 300, DhtmlxGridColumnFilterType.Text); Add("Jurisdiction", x => isAnonymousOrUnassigned ? new HtmlString(x.WaterQualityManagementPlan.StormwaterJurisdiction.GetOrganizationDisplayName()) : x.WaterQualityManagementPlan.StormwaterJurisdiction.GetDisplayNameAsDetailUrl(), 150); Add("Verification Date", x => x.VerificationDate, 150); Add("Last Edited Date", x => x.LastEditedDate, 150); Add("Last Edited By", x => x.LastEditedByPerson.GetFullNameFirstLast(), 150, DhtmlxGridColumnFilterType.SelectFilterStrict); Add("Type of Verification", x => x.WaterQualityManagementPlanVerifyType.WaterQualityManagementPlanVerifyTypeName, 150, DhtmlxGridColumnFilterType.SelectFilterStrict); Add("Visit Status", x => x.WaterQualityManagementPlanVisitStatus.WaterQualityManagementPlanVisitStatusName, 150, DhtmlxGridColumnFilterType.SelectFilterStrict); Add("Verification Status", x => x.WaterQualityManagementPlanVerifyStatus?.WaterQualityManagementPlanVerifyStatusName, 200, DhtmlxGridColumnFilterType.SelectFilterStrict); Add("Source Control Condition", x => x.SourceControlCondition, 150); Add("Enforcement of Follow-up Actions", x => x.EnforcementOrFollowupActions, 150); Add("Draft or Finalized", x => x.IsDraft ? "Draft" : "Finalized", 100, DhtmlxGridColumnFilterType.SelectFilterStrict); }
public DetailViewData(Person currentPerson, Models.WaterQualityManagementPlan waterQualityManagementPlan, WaterQualityManagementPlanVerify waterQualityManagementPlanVerifyDraft, MapInitJson mapInitJson, List <Models.TreatmentBMP> treatmentBMPs, ParcelGridSpec parcelGridSpec, List <WaterQualityManagementPlanVerify> waterQualityManagementPlanVerifies, List <WaterQualityManagementPlanVerifyQuickBMP> waterQualityManagementPlanVerifyQuickBmPs, List <WaterQualityManagementPlanVerifyTreatmentBMP> waterQualityManagementPlanVerifyTreatmentBmPs, HRUCharacteristicsViewData hruCharacteristicsViewData, bool anyLspcBasins, List <DryWeatherFlowOverride> dryWeatherFlowOverrides, List <WaterQualityManagementPlanModelingApproach> waterQualityManagementPlanModelingApproaches, ModeledPerformanceViewData modeledPerformanceViewData) : base(currentPerson, NeptuneArea.OCStormwaterTools) { WaterQualityManagementPlan = waterQualityManagementPlan; PageTitle = WaterQualityManagementPlan.WaterQualityManagementPlanName; EntityName = $"{FieldDefinitionType.WaterQualityManagementPlan.GetFieldDefinitionLabelPluralized()}"; EntityUrl = SitkaRoute <WaterQualityManagementPlanController> .BuildUrlFromExpression(x => x.Index()); CurrentPersonCanManageWaterQualityManagementPlans = new WaterQualityManagementPlanManageFeature() .HasPermission(currentPerson, waterQualityManagementPlan) .HasPermission; currentPerson.IsManagerOrAdmin(); EditInventoriedBMPsUrl = SitkaRoute <WaterQualityManagementPlanController> .BuildUrlFromExpression(c => c.EditWqmpBmps(WaterQualityManagementPlan)); EditSimplifiedStructuralBMPsUrl = SitkaRoute <WaterQualityManagementPlanController> .BuildUrlFromExpression(c => c.EditSimplifiedStructuralBMPs(WaterQualityManagementPlan)); EditSourceControlBMPsUrl = SitkaRoute <WaterQualityManagementPlanController> .BuildUrlFromExpression(c => c.EditSourceControlBMPs(WaterQualityManagementPlan)); EditModelingApproachUrl = SitkaRoute <WaterQualityManagementPlanController> .BuildUrlFromExpression(c => c.EditModelingApproach(WaterQualityManagementPlan)); EditParcelsUrl = SitkaRoute <WaterQualityManagementPlanController> .BuildUrlFromExpression(c => c.EditWqmpParcels(WaterQualityManagementPlan)); NewDocumentUrl = SitkaRoute <WaterQualityManagementPlanDocumentController> .BuildUrlFromExpression(c => c.New(waterQualityManagementPlan)); MapInitJson = mapInitJson; ParameterizationErrors = CheckForParameterizationErrors(waterQualityManagementPlan); ParcelGridSpec = parcelGridSpec; ParcelGridName = "parcelGrid"; ParcelGridDataUrl = SitkaRoute <WaterQualityManagementPlanController> .BuildUrlFromExpression(c => c.ParcelsForWaterQualityManagementPlanGridData(waterQualityManagementPlan)); HasSavedWqmpDraft = waterQualityManagementPlanVerifyDraft != null && waterQualityManagementPlanVerifyDraft.IsDraft; BeginOMVerificationRecordUrl = HasSavedWqmpDraft ? SitkaRoute <WaterQualityManagementPlanController> .BuildUrlFromExpression(c => c.EditWqmpVerifyModal(waterQualityManagementPlanVerifyDraft)) : SitkaRoute <WaterQualityManagementPlanController> .BuildUrlFromExpression(c => c.NewWqmpVerify(waterQualityManagementPlan)); SourceControlBMPs = waterQualityManagementPlan.SourceControlBMPs .Where(x => x.IsPresent == true || x.SourceControlBMPNote != null) .OrderBy(x => x.SourceControlBMPAttributeID) .GroupBy(x => x.SourceControlBMPAttribute.SourceControlBMPAttributeCategoryID); WaterQualityManagementPlanVerifies = waterQualityManagementPlanVerifies; WaterQualityManagementPlanVerifyQuickBMPs = waterQualityManagementPlanVerifyQuickBmPs; WaterQualityManagementPlanVerifyTreatmentBMPs = waterQualityManagementPlanVerifyTreatmentBmPs; HRUCharacteristicsViewData = hruCharacteristicsViewData; TreatmentBMPs = treatmentBMPs; QuickBMPs = waterQualityManagementPlan.QuickBMPs.OrderBy(x => x.QuickBMPName).ToList(); SourceControlBMPs = waterQualityManagementPlan.SourceControlBMPs .Where(x => x.SourceControlBMPNote != null || (x.IsPresent != null && x.IsPresent == true)) .OrderBy(x => x.SourceControlBMPAttributeID) .GroupBy(x => x.SourceControlBMPAttribute.SourceControlBMPAttributeCategoryID); var calculatedParcelAcres = WaterQualityManagementPlan .CalculateParcelAcreageTotal(); // This is 'calculated' by summing parcel recorded acres - not sure that's what's intended by calculated in this case // TODO: Never compare floating-point values to zero. We should establish an application-wide error tolerance and use that instead of the direct comparison CalculatedParcelArea = calculatedParcelAcres != 0 ? $"{Math.Round(calculatedParcelAcres, 2).ToString(CultureInfo.InvariantCulture)} acres" : "No parcels have been associated with this WQMP"; TrashCaptureEffectiveness = WaterQualityManagementPlan.TrashCaptureEffectiveness == null ? "Not Provided" : WaterQualityManagementPlan.TrashCaptureEffectiveness + "%"; WaterQualityManagementPlanModelingApproaches = waterQualityManagementPlanModelingApproaches; ModeledPerformanceViewData = modeledPerformanceViewData; FieldDefinitionForPercentOfSiteTreated = FieldDefinitionType.PercentOfSiteTreated; FieldDefinitionForPercentCaptured = FieldDefinitionType.PercentCaptured; FieldDefinitionForPercentRetained = FieldDefinitionType.PercentRetained; FieldDefinitionForFullyParameterized = FieldDefinitionType.FullyParameterized; FieldDefinitionForDelineationStatus = FieldDefinitionType.DelineationStatus; FieldDefinitionForDryWeatherFlowOverride = FieldDefinitionType.DryWeatherFlowOverride; AnyLSPCBasins = anyLspcBasins; UsesDetailedModelingApproach = WaterQualityManagementPlan.WaterQualityManagementPlanModelingApproachID == WaterQualityManagementPlanModelingApproach.Detailed .WaterQualityManagementPlanModelingApproachID; if (UsesDetailedModelingApproach) { AnyDetailedBMPsNotFullyParameterized = TreatmentBMPs.Any(x => !(x.IsFullyParameterized() && (x.Delineation?.IsVerified ?? false))); AllDetailedBMPsNotFullyParameterized = TreatmentBMPs.All(x => !(x.IsFullyParameterized() && (x.Delineation?.IsVerified ?? false))); // this is redundant but I just want to make this perfectly clear. AnySimpleBMPsNotFullyParameterized = false; AllSimpleBMPsNotFullyParameterized = false; } else { AnySimpleBMPsNotFullyParameterized = QuickBMPs.Any(x => !x.IsFullyParameterized()); AllSimpleBMPsNotFullyParameterized = QuickBMPs.All(x => !x.IsFullyParameterized()); // this is redundant but I just want to make this perfectly clear. AnyDetailedBMPsNotFullyParameterized = false; AllDetailedBMPsNotFullyParameterized = false; } }
public WaterQualityManagementPlanIndexGridSpec(Person currentPerson) { var fieldDefinitionWaterQualityManagementPlan = FieldDefinitionType.WaterQualityManagementPlan; var waterQualityManagementPlanLabelSingular = fieldDefinitionWaterQualityManagementPlan.GetFieldDefinitionLabel(); ObjectNameSingular = waterQualityManagementPlanLabelSingular; ObjectNamePlural = fieldDefinitionWaterQualityManagementPlan.GetFieldDefinitionLabelPluralized(); SaveFiltersInCookie = true; var waterQualityManagementPlanDeleteFeature = new WaterQualityManagementPlanDeleteFeature(); var qualityManagementPlanManageFeature = new WaterQualityManagementPlanManageFeature(); var isAnonymousOrUnassigned = currentPerson.IsAnonymousOrUnassigned(); Add(string.Empty, x => DhtmlxGridHtmlHelpers.MakeDeleteIconAndLinkBootstrap(x.GetDeleteUrl(), waterQualityManagementPlanDeleteFeature.HasPermission(currentPerson, x).HasPermission), 26, DhtmlxGridColumnFilterType.None); Add(string.Empty, x => DhtmlxGridHtmlHelpers.MakeEditIconAsModalDialogLinkBootstrap(new ModalDialogForm(x.GetEditUrl(), ModalDialogFormHelper.DefaultDialogWidth, $"Edit {waterQualityManagementPlanLabelSingular}"), qualityManagementPlanManageFeature.HasPermission(currentPerson, x).HasPermission), 26, DhtmlxGridColumnFilterType.None); Add("Name", x => x.GetDisplayNameAsUrl(), 300, DhtmlxGridColumnFilterType.Text); Add("Jurisdiction", x => isAnonymousOrUnassigned ? new HtmlString(x.StormwaterJurisdiction.GetOrganizationDisplayName()) : x.StormwaterJurisdiction.GetDisplayNameAsDetailUrl(), 150); Add("Priority", x => x.WaterQualityManagementPlanPriority?.WaterQualityManagementPlanPriorityDisplayName, 100, DhtmlxGridColumnFilterType.SelectFilterStrict); Add("Status", x => x.WaterQualityManagementPlanStatus?.WaterQualityManagementPlanStatusDisplayName, 100, DhtmlxGridColumnFilterType.SelectFilterStrict); Add("Development Type", x => x.WaterQualityManagementPlanDevelopmentType?.WaterQualityManagementPlanDevelopmentTypeDisplayName, 100, DhtmlxGridColumnFilterType.SelectFilterStrict); Add("Land Use", x => x.WaterQualityManagementPlanLandUse?.WaterQualityManagementPlanLandUseDisplayName, 100, DhtmlxGridColumnFilterType.SelectFilterStrict); Add("Permit Term", x => x.WaterQualityManagementPlanPermitTerm?.WaterQualityManagementPlanPermitTermDisplayName, 100, DhtmlxGridColumnFilterType.SelectFilterStrict); Add("Approval Date", x => x.ApprovalDate, 120); Add("Date of Construction", x => x.DateOfContruction, 120); Add(FieldDefinitionType.HydromodificationApplies.ToGridHeaderString(), x => x.HydromodificationAppliesType?.HydromodificationAppliesTypeDisplayName, 130, DhtmlxGridColumnFilterType.SelectFilterStrict); Add("Hydrologic Subarea", x => x.HydrologicSubarea?.HydrologicSubareaName, 120, DhtmlxGridColumnFilterType.SelectFilterStrict); if (!currentPerson.IsAnonymousOrUnassigned()) { Add("Maintenance Contact Organization", x => x.MaintenanceContactOrganization, 120); Add("Maintenance Contact Name", x => x.MaintenanceContactName, 100); Add("Maintenance Contact Address", x => x.MaintenanceContactAddressToString(), 200); Add("Maintenance Contact Phone", x => x.MaintenanceContactPhone, 70); } Add("# of Inventoried BMPs", x => currentPerson.GetInventoriedBMPsForWQMP(x).Count(), 100); Add("# of Simplified BMPs", x => x.QuickBMPs.Count, 100); Add("Modeling Approach", x => x.WaterQualityManagementPlanModelingApproach.WaterQualityManagementPlanModelingApproachDisplayName, 100, DhtmlxGridColumnFilterType.SelectFilterStrict); Add(FieldDefinitionType.FullyParameterized.ToGridHeaderString("Fully Parameterized?"), x => x.IsFullyParameterized() ? new HtmlString("Yes") : new HtmlString("No"), 120); Add("# of Documents", x => x.WaterQualityManagementPlanDocuments.Count, 100); Add(FieldDefinitionType.HasAllRequiredDocuments.ToGridHeaderString(), x => x.HasAllRequiredDocuments() ? BootstrapHtmlHelpers.MakeGlyphIconWithHiddenText("glyphicon-ok-circle", "Yes") : new HtmlString("<span style='display:none;'>No</span>") , 100, DhtmlxGridColumnFilterType.SelectFilterHtmlStrict, DhtmlxGridColumnAlignType.Center); Add("Record Number", x => x.RecordNumber, 150); Add("Recorded Parcel Acreage", x => x.RecordedWQMPAreaInAcres, 100); Add("Calculated Parcel Acreage", x => Math.Round(x.CalculateParcelAcreageTotal(), 1), 100); Add("Latest O&M Verification", x => currentPerson.IsAnonymousOrUnassigned() ? new HtmlString(x.GetLatestOandMVerificationDate().IsNullOrWhiteSpace() ? "N/A" : x.GetLatestOandMVerificationDate()) :new HtmlString(!x.GetLatestOandMVerificationDate().IsNullOrWhiteSpace() ? $"<a href=\"{x.GetLatestOandMVerificationUrl()}\" alt=\"{x.GetLatestOandMVerificationDate()}\" title=\"{x.GetLatestOandMVerificationDate()}\" >{x.GetLatestOandMVerificationDate()}</a>" : "N/A"), 100); Add(FieldDefinitionType.TrashCaptureStatus.ToGridHeaderString(), x => x.TrashCaptureStatusType.TrashCaptureStatusTypeDisplayName, 130, DhtmlxGridColumnFilterType.SelectFilterStrict); }