mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
Generate component, model, action & reducer for breadcrumbs
This commit is contained in:
@@ -6,9 +6,11 @@ import { AppComponent } from './app.component';
|
||||
import { ComponentsModule } from './modules/components.module';
|
||||
import { processReducer } from './core/reducers/process.reducer';
|
||||
import { StoreModule } from '@ngrx/store';
|
||||
import { breadcrumbReducer } from './core/reducers/breadcrumb.reducer';
|
||||
|
||||
const rootReducer = {
|
||||
processes: processReducer
|
||||
processes: processReducer,
|
||||
breadcrumbs: breadcrumbReducer
|
||||
};
|
||||
|
||||
@NgModule({
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Process } from './core/models/process.model';
|
||||
import { Breadcrumb } from './core/models/breadcrumb.model';
|
||||
|
||||
export class AppState {
|
||||
readonly processes: Process[];
|
||||
readonly breadcrumbs: Breadcrumb[];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<p>
|
||||
breadcrumbs works!
|
||||
</p>
|
||||
25
src/app/components/breadcrumbs/breadcrumbs.component.spec.ts
Normal file
25
src/app/components/breadcrumbs/breadcrumbs.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { BreadcrumbsComponent } from './breadcrumbs.component';
|
||||
|
||||
describe('BreadcrumbsComponent', () => {
|
||||
let component: BreadcrumbsComponent;
|
||||
let fixture: ComponentFixture<BreadcrumbsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ BreadcrumbsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(BreadcrumbsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
15
src/app/components/breadcrumbs/breadcrumbs.component.ts
Normal file
15
src/app/components/breadcrumbs/breadcrumbs.component.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-breadcrumbs',
|
||||
templateUrl: './breadcrumbs.component.html',
|
||||
styleUrls: ['./breadcrumbs.component.scss']
|
||||
})
|
||||
export class BreadcrumbsComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
<div class="content-body">
|
||||
<app-breadcrumbs *ngIf="router.url !== '/dashboard'"></app-breadcrumbs>
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-content',
|
||||
@@ -7,7 +8,7 @@ import { Component, OnInit } from '@angular/core';
|
||||
})
|
||||
export class ContentComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
constructor(private router: Router) { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
10
src/app/core/actions/breadcrumb.actions.ts
Normal file
10
src/app/core/actions/breadcrumb.actions.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Action } from '@ngrx/store';
|
||||
import { Breadcrumb } from '../models/breadcrumb.model';
|
||||
|
||||
export const ADD_BREADCRUMB = 'ADD_BERADCRUMB';
|
||||
|
||||
export class AddBreadcrumb implements Action {
|
||||
type: string;
|
||||
|
||||
constructor(public payload: Breadcrumb) {}
|
||||
}
|
||||
4
src/app/core/models/breadcrumb.model.ts
Normal file
4
src/app/core/models/breadcrumb.model.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export interface Breadcrumb {
|
||||
name: string;
|
||||
path: string;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { Process } from './process.model';
|
||||
|
||||
describe('Process', () => {
|
||||
it('should create an instance', () => {
|
||||
expect(new Process()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
11
src/app/core/reducers/breadcrumb.reducer.ts
Normal file
11
src/app/core/reducers/breadcrumb.reducer.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Breadcrumb } from '../models/breadcrumb.model';
|
||||
import { ADD_BREADCRUMB } from '../actions/breadcrumb.actions';
|
||||
|
||||
export function breadcrumbReducer(breadcrumbs: Breadcrumb[] = [], action: any) {
|
||||
switch (action.type) {
|
||||
case ADD_BREADCRUMB:
|
||||
return [...breadcrumbs, action.payload];
|
||||
default:
|
||||
return breadcrumbs;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { ArticleSearchComponent } from 'src/app/components/article-search/articl
|
||||
import { DashboardComponent } from 'src/app/components/dashboard/dashboard.component';
|
||||
import { AppRoutingModule } from 'src/app/app-routing.module';
|
||||
import { MenuComponent } from '../components/menu/menu.component';
|
||||
import { BreadcrumbsComponent } from '../components/breadcrumbs/breadcrumbs.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@@ -17,7 +18,8 @@ import { MenuComponent } from '../components/menu/menu.component';
|
||||
ContentComponent,
|
||||
ArticleSearchComponent,
|
||||
DashboardComponent,
|
||||
MenuComponent
|
||||
MenuComponent,
|
||||
BreadcrumbsComponent
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
@@ -30,7 +32,8 @@ import { MenuComponent } from '../components/menu/menu.component';
|
||||
ContentComponent,
|
||||
ArticleSearchComponent,
|
||||
DashboardComponent,
|
||||
MenuComponent
|
||||
MenuComponent,
|
||||
BreadcrumbsComponent
|
||||
]
|
||||
})
|
||||
export class ComponentsModule { }
|
||||
|
||||
Reference in New Issue
Block a user