public ViewResult Detail(PerformanceMeasurePrimaryKey performanceMeasurePrimaryKey)
        {
            var performanceMeasure          = performanceMeasurePrimaryKey.EntityObject;
            var canManagePerformanceMeasure = new PerformanceMeasureManageFeature().HasPermissionByFirmaSession(CurrentFirmaSession);
            var isAdmin = new FirmaAdminFeature().HasPermissionByFirmaSession(CurrentFirmaSession);

            var performanceMeasureChartViewData = new PerformanceMeasureChartViewData(performanceMeasure,
                                                                                      CurrentFirmaSession, false, canManagePerformanceMeasure,
                                                                                      performanceMeasure.GetAssociatedProjectsWithReportedValues(CurrentFirmaSession));

            // Avoid scrolling the legend if it can be displayed on two lines
            performanceMeasureChartViewData.ViewGoogleChartViewData.GoogleChartJsons.ForEach(x =>
            {
                if (x.GoogleChartConfiguration.Legend != null && x.GoogleChartConfiguration.Legend.MaxLines == null)
                {
                    x.GoogleChartConfiguration.Legend.MaxLines = 2;
                }
            });

            var entityNotesViewData = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(performanceMeasure.PerformanceMeasureNotes),
                SitkaRoute <PerformanceMeasureNoteController> .BuildUrlFromExpression(c =>
                                                                                      c.New(performanceMeasure.PrimaryKey)),
                performanceMeasure.PerformanceMeasureDisplayName,
                canManagePerformanceMeasure);

            var viewData = new DetailViewData(CurrentFirmaSession, performanceMeasure, performanceMeasureChartViewData,
                                              entityNotesViewData, canManagePerformanceMeasure, isAdmin);

            return(RazorView <Detail, DetailViewData>(viewData));
        }
Exemplo n.º 2
0
        public ViewResult GrantAllocationDetail(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;

            if (grantAllocation == null)
            {
                throw new Exception($"Could not find GrantAllocationID # {grantAllocationPrimaryKey.PrimaryKeyValue}; has it been deleted?");
            }

            var taxonomyLevel = MultiTenantHelpers.GetTaxonomyLevel();
            var grantAllocationBasicsViewData         = new GrantAllocationBasicsViewData(grantAllocation, false, taxonomyLevel);
            var userHasEditGrantAllocationPermissions = new GrantAllocationEditAsAdminFeature().HasPermissionByPerson(CurrentPerson);
            var grantAllocationNotesViewData          = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(new List <IEntityNote>(grantAllocation.GrantAllocationNotes)),
                SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(x => x.NewGrantAllocationNote(grantAllocationPrimaryKey)),
                grantAllocation.GrantAllocationName,
                userHasEditGrantAllocationPermissions);
            var grantAllocationNoteInternalsViewData = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(new List <IEntityNote>(grantAllocation.GrantAllocationNoteInternals)),
                SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(x => x.NewGrantAllocationNoteInternal(grantAllocationPrimaryKey)),
                grantAllocation.GrantAllocationName,
                userHasEditGrantAllocationPermissions);

            var costTypes = CostType.All.Where(x => x.IsValidInvoiceLineItemCostType).OrderBy(x => x.CostTypeDisplayName).ToList();

            const string chartTitle       = "Grant Allocation Expenditures";
            var          chartContainerID = chartTitle.Replace(" ", "");

            // If ProjectGrantAllocationExpenditures is empty, ToGoogleChart returns null...
            var googleChart = grantAllocation.GrantAllocationExpenditures
                              .ToGoogleChart(x => x.CostType?.CostTypeDisplayName,
                                             costTypes.Select(x => x.CostTypeDisplayName).ToList(),
                                             x => x.CostType?.CostTypeDisplayName,
                                             chartContainerID,
                                             grantAllocation.DisplayName);

            // Which makes this guy bork (bork bork bork)
            googleChart?.GoogleChartConfiguration.Legend.SetLegendPosition(GoogleChartLegendPosition.Top);
            var viewGoogleChartViewData = new ViewGoogleChartViewData(googleChart, chartTitle, 350, false);

            var projectGrantAllocationRequestsGridSpec = new ProjectGrantAllocationRequestsGridSpec()
            {
                ObjectNameSingular  = "Project",
                ObjectNamePlural    = "Projects",
                SaveFiltersInCookie = true
            };

            var grantAllocationExpendituresGridSpec = new GrantAllocationExpendituresGridSpec();
            var grantAllocationAwardsGridSpec       = new GrantAllocationAwardGridSpec(CurrentPerson, grantAllocation);

            var viewData = new Views.GrantAllocation.DetailViewData(CurrentPerson, grantAllocation, grantAllocationBasicsViewData, grantAllocationNotesViewData, grantAllocationNoteInternalsViewData, viewGoogleChartViewData, projectGrantAllocationRequestsGridSpec, grantAllocationExpendituresGridSpec, grantAllocationAwardsGridSpec);

            return(RazorView <Views.GrantAllocation.Detail, Views.GrantAllocation.DetailViewData>(viewData));
        }
        public DocumentsAndNotesViewData(Person currentPerson, ProjectUpdateBatch projectUpdateBatch, UpdateStatus updateStatus, string diffUrl) : base(currentPerson, projectUpdateBatch, updateStatus, new List <string>(), ProjectUpdateSection.NotesAndDocuments.ProjectUpdateSectionDisplayName)
        {
            EntityNotesViewData = new EntityNotesViewData(EntityNote.CreateFromEntityNote(new List <IEntityNote>(projectUpdateBatch.ProjectNoteUpdates)),
                                                          SitkaRoute <ProjectNoteUpdateController> .BuildUrlFromExpression(x => x.New(projectUpdateBatch)),
                                                          projectUpdateBatch.Project.DisplayName,
                                                          IsEditable);
            ProjectDocumentsViewData = new ProjectDocumentsDetailViewData(EntityDocument.CreateFromEntityDocument(new List <IEntityDocument>(projectUpdateBatch.ProjectDocumentUpdates)),
                                                                          SitkaRoute <ProjectDocumentUpdateController> .BuildUrlFromExpression(x => x.New(projectUpdateBatch)),
                                                                          projectUpdateBatch.Project.DisplayName,
                                                                          IsEditable);
            RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshNotesAndDocuments(projectUpdateBatch.Project));

            DiffUrl = diffUrl;
        }
        public ViewResult GrantModificationDetail(GrantModificationPrimaryKey grantModificationPrimaryKey)
        {
            var grantModification = grantModificationPrimaryKey.EntityObject;
            var userHasEditGrantModificationPermissions = new GrantModificationEditAsAdminFeature().HasPermissionByPerson(CurrentPerson);


            var internalGrantModificationNotesViewData = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(new List <IEntityNote>(grantModification.GrantModificationNoteInternals)),
                SitkaRoute <GrantModificationController> .BuildUrlFromExpression(x => x.NewGrantModificationNoteInternal(grantModificationPrimaryKey)),
                grantModification.GrantModificationName,
                userHasEditGrantModificationPermissions);

            var viewData = new GrantModificationDetailViewData(CurrentPerson, grantModification, internalGrantModificationNotesViewData);

            return(RazorView <GrantModificationDetail, GrantModificationDetailViewData>(viewData));
        }
        public ViewResult ObligationRequestDetail(ObligationRequestPrimaryKey obligationRequestPrimaryKey)
        {
            var obligationRequest = obligationRequestPrimaryKey.EntityObject;

            var userCanInteractWithSubmissionNotes = new ObligationRequestSubmissionNoteFeature().HasPermissionByFirmaSession(CurrentFirmaSession);

            var obligationRequestNotesViewData = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(obligationRequest.ObligationRequestSubmissionNotes),
                SitkaRoute <ObligationRequestSubmissionNotesController> .BuildUrlFromExpression(x => x.New(obligationRequest)),
                FieldDefinitionEnum.ObligationRequest.ToType().FieldDefinitionDisplayName,
                userCanInteractWithSubmissionNotes);

            var viewData = new ObligationRequestDetailViewData(CurrentFirmaSession, obligationRequest, userCanInteractWithSubmissionNotes, obligationRequestNotesViewData);

            return(RazorView <ObligationRequestDetail, ObligationRequestDetailViewData>(viewData));
        }
        public AttachmentsAndNotesViewData(FirmaSession currentFirmaSession, ProjectUpdateBatch projectUpdateBatch, ProjectUpdateStatus projectUpdateStatus, string diffUrl) : base(currentFirmaSession, projectUpdateBatch, projectUpdateStatus, new List <string>(), ProjectUpdateSection.AttachmentsAndNotes.ProjectUpdateSectionDisplayName)
        {
            EntityNotesViewData = new EntityNotesViewData(EntityNote.CreateFromEntityNote(projectUpdateBatch.ProjectNoteUpdates),
                                                          SitkaRoute <ProjectNoteUpdateController> .BuildUrlFromExpression(x => x.New(projectUpdateBatch)),
                                                          projectUpdateBatch.Project.GetDisplayName(),
                                                          IsEditable);
            ProjectAttachmentsViewData = new ProjectAttachmentsDetailViewData(
                EntityAttachment.CreateFromProjectAttachment(projectUpdateBatch.ProjectAttachmentUpdates),
                SitkaRoute <ProjectAttachmentUpdateController> .BuildUrlFromExpression(x => x.New(projectUpdateBatch)),
                projectUpdateBatch.Project.GetDisplayName(),
                IsEditable,
                projectUpdateBatch.GetAllAttachmentTypes().ToList(),
                currentFirmaSession);
            RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshNotesAndAttachments(projectUpdateBatch.Project));

            DiffUrl = diffUrl;

            var applicableWizardSections = projectUpdateBatch.GetApplicableWizardSections(currentFirmaSession, true, projectUpdateBatch.Project.HasEditableCustomAttributes(CurrentFirmaSession));
            var currentSection           = applicableWizardSections.Single(x => x.SectionDisplayName.Equals(ProjectUpdateSection.AttachmentsAndNotes.ProjectUpdateSectionDisplayName, StringComparison.InvariantCultureIgnoreCase));
            var nextProjectUpdateSection = applicableWizardSections.Where(x => x.SortOrder > currentSection.SortOrder).OrderBy(x => x.SortOrder).FirstOrDefault();

            NextSectionUrl = nextProjectUpdateSection?.SectionUrl;
        }