-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial "requisition-management" sub project with routing inclusion f…
…rom My Account
- Loading branch information
Showing
30 changed files
with
506 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div class="container main-container"> | ||
<div class="d-flex py-2 border-bottom"> | ||
<a | ||
*ngIf="user$ | async as user; else notLoggedIn" | ||
class="text-uppercase" | ||
routerLink="/logout" | ||
[queryParams]="{ returnUrl: '/login?returnUrl=/requisition-management' }" | ||
>{{ 'account.logout.link' | translate }}</a | ||
> | ||
<ng-template #notLoggedIn> | ||
<a | ||
class="text-uppercase" | ||
routerLink="/login" | ||
[queryParams]="{ returnUrl: '/login?returnUrl=/requisition-management' }" | ||
>{{ 'account.login.link' | translate }}</a | ||
> | ||
</ng-template> | ||
</div> | ||
|
||
<router-outlet></router-outlet> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { AccountFacade } from 'ish-core/facades/account.facade'; | ||
import { User } from 'ish-core/models/user/user.model'; | ||
|
||
@Component({ | ||
selector: 'ish-requisition-management-root', | ||
templateUrl: './app.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
// tslint:disable-next-line: component-creation-test | ||
export class AppComponent implements OnInit { | ||
user$: Observable<User>; | ||
|
||
constructor(private accountFacade: AccountFacade) {} | ||
|
||
ngOnInit() { | ||
this.user$ = this.accountFacade.user$; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { RouterModule } from '@angular/router'; | ||
|
||
import { CoreModule } from 'ish-core/core.module'; | ||
import { AuthGuard } from 'ish-core/guards/auth.guard'; | ||
import { LogoutGuard } from 'ish-core/guards/logout.guard'; | ||
import { FormsSharedModule } from 'ish-shared/forms/forms.module'; | ||
|
||
import { AppComponent } from './app.component'; | ||
import { LoginComponent } from './login.component'; | ||
|
||
@NgModule({ | ||
declarations: [AppComponent, LoginComponent], | ||
imports: [ | ||
BrowserModule, | ||
CoreModule, | ||
FormsSharedModule, | ||
NoopAnimationsModule, | ||
RouterModule.forRoot([ | ||
{ | ||
path: 'login', | ||
component: LoginComponent, | ||
}, | ||
{ | ||
path: 'logout', | ||
canActivate: [LogoutGuard], | ||
component: LoginComponent, | ||
}, | ||
{ | ||
path: 'requisition-management', | ||
loadChildren: () => import('./app/requisition-management.module').then(m => m.RequisitionManagementModule), | ||
canActivate: [AuthGuard], | ||
canActivateChild: [AuthGuard], | ||
}, | ||
{ | ||
path: '**', | ||
redirectTo: 'requisition-management', | ||
pathMatch: 'full', | ||
}, | ||
]), | ||
], | ||
providers: [], | ||
bootstrap: [AppComponent], | ||
}) | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// tslint:disable: no-barrel-files | ||
|
||
export { RequisitionManagementModule } from '../requisition-management.module'; | ||
|
||
export { RequisitionManagementBreadcrumbService } from '../services/requisition-management-breadcrumb/requisition-management-breadcrumb.service'; |
11 changes: 11 additions & 0 deletions
11
projects/requisition-management/src/app/facades/requisition-management.facade.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Store } from '@ngrx/store'; | ||
|
||
// tslint:disable:member-ordering | ||
@Injectable({ providedIn: 'root' }) | ||
export class RequisitionManagementFacade { | ||
constructor(private store: Store) { | ||
// tslint:disable-next-line: no-console | ||
console.log(this.store); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
projects/requisition-management/src/app/pages/approver/approver-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>{{ 'account.requisitions.approvals' | translate }}</h1> | ||
|
||
<p>{{ 'account.requisitions.approvals.text' | translate }}</p> |
30 changes: 30 additions & 0 deletions
30
projects/requisition-management/src/app/pages/approver/approver-page.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
import { ApproverPageComponent } from './approver-page.component'; | ||
|
||
describe('Approver Page Component', () => { | ||
let component: ApproverPageComponent; | ||
let fixture: ComponentFixture<ApproverPageComponent>; | ||
let element: HTMLElement; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [RouterTestingModule, TranslateModule.forRoot()], | ||
declarations: [ApproverPageComponent], | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ApproverPageComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.nativeElement; | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
expect(element).toBeTruthy(); | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
}); | ||
}); |
8 changes: 8 additions & 0 deletions
8
projects/requisition-management/src/app/pages/approver/approver-page.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'ish-approver-page', | ||
templateUrl: './approver-page.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ApproverPageComponent {} |
3 changes: 3 additions & 0 deletions
3
projects/requisition-management/src/app/pages/buyer/buyer-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>{{ 'account.requisitions.requisitions' | translate }}</h1> | ||
|
||
<p>{{ 'account.requisitions.requisitions.text' | translate }}</p> |
30 changes: 30 additions & 0 deletions
30
projects/requisition-management/src/app/pages/buyer/buyer-page.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
import { BuyerPageComponent } from './buyer-page.component'; | ||
|
||
describe('Buyer Page Component', () => { | ||
let component: BuyerPageComponent; | ||
let fixture: ComponentFixture<BuyerPageComponent>; | ||
let element: HTMLElement; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [RouterTestingModule, TranslateModule.forRoot()], | ||
declarations: [BuyerPageComponent], | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(BuyerPageComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.nativeElement; | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
expect(element).toBeTruthy(); | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
}); | ||
}); |
8 changes: 8 additions & 0 deletions
8
projects/requisition-management/src/app/pages/buyer/buyer-page.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'ish-buyer-page', | ||
templateUrl: './buyer-page.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class BuyerPageComponent {} |
21 changes: 21 additions & 0 deletions
21
projects/requisition-management/src/app/pages/requisition-management-routing.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
|
||
import { ApproverPageComponent } from './approver/approver-page.component'; | ||
import { BuyerPageComponent } from './buyer/buyer-page.component'; | ||
|
||
/** | ||
* routes for the requisition management | ||
* | ||
* visible for testing | ||
*/ | ||
export const routes: Routes = [ | ||
{ path: 'approver', component: ApproverPageComponent }, | ||
{ path: 'buyer', component: BuyerPageComponent }, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class RequisitionManagementRoutingModule {} |
14 changes: 14 additions & 0 deletions
14
projects/requisition-management/src/app/requisition-management.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { SharedModule } from 'ish-shared/shared.module'; | ||
|
||
import { ApproverPageComponent } from './pages/approver/approver-page.component'; | ||
import { BuyerPageComponent } from './pages/buyer/buyer-page.component'; | ||
import { RequisitionManagementRoutingModule } from './pages/requisition-management-routing.module'; | ||
import { RequisitionManagementStoreModule } from './store/requisition-management-store.module'; | ||
|
||
@NgModule({ | ||
declarations: [ApproverPageComponent, BuyerPageComponent], | ||
imports: [RequisitionManagementRoutingModule, RequisitionManagementStoreModule, SharedModule], | ||
}) | ||
export class RequisitionManagementModule {} |
88 changes: 88 additions & 0 deletions
88
...vices/requisition-management-breadcrumb/requisition-management-breadcrumb.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { Component, Type } from '@angular/core'; | ||
import { TestBed } from '@angular/core/testing'; | ||
import { Route, Router } from '@angular/router'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
import { CoreStoreModule } from 'ish-core/store/core/core-store.module'; | ||
|
||
import { routes } from '../../pages/requisition-management-routing.module'; | ||
|
||
import { RequisitionManagementBreadcrumbService } from './requisition-management-breadcrumb.service'; | ||
|
||
// tslint:disable-next-line: no-any | ||
function adaptRoutes(rts: Route[], cmp: Type<any>): Route[] { | ||
return rts.map(r => ({ | ||
...r, | ||
component: r.component && cmp, | ||
children: r.children && adaptRoutes(r.children, cmp), | ||
})); | ||
} | ||
|
||
describe('Requisition Management Breadcrumb Service', () => { | ||
let requisitionManagementBreadcrumbService: RequisitionManagementBreadcrumbService; | ||
let router: Router; | ||
|
||
beforeEach(() => { | ||
@Component({ template: 'dummy' }) | ||
class DummyComponent {} | ||
TestBed.configureTestingModule({ | ||
declarations: [DummyComponent], | ||
imports: [ | ||
CoreStoreModule.forTesting(['router', 'configuration']), | ||
RouterTestingModule.withRoutes([ | ||
...adaptRoutes(routes, DummyComponent), | ||
{ path: '**', component: DummyComponent }, | ||
]), | ||
TranslateModule.forRoot(), | ||
], | ||
}); | ||
requisitionManagementBreadcrumbService = TestBed.inject(RequisitionManagementBreadcrumbService); | ||
router = TestBed.inject(Router); | ||
router.initialNavigation(); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(requisitionManagementBreadcrumbService).toBeTruthy(); | ||
}); | ||
|
||
describe('breadcrumb$', () => { | ||
describe('unrelated routes', () => { | ||
it('should not report a breadcrumb for unrelated routes', done => { | ||
router.navigateByUrl('/foobar'); | ||
requisitionManagementBreadcrumbService.breadcrumb$('/my-account').subscribe(fail, fail, fail); | ||
setTimeout(done, 2000); | ||
}); | ||
}); | ||
|
||
describe('requisition management routes', () => { | ||
it('should set breadcrumb for requisitions list view', done => { | ||
router.navigateByUrl('/buyer'); | ||
requisitionManagementBreadcrumbService.breadcrumb$('/my-account').subscribe(breadcrumbData => { | ||
expect(breadcrumbData).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"key": "account.requisitions.requisitions", | ||
}, | ||
] | ||
`); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should set breadcrumb for requisitions list view', done => { | ||
router.navigateByUrl('/approver'); | ||
requisitionManagementBreadcrumbService.breadcrumb$('/my-account').subscribe(breadcrumbData => { | ||
expect(breadcrumbData).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"key": "account.requisitions.approvals", | ||
}, | ||
] | ||
`); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
ae05e1d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Azure Demo Servers are available: