public async Task PostLabel([FromBody] PortfolioConfigAddLabelRequest labelRequest)
        {
            using (var context = new PortfolioContext())
            {
                var portfolio = await context.Portfolios
                                .Include(p => p.Configuration.Labels)
                                .Include(p => p.Configuration.LabelGroups)
                                .SingleAsync(p => p.ViewKey == labelRequest.ViewKey);

                var label = portfolio.Configuration.Labels.SingleOrDefault(l => l.FieldName == labelRequest.FieldName);
                var group = labelRequest.FieldGroup == null ? null : portfolio.Configuration.LabelGroups.Single(l => l.Name == labelRequest.FieldGroup);
                if (label == null)
                {
                    label = new PortfolioLabelConfig();
                    portfolio.Configuration.Labels.Add(label);
                }

                // Update the label's fields
                label       = PortfolioMapper.ConfigMapper.Map(labelRequest, label);
                label.Group = group;

                // Save
                await context.SaveChangesAsync();
            }
        }
示例#2
0
 internal _projectPropertyMap(PropertyInfo property, PortfolioConfiguration config) : base(property)
 {
     this.property = property;
     this.json     = property.GetCustomAttribute <JsonPropertyAttribute>();
     this.label    = config.Labels.SingleOrDefault(l => l.FieldName == (json?.PropertyName ?? property.Name));
 }
        public PortfolioLabelConfig[] GetCustomFilterLabels(PortfolioConfiguration config)
        {
            var customLabels = new PortfolioLabelConfig[] {
                new PortfolioLabelConfig()
                {
                    Included  = true,
                    Group     = config.LabelGroups.SingleOrDefault(g => g.Name == FieldGroupConstants.FieldGroupName_ProjectTeam),
                    Label     = FilterFieldConstants.TeamMemberNameName,
                    FieldName = FilterFieldConstants.TeamMemberNameFilter,
                    FieldType = PortfolioFieldType.FreeText
                },
                new PortfolioLabelConfig()
                {
                    Included  = true,
                    Group     = config.LabelGroups.SingleOrDefault(g => g.Name == FieldGroupConstants.FieldGroupName_ProjectTeam),
                    Label     = FilterFieldConstants.LeadTeamName,
                    FieldName = FilterFieldConstants.LeadTeamFilter,
                    FieldType = PortfolioFieldType.OptionList
                },
                new PortfolioLabelConfig()
                {
                    Included  = true,
                    Group     = config.LabelGroups.SingleOrDefault(g => g.Name == FieldGroupConstants.FieldGroupName_Updates),
                    Label     = FilterFieldConstants.LastUpdateName,
                    FieldName = FilterFieldConstants.LastUpdateFilter,
                    FieldType = PortfolioFieldType.Date
                },
                new PortfolioLabelConfig()
                {
                    Included  = true,
                    Group     = config.LabelGroups.SingleOrDefault(g => g.Name == FieldGroupConstants.FieldGroupName_Updates),
                    Label     = FilterFieldConstants.NoUpdatesName,
                    FieldName = FilterFieldConstants.NoUpdatesFilter,
                    FieldType = PortfolioFieldType.NullableBoolean
                },
                new PortfolioLabelConfig()
                {
                    Included  = true,
                    Group     = config.LabelGroups.SingleOrDefault(g => g.Name == FieldGroupConstants.FieldGroupName_ProjectPlan),
                    Label     = FilterFieldConstants.PastIntendedStartDateName,
                    FieldName = FilterFieldConstants.PastIntendedStartDateFilter,
                    FieldType = PortfolioFieldType.NullableBoolean
                },
                new PortfolioLabelConfig()
                {
                    Included  = true,
                    Group     = config.LabelGroups.SingleOrDefault(g => g.Name == FieldGroupConstants.FieldGroupName_ProjectPlan),
                    Label     = FilterFieldConstants.MissedEndDateName,
                    FieldName = FilterFieldConstants.MissedEndDateFilter,
                    FieldType = PortfolioFieldType.NullableBoolean
                },
                new PortfolioLabelConfig()
                {
                    Included  = true,
                    Group     = config.LabelGroups.SingleOrDefault(g => g.Name == FieldGroupConstants.FieldGroupName_Prioritisation),
                    Label     = FilterFieldConstants.PriorityGroupName,
                    FieldName = FilterFieldConstants.PriorityGroupFilter,
                    FieldType = PortfolioFieldType.OptionList
                }
            };

            return(customLabels);
        }
        public PortfolioLabelConfig[] GetDefaultLabels()
        {
            var labels = new PortfolioLabelConfig[]
            {
                //      FieldGroup      FieldTitle     FieldName                    Included IncludeLock AdmLock FieldType FieldTypeLocked
                Factory(FieldGroupName_ProjectIDs, "Project ID", ProjectPropertyConstants.ProjectId, true, true, true, PortfolioFieldType.Auto),
                Factory(FieldGroupName_ProjectIDs, "Business Case Number", ProjectPropertyConstants.business_case_number, true, false, false, PortfolioFieldType.FreeText, flags: EditorCanView),
                Factory(FieldGroupName_ProjectIDs, "FS Number", ProjectPropertyConstants.fs_number, false, false, false, PortfolioFieldType.FreeText, flags: EditorCanView),

                Factory(FieldGroupName_AboutTheProject, "Project title", ProjectPropertyConstants.project_name, true, true, false, PortfolioFieldType.FreeText, flags: EditorCanView | Filterable | FilterProject | Required),
                Factory(FieldGroupName_AboutTheProject, "Short description", ProjectPropertyConstants.short_desc, true, false, false, PortfolioFieldType.MediumFreeTextArea, flags: EditorCanView),
                Factory(FieldGroupName_AboutTheProject, "Risk rating", ProjectPropertyConstants.risk_rating, false, false, false, PortfolioFieldType.OptionList),
                Factory(FieldGroupName_AboutTheProject, "Theme", ProjectPropertyConstants.theme, true, false, false, PortfolioFieldType.OptionList, flags: Filterable | FilterProject, options: "Theme1, Theme2, Theme3"),
                Factory(FieldGroupName_AboutTheProject, "Project type", ProjectPropertyConstants.project_type, false, false, false, PortfolioFieldType.OptionList, flags: Filterable | FilterProject),
                Factory(FieldGroupName_AboutTheProject, "Project size", ProjectPropertyConstants.project_size, false, false, false, PortfolioFieldType.OptionList),
                Factory(FieldGroupName_AboutTheProject, "Category", ProjectPropertyConstants.category, true, false, false, PortfolioFieldType.OptionList, flags: Filterable | FilterProject),
                Factory(FieldGroupName_AboutTheProject, "Secondary category", ProjectPropertyConstants.subcat, true, false, false, PortfolioFieldType.PredefinedMultiList), // Uses the same values as category
                Factory(FieldGroupName_AboutTheProject, "Directorate", ProjectPropertyConstants.direct, true, false, false, PortfolioFieldType.PredefinedList, flags: Filterable | FilterProject),
                Factory(FieldGroupName_AboutTheProject, "Strategic objectives", ProjectPropertyConstants.strategic_objectives, false, false, false, PortfolioFieldType.PredefinedList, flags: Filterable | FilterProject),
                Factory(FieldGroupName_AboutTheProject, "Programme", ProjectPropertyConstants.programme, false, false, false, PortfolioFieldType.OptionList, flags: EditorCanView | Filterable | FilterProject),
                Factory(FieldGroupName_AboutTheProject, "Programme description", ProjectPropertyConstants.programme_description, false, false, false, PortfolioFieldType.MediumFreeTextArea, flags: EditorCanView),
                Factory(FieldGroupName_AboutTheProject, "Project channel (link)", ProjectPropertyConstants.link, true, false, false, PortfolioFieldType.NamedLink),
                Factory(FieldGroupName_AboutTheProject, "Related projects", ProjectPropertyConstants.rels, true, false, false, PortfolioFieldType.AjaxMultiSearch),
                Factory(FieldGroupName_AboutTheProject, "Dependencies", ProjectPropertyConstants.dependencies, false, false, false, PortfolioFieldType.AjaxMultiSearch),
                Factory(FieldGroupName_AboutTheProject, "Key documents", ProjectPropertyConstants.documents, true, false, false, PortfolioFieldType.LinkedItemList),

                Factory(FieldGroupName_ProjectTeam, "Project lead", ProjectPropertyConstants.ProjectLead, false, false, false, PortfolioFieldType.ADUserSearch, flags: Filterable | FilterProject),
                Factory(FieldGroupName_ProjectTeam, "Lead role", ProjectPropertyConstants.oddlead_role, false, false, false, PortfolioFieldType.OptionList, options: "Role, Support, Implementation, Management"),
                Factory(FieldGroupName_ProjectTeam, "Lead team", ProjectPropertyConstants.g6team, false, false, false, PortfolioFieldType.Auto, flags: Read),
                Factory(FieldGroupName_ProjectTeam, "Key contact 1", ProjectPropertyConstants.key_contact1, false, false, false, PortfolioFieldType.ADUserSearch),
                Factory(FieldGroupName_ProjectTeam, "Key contact 2", ProjectPropertyConstants.key_contact2, false, false, false, PortfolioFieldType.ADUserSearch),
                Factory(FieldGroupName_ProjectTeam, "Key contact 3", ProjectPropertyConstants.key_contact3, false, false, false, PortfolioFieldType.ADUserSearch),
                Factory(FieldGroupName_ProjectTeam, "Supplier", ProjectPropertyConstants.Supplier, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_ProjectTeam, "Project team", ProjectPropertyConstants.team, false, false, false, PortfolioFieldType.ADUserMultiSearch),
                Factory(FieldGroupName_ProjectTeam, $"{FieldGroupName_ProjectTeam} setting 1", ProjectPropertyConstants.project_team_setting1, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_ProjectTeam, $"{FieldGroupName_ProjectTeam} setting 2", ProjectPropertyConstants.project_team_setting2, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_ProjectTeam, $"{FieldGroupName_ProjectTeam} option 1", ProjectPropertyConstants.project_team_option1, false, false, false, PortfolioFieldType.OptionList),
                Factory(FieldGroupName_ProjectTeam, $"{FieldGroupName_ProjectTeam} option 2", ProjectPropertyConstants.project_team_option2, false, false, false, PortfolioFieldType.OptionList),

                Factory(FieldGroupName_ProjectPlan, "Intended start date", ProjectPropertyConstants.IntendedStartDate, false, false, false, PortfolioFieldType.ProjectDate),
                Factory(FieldGroupName_ProjectPlan, "Actual start date", ProjectPropertyConstants.ActualStartDate, false, false, false, PortfolioFieldType.ProjectDate),
                Factory(FieldGroupName_ProjectPlan, "Expected current phase end date", ProjectPropertyConstants.ExpectedCurrentPhaseEndDate, false, false, false, PortfolioFieldType.ProjectDate),
                Factory(FieldGroupName_ProjectPlan, "Expected end date", ProjectPropertyConstants.ExpectedEndDate, false, false, false, PortfolioFieldType.ProjectDate),
                Factory(FieldGroupName_ProjectPlan, "Actual end date", ProjectPropertyConstants.ActualEndDate, false, false, false, PortfolioFieldType.ProjectDate),
                Factory(FieldGroupName_ProjectPlan, "Hard deadline", ProjectPropertyConstants.HardDeadline, false, false, false, PortfolioFieldType.ProjectDate),
                Factory(FieldGroupName_ProjectPlan, "Percentage completed", ProjectPropertyConstants.p_comp, false, false, false, PortfolioFieldType.Percentage),
                Factory(FieldGroupName_ProjectPlan, "Milestones", ProjectPropertyConstants.milestones, false, false, false, PortfolioFieldType.Milestones),
                Factory(FieldGroupName_ProjectPlan, $"{FieldGroupName_ProjectPlan} setting 1", ProjectPropertyConstants.project_plan_setting1, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_ProjectPlan, $"{FieldGroupName_ProjectPlan} setting 2", ProjectPropertyConstants.project_plan_setting2, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_ProjectPlan, $"{FieldGroupName_ProjectPlan} option 1", ProjectPropertyConstants.project_plan_option1, false, false, false, PortfolioFieldType.OptionList),
                Factory(FieldGroupName_ProjectPlan, $"{FieldGroupName_ProjectPlan} option 2", ProjectPropertyConstants.project_plan_option2, false, false, false, PortfolioFieldType.OptionList),

                Factory(FieldGroupName_ProgressIndicators, "Phase", ProjectPropertyConstants.phase, true, true, false, PortfolioFieldType.PhaseChoice, flags: Filterable | FilterProject),
                Factory(FieldGroupName_ProgressIndicators, "RAG", ProjectPropertyConstants.rag, true, false, false, PortfolioFieldType.RAGChoice, flags: Filterable | FilterProject),
                Factory(FieldGroupName_ProgressIndicators, "How to get to green", ProjectPropertyConstants.how_get_green, false, false, false, PortfolioFieldType.SmallFreeTextArea),
                Factory(FieldGroupName_ProgressIndicators, "Status", ProjectPropertyConstants.onhold, false, false, false, PortfolioFieldType.OptionList, flags: Filterable | FilterProject),
                Factory(FieldGroupName_ProgressIndicators, $"{FieldGroupName_ProgressIndicators} setting 1", ProjectPropertyConstants.progress_setting1, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_ProgressIndicators, $"{FieldGroupName_ProgressIndicators} setting 2", ProjectPropertyConstants.progress_setting2, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_ProgressIndicators, $"{FieldGroupName_ProgressIndicators} option 1", ProjectPropertyConstants.progress_option1, false, false, false, PortfolioFieldType.OptionList),
                Factory(FieldGroupName_ProgressIndicators, $"{FieldGroupName_ProgressIndicators} option 2", ProjectPropertyConstants.progress_option2, false, false, false, PortfolioFieldType.OptionList),

                //      FieldGroup      FieldTitle     FieldName                    Included IncludeLock AdmLock FieldType FieldTypeLocked
                Factory(FieldGroupName_Updates, "Update", ProjectPropertyConstants.update, true, false, false, PortfolioFieldType.ProjectUpdateText),
                Factory(FieldGroupName_Updates, "Forward look", ProjectPropertyConstants.forward_look, false, false, false, PortfolioFieldType.LargeFreeTextArea),
                Factory(FieldGroupName_Updates, "Emerging issues, risks", ProjectPropertyConstants.emerging_issues, false, false, false, PortfolioFieldType.LargeFreeTextArea),

                Factory(FieldGroupName_Prioritisation, "Priority score", ProjectPropertyConstants.priority_main, false, false, false, PortfolioFieldType.PredefinedList, options: priorityOptions),
                Factory(FieldGroupName_Prioritisation, "Priority group", ProjectPropertyConstants.pgroup, false, false, false, PortfolioFieldType.Auto, flags: PortfolioFieldFlags.Read),
                Factory(FieldGroupName_Prioritisation, "Funded", ProjectPropertyConstants.funded, false, false, false, PortfolioFieldType.PredefinedList, options: fundedOptions),
                Factory(FieldGroupName_Prioritisation, "Confidence in delivery", ProjectPropertyConstants.confidence, false, false, false, PortfolioFieldType.PredefinedList, options: fundedOptions),
                Factory(FieldGroupName_Prioritisation, "Priorities impacted", ProjectPropertyConstants.priorities, false, false, false, PortfolioFieldType.PredefinedList, options: fundedOptions),
                Factory(FieldGroupName_Prioritisation, "Benefits", ProjectPropertyConstants.benefits, false, false, false, PortfolioFieldType.PredefinedList, options: fundedOptions),
                Factory(FieldGroupName_Prioritisation, "Criticality", ProjectPropertyConstants.criticality, false, false, false, PortfolioFieldType.PredefinedList, options: fundedOptions),

                Factory(FieldGroupName_Budget, "Budget category", ProjectPropertyConstants.budgettype, false, false, false, PortfolioFieldType.OptionList),
                Factory(FieldGroupName_Budget, "Budget amount", ProjectPropertyConstants.budget, false, false, false, PortfolioFieldType.Budget),
                Factory(FieldGroupName_Budget, "Amount spent", ProjectPropertyConstants.spent, false, false, false, PortfolioFieldType.Budget),
                Factory(FieldGroupName_Budget, "Forecast spend at completion", ProjectPropertyConstants.forecast_spend, false, false, false, PortfolioFieldType.Budget),
                Factory(FieldGroupName_Budget, "Cost centre", ProjectPropertyConstants.cost_centre, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_Budget, $"{FieldGroupName_Budget} field 1", ProjectPropertyConstants.budget_field1, false, false, false, PortfolioFieldType.Budget),
                Factory(FieldGroupName_Budget, $"{FieldGroupName_Budget} field 2", ProjectPropertyConstants.budget_field2, false, false, false, PortfolioFieldType.Budget),
                Factory(FieldGroupName_Budget, $"{FieldGroupName_Budget} option 1", ProjectPropertyConstants.budget_option1, false, false, false, PortfolioFieldType.OptionList),
                Factory(FieldGroupName_Budget, $"{FieldGroupName_Budget} option 2", ProjectPropertyConstants.budget_option2, false, false, false, PortfolioFieldType.OptionList),

                Factory(FieldGroupName_FSAProcesses, "Assurance gate number", ProjectPropertyConstants.fsaproc_assurance_gatenumber, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_FSAProcesses, "Assurance gate completed", ProjectPropertyConstants.fsaproc_assurance_gatecompleted, false, false, false, PortfolioFieldType.ProjectDate),
                Factory(FieldGroupName_FSAProcesses, "Next gate", ProjectPropertyConstants.fsaproc_assurance_nextgate, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_FSAProcesses, $"{FieldGroupName_FSAProcesses} setting 1", ProjectPropertyConstants.processes_setting1, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_FSAProcesses, $"{FieldGroupName_FSAProcesses} setting 2", ProjectPropertyConstants.processes_setting2, false, false, false, PortfolioFieldType.FreeText),
                Factory(FieldGroupName_FSAProcesses, $"{FieldGroupName_FSAProcesses} option 1", ProjectPropertyConstants.processes_option1, false, false, false, PortfolioFieldType.OptionList),
                Factory(FieldGroupName_FSAProcesses, $"{FieldGroupName_FSAProcesses} option 2", ProjectPropertyConstants.processes_option2, false, false, false, PortfolioFieldType.OptionList),
            };

            SetMasterLabel(labels, ProjectPropertyConstants.subcat, ProjectPropertyConstants.category);
            SetMasterLabel(labels, ProjectPropertyConstants.programme_description, ProjectPropertyConstants.programme);
            SetMasterLabel(labels, ProjectPropertyConstants.oddlead_role, ProjectPropertyConstants.ProjectLead);
            SetMasterLabel(labels, ProjectPropertyConstants.g6team, ProjectPropertyConstants.ProjectLead);
            SetMasterLabel(labels, ProjectPropertyConstants.how_get_green, ProjectPropertyConstants.rag);

            return(labels);
        }