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));
        }
        public IndexViewData(Person currentPerson, Models.FirmaPage firmaPage) : base(currentPerson, firmaPage)
        {
            PageTitle = MultiTenantHelpers.GetPerformanceMeasureNamePluralized();

            var hasPerformanceMeasureManagePermissions = new PerformanceMeasureManageFeature().HasPermissionByPerson(currentPerson);

            HasPerformanceMeasureManagePermissions = hasPerformanceMeasureManagePermissions;
            PerformanceMeasureGridSpec             = new PerformanceMeasureGridSpec(currentPerson)
            {
                ObjectNameSingular  = MultiTenantHelpers.GetPerformanceMeasureName(),
                ObjectNamePlural    = MultiTenantHelpers.GetPerformanceMeasureNamePluralized(),
                SaveFiltersInCookie = true
            };

            if (HasPerformanceMeasureManagePermissions)
            {
                var contentUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(c => c.New());

                PerformanceMeasureGridSpec.CreateEntityModalDialogForm = new ModalDialogForm(contentUrl, $"Create a new {Models.FieldDefinition.PerformanceMeasure.GetFieldDefinitionLabel()}");
            }
            PerformanceMeasureGridSpec.CustomExcelDownloadLinkText = $"Download with {Models.FieldDefinition.PerformanceMeasureSubcategory.GetFieldDefinitionLabelPluralized()}";
            PerformanceMeasureGridSpec.CustomExcelDownloadUrl      = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(tc => tc.IndexExcelDownload());

            PerformanceMeasureGridName    = "performanceMeasuresGrid";
            PerformanceMeasureGridDataUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(c => c.PerformanceMeasureGridJsonData());

            EditSortOrderUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(x => x.EditSortOrder());
        }
        public PerformanceMeasureGridSpec(FirmaSession currentFirmaSession)
        {
            var hasDeletePermission = new PerformanceMeasureManageFeature().HasPermissionByFirmaSession(currentFirmaSession);

            if (hasDeletePermission)
            {
                Add(string.Empty, x => x.PerformanceMeasureDataSourceType.IsCustomCalculation ? new HtmlString("") : DhtmlxGridHtmlHelpers.MakeDeleteIconAndLinkBootstrap(x.GetDeleteUrl(), true), 30, DhtmlxGridColumnFilterType.None);
            }
            Add(FieldDefinitionEnum.PerformanceMeasure.ToType().ToGridHeaderString(MultiTenantHelpers.GetPerformanceMeasureName()),
                a => UrlTemplate.MakeHrefString(a.GetSummaryUrl(), a.PerformanceMeasureDisplayName),
                300,
                DhtmlxGridColumnFilterType.Text);
            Add(FieldDefinitionEnum.MeasurementUnit.ToType().ToGridHeaderString("Unit"), a => a.MeasurementUnitType == MeasurementUnitType.Dollars ? a.MeasurementUnitType.MeasurementUnitTypeDisplayName  : a.MeasurementUnitType.LegendDisplayName, 80, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.PerformanceMeasureType.ToType().ToGridHeaderString("Type"), a => a.PerformanceMeasureType.PerformanceMeasureTypeDisplayName, 60, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add("Description", a => a.PerformanceMeasureDefinition, 400, DhtmlxGridColumnFilterType.Html);
            Add($"# of {FieldDefinitionEnum.PerformanceMeasureSubcategory.ToType().GetFieldDefinitionLabelPluralized()}", a => a.GetRealSubcategoryCount(), 110);
            Add($"# of {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()} Reporting", a => a.ReportedProjectsCount(currentFirmaSession), 80);
            Add($"# of {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()} Expecting", a => a.ExpectedProjectsCount(currentFirmaSession), 80);
        }
        public PerformanceMeasureGridSpec(Person currentPerson)
        {
            var hasDeletePermission = new PerformanceMeasureManageFeature().HasPermissionByPerson(currentPerson);

            if (hasDeletePermission)
            {
                Add(string.Empty, x => x.PerformanceMeasureDataSourceType.IsCustomCalculation ? new HtmlString("") : DhtmlxGridHtmlHelpers.MakeDeleteIconAndLinkBootstrap(x.GetDeleteUrl(), true, true), 30, DhtmlxGridColumnFilterType.None);
            }
            Add(Models.FieldDefinition.PerformanceMeasure.ToGridHeaderString(MultiTenantHelpers.GetPerformanceMeasureName()),
                a => UrlTemplate.MakeHrefString(a.GetSummaryUrl(), a.PerformanceMeasureDisplayName),
                300,
                DhtmlxGridColumnFilterType.Text);
            Add(Models.FieldDefinition.MeasurementUnit.ToGridHeaderString("Unit"), a => a.MeasurementUnitType.MeasurementUnitTypeDisplayName, 80, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(Models.FieldDefinition.PerformanceMeasureType.ToGridHeaderString("Type"), a => a.PerformanceMeasureType.PerformanceMeasureTypeDisplayName, 60, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add("Description", a => a.PerformanceMeasureDefinition, 400, DhtmlxGridColumnFilterType.Html);
            Add($"# of {Models.FieldDefinition.PerformanceMeasureSubcategory.GetFieldDefinitionLabelPluralized()}", a => a.GetRealSubcategoryCount(), 110);
            Add($"# of {Models.FieldDefinition.Project.GetFieldDefinitionLabelPluralized()}", a => a.ReportedProjectsCount(currentPerson), 80);
            Add($"Primary {MultiTenantHelpers.GetAssociatePerformanceMeasureTaxonomyLevel().GetFieldDefinition().GetFieldDefinitionLabel()}", a => a.GetPrimaryTaxonomyTier() == null ? new HtmlString(string.Empty) : a.GetPrimaryTaxonomyTier().GetDisplayNameAsUrl(), 150);
        }
示例#5
0
        public IndexViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.FirmaPage firmaPage) : base(currentFirmaSession, firmaPage)
        {
            PageTitle = MultiTenantHelpers.GetPerformanceMeasureNamePluralized();

            HasPerformanceMeasureManagePermissions = new PerformanceMeasureManageFeature().HasPermissionByFirmaSession(CurrentFirmaSession);
            PerformanceMeasureGridSpec             = new PerformanceMeasureGridSpec(currentFirmaSession)
            {
                ObjectNameSingular  = MultiTenantHelpers.GetPerformanceMeasureName(),
                ObjectNamePlural    = MultiTenantHelpers.GetPerformanceMeasureNamePluralized(),
                SaveFiltersInCookie = true
            };

            NewUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(c => c.New());

            PerformanceMeasureGridSpec.CustomExcelDownloadLinkText = $"Download with {FieldDefinitionEnum.PerformanceMeasureSubcategory.ToType().GetFieldDefinitionLabelPluralized()}";
            PerformanceMeasureGridSpec.CustomExcelDownloadUrl      = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(tc => tc.IndexExcelDownload());

            PerformanceMeasureGridName    = "performanceMeasuresGrid";
            PerformanceMeasureGridDataUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(c => c.PerformanceMeasureGridJsonData());

            EditSortOrderUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(x => x.EditSortOrder());
        }
        public PerformanceMeasureChartViewData(Models.PerformanceMeasure performanceMeasure,
                                               int height,
                                               Person currentPerson,
                                               bool showLastUpdatedDate,
                                               bool fromPerformanceMeasureDetailPage,
                                               List <Models.Project> projects)
        {
            PerformanceMeasure = performanceMeasure;
            HyperlinkPerformanceMeasureName = !fromPerformanceMeasureDetailPage;

            GoogleChartJsons = performanceMeasure.GetGoogleChartJsonDictionary(projects);

            var performanceMeasureActuals = PerformanceMeasure.PerformanceMeasureActuals.Where(x => projects.Contains(x.Project)).ToList();

            ChartTotal          = performanceMeasureActuals.Any() ? performanceMeasureActuals.Sum(x => x.ActualValue) : (double?)null;
            ChartTotalFormatted = PerformanceMeasure.MeasurementUnitType.DisplayValue(ChartTotal);
            ChartTotalUnit      = PerformanceMeasure.MeasurementUnitType.LegendDisplayName;

            var currentPersonHasManagePermission = new PerformanceMeasureManageFeature().HasPermissionByPerson(currentPerson);

            CanManagePerformanceMeasures = currentPersonHasManagePermission && fromPerformanceMeasureDetailPage;

            ShowLastUpdatedDate     = showLastUpdatedDate;
            ChartTitle              = performanceMeasure.DisplayName;
            ViewGoogleChartViewData = new ViewGoogleChartViewData(GoogleChartJsons,
                                                                  ChartTitle,
                                                                  height,
                                                                  null,
                                                                  performanceMeasure.GetJavascriptSafeChartUniqueName(),
                                                                  CanManagePerformanceMeasures,
                                                                  SitkaRoute <GoogleChartController> .BuildUrlFromExpression(c => c.DownloadPerformanceMeasureChartData()),
                                                                  true,
                                                                  true,
                                                                  performanceMeasure,
                                                                  HyperlinkPerformanceMeasureName);
        }