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: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Jun 19, 2020
1 parent 59a4702 commit 64461f2
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 171 deletions.
5 changes: 0 additions & 5 deletions projects/admin/src/app/app.component.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 64461f2

Please sign in to comment.