Skip to content

Commit

Permalink
menu: refactor switch library entry
Browse files Browse the repository at this point in the history
The switch library was only displayed on the root page of the
professional interface. This commit change this behavior and now this
menu is displayed on all pages (if user has required rights).

This commit also removes the top panel containing the current library
name. The current library code is now used as label of the switch
library menu instead of "Switch library" string.

This commit also fix the dynamic population problem of the switch
library menu : When a new library was added, this library was not
dynamically added to the switch library menu. This commit fixes this
problem.

- Closes rero/rero-ils#821
- Closes rero/rero-ils#822

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai and Garfield-fr committed Jun 19, 2020
1 parent 59a4702 commit e5d541f
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 174 deletions.
4 changes: 1 addition & 3 deletions projects/admin/src/app/app.component.spec.ts
Expand Up @@ -27,7 +27,6 @@ import { RecordModule } from '@rero/ng-core';
import { HttpClientModule } from '@angular/common/http';
import { TranslateModule } from '@ngx-translate/core';
import { FormsModule } from '@angular/forms';
import { InterfaceInfoComponent } from './interface-info/interface-info.component';

describe('AppComponent', () => {
beforeEach(async(() => {
Expand All @@ -45,8 +44,7 @@ describe('AppComponent', () => {
],
declarations: [
AppComponent,
MenuComponent,
InterfaceInfoComponent
MenuComponent
]
}).compileComponents();
}));
Expand Down
5 changes: 0 additions & 5 deletions projects/admin/src/app/app.component.ts
Expand Up @@ -142,11 +142,6 @@ export class AppComponent implements OnInit, OnDestroy {
this.localStorageService.updateDate(User.STORAGE_KEY);
}
}

// Library Switch menu show only on homepage
this.librarySwitchService.show(
(event.url === '/') ? true : false
);
})
);
}
Expand Down
3 changes: 0 additions & 3 deletions projects/admin/src/app/app.module.ts
Expand Up @@ -30,7 +30,6 @@ import { ErrorPageComponent } from './error/error-page/error-page.component';
import { FrontpageBoardComponent } from './frontpage/frontpage-board/frontpage-board.component';
import { FrontpageComponent } from './frontpage/frontpage.component';
import { NoCacheHeaderInterceptor } from './interceptor/no-cache-header.interceptor';
import { InterfaceInfoComponent } from './interface-info/interface-info.component';
import { MenuComponent } from './menu/menu.component';
import { BioInformationsPipe } from './pipe/bio-informations.pipe';
import { BirthDatePipe } from './pipe/birth-date.pipe';
Expand Down Expand Up @@ -151,10 +150,8 @@ import { OrderLineComponent } from './record/detail-view/acquisition-order-detai
ItemTransactionComponent,
ItemTransactionsComponent,
PatronDetailViewComponent,
InterfaceInfoComponent,
RefComponent,
RemoteAutocompleteInputTypeComponent,
InterfaceInfoComponent,
VendorDetailViewComponent,
VendorBriefViewComponent,
AddressTypeComponent,
Expand Down

This file was deleted.

55 changes: 0 additions & 55 deletions projects/admin/src/app/interface-info/interface-info.component.ts

This file was deleted.

1 change: 0 additions & 1 deletion projects/admin/src/app/menu/menu.component.html
Expand Up @@ -14,7 +14,6 @@
 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/>.
-->
<admin-interface-info></admin-interface-info>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark d-flex">
<div class="container">
<a [routerLink]="['/']" class="navbar-brand pr-2 text-sm">
Expand Down
1 change: 0 additions & 1 deletion projects/admin/src/app/menu/menu.component.spec.ts
Expand Up @@ -33,7 +33,6 @@ describe('MenuComponent', () => {

const libraryTestingSwitchService = jasmine.createSpyObj(
'LibrarySwitchService', ['generateMenu']);
libraryTestingSwitchService.onVisibleMenu$ = of(false);
libraryTestingSwitchService.entries = [{ entries: [] }];
libraryTestingSwitchService.onGenerate$ = of([]);

Expand Down
21 changes: 6 additions & 15 deletions projects/admin/src/app/menu/menu.component.ts
Expand Up @@ -47,7 +47,7 @@ export class MenuComponent implements OnInit {
librariesSwitchMenu = {
navCssClass: 'navbar-nav',
entries: [{
name: this._translateService.instant('Switch library'),
name: '', // start with empty value, it will be changed when menu is generated
iconCssClass: 'fa fa-random',
entries: []
}]
Expand All @@ -58,7 +58,6 @@ export class MenuComponent implements OnInit {
userMenu = {
navCssClass: 'navbar-nav',
dropdownMenuCssClass: 'dropdown-menu-right',
iconCssClass: 'fa fa-user',
entries: []
};

Expand Down Expand Up @@ -86,6 +85,7 @@ export class MenuComponent implements OnInit {

this.userMenu.entries.push({
name: `${currentUser.first_name[0]}${currentUser.last_name[0]}`,
iconCssClass: 'fa fa-user',
entries: [
{
name: this._translateService.instant('Public interface'),
Expand Down Expand Up @@ -117,19 +117,10 @@ export class MenuComponent implements OnInit {
this.userMenu.entries[0].entries[0].href = `/${organisation.metadata.code}/`;
});

this._librarySwitchService.onVisibleMenu$.subscribe((visible) => {
if (
visible
&& this._userService.hasRole('system_librarian')
&& this._librarySwitchService.entries.length === 0) {
this._librarySwitchService.generateMenu();
}
});

this._librarySwitchService.onGenerate$.subscribe((entries: any) => {
this.librariesSwitchMenu.entries[0].entries = entries;
});

// SWITCH LIBRARY MENU ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
this._librarySwitchService.generateMenu();
this._librarySwitchService.onGenerate$.subscribe((entries: any) => this.librariesSwitchMenu.entries[0].entries = entries);
this._librarySwitchService.currentLibraryRecord$.subscribe((library: any) => this.librariesSwitchMenu.entries[0].name = library.code);
}

/**
Expand Down

0 comments on commit e5d541f

Please sign in to comment.