예제 #1
0
        public AgreementIndexViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.FirmaPage firmaPage) : base(currentFirmaSession, firmaPage)
        {
            PageTitle = MultiTenantHelpers.GetAgreementNamePluralized();

            HasAgreementManagePermissions = new AgreementManageFeature().HasPermissionByFirmaSession(currentFirmaSession);
            DisplayActionButtons          = HasAgreementManagePermissions;

            AgreementGridSpec = new AgreementGridSpec(currentFirmaSession)
            {
                ObjectNameSingular  = MultiTenantHelpers.GetAgreementName(),
                ObjectNamePlural    = MultiTenantHelpers.GetAgreementNamePluralized(),
                SaveFiltersInCookie = true
            };

            AgreementGridName    = "AgreementsGrid";
            AgreementGridDataUrl = SitkaRoute <AgreementController> .BuildUrlFromExpression(c => c.AgreementGridJsonData());

            AgreementIndexViewPageContentViewData = new ViewPageContentViewData(firmaPage, true);

            bool hasAgreementManagementRights = new AgreementManageFeature().HasPermissionByPerson(currentFirmaSession.Person);

            ShowAgreementEditingControls = FirmaWebConfiguration.FeatureAlevinAgreementCreationAndEditing && hasAgreementManagementRights;
            NewAgreementUrl = SitkaRoute <AgreementController> .BuildUrlFromExpression(t => t.NewAgreement());

            //AgreementGridSpec.CustomExcelDownloadLinkText = $"Download with {FieldDefinitionEnum.AgreementSubcategory.ToType().GetFieldDefinitionLabelPluralized()}";
            //AgreementGridSpec.CustomExcelDownloadUrl = SitkaRoute<AgreementController>.BuildUrlFromExpression(tc => tc.IndexExcelDownload());
        }
        public OrganizationDetailViewData(FirmaSession currentFirmaSession,
                                          ProjectFirmaModels.Models.Organization organization,
                                          MapInitJson mapInitJson,
                                          LayerGeoJson projectLocationsLayerGeoJson,
                                          bool hasSpatialData,
                                          List <ProjectFirmaModels.Models.PerformanceMeasure> performanceMeasures,
                                          ViewGoogleChartViewData expendituresDirectlyFromOrganizationViewGoogleChartViewData,
                                          ViewGoogleChartViewData expendituresReceivedFromOtherOrganizationsViewGoogleChartViewData,
                                          List <MatchmakerTaxonomyTier> topLevelMatchmakerTaxonomyTier,
                                          int maximumTaxonomyLeaves,
                                          OrganizationDetailTab activeTab, MapInitJson matchMakerAreaOfInterestInitJson,
                                          List <IGrouping <ProjectFirmaModels.Models.ClassificationSystem, MatchmakerOrganizationClassification> >
                                          matchmakerClassificationsGroupedByClassificationSystem,
                                          List <ProjectFirmaModels.Models.ClassificationSystem> allClassificationSystems) : base(currentFirmaSession)
        {
            Organization = organization;
            Check.EnsureNotNull(organization);
            PageTitle  = organization.GetDisplayName();
            EntityName = $"{FieldDefinitionEnum.Organization.ToType().GetFieldDefinitionLabel()}";
            UserHasOrganizationManagePermissions = new OrganizationManageFeature().HasPermissionByFirmaSession(currentFirmaSession);
            UserHasOrganizationManagePrimaryContactPermissions = new OrganizationPrimaryContactManageFeature().HasPermissionByFirmaSession(currentFirmaSession);

            EditOrganizationUrl = SitkaRoute <OrganizationController> .BuildUrlFromExpression(c => c.Edit(organization));

            EditBoundaryUrl =
                SitkaRoute <OrganizationController> .BuildUrlFromExpression(c => c.EditBoundary(organization));

            DeleteOrganizationBoundaryUrl =
                SitkaRoute <OrganizationController> .BuildUrlFromExpression(
                    c => c.DeleteOrganizationBoundary(organization));

            EditOrganizationPrimaryContactUrl = SitkaRoute <OrganizationController> .BuildUrlFromExpression(c => c.EditPrimaryContact(organization));

            AgreementsGridSpec = new AgreementGridSpec(currentFirmaSession)
            {
                ObjectNameSingular  = MultiTenantHelpers.GetAgreementName(),
                ObjectNamePlural    = MultiTenantHelpers.GetAgreementNamePluralized(),
                SaveFiltersInCookie = true
            };

            AgreementsGridName    = "OrganizationAgreementsGrid";
            AgreementsGridDataUrl = SitkaRoute <AgreementController> .BuildUrlFromExpression(c => c.AgreementGridForOrganizationJsonData(this.Organization.OrganizationID));

            ProjectsIncludingLeadImplementingGridSpec =
                new ProjectsIncludingLeadImplementingGridSpec(organization, currentFirmaSession, false)
            {
                ObjectNameSingular  = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}",
                ObjectNamePlural    = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()} associated with {organization.GetDisplayName()}",
                SaveFiltersInCookie = true
            };

            ProjectOrganizationsGridName    = "projectOrganizationsFromOrganizationGrid";
            ProjectOrganizationsGridDataUrl =
                SitkaRoute <OrganizationController> .BuildUrlFromExpression(
                    tc => tc.ProjectsIncludingLeadImplementingGridJsonData(organization));

            ProjectStewardOrLeadImplementorFieldDefinitionName = MultiTenantHelpers.HasCanStewardProjectsOrganizationRelationship()
                ? FieldDefinitionEnum.ProjectsStewardOrganizationRelationshipToProject.ToType().GetFieldDefinitionLabel()
                : "Lead Implementer";

            ProjectFundingSourceExpendituresForOrganizationGridSpec =
                new ProjectFundingSourceExpendituresForOrganizationGridSpec(organization)
            {
                ObjectNameSingular  = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} {FieldDefinitionEnum.ReportedExpenditure.ToType().GetFieldDefinitionLabel()}",
                ObjectNamePlural    = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} {FieldDefinitionEnum.ReportedExpenditure.ToType().GetFieldDefinitionLabelPluralized()}",
                SaveFiltersInCookie = true
            };

            ProjectFundingSourceExpendituresForOrganizationGridName    = "projectCalendarYearExpendituresForOrganizationGrid";
            ProjectFundingSourceExpendituresForOrganizationGridDataUrl =
                SitkaRoute <OrganizationController> .BuildUrlFromExpression(
                    tc => tc.ProjectFundingSourceExpendituresForOrganizationGridJsonData(organization));

            ManageFundingSourcesUrl = SitkaRoute <FundingSourceController> .BuildUrlFromExpression(c => c.Index());

            IndexUrl = SitkaRoute <OrganizationController> .BuildUrlFromExpression(c => c.Index());

            MapInitJson = mapInitJson;
            ProjectLocationsLayerGeoJson = projectLocationsLayerGeoJson;
            HasSpatialData = hasSpatialData;
            ExpendituresDirectlyFromOrganizationViewGoogleChartViewData       = expendituresDirectlyFromOrganizationViewGoogleChartViewData;
            ExpendituresReceivedFromOtherOrganizationsViewGoogleChartViewData = expendituresReceivedFromOtherOrganizationsViewGoogleChartViewData;

            PerformanceMeasureChartViewDatas = performanceMeasures.Select(x => organization.GetPerformanceMeasureChartViewData(x, currentFirmaSession)).ToList();

            NewFundingSourceUrl = SitkaRoute <FundingSourceController> .BuildUrlFromExpression(c => c.New());

            CanCreateNewFundingSource = new FundingSourceCreateFeature().HasPermissionByFirmaSession(currentFirmaSession) &&
                                        (currentFirmaSession.Person.RoleID != ProjectFirmaModels.Models.Role.ProjectSteward.RoleID || // If person is project steward, they can only create funding sources for their organization
                                         currentFirmaSession.Person.OrganizationID == organization.OrganizationID);
            ShowProposals        = currentFirmaSession.CanViewProposals();
            ProposalsPanelHeader = MultiTenantHelpers.ShowProposalsToThePublic()
                ? FieldDefinitionEnum.Proposal.ToType().GetFieldDefinitionLabelPluralized()
                : $"{FieldDefinitionEnum.Proposal.ToType().GetFieldDefinitionLabelPluralized()} (Not Visible to the Public)";

            ProposalsGridSpec =
                new ProjectsIncludingLeadImplementingGridSpec(organization, currentFirmaSession, true)
            {
                ObjectNameSingular  = $"{FieldDefinitionEnum.Proposal.ToType().GetFieldDefinitionLabel()}",
                ObjectNamePlural    = $"{FieldDefinitionEnum.Proposal.ToType().GetFieldDefinitionLabelPluralized()} associated with {organization.GetDisplayName()}",
                SaveFiltersInCookie = true
            };

            ProposalsGridName    = "proposalsGrid";
            ProposalsGridDataUrl =
                SitkaRoute <OrganizationController> .BuildUrlFromExpression(
                    tc => tc.ProposalsGridJsonData(organization));

            ShowPendingProjects = currentFirmaSession.Person.CanViewPendingProjects();

            // If they have no permissions, just say "yes" or "no" if GUID set.
            // If they have manage permissions, show the GUID, otherwise "None".
            bool   hasKeystoneOrganizationGuid = (organization.KeystoneOrganizationGuid != null);
            string hasKeystoneOrganizationGuidBooleanAsString = hasKeystoneOrganizationGuid.ToYesNo();
            string organizationKeystoneGuidAsStringOrNone     = hasKeystoneOrganizationGuid ? organization.KeystoneOrganizationGuid.ToString() : "None";

            OrganizationKeystoneGuidDisplayString = UserHasOrganizationManagePermissions ? organizationKeystoneGuidAsStringOrNone : hasKeystoneOrganizationGuidBooleanAsString;

            PendingProjectsGridSpec =
                new ProjectsIncludingLeadImplementingGridSpec(organization, currentFirmaSession, true)
            {
                ObjectNameSingular  = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}",
                ObjectNamePlural    = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()} associated with {organization.GetDisplayName()}",
                SaveFiltersInCookie = true
            };

            PendingProjectsGridName    = "pendingProjectsGrid";
            PendingProjectsGridDataUrl =
                SitkaRoute <OrganizationController> .BuildUrlFromExpression(
                    tc => tc.PendingProjectsGridJsonData(organization));

            TenantHasCanStewardProjectsOrganizationRelationship = MultiTenantHelpers.HasCanStewardProjectsOrganizationRelationship();
            var allAssociatedProjects = Organization.GetAllAssociatedProjects();

            NumberOfStewardedProjects       = allAssociatedProjects.Count(x => x.IsActiveProject() && x.GetCanStewardProjectsOrganization() == Organization);
            NumberOfLeadImplementedProjects = allAssociatedProjects.Count(x => x.IsActiveProject() && x.GetPrimaryContactOrganization() == Organization);
            NumberOfProjectsContributedTo   = allAssociatedProjects.ToList().GetActiveProjects().Count;
            DescriptionViewData             = new ViewPageContentViewData(organization, currentFirmaSession);

            UserHasViewEditProfilePermission = new OrganizationProfileViewEditFeature().HasPermission(currentFirmaSession, organization).HasPermission;

            bool matchmakerEnabledForTenant           = MultiTenantHelpers.GetTenantAttributeFromCache().EnableMatchmaker;
            bool matchmakerOptedInForThisOrganization = Organization.MatchmakerOptIn.HasValue && Organization.MatchmakerOptIn.Value;

            ShowMatchmakerProfileTab        = matchmakerEnabledForTenant;
            ShowMatchmakerProfileTabDetails = matchmakerEnabledForTenant && (UserHasViewEditProfilePermission || matchmakerOptedInForThisOrganization);

            FieldDefinitionForProject  = FieldDefinitionEnum.Project.ToType();
            EditProfileMatchmakerOptIn = SitkaRoute <OrganizationController> .BuildUrlFromExpression(c => c.EditProfileMatchmakerOptIn(organization));

            EditProfileSupplementalInformationUrl = SitkaRoute <OrganizationController> .BuildUrlFromExpression(c => c.EditProfileSupplementalInformation(organization));

            EditProfileTaxonomyUrl = SitkaRoute <OrganizationController> .BuildUrlFromExpression(c => c.EditProfileTaxonomy(organization));

            EditAreaOfInterestUrl = SitkaRoute <OrganizationController> .BuildUrlFromExpression(c => c.EditMatchMakerAreaOfInterest(organization));

            EditAreaOfInterestDialogFormID = OrganizationController.GenerateEditOrganizationMatchMakerAreaOfInterestFormID(organization);
            HasAreaOfInterest         = (Organization.UseOrganizationBoundaryForMatchmaker && Organization.OrganizationBoundary != null) || (!Organization.UseOrganizationBoundaryForMatchmaker && Organization.MatchMakerAreaOfInterestLocations.Any());
            AreaOfInterestMapInitJson = matchMakerAreaOfInterestInitJson;

            OrganizationMatchmakerKeywordsViewData = new OrganizationMatchmakerKeywordsViewData(organization);
            EditMatchmakerKeywordsUrl = SitkaRoute <KeywordController> .BuildUrlFromExpression(c => c.EditMatchMakerKeywordsModal(organization));

            EditMatchmakerKeywordDialogFormID = OrganizationMatchmakerKeywordsViewData.EditMatchmakerKeywordDialogFormID;

            TopLevelMatchmakerTaxonomyTier = topLevelMatchmakerTaxonomyTier;
            TaxonomyTrunkDisplayName       = FieldDefinitionEnum.TaxonomyTrunk.ToType().GetFieldDefinitionLabel();
            TaxonomyBranchDisplayName      = FieldDefinitionEnum.TaxonomyBranch.ToType().GetFieldDefinitionLabel();
            TaxonomyLeafDisplayName        = FieldDefinitionEnum.TaxonomyLeaf.ToType().GetFieldDefinitionLabel();
            TaxonomyLevel         = MultiTenantHelpers.GetTaxonomyLevel();
            MaximumTaxonomyLeaves = maximumTaxonomyLeaves;
            ActiveTab             = activeTab;

            EditOrgClassificationsUrl = SitkaRoute <OrganizationController> .BuildUrlFromExpression(c => c.EditMatchMakerClassifications(organization));

            MatchmakerClassificationsGroupedByClassificationSystem = matchmakerClassificationsGroupedByClassificationSystem;
            AllClassificationSystems = allClassificationSystems;

            EditOrgPerformanceMeasuresUrl = SitkaRoute <OrganizationController> .BuildUrlFromExpression(c => c.EditMatchMakerPerformanceMeasures(organization));

            ProjectFinderPageUrl = SitkaRoute <ProjectFinderController> .BuildUrlFromExpression(c => c.Organization(organization));

            MatchmakerProfileCompletionDictionary = organization.GetMatchmakerOrganizationProfileCompletionDictionary();

            MatchmakerProfileIncomplete           = !MatchmakerProfileCompletionDictionary.Values.Any(x => x);
            MatchmakerProjectFinderButtonDisabled = !organization.MatchmakerOptIn.HasValue || !organization.MatchmakerOptIn.Value || MatchmakerProfileIncomplete;
            ShouldShowBackgroundTab = DescriptionViewData.HasPageContent || new OrganizationBackgroundEditFeature().HasPermission(currentFirmaSession, organization).HasPermission;
            MatchmakerProjectFinderButtonContent = GetMatchmakerProjectFinderButtonContent(organization, MatchmakerProfileCompletionDictionary);
        }