Skip to content

Commit

Permalink
feat: make project title editable on project settings
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Oct 8, 2019
1 parent f32e1d5 commit a578dde
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {FormlyFieldConfig, FormlyFormOptions} from '@ngx-formly/core';
import {ProjectService} from '../../project.service';
import {DEFAULT_PROJECT} from '../../project.const';
import {JiraCfg} from '../../../issue/jira/jira';
import {BASIC_PROJECT_CONFIG_FORM_CONFIG, PROJECT_THEME_CONFIG_FORM_CONFIG} from '../../project-form-cfg.const';
import {CREATE_PROJECT_BASIC_CONFIG_FORM_CONFIG, PROJECT_THEME_CONFIG_FORM_CONFIG} from '../../project-form-cfg.const';
import {IssueIntegrationCfgs} from '../../../issue/issue';
import {DialogJiraInitialSetupComponent} from '../../../issue/jira/dialog-jira-initial-setup/dialog-jira-initial-setup.component';
import {SS_PROJECT_TMP} from '../../../../core/persistence/ls-keys.const';
Expand Down Expand Up @@ -56,7 +56,7 @@ export class DialogCreateProjectComponent implements OnInit, OnDestroy {
private _cd: ChangeDetectorRef,
) {
// somehow they are only unproblematic if assigned here,
this.basicSettingsFormCfg = BASIC_PROJECT_CONFIG_FORM_CONFIG.items;
this.basicSettingsFormCfg = CREATE_PROJECT_BASIC_CONFIG_FORM_CONFIG.items;
this.themeFormCfg = PROJECT_THEME_CONFIG_FORM_CONFIG.items;
}

Expand Down
20 changes: 18 additions & 2 deletions src/app/features/project/project-form-cfg.const.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ConfigFormSection, GenericConfigFormSection} from '../config/global-config.model';
import {T} from '../../t.const';
import {ProjectThemeCfg} from './project.model';
import {Project, ProjectThemeCfg} from './project.model';

const HUES = [
{value: '50', label: '50'},
Expand Down Expand Up @@ -93,7 +93,23 @@ export const PROJECT_THEME_CONFIG_FORM_CONFIG: ConfigFormSection<ProjectThemeCfg
]
};

export const BASIC_PROJECT_CONFIG_FORM_CONFIG: GenericConfigFormSection = {

export const BASIC_PROJECT_CONFIG_FORM_CONFIG: ConfigFormSection<Project> = {
title: T.F.PROJECT.FORM_BASIC.TITLE,
key: 'basic',
items: [
{
key: 'title',
type: 'input',
templateOptions: {
required: true,
label: T.F.PROJECT.FORM_BASIC.L_TITLE,
},
},
]
};

export const CREATE_PROJECT_BASIC_CONFIG_FORM_CONFIG: GenericConfigFormSection = {
title: 'Project Settings & Theme',
key: 'basic',
/* tslint:disable */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
<div class="component-wrapper">
<h1 class="mat-h1">{{T.PS.PROJECT_SETTINGS|translate}}</h1>

<section class="config-section ">
<section class="config-section">
<config-section (save)="saveBasicSettings($event)"
[cfg]="currentProject"
[section]="basicFormCfg"></config-section>
</section>

<section class="config-section">
<config-section (save)="saveProjectThemCfg($event)"
[cfg]="currentProjectTheme"
[section]="projectThemeSettingsFormCfg"></config-section>
Expand Down
17 changes: 16 additions & 1 deletion src/app/pages/project-settings/project-settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import {IssueIntegrationCfg, IssueIntegrationCfgs, IssueProviderKey} from '../..
import {Subscription} from 'rxjs';
import {GlobalConfigService} from '../../features/config/global-config.service';
import {ProjectService} from '../../features/project/project.service';
import {PROJECT_THEME_CONFIG_FORM_CONFIG} from '../../features/project/project-form-cfg.const';
import {
BASIC_PROJECT_CONFIG_FORM_CONFIG,
PROJECT_THEME_CONFIG_FORM_CONFIG
} from '../../features/project/project-form-cfg.const';
import {ISSUE_PROVIDER_FORM_CFGS} from '../../features/issue/issue.const';
import {GLOBAL_CONFIG_FORM_CONFIG} from '../../features/config/global-config-form-config.const';
import {IS_ELECTRON} from '../../app.constants';
Expand All @@ -29,6 +32,7 @@ export class ProjectSettingsComponent implements OnInit, OnDestroy {
projectThemeSettingsFormCfg: ConfigFormSection<ProjectThemeCfg>;
issueIntegrationFormCfg: ConfigFormConfig;
globalConfigFormCfg: ConfigFormConfig;
basicFormCfg: ConfigFormSection<Project>;

currentProject: Project;
currentProjectTheme: ProjectThemeCfg;
Expand All @@ -46,6 +50,7 @@ export class ProjectSettingsComponent implements OnInit, OnDestroy {
// somehow they are only unproblematic if assigned here
this.projectThemeSettingsFormCfg = PROJECT_THEME_CONFIG_FORM_CONFIG;
this.issueIntegrationFormCfg = ISSUE_PROVIDER_FORM_CFGS;
this.basicFormCfg = BASIC_PROJECT_CONFIG_FORM_CONFIG;
this.globalConfigFormCfg = GLOBAL_CONFIG_FORM_CONFIG.filter((cfg) => IS_ELECTRON || !cfg.isElectronOnly);
}

Expand Down Expand Up @@ -91,6 +96,16 @@ export class ProjectSettingsComponent implements OnInit, OnDestroy {
}
}

saveBasicSettings($event: { sectionKey: GlobalConfigSectionKey | ProjectCfgFormKey, config: Project }) {
if (!$event.config) {
throw new Error('Not enough data');
} else {
this.projectService.update(this.currentProject.id, {
title: $event.config.title,
});
}
}

saveIssueProviderCfg($event: { sectionKey: GlobalConfigSectionKey | ProjectCfgFormKey, config: IssueIntegrationCfg }) {
const {sectionKey, config} = $event;
const sectionKeyIN = sectionKey as IssueProviderKey;
Expand Down
4 changes: 4 additions & 0 deletions src/app/t.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ export const T = {
'SETUP_GIT': 'F.PROJECT.D_CREATE.SETUP_GIT',
'SETUP_JIRA': 'F.PROJECT.D_CREATE.SETUP_JIRA'
},
'FORM_BASIC': {
'TITLE': 'F.PROJECT.FORM_BASIC.TITLE',
'L_TITLE': 'F.PROJECT.FORM_BASIC.L_TITLE'
},
'FORM_THEME': {
'D_IS_DARK_THEME': 'F.PROJECT.FORM_THEME.D_IS_DARK_THEME',
'HELP': 'F.PROJECT.FORM_THEME.HELP',
Expand Down
4 changes: 4 additions & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@
"SETUP_GIT": "Setup Github Integration",
"SETUP_JIRA": "Setup Jira Integration"
},
"FORM_BASIC": {
"TITLE": "Basic Settings",
"L_TITLE": "Project Name"
},
"FORM_THEME": {
"D_IS_DARK_THEME": "Won`t be used if system supports global dark mode.",
"HELP": "Theme settings for your project.",
Expand Down

0 comments on commit a578dde

Please sign in to comment.