public ProjectIndexGridSpec(Person currentPerson , bool allowTaggingFunctionality , bool allowDeleteFunctionality , Dictionary <int, vTotalTreatedAcresByProject> totalTreatedAcresByProjectDictionary , Dictionary <int, List <Models.Program> > programsByProject) { var userHasTagManagePermissions = new FirmaAdminFeature().HasPermissionByPerson(currentPerson); var userHasDeletePermissions = new ProjectDeleteFeature().HasPermissionByPerson(currentPerson); if (userHasTagManagePermissions && allowTaggingFunctionality) { BulkTagModalDialogForm = new BulkTagModalDialogForm(SitkaRoute <TagController> .BuildUrlFromExpression(x => x.BulkTagProjects(null)), $"Tag Checked {Models.FieldDefinition.Project.GetFieldDefinitionLabelPluralized()}", $"Tag {Models.FieldDefinition.Project.GetFieldDefinitionLabelPluralized()}"); AddCheckBoxColumn(); Add("ProjectID", x => x.ProjectID, 0); } if (userHasDeletePermissions && allowDeleteFunctionality) { Add(string.Empty, x => DhtmlxGridHtmlHelpers.MakeDeleteIconAndLinkBootstrap(x.GetDeleteUrl(), true, true), 30, DhtmlxGridColumnFilterType.None); } Add(string.Empty, x => MakeFactSheetUrl(x), 30, DhtmlxGridColumnFilterType.None); Add(Models.FieldDefinition.FhtProjectNumber.ToGridHeaderString(), x => UrlTemplate.MakeHrefString(x.GetDetailUrl(), x.FhtProjectNumber), 100, DhtmlxGridColumnFilterType.Text); Add(Models.FieldDefinition.ProjectName.ToGridHeaderString(), x => UrlTemplate.MakeHrefString(x.GetDetailUrl(), x.ProjectName), 200, DhtmlxGridColumnFilterType.Html); Add(Models.FieldDefinition.ProjectType.ToGridHeaderString(), x => x.ProjectType.DisplayName, 120, DhtmlxGridColumnFilterType.SelectFilterStrict); Add(Models.FieldDefinition.ProjectStage.ToGridHeaderString(), x => x.ProjectStage.ProjectStageDisplayName, 90, DhtmlxGridColumnFilterType.SelectFilterStrict); Add(Models.FieldDefinition.ProjectTotalCompletedTreatmentAcres.ToGridHeaderString(), x => TotalTreatedAcres(x, totalTreatedAcresByProjectDictionary), 100, DhtmlxGridColumnFormatType.Decimal); Add($"{MultiTenantHelpers.GetIsPrimaryContactOrganizationRelationship().RelationshipTypeName} Organization", x => x.GetPrimaryContactOrganization()?.DisplayName, 200, DhtmlxGridColumnFilterType.SelectFilterStrict); Add(Models.FieldDefinition.Program.ToGridHeaderStringPlural("Programs"), x => Program(x, programsByProject), 90, DhtmlxGridColumnFilterType.Html); Add($"Associated {Models.FieldDefinition.PriorityLandscape.ToGridHeaderString()}", x => x.ProjectPriorityLandscapes.FirstOrDefault()?.PriorityLandscape?.DisplayName, 125, DhtmlxGridColumnFilterType.SelectFilterStrict); }
public ProjectCustomGridSpec(FirmaSession currentFirmaSession, List <ProjectCustomGridConfiguration> projectCustomGridConfigurations, ProjectCustomGridTypeEnum projectCustomGridTypeEnum, Dictionary <int, vProjectDetail> projectDetailsDictionary, ProjectFirmaModels.Models.Tenant tenant) { bool userHasTagManagePermissions = new FirmaAdminFeature().HasPermissionByFirmaSession(currentFirmaSession); bool userHasDeletePermissions = new ProjectDeleteFeature().HasPermissionByFirmaSession(currentFirmaSession); bool userHasEditProjectAsAdminPermissions = new ProjectEditAsAdminFeature().HasPermissionByFirmaSession(currentFirmaSession); bool userHasReportDownloadPermissions = new ReportTemplateGenerateReportsFeature().HasPermissionByFirmaSession(currentFirmaSession); var geospatialAreas = HttpRequestStorage.DatabaseEntities.vGeospatialAreas.Where(x => x.TenantID == tenant.TenantID).ToDictionary(x => x.GeospatialAreaID); var projectCustomAttributes = HttpRequestStorage.DatabaseEntities.vProjectCustomAttributeValues.Where(x => x.TenantID == tenant.TenantID) .GroupBy(x => x.ProjectID) .ToDictionary(grp => grp.Key, y => y.ToList()); var projectGeospatialAreas = HttpRequestStorage.DatabaseEntities.ProjectGeospatialAreas .GroupBy(x => x.ProjectID).ToDictionary(grp => grp.Key, y => y.ToList()); var taxonomyLeafs = HttpRequestStorage.DatabaseEntities.TaxonomyLeafs.ToDictionary(x => x.TaxonomyLeafID); var projectLabel = FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel(); bool hasProjectApprovalPermissionBySession = new ProjectApproveFeature().HasPermissionByFirmaSession(currentFirmaSession); var statusUpdateLabel = FieldDefinitionEnum.StatusUpdate.ToType().GetFieldDefinitionLabel(); var sitkaAdminPersonIDs = HttpRequestStorage.DatabaseEntities.AllPeople.Where(x => x.RoleID == ProjectFirmaModels.Models.Role.SitkaAdmin.RoleID).Select(x => x.PersonID).ToList(); // Mandatory fields before AddMandatoryFieldsBefore(userHasTagManagePermissions, userHasReportDownloadPermissions, userHasDeletePermissions, projectCustomGridTypeEnum); // Implement configured fields here AddConfiguredFields(currentFirmaSession , projectCustomGridConfigurations , userHasEditProjectAsAdminPermissions , projectDetailsDictionary , geospatialAreas , taxonomyLeafs , projectGeospatialAreas , projectCustomAttributes , projectLabel , hasProjectApprovalPermissionBySession , statusUpdateLabel , sitkaAdminPersonIDs); // Mandatory fields appearing AFTER configurable fields AddMandatoryFieldsAfter(userHasTagManagePermissions); }
public IndexGridSpec(Person currentPerson, Dictionary <int, FundingType> fundingTypes, List <GeospatialAreaType> geospatialAreaTypes, List <ProjectFirmaModels.Models.ProjectCustomAttributeType> projectCustomAttributeTypes) { var userHasTagManagePermissions = new FirmaAdminFeature().HasPermissionByPerson(currentPerson); var userHasDeletePermissions = new ProjectDeleteFeature().HasPermissionByPerson(currentPerson); var userHasEmailViewingPermissions = new LoggedInAndNotUnassignedRoleUnclassifiedFeature().HasPermissionByPerson(currentPerson); if (userHasTagManagePermissions) { BulkTagModalDialogForm = new BulkTagModalDialogForm(SitkaRoute <TagController> .BuildUrlFromExpression(x => x.BulkTagProjects(null)), $"Tag Checked {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}", $"Tag {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}"); AddCheckBoxColumn(); Add("ProjectID", x => x.ProjectID, 0); } if (userHasDeletePermissions) { Add(string.Empty, x => DhtmlxGridHtmlHelpers.MakeDeleteIconAndLinkBootstrap(x.GetDeleteUrl(), true), 30, DhtmlxGridColumnFilterType.None); } Add(string.Empty, x => UrlTemplate.MakeHrefString(x.GetFactSheetUrl(), FirmaDhtmlxGridHtmlHelpers.FactSheetIcon.ToString()), 30, DhtmlxGridColumnFilterType.None); Add(FieldDefinitionEnum.ProjectName.ToType().ToGridHeaderString(), x => UrlTemplate.MakeHrefString(x.GetDetailUrl(), x.ProjectName), 300, DhtmlxGridColumnFilterType.Html); if (MultiTenantHelpers.HasCanStewardProjectsOrganizationRelationship()) { Add(FieldDefinitionEnum.ProjectsStewardOrganizationRelationshipToProject.ToType().ToGridHeaderString(), x => x.GetCanStewardProjectsOrganization()?.GetShortNameAsUrl() ?? new HtmlString(""), 150, DhtmlxGridColumnFilterType.Html); } Add(FieldDefinitionEnum.IsPrimaryContactOrganization.ToType().ToGridHeaderString(), x => x.GetPrimaryContactOrganization().GetShortNameAsUrl(), 150, DhtmlxGridColumnFilterType.Html); Add(FieldDefinitionEnum.ProjectPrimaryContact.ToType().ToGridHeaderString(), x => x.GetPrimaryContact() != null ? UrlTemplate.MakeHrefString(x.GetPrimaryContact().GetDetailUrl(), x.GetPrimaryContact().GetFullNameLastFirst()) : new HtmlString(""), 150, DhtmlxGridColumnFilterType.Html); if (userHasEmailViewingPermissions) { Add(FieldDefinitionEnum.ProjectPrimaryContactEmail.ToType().ToGridHeaderString(), x => x.GetPrimaryContact() != null ? new HtmlString($"<a href='mailto:{x.GetPrimaryContact().Email}'> {x.GetPrimaryContact().Email}</a>") : new HtmlString(""), 200, DhtmlxGridColumnFilterType.SelectFilterHtmlStrict); } Add(FieldDefinitionEnum.ProjectStage.ToType().ToGridHeaderString(), x => x.ProjectStage.ProjectStageDisplayName, 90, DhtmlxGridColumnFilterType.SelectFilterStrict); Add(FieldDefinitionEnum.PlanningDesignStartYear.ToType().ToGridHeaderString(), x => ProjectModelExtensions.GetPlanningDesignStartYear(x), 90, DhtmlxGridColumnFilterType.SelectFilterStrict); Add(FieldDefinitionEnum.ImplementationStartYear.ToType().ToGridHeaderString(), x => ProjectModelExtensions.GetImplementationStartYear(x), 115, DhtmlxGridColumnFilterType.SelectFilterStrict); Add(FieldDefinitionEnum.CompletionYear.ToType().ToGridHeaderString(), x => ProjectModelExtensions.GetCompletionYear(x), 90, DhtmlxGridColumnFilterType.SelectFilterStrict); Add($"Primary {FieldDefinitionEnum.TaxonomyLeaf.ToType().ToGridHeaderString()}", x => x.TaxonomyLeaf.GetDisplayNameAsUrl(), 200, DhtmlxGridColumnFilterType.Html); var enableSecondaryProjectTaxonomyLeaf = MultiTenantHelpers.GetTenantAttribute().EnableSecondaryProjectTaxonomyLeaf; if (enableSecondaryProjectTaxonomyLeaf) { Add(FieldDefinitionEnum.SecondaryProjectTaxonomyLeaf.ToType().ToGridHeaderStringPlural(), x => new HtmlString(string.Join(", ", x.SecondaryProjectTaxonomyLeafs.Select(y => y.TaxonomyLeaf.GetDisplayNameAsUrl().ToString()))), 300, DhtmlxGridColumnFilterType.Html); } // Agreements for this project Add(FieldDefinitionEnum.Agreement.ToType().ToGridHeaderStringPlural(), x => GetAgreementHrefsString(x), 100, DhtmlxGridColumnFilterType.Text); // TODO: add links to Cost Authorities Add(FieldDefinitionEnum.CostAuthorityWorkBreakdownStructure.ToType().ToGridHeaderStringPlural(), x => GetCostAuthorityHrefsString(x), 100, DhtmlxGridColumnFilterType.Text); Add($"Number Of Reported {MultiTenantHelpers.GetPerformanceMeasureName()} Records", x => x.PerformanceMeasureActuals.Count, 100); Add($"Number Of {FieldDefinitionEnum.ReportedExpenditure.ToType().GetFieldDefinitionLabel()} Records", x => x.ProjectFundingSourceExpenditures.Count, 100); Add(FieldDefinitionEnum.FundingType.ToType().ToGridHeaderString(), x => x.FundingTypeID.HasValue ? fundingTypes[x.FundingTypeID.Value].FundingTypeDisplayName : "", 300, DhtmlxGridColumnFilterType.SelectFilterStrict); Add(FieldDefinitionEnum.EstimatedTotalCost.ToType().ToGridHeaderString(), x => x.GetEstimatedTotalRegardlessOfFundingType(), 110, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total); Add(FieldDefinitionEnum.SecuredFunding.ToType().ToGridHeaderString(), x => x.GetSecuredFunding(), 110, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total); Add(FieldDefinitionEnum.TargetedFunding.ToType().ToGridHeaderString(), x => x.GetTargetedFunding(), 100, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total); Add(FieldDefinitionEnum.NoFundingSourceIdentified.ToType().ToGridHeaderString(), x => x.GetNoFundingSourceIdentifiedAmount(), 110, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total); foreach (var projectCustomAttributeType in projectCustomAttributeTypes.OrderBy(x => x.ProjectCustomAttributeTypeName)) { if (projectCustomAttributeType.IncludeInProjectGrid && projectCustomAttributeType.HasViewPermission(currentPerson)) { Add($"{projectCustomAttributeType.ProjectCustomAttributeTypeName}", a => a.GetProjectCustomAttributesValue(projectCustomAttributeType), 150, DhtmlxGridColumnFilterType.Text); } } foreach (var geospatialAreaType in geospatialAreaTypes.OrderBy(x => x.GeospatialAreaTypeName)) { Add($"{geospatialAreaType.GeospatialAreaTypeNamePluralized}", a => a.GetProjectGeospatialAreaNamesAsHyperlinks(geospatialAreaType), 350, DhtmlxGridColumnFilterType.Html); } Add(FieldDefinitionEnum.ProjectDescription.ToType().ToGridHeaderString(), x => x.ProjectDescription, 200); if (userHasTagManagePermissions) { Add("Tags", x => new HtmlString(!x.ProjectTags.Any() ? string.Empty : string.Join(", ", x.ProjectTags.Select(pt => pt.Tag.GetDisplayNameAsUrl()))), 100, DhtmlxGridColumnFilterType.Html); } Add("# of Photos", x => x.ProjectImages.Count, 60); }