-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
menu: generation of menus by services
Menu refactoring to allow future easy addition of further entries. * Fixes url parsing on library switch. Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
- Loading branch information
1 parent
c7cfbf4
commit 772e91e
Showing
55 changed files
with
1,708 additions
and
611 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
44 changes: 44 additions & 0 deletions
44
projects/admin/src/app/menu/menu-dashboard/menu-dashboard.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,44 @@ | ||
<!-- | ||
RERO ILS UI | ||
Copyright (C) 2020 RERO | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, version 3 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
<ng-container *ngIf="menu"> | ||
<div class="row justify-content-center"> | ||
<ng-container *ngFor="let item of menu.getChildren()"> | ||
<div class="col-lg-2"> | ||
<div class="card mb-2" [attr.id]="item.getAttribute('id') | idAttribute:{prefix: 'dashboard'}"> | ||
<div class="card-header bg-dark text-white text-wrap"> | ||
<i *ngIf="item.hasExtra('iconClass')" [ngClass]="item.getExtra('iconClass')"></i> | ||
{{ item.getName() }} | ||
</div> | ||
<div class="list-group list-group-flush"> | ||
<ng-container *ngFor="let subItem of item.getChildren()"> | ||
<a | ||
class="list-group-item list-group-item-action text-wrap border-bottom-0 my-0 py-2" | ||
[attr.id]="subItem.getAttribute('id') | idAttribute:{prefix: 'dashboard'}" | ||
[attr.target]="subItem.getAttribute('target')" | ||
[routerLink]="subItem.getRouterLink()" | ||
[queryParams]="subItem.getQueryParams() ? subItem.getQueryParams() : {}" | ||
> | ||
<i *ngIf="subItem.hasExtra('iconClass')" [ngClass]="subItem.getExtra('iconClass')"></i> | ||
{{ subItem.getName() }} | ||
</a> | ||
</ng-container> | ||
</div> | ||
</div> | ||
</div> | ||
</ng-container> | ||
</div> | ||
</ng-container> |
60 changes: 60 additions & 0 deletions
60
projects/admin/src/app/menu/menu-dashboard/menu-dashboard.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,60 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2020 RERO | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { IdAttributePipe, SharedModule, User, UserService } from '@rero/shared'; | ||
|
||
import { MenuDashboardComponent } from './menu-dashboard.component'; | ||
|
||
describe('MenuDashboardComponent', () => { | ||
let component: MenuDashboardComponent; | ||
let fixture: ComponentFixture<MenuDashboardComponent>; | ||
|
||
const user = new User({ | ||
currentLibrary: 1 | ||
}); | ||
const userServiceSpy = jasmine.createSpyObj('UserService', ['']); | ||
userServiceSpy.user = user; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [MenuDashboardComponent], | ||
imports: [ | ||
SharedModule, | ||
HttpClientTestingModule, | ||
TranslateModule.forRoot() | ||
], | ||
providers: [ | ||
IdAttributePipe, | ||
{ provide: UserService, useValue: userServiceSpy } | ||
] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(MenuDashboardComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
projects/admin/src/app/menu/menu-dashboard/menu-dashboard.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,52 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2020 RERO | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { Component, OnInit } from '@angular/core'; | ||
import { MenuItemInterface } from '@rero/ng-core'; | ||
import { MenuUserServicesService } from '../service/menu-user-services.service'; | ||
|
||
@Component({ | ||
selector: 'admin-menu-dashboard', | ||
templateUrl: './menu-dashboard.component.html' | ||
}) | ||
export class MenuDashboardComponent implements OnInit { | ||
|
||
/** User menu */ | ||
private _menu: MenuItemInterface; | ||
|
||
/** | ||
* User services menu | ||
* @return MenuItemInterface | ||
*/ | ||
get menu(): MenuItemInterface { | ||
return this._menu; | ||
} | ||
|
||
/** | ||
* Constructor | ||
* @param _menuUserService - MenuUserService | ||
*/ | ||
constructor(private _menuUserServicesService: MenuUserServicesService) { } | ||
|
||
/** Init */ | ||
ngOnInit() { | ||
if (!(this._menuUserServicesService.menu)) { | ||
this._menuUserServicesService.generate(); | ||
} | ||
this._menu = this._menuUserServicesService.menu; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
projects/admin/src/app/menu/menu-language/menu-language.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,18 @@ | ||
<!-- | ||
RERO ILS UI | ||
Copyright (C) 2020 RERO | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, version 3 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
|
||
<ng-core-menu-widget [menu]="menu" (clickItem)="changeLang($event)"></ng-core-menu-widget> |
53 changes: 53 additions & 0 deletions
53
projects/admin/src/app/menu/menu-language/menu-language.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,53 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2020 RERO | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { TranslateModule, TranslateService } from '@ngx-translate/core'; | ||
import { BsLocaleService } from 'ngx-bootstrap/datepicker'; | ||
import { MenuLanguageComponent } from './menu-language.component'; | ||
|
||
|
||
describe('MenuLanguageComponent', () => { | ||
let component: MenuLanguageComponent; | ||
let fixture: ComponentFixture<MenuLanguageComponent>; | ||
let translateService: TranslateService; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ MenuLanguageComponent ], | ||
imports: [ | ||
TranslateModule.forRoot() | ||
], | ||
providers: [ | ||
BsLocaleService | ||
] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
translateService = TestBed.inject(TranslateService); | ||
translateService.use('en'); | ||
fixture = TestBed.createComponent(MenuLanguageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.