public DetailViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.Project project, List <ProjectStage> projectStages, ProjectBasicsViewData projectBasicsViewData, ProjectLocationSummaryViewData projectLocationSummaryViewData, ProjectBudgetSummaryViewData projectBudgetSummaryViewData, ProjectBudgetsAnnualViewData projectBudgetsAnnualViewData, ProjectBudgetsAnnualByCostTypeViewData projectBudgetsAnnualByCostTypeViewData, TechnicalAssistanceRequestsDetailViewData technicalAssistanceRequestDetailViewData, PerformanceMeasureExpectedSummaryViewData performanceMeasureExpectedSummaryViewData, PerformanceMeasureReportedValuesGroupedViewData performanceMeasureReportedValuesGroupedViewData, ProjectExpendituresDetailViewData projectExpendituresDetailViewData, ProjectExpendituresByCostTypeDetailViewData projectExpendituresByCostTypeDetailViewData, ImageGalleryViewData imageGalleryViewData, EntityNotesViewData projectNotesViewData, EntityNotesViewData internalNotesViewData, EntityExternalLinksViewData entityExternalLinksViewData, ProjectBasicsTagsViewData projectBasicsTagsViewData, bool userHasProjectAdminPermissions, bool userHasEditProjectPermissions, bool userHasProjectUpdatePermissions, bool userHasPerformanceMeasureActualManagePermissions, string mapFormID, string editProjectCustomAttributesUrl, string editSimpleProjectLocationUrl, string editDetailedProjectLocationUrl, string editProjectOrganizationsUrl, string editPerformanceMeasureExpectedsUrl, string editPerformanceMeasureActualsUrl, string editReportedExpendituresUrl, bool reportFinancialsByCostType, AuditLogsGridSpec auditLogsGridSpec, string auditLogsGridDataUrl, string editExternalLinksUrl, ProjectNotificationGridSpec projectNotificationGridSpec, string projectNotificationGridName, string projectNotificationGridDataUrl, bool userCanEditProposal, ProjectOrganizationsDetailViewData projectOrganizationsDetailViewData, ProjectPotentialPartnerDetailViewData projectPotentialPartnerDetailViewData, List <ProjectFirmaModels.Models.ClassificationSystem> classificationSystems, string editProjectBoundingBoxFormID, List <GeospatialAreaType> geospatialAreaTypes, DisplayProjectCustomAttributesViewData displayProjectCustomAttributeTypesViewData, ProjectContactsDetailViewData projectContactsDetailViewData, string editProjectContactsUrl, string editExpectedFundingUrl, ProjectTimelineDisplayViewData projectTimelineDisplayViewData, bool userHasProjectTimelinePermissions, List <ProjectEvaluation> projectEvaluationsUserHasAccessTo, bool userHasStartUpdateWorkflowPermission) : base(currentFirmaSession, project) { PageTitle = project.GetDisplayName(); BreadCrumbTitle = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} Detail"; ProjectStages = projectStages; EditProjectUrl = project.GetEditUrl(); UserHasProjectAdminPermissions = userHasProjectAdminPermissions; UserHasEditProjectPermissions = userHasEditProjectPermissions; UserHasPerformanceMeasureActualManagePermissions = userHasPerformanceMeasureActualManagePermissions; UserHasProjectTimelinePermissions = userHasProjectTimelinePermissions; CanLaunchProjectOrProposalWizard = userHasStartUpdateWorkflowPermission; WithdrawUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(c => c.Withdraw(project)); var projectAlerts = new List <string>(); var proposedProjectListUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.Proposed()); var backToAllProposalsText = "Back to all Proposals"; var pendingProjectsListUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.Pending()); var backToAllPendingProjectsText = $"Back to all Pending {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}"; var currentPerson = currentFirmaSession.Person; if (project.IsRejected()) { var projectApprovalStatus = project.ProjectApprovalStatus; ProjectUpdateButtonText = projectApprovalStatus == ProjectApprovalStatus.Draft || projectApprovalStatus == ProjectApprovalStatus.Returned ? $"Edit Pending {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}" : $"Review Pending {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}"; ProjectWizardUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.EditBasics(project.ProjectID)); if (project.IsProposal()) { ProjectListUrl = proposedProjectListUrl; BackToProjectsText = backToAllProposalsText; } else if (project.IsPendingProject()) { ProjectListUrl = pendingProjectsListUrl; BackToProjectsText = backToAllPendingProjectsText; } if (userHasProjectAdminPermissions || currentPerson.CanStewardProject(project)) { projectAlerts.Add( $"This {FieldDefinitionEnum.Project.ToType().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 Proposal" : "Review Proposal"; ProjectWizardUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.EditBasics(project.ProjectID)); ProjectListUrl = proposedProjectListUrl; BackToProjectsText = backToAllProposalsText; if ((projectApprovalStatus == ProjectApprovalStatus.Draft || projectApprovalStatus == ProjectApprovalStatus.Returned) && (userHasProjectAdminPermissions || userHasStartUpdateWorkflowPermission)) { projectAlerts.Add( $"This {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} is in the Proposal stage. Any edits to this {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} must be made using the Add New {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} workflow."); } else if (projectApprovalStatus == ProjectApprovalStatus.PendingApproval) { if (userHasProjectAdminPermissions || currentPerson.IsPersonAProjectOwnerWhoCanStewardProjects() && currentPerson.CanStewardProject(project)) { projectAlerts.Add($"This {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} has been submitted and is awaiting review."); } else if (userHasStartUpdateWorkflowPermission) { projectAlerts.Add($"This {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} has been submitted, no change can be made."); CanLaunchProjectOrProposalWizard = false; ShowWithdrawProjectButton = true; } } } else if (project.IsPendingProject()) { var projectApprovalStatus = project.ProjectApprovalStatus; ProjectUpdateButtonText = projectApprovalStatus == ProjectApprovalStatus.Draft || projectApprovalStatus == ProjectApprovalStatus.Returned ? $"Edit Pending {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}" : $"Review Pending {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}"; ProjectWizardUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.EditBasics(project.ProjectID)); ProjectListUrl = pendingProjectsListUrl; BackToProjectsText = backToAllPendingProjectsText; if ((projectApprovalStatus == ProjectApprovalStatus.Draft || projectApprovalStatus == ProjectApprovalStatus.Returned) && (userHasProjectAdminPermissions || userHasStartUpdateWorkflowPermission)) { projectAlerts.Add( $"This {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} is pending. Any edits to this {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} must be made using the Add New {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} workflow."); } else if (projectApprovalStatus == ProjectApprovalStatus.PendingApproval) { if (userHasProjectAdminPermissions || currentPerson.IsPersonAProjectOwnerWhoCanStewardProjects() && currentPerson.CanStewardProject(project)) { projectAlerts.Add($"This {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} has been submitted and is awaiting review."); } else if (userHasStartUpdateWorkflowPermission) { projectAlerts.Add($"This {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} is pending, no change can be made."); CanLaunchProjectOrProposalWizard = false; ShowWithdrawProjectButton = true; } } } else { var latestUpdateState = project.GetLatestUpdateStateResilientToDuplicateUpdateBatches(); ProjectUpdateButtonText = latestUpdateState == ProjectUpdateState.Submitted || latestUpdateState == ProjectUpdateState.Returned ? "Review Update" : $"Update {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}"; ProjectWizardUrl = project.GetProjectUpdateUrl(); ProjectListUrl = FullProjectListUrl; BackToProjectsText = $"Back to all {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}"; if (currentPerson.IsPersonAProjectOwnerWhoCanStewardProjects()) { if (currentPerson.CanStewardProject(project)) { projectAlerts.Add( $"You are a {FieldDefinitionEnum.ProjectSteward.ToType().GetFieldDefinitionLabel()} for this {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}. You may edit this {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} by using the <i class=\"glyphicon glyphicon-edit\"></i> icon on each panel.<br/>"); } else { projectAlerts.Add( $"You are a {FieldDefinitionEnum.ProjectSteward.ToType().GetFieldDefinitionLabel()}, but not for this {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}. You may only edit {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()} that are associated with your {FieldDefinitionEnum.ProjectStewardshipArea.ToType().GetFieldDefinitionLabel()}."); } } } if (ProjectModelExtensions.GetLatestNotApprovedUpdateBatch(project) != null) { if (userHasEditProjectPermissions) { projectAlerts.Add($"This {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} has an Update in progress. Changes made through this page will be overwritten when the Update is approved."); } else { projectAlerts.Add($"This {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} has an Update in progress."); } } ProjectAlerts = projectAlerts; ProjectBasicsViewData = projectBasicsViewData; ProjectBasicsTagsViewData = projectBasicsTagsViewData; EditProjectCustomAttributesUrl = editProjectCustomAttributesUrl; ProjectLocationSummaryViewData = projectLocationSummaryViewData; MapFormID = mapFormID; EditSimpleProjectLocationUrl = editSimpleProjectLocationUrl; EditDetailedProjectLocationUrl = editDetailedProjectLocationUrl; EditProjectBoundingBoxUrl = SitkaRoute <ProjectLocationController> .BuildUrlFromExpression(c => c.EditProjectBoundingBox(project)); EditProjectBoundingBoxFormID = editProjectBoundingBoxFormID; EditProjectOrganizationsUrl = editProjectOrganizationsUrl; PerformanceMeasureExpectedSummaryViewData = performanceMeasureExpectedSummaryViewData; EditPerformanceMeasureExpectedsUrl = editPerformanceMeasureExpectedsUrl; PerformanceMeasureReportedValuesGroupedViewData = performanceMeasureReportedValuesGroupedViewData; EditPerformanceMeasureActualsUrl = editPerformanceMeasureActualsUrl; ProjectBudgetSummaryViewData = projectBudgetSummaryViewData; ProjectBudgetsAnnualViewData = projectBudgetsAnnualViewData; ProjectBudgetsAnnualByCostTypeViewData = projectBudgetsAnnualByCostTypeViewData; EditTechnicalAssistanceRequestsUrl = SitkaRoute <TechnicalAssistanceRequestController> .BuildUrlFromExpression(c => c.EditTechnicalAssistanceRequestsForProject(project)); TechnicalAssistanceRequestDetailViewData = technicalAssistanceRequestDetailViewData; EditExpectedFundingUrl = editExpectedFundingUrl; ProjectExpendituresDetailViewData = projectExpendituresDetailViewData; ProjectExpendituresByCostTypeDetailViewData = projectExpendituresByCostTypeDetailViewData; EditReportedExpendituresUrl = editReportedExpendituresUrl; GeospatialAreaTypes = geospatialAreaTypes; DisplayProjectCustomAttributeTypesViewData = displayProjectCustomAttributeTypesViewData; EditExternalLinksUrl = editExternalLinksUrl; ImageGalleryViewData = imageGalleryViewData; ProjectNotesViewData = projectNotesViewData; InternalNotesViewData = internalNotesViewData; EntityExternalLinksViewData = entityExternalLinksViewData; ProjectUpdateBatchGridSpec = new ProjectUpdateBatchGridSpec { ObjectNameSingular = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} Update", ObjectNamePlural = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} Updates", SaveFiltersInCookie = true }; ProjectUpdateBatchGridName = "projectUpdateBatch"; ProjectUpdateBatchGridDataUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(x => x.ProjectUpdateBatchGridJsonData(project.ProjectID)); ReportFinancialsByCostType = reportFinancialsByCostType; AuditLogsGridSpec = auditLogsGridSpec; AuditLogsGridName = "projectAuditLogsGrid"; AuditLogsGridDataUrl = auditLogsGridDataUrl; ProjectNotificationGridSpec = projectNotificationGridSpec; ProjectNotificationGridName = projectNotificationGridName; ProjectNotificationGridDataUrl = projectNotificationGridDataUrl; ProjectOrganizationsDetailViewData = projectOrganizationsDetailViewData; // Potential Partner panel ProjectPotentialPartnerDetailViewData = projectPotentialPartnerDetailViewData; ProjectContactsDetailViewData = projectContactsDetailViewData; EditProjectContactsUrl = editProjectContactsUrl; EditProjectGeospatialAreaFormID = ProjectGeospatialAreaController.GetEditProjectGeospatialAreasFormID(); ProjectStewardCannotEditUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.ProjectStewardCannotEdit()); ProjectStewardCannotEditPendingApprovalUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.ProjectStewardCannotEditPendingApproval(project)); ClassificationSystems = classificationSystems; ProjectAttachmentsDetailViewData = new ProjectAttachmentsDetailViewData( EntityAttachment.CreateFromProjectAttachment(project.ProjectAttachments), SitkaRoute <ProjectAttachmentController> .BuildUrlFromExpression(x => x.New(project)), project.ProjectName, new ProjectEditAsAdminFeature().HasPermission(currentFirmaSession, project).HasPermission, project.GetAllAttachmentTypes().ToList(), currentFirmaSession); ProjectTimelineDisplayViewData = projectTimelineDisplayViewData; ProjectEvaluationsUserHasAccessTo = projectEvaluationsUserHasAccessTo; ShowFactSheetButton = OfferProjectFactSheetLinkFeature.OfferProjectFactSheetLink(currentFirmaSession, project); }
protected ProjectCreateViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.Project project, string currentSectionDisplayName, ProposalSectionsStatus proposalSectionsStatus) : this(currentFirmaSession, project, currentSectionDisplayName, false) { Check.Assert(project != null, "Project should be created in database by this point so it cannot be null."); Check.Assert(currentSectionDisplayName.Equals("Instructions", StringComparison.InvariantCultureIgnoreCase) || currentSectionDisplayName.Equals("Basics", StringComparison.InvariantCultureIgnoreCase) || proposalSectionsStatus.IsBasicsSectionComplete, $"Can't access this section of the Proposal - You must complete the basics first ({project.GetEditUrl()})"); CurrentPersonCanWithdraw = new ProjectCreateFeature().HasPermission(currentFirmaSession, project).HasPermission; Project = project; ProposalSectionsStatus = proposalSectionsStatus; CanAdvanceStage = ProposalSectionsStatus.AreAllSectionsValidForProject(project, CurrentFirmaSession); // ReSharper disable PossibleNullReferenceException ProjectStateIsValidInWizard = project.ProjectApprovalStatus == ProjectApprovalStatus.Draft || project.ProjectApprovalStatus == ProjectApprovalStatus.Returned || project.ProjectApprovalStatus == ProjectApprovalStatus.PendingApproval; // ReSharper restore PossibleNullReferenceException IsInstructionsPage = currentSectionDisplayName.Equals("Instructions", StringComparison.InvariantCultureIgnoreCase); InstructionsPageUrl = project.ProjectStage == ProjectStage.Proposal ? SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.InstructionsProposal(project.ProjectID)) : SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.InstructionsEnterHistoric(project.ProjectID)); var fieldDefinitionLabelForProject = FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel(); var pageTitle = project.ProjectStage == ProjectStage.Proposal ? $"Propose {fieldDefinitionLabelForProject}" : $"Add {fieldDefinitionLabelForProject}"; PageTitle = $"{pageTitle}: {project.GetDisplayName()}"; ProposalDetailUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(x => x.Detail(project)); ProposalBasicsUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.EditBasics(project.ProjectID)); ProposalAttachmentsAndNotesUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.AttachmentsAndNotes(project.ProjectID)); ProposalPhotosUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Photos(project.ProjectID)); SubmitUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Submit(project)); ApproveUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Approve(project)); ReturnUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Return(project)); WithdrawUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Withdraw(project)); RejectUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Reject(project)); TrainingUrl = SitkaRoute <HomeController> .BuildUrlFromExpression(x => x.Training()); ProjectStage = project.ProjectStage; HasCustomAttributesEditableByUser = project.HasEditableCustomAttributes(currentFirmaSession); }