Skip to content

Commit

Permalink
feat: update checklist route for #168
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 27, 2020
1 parent f596c05 commit 8f80055
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
16 changes: 8 additions & 8 deletions scully.ledge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ function thinkTankPlugin(route, config) {

function checklistsPlugin(route, config) {
return Promise.resolve([
{ route: '/checklists/0' },
{ route: '/checklists/1' },
{ route: '/checklists/2' },
{ route: '/checklists/3' },
{ route: '/checklists/4' },
{ route: '/checklists/5' },
{ route: '/checklists/6' },
{ route: '/checklists/7' },
{ route: '/checklists/new-project' },
{ route: '/checklists/agile-practise' },
{ route: '/checklists/azure-devops' },
{ route: '/checklists/aws-devops' },
{ route: '/checklists/devsecops' },
{ route: '/checklists/xp-practise' },
{ route: '/checklists/code-review' },
{ route: '/checklists/frontend' },
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ChecklistsComponent } from './checklists.component';

const routes: Routes = [
{
path: ':selectedIndex',
path: ':name',
component: ChecklistsComponent,
},
{ path: '', pathMatch: 'full', redirectTo: '0' },
Expand Down
28 changes: 18 additions & 10 deletions src/app/presentation/checklists/checklists.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export class ChecklistsComponent implements OnInit {
selectedTabIndex = 0;

contentMap = [
{ name: '新项目检查清单' },
{ name: '敏捷实践检查清单' },
{ name: 'DevOps 检查清单(Azure)' },
{ name: 'DevOps 检查清单(AWS)' },
{ name: 'DevSecOps 检查清单' },
{ name: '极限编程检查清单' },
{ name: '代码回顾检查清单' },
{ name: '前端项目检查清单' },
{ name: '新项目检查清单', route: 'new-project' },
{ name: '敏捷实践检查清单', route: 'agile-practise' },
{ name: 'DevOps 检查清单(Azure)', route: 'azure-devops' },
{ name: 'DevOps 检查清单(AWS)', route: 'aws-devops' },
{ name: 'DevSecOps 检查清单', route: 'devsecops' },
{ name: '极限编程检查清单', route: 'xp-practise' },
{ name: '代码回顾检查清单', route: 'code-review' },
{ name: '前端项目检查清单', route: 'frontend' },
];

constructor(
Expand All @@ -58,7 +58,12 @@ export class ChecklistsComponent implements OnInit {

ngOnInit(): void {
this.activatedRoute.paramMap.subscribe((p) => {
this.selectedTabIndex = Number(p.get('selectedIndex'));
const routeName = p.get('name');
for (const [index, item] of this.contentMap.entries()) {
if (item.name === routeName) {
this.selectedTabIndex = index;
}
}
});
this.storage.get('checklists.last.index').subscribe((value: string) => {
if (!!value) {
Expand All @@ -72,7 +77,10 @@ export class ChecklistsComponent implements OnInit {
this.selectedTabIndex = $event.index;
this.setTitle();

this.router.navigate(['/checklists/', this.selectedTabIndex]);
this.router.navigate([
'/checklists/',
this.contentMap[this.selectedTabIndex].route,
]);
this.storage
.set('checklists.last.index', this.selectedTabIndex)
.subscribe();
Expand Down

0 comments on commit 8f80055

Please sign in to comment.