public ProjectMapPopupViewData(Models.Project project, bool showDetailedInformation)
        {
            //Project = project;
            DisplayNameAsUrlBlankTarget = project.DisplayNameAsUrlBlankTarget;
            KeyPhoto           = project.KeyPhoto;
            Duration           = project.Duration;
            ProjectStage       = project.ProjectStage;
            ProjectType        = project.ProjectType;
            EstimatedTotalCost = project.EstimatedTotalCost.HasValue ? project.EstimatedTotalCost.ToStringCurrency() : "Unknown";
            var leadImplementerOrg =
                project.ProjectOrganizations.FirstOrDefault(po => po.RelationshipTypeID == 33);

            LeadImplementerOrganizationName =
                leadImplementerOrg != null?leadImplementerOrg.Organization.GetDisplayNameAsUrlBlankTarget() : new HtmlString(string.Empty);

            var dict = new Dictionary <Models.ClassificationSystem, string>();

            MoreEnumerable.ForEach(project.ProjectClassifications.Select(x => x.Classification.ClassificationSystem).Distinct(), x => dict.Add(x, string.Join(", ", project.ProjectClassifications.Select(y => y.Classification).Where(y => y.ClassificationSystem == x).Select(y => y.DisplayName).ToList())));
            ClassificationsBySystem = dict;

            ProjectDisplayName   = project.DisplayName;
            ProjectDetailUrl     = project.GetDetailUrl();
            FactSheetUrl         = project.GetFactSheetUrl();
            DetailLinkDescriptor = project.IsProposal() ? $"This {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} is a proposal. For description and expected results, see the" : $"For {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} information & results, see the";
            InitializeDisplayNames();
            TaxonomyLevel = MultiTenantHelpers.GetTaxonomyLevel();

            ShowDetailedInformation = showDetailedInformation;
        }
        public ProjectDocumentsDetailViewData(Models.Project project, Person currentPerson)
        {
            Project       = project;
            CurrentPerson = currentPerson;

            NewProjectDocumentUrl = SitkaRoute <ProjectDocumentController> .BuildUrlFromExpression(c => c.New(project));

            EditProjectDocumentUrlTemplate = new UrlTemplate <int>(
                SitkaRoute <ProjectDocumentController> .BuildUrlFromExpression(c => c.Edit(UrlTemplate.Parameter1Int)));
            DeleteProjectDocumentUrlTemplate = new UrlTemplate <int>(
                SitkaRoute <ProjectDocumentController> .BuildUrlFromExpression(c => c.Delete(UrlTemplate.Parameter1Int)));

            UserHasProjectManagePermissions =
                Project.IsProposal() ?
                new ProjectCreateFeature().HasPermission(currentPerson, project).HasPermission
                 : new ProjectEditAsAdminFeature().HasPermission(currentPerson, project).HasPermission;
            ProjectDocumentEditAsAdminFeature = new ProjectDocumentEditAsAdminFeature();
        }
Ejemplo n.º 3
0
        public DetailViewData(Person currentPerson, Models.Project project, List <ProjectStage> projectStages,
                              ProjectBasicsViewData projectBasicsViewData, ProjectAttributesViewData projectAttributesViewData,
                              ProjectLocationSummaryViewData projectLocationSummaryViewData,
                              ProjectFundingDetailViewData projectFundingDetailViewData,
                              PerformanceMeasureExpectedSummaryViewData performanceMeasureExpectedSummaryViewData,
                              PerformanceMeasureReportedValuesGroupedViewData performanceMeasureReportedValuesGroupedViewData,
                              ProjectExpendituresDetailViewData projectExpendituresDetailViewData,
                              ImageGalleryViewData imageGalleryViewData, EntityNotesViewData projectNotesViewData,
                              EntityNotesViewData internalNotesViewData,
                              EntityExternalLinksViewData entityExternalLinksViewData,
                              ProjectBasicsTagsViewData projectBasicsTagsViewData, bool userHasProjectAdminPermissions,
                              bool userHasEditProjectPermissions, bool userHasProjectUpdatePermissions,
                              bool userHasPerformanceMeasureActualManagePermissions, string mapFormID,
                              string editSimpleProjectLocationUrl, string editDetailedProjectLocationUrl,
                              string editProjectOrganizationsUrl, string editPerformanceMeasureExpectedsUrl,
                              string editPerformanceMeasureActualsUrl, string editReportedExpendituresUrl,
                              AuditLogsGridSpec auditLogsGridSpec, string auditLogsGridDataUrl,
                              string editExternalLinksUrl, ProjectNotificationGridSpec projectNotificationGridSpec,
                              string projectNotificationGridName, string projectNotificationGridDataUrl, bool userCanEditProposal,
                              ProjectOrganizationsDetailViewData projectOrganizationsDetailViewData,
                              List <Models.ClassificationSystem> classificationSystems,
                              string editProjectBoundingBoxFormID, ProjectPeopleDetailViewData projectPeopleDetailViewData,
                              TreatmentAreaGridSpec treatmentAreaGridSpec,
                              string treatmentAreaGridDataUrl
                              , TreatmentGridSpec treatmentGridSpec
                              , string treatmentGridDataUrl
                              , string editProjectRegionUrl
                              , string editProjectPriorityLandscapeUrl,
                              InteractionEventGridSpec projectInteractionEventsGridSpec, string projectInteractionEventsGridDataUrl)
            : base(currentPerson, project)
        {
            PageTitle       = project.DisplayName.ToEllipsifiedStringClean(110);
            BreadCrumbTitle = $"{Models.FieldDefinition.Project.GetFieldDefinitionLabel()} Detail";

            ProjectStages = projectStages;

            EditProjectUrl = project.GetEditUrl();

            EditProjectAttributesUrl = project.GetEditProjectAttributesUrl();

            CanViewProjectFactSheet = ProjectController.FactSheetIsAvailable(project);

            UserHasProjectAdminPermissions = userHasProjectAdminPermissions;
            UserHasEditProjectPermissions  = userHasEditProjectPermissions;
            UserHasPerformanceMeasureActualManagePermissions = userHasPerformanceMeasureActualManagePermissions;

            var projectAlerts          = new List <string>();
            var proposedProjectListUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.Proposed());

            var backToAllProposalsText = "Back to all Applications";
            var pendingProjectsListUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.Pending());

            var backToAllPendingProjectsText = $"Back to all Pending {Models.FieldDefinition.Project.GetFieldDefinitionLabelPluralized()}";

            if (project.IsRejected())
            {
                var projectApprovalStatus = project.ProjectApprovalStatus;
                ProjectUpdateButtonText =
                    projectApprovalStatus == ProjectApprovalStatus.Draft ||
                    projectApprovalStatus == ProjectApprovalStatus.Returned
                        ? $"Edit Pending {Models.FieldDefinition.Project.GetFieldDefinitionLabel()}"
                        : $"Review Pending {Models.FieldDefinition.Project.GetFieldDefinitionLabel()}";
                ProjectWizardUrl =
                    SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.EditBasics(project.ProjectID));

                CanLaunchProjectOrProposalWizard = userCanEditProposal;
                if (project.IsProposal())
                {
                    ProjectListUrl     = proposedProjectListUrl;
                    BackToProjectsText = backToAllProposalsText;
                }
                else if (project.IsPendingProject())
                {
                    ProjectListUrl     = pendingProjectsListUrl;
                    BackToProjectsText = backToAllPendingProjectsText;
                }

                if (userHasProjectAdminPermissions || currentPerson.CanStewardProject(project))
                {
                    projectAlerts.Add(
                        $"This {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} was rejected and can no longer be edited. It can be deleted, or preserved for archival purposes.");
                }
            }
            else if (project.IsProposal())
            {
                var projectApprovalStatus = project.ProjectApprovalStatus;
                ProjectUpdateButtonText =
                    projectApprovalStatus == ProjectApprovalStatus.Draft ||
                    projectApprovalStatus == ProjectApprovalStatus.Returned
                        ? "Edit Application"
                        : "Review Application";
                ProjectWizardUrl =
                    SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.EditBasics(project.ProjectID));

                CanLaunchProjectOrProposalWizard = userCanEditProposal;
                ProjectListUrl     = proposedProjectListUrl;
                BackToProjectsText = backToAllProposalsText;
                if (userHasProjectAdminPermissions || currentPerson.CanStewardProject(project))
                {
                    projectAlerts.Add(
                        $"This {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} is in the {Models.FieldDefinition.Application.GetFieldDefinitionLabel()} stage. Any edits to this {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} must be made using the Add New {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} workflow.");
                }
            }
            else if (project.IsPendingProject())
            {
                var projectApprovalStatus = project.ProjectApprovalStatus;
                ProjectUpdateButtonText =
                    projectApprovalStatus == ProjectApprovalStatus.Draft ||
                    projectApprovalStatus == ProjectApprovalStatus.Returned
                        ? $"Edit Pending {Models.FieldDefinition.Project.GetFieldDefinitionLabel()}"
                        : $"Review Pending {Models.FieldDefinition.Project.GetFieldDefinitionLabel()}";
                ProjectWizardUrl =
                    SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.EditBasics(project.ProjectID));

                CanLaunchProjectOrProposalWizard = userCanEditProposal;
                ProjectListUrl     = pendingProjectsListUrl;
                BackToProjectsText = backToAllPendingProjectsText;
                if (userHasProjectAdminPermissions || currentPerson.CanStewardProject(project))
                {
                    projectAlerts.Add(
                        $"This {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} is pending. Any edits to this {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} must be made using the Add New {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} workflow.");
                }
            }
            else
            {
                var latestUpdateState = project.GetLatestUpdateState();
                ProjectUpdateButtonText =
                    latestUpdateState == ProjectUpdateState.Submitted ||
                    latestUpdateState == ProjectUpdateState.Returned
                        ? "Review Update"
                        : $"Update {Models.FieldDefinition.Project.GetFieldDefinitionLabel()}";
                ProjectWizardUrl = project.GetProjectUpdateUrl();
                CanLaunchProjectOrProposalWizard = userHasProjectUpdatePermissions;
                ProjectListUrl     = FullProjectListUrl;
                BackToProjectsText = $"Back to all {Models.FieldDefinition.Project.GetFieldDefinitionLabelPluralized()}";


                if (currentPerson.PersonIsProjectOwnerWhoCanStewardProjects)
                {
                    if (currentPerson.CanStewardProject(project))
                    {
                        projectAlerts.Add(
                            $"You are a {Models.FieldDefinition.ProjectSteward.GetFieldDefinitionLabel()} for this {Models.FieldDefinition.Project.GetFieldDefinitionLabel()}. You may edit this {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} by using the <i class=\"glyphicon glyphicon-edit\"></i> icon on each panel.<br/>");
                    }
                    else
                    {
                        projectAlerts.Add(
                            $"You are a {Models.FieldDefinition.ProjectSteward.GetFieldDefinitionLabel()}, but not for this {Models.FieldDefinition.Project.GetFieldDefinitionLabel()}. You may only edit {Models.FieldDefinition.Project.GetFieldDefinitionLabelPluralized()} that are associated with your {Models.FieldDefinition.ProjectStewardshipArea.GetFieldDefinitionLabel()}.");
                    }
                }
            }


            if (project.GetLatestNotApprovedUpdateBatch() != null)
            {
                if (userHasProjectAdminPermissions || currentPerson.CanStewardProject(project))
                {
                    projectAlerts.Add($"This {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} has an Update in progress. Changes made through this page will be overwritten when the Update is approved.");
                }
                else
                {
                    projectAlerts.Add($"This {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} has an Update in progress.");
                }
            }

            ProjectAlerts = projectAlerts;

            ProjectBasicsViewData     = projectBasicsViewData;
            ProjectBasicsTagsViewData = projectBasicsTagsViewData;

            ProjectLocationSummaryViewData = projectLocationSummaryViewData;
            MapFormID = mapFormID;
            EditSimpleProjectLocationUrl    = editSimpleProjectLocationUrl;
            EditDetailedProjectLocationUrl  = editDetailedProjectLocationUrl;
            EditProjectRegionUrl            = editProjectRegionUrl;
            EditProjectPriorityLandscapeUrl = editProjectPriorityLandscapeUrl;

            EditProjectBoundingBoxUrl = SitkaRoute <ProjectLocationController> .BuildUrlFromExpression(c => c.EditProjectBoundingBox(project));

            EditProjectBoundingBoxFormID = editProjectBoundingBoxFormID;
            ProjectAttributesViewData    = projectAttributesViewData;

            EditProjectOrganizationsUrl = editProjectOrganizationsUrl;

            PerformanceMeasureExpectedSummaryViewData = performanceMeasureExpectedSummaryViewData;
            EditPerformanceMeasureExpectedsUrl        = editPerformanceMeasureExpectedsUrl;

            PerformanceMeasureReportedValuesGroupedViewData = performanceMeasureReportedValuesGroupedViewData;
            EditPerformanceMeasureActualsUrl = editPerformanceMeasureActualsUrl;

            ProjectFundingDetailViewData = projectFundingDetailViewData;
            EditExpectedFundingUrl       =
                SitkaRoute <ProjectGrantAllocationRequestController> .BuildUrlFromExpression(c =>
                                                                                             c.EditProjectGrantAllocationRequestsForProject(project));

            ProjectExpendituresDetailViewData = projectExpendituresDetailViewData;
            EditReportedExpendituresUrl       = editReportedExpendituresUrl;
            ProjectPeopleDetailViewData       = projectPeopleDetailViewData;
            EditExternalLinksUrl = editExternalLinksUrl;
            ImageGalleryViewData = imageGalleryViewData;

            ProjectNotesViewData  = projectNotesViewData;
            InternalNotesViewData = internalNotesViewData;

            EntityExternalLinksViewData = entityExternalLinksViewData;

            ProjectUpdateBatchGridSpec = new ProjectUpdateBatchGridSpec
            {
                ObjectNameSingular  = $"{Models.FieldDefinition.Project.GetFieldDefinitionLabel()} Update",
                ObjectNamePlural    = $"{Models.FieldDefinition.Project.GetFieldDefinitionLabel()} Updates",
                SaveFiltersInCookie = true
            };
            ProjectUpdateBatchGridName    = "projectUpdateBatch";
            ProjectUpdateBatchGridDataUrl =
                SitkaRoute <ProjectController> .BuildUrlFromExpression(x =>
                                                                       x.ProjectUpdateBatchGridJsonData(project.ProjectID));

            AuditLogsGridSpec    = auditLogsGridSpec;
            AuditLogsGridName    = "projectAuditLogsGrid";
            AuditLogsGridDataUrl = auditLogsGridDataUrl;

            ProjectNotificationGridSpec        = projectNotificationGridSpec;
            ProjectNotificationGridName        = projectNotificationGridName;
            ProjectNotificationGridDataUrl     = projectNotificationGridDataUrl;
            ProjectOrganizationsDetailViewData = projectOrganizationsDetailViewData;

            EditProjectPriorityLandscapeFormID = ProjectPriorityLandscapeController.GetEditProjectPriorityLandscapesFormID();
            EditProjectRegionFormID            = ProjectRegionController.GetEditProjectRegionsFormID();

            ProjectStewardCannotEditUrl =
                SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.ProjectStewardCannotEdit());

            ProjectStewardCannotEditPendingApprovalUrl =
                SitkaRoute <ProjectController> .BuildUrlFromExpression(c =>
                                                                       c.ProjectStewardCannotEditPendingApproval(project));

            ClassificationSystems = classificationSystems;

            ProjectCostShareViewData = new ProjectCostShareViewData(project, currentPerson);

            ProjectDocumentsDetailViewData = new ProjectDocumentsDetailViewData(
                EntityDocument.CreateFromEntityDocument(new List <IEntityDocument>(project.ProjectDocuments)),
                SitkaRoute <ProjectDocumentController> .BuildUrlFromExpression(x => x.New(project)), project.ProjectName,
                new ProjectEditAsAdminFeature().HasPermission(currentPerson, project).HasPermission);

            EditProjectPeopleUrl =
                SitkaRoute <ProjectPersonController> .BuildUrlFromExpression(x => x.EditPeople(project));

            TreatmentAreaGridSpec    = treatmentAreaGridSpec;
            TreatmentAreaGrid        = "treatmentAreaGrid";
            TreatmentAreaGridDataUrl = treatmentAreaGridDataUrl;


            TreatmentGridSpec    = treatmentGridSpec;
            TreatmentGrid        = "treatmentGrid";
            TreatmentGridDataUrl = treatmentGridDataUrl;

            ProjectInteractionEventsGridSpec    = projectInteractionEventsGridSpec;
            ProjectInteractionEventsGridName    = "projectInteractionEventsGrid";
            ProjectInteractionEventsGridDataUrl = projectInteractionEventsGridDataUrl;

            ProjectAgreementByGrantAllocations = ProjectAgreementByGrantAllocation.MakeAgreementProjectsByGrantAllocation(Project.ProjectGrantAllocationRequests.ToList());
        }