latest fixes

This commit is contained in:
lotte
2018-12-13 16:17:21 +01:00
parent 8856e48616
commit dceb835e53
16 changed files with 80 additions and 35 deletions

View File

@@ -213,6 +213,7 @@
}, },
"sidebar": { "sidebar": {
"section": { "section": {
"toggle": "Toggle sidebar",
"new": "New", "new": "New",
"new_community": "Community", "new_community": "Community",
"new_collection": "Collection", "new_collection": "Collection",
@@ -244,13 +245,16 @@
"curation_task": "Curation Task", "curation_task": "Curation Task",
"statistics_task": "Statistics Task", "statistics_task": "Statistics Task",
"control_panel": "Control Panel", "control_panel": "Control Panel",
"browse_global": "All of DSpace", "browse_global": "All of DSpace",
"browse_global_communities_and_collections": "Communities & Collections", "browse_global_communities_and_collections": "Communities & Collections",
"browse_global_by_issue_date": "By Issue Date", "browse_global_by_issue_date": "By Issue Date",
"browse_global_by_author": "By Author", "browse_global_by_author": "By Author",
"statistics": "Statistics" "browse_global_by_title": "By Title",
"statistics": "Statistics",
"browse_community": "This Community",
"browse_community_by_issue_date": "By Issue Date",
"browse_community_by_author": "By Author",
"browse_community_by_title": "By Title"
} }
} }
}, },

View File

@@ -3,7 +3,9 @@
[@slideSidebar]="{ [@slideSidebar]="{
value: (!(sidebarExpanded | async) ? 'collapsed' : 'expanded'), value: (!(sidebarExpanded | async) ? 'collapsed' : 'expanded'),
params: {sidebarWidth: (sidebarWidth | async)} params: {sidebarWidth: (sidebarWidth | async)}
}" (@slideSidebar.done)="finishSlide($event)" (@slideSidebar.start)="startSlide($event)" *ngIf="menuVisible | async" (mouseenter)="expandPreview($event)" (mouseleave)="collapsePreview($event)"> }" (@slideSidebar.done)="finishSlide($event)" (@slideSidebar.start)="startSlide($event)"
*ngIf="menuVisible | async" (mouseenter)="expandPreview($event)"
(mouseleave)="collapsePreview($event)">
<div class="sidebar-top-level-items"> <div class="sidebar-top-level-items">
<ul class="navbar-nav"> <ul class="navbar-nav">
<li class="admin-menu-header sidebar-section"> <li class="admin-menu-header sidebar-section">
@@ -30,13 +32,14 @@
<a class="nav-item nav-link shortcut-icon" <a class="nav-item nav-link shortcut-icon"
href="#" href="#"
(click)="toggle($event)"> (click)="toggle($event)">
<i class="fas fa-fw" [ngClass]="{'fa-angle-double-right': (menuCollapsed | async), 'fa-angle-double-left': !(menuCollapsed | async)}"></i> <i class="fas fa-fw"
[ngClass]="{'fa-angle-double-right': (menuCollapsed | async), 'fa-angle-double-left': !(menuCollapsed | async)}"></i>
</a> </a>
<div class="sidebar-collapsible"> <div class="sidebar-collapsible">
<a class="nav-item nav-link sidebar-section" <a class="nav-item nav-link sidebar-section"
href="#" href="#"
(click)="toggle($event)"> (click)="toggle($event)">
<span class="section-header-text">Collapse</span> <span class="section-header-text">{{'admin.sidebar.section.toggle' | translate }}</span>
</a> </a>
</div> </div>
</div> </div>

View File

@@ -392,7 +392,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'admin.sidebar.section.registries_metadata', text: 'admin.sidebar.section.registries_metadata',
link: '/registries/metadata' link: 'admin/registries/metadata'
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
{ {
@@ -403,7 +403,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'admin.sidebar.section.registries_format', text: 'admin.sidebar.section.registries_format',
link: '/registries/format' link: 'admin/registries/bitstream-formats'
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },

View File

@@ -58,7 +58,6 @@ export class SearchFiltersComponent {
* @returns {Observable<boolean>} Emits true whenever a given filter config should be shown * @returns {Observable<boolean>} Emits true whenever a given filter config should be shown
*/ */
isActive(filterConfig: SearchFilterConfig): Observable<boolean> { isActive(filterConfig: SearchFilterConfig): Observable<boolean> {
// console.log(filter.name);
return this.filterService.getSelectedValuesForFilter(filterConfig).pipe( return this.filterService.getSelectedValuesForFilter(filterConfig).pipe(
mergeMap((isActive) => { mergeMap((isActive) => {
if (isNotEmpty(isActive)) { if (isNotEmpty(isActive)) {

View File

@@ -41,7 +41,6 @@ export class ServerAuthService extends AuthService {
// TODO this should be cleaned up, AuthStatus could be parsed by the RemoteDataService as a whole... // TODO this should be cleaned up, AuthStatus could be parsed by the RemoteDataService as a whole...
const person$ = this.rdbService.buildSingle<NormalizedEPerson, EPerson>(status.eperson.toString()); const person$ = this.rdbService.buildSingle<NormalizedEPerson, EPerson>(status.eperson.toString());
// person$.subscribe(() => console.log('test'));
return person$.pipe(map((eperson) => eperson.payload)); return person$.pipe(map((eperson) => eperson.payload));
} else { } else {
throw(new Error('Not authenticated')); throw(new Error('Not authenticated'));

View File

@@ -7,7 +7,7 @@
<ng-container <ng-container
*ngComponentOutlet="itemComponents.get(section.id); injector: itemInjectors.get(section.id);"></ng-container> *ngComponentOutlet="itemComponents.get(section.id); injector: itemInjectors.get(section.id);"></ng-container>
</a> </a>
<ul @slide *ngIf="(active | async)" <ul @slide *ngIf="(active | async)" (click)="deactivateSection($event)"
class="m-0 shadow-none border-top-0 dropdown-menu show"> class="m-0 shadow-none border-top-0 dropdown-menu show">
<ng-container *ngFor="let subSection of (subSections | async)"> <ng-container *ngFor="let subSection of (subSections | async)">
<ng-container <ng-container

View File

@@ -49,6 +49,7 @@ export class NavbarComponent extends MenuComponent implements OnInit {
type: MenuItemType.TEXT, type: MenuItemType.TEXT,
text: 'admin.sidebar.section.browse_global' text: 'admin.sidebar.section.browse_global'
} as TextMenuItemModel, } as TextMenuItemModel,
index: 0
}, },
{ {
id: 'browse_global_communities_and_collections', id: 'browse_global_communities_and_collections',
@@ -71,6 +72,16 @@ export class NavbarComponent extends MenuComponent implements OnInit {
text: 'admin.sidebar.section.browse_global_by_issue_date', text: 'admin.sidebar.section.browse_global_by_issue_date',
link: '#' link: '#'
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, {
id: 'browse_global_global_by_title',
parentID: 'browse_global',
active: false,
visible: true,
model: {
type: MenuItemType.LINK,
text: 'admin.sidebar.section.browse_global_by_title',
link: '/browse/title'
} as LinkMenuItemModel,
}, },
{ {
id: 'browse_global_by_author', id: 'browse_global_by_author',
@@ -80,7 +91,7 @@ export class NavbarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'admin.sidebar.section.browse_global_by_author', text: 'admin.sidebar.section.browse_global_by_author',
link: '#' link: '/browse/author'
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
@@ -94,6 +105,7 @@ export class NavbarComponent extends MenuComponent implements OnInit {
text: 'admin.sidebar.section.statistics', text: 'admin.sidebar.section.statistics',
link: '#' link: '#'
} as LinkMenuItemModel, } as LinkMenuItemModel,
index: 2
}, },
]; ];
menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, menuSection)); menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, menuSection));

View File

@@ -7,16 +7,20 @@ import { cold, hot } from 'jasmine-marbles';
import * as fromRouter from '@ngrx/router-store'; import * as fromRouter from '@ngrx/router-store';
import { CollapseMenuAction } from '../shared/menu/menu.actions'; import { CollapseMenuAction } from '../shared/menu/menu.actions';
import { MenuID } from '../shared/menu/initial-menus-state'; import { MenuID } from '../shared/menu/initial-menus-state';
import { MenuService } from '../shared/menu/menu.service';
import { MenuServiceStub } from '../shared/testing/menu-service-stub';
describe('NavbarEffects', () => { describe('NavbarEffects', () => {
let navbarEffects: NavbarEffects; let navbarEffects: NavbarEffects;
let actions: Observable<any>; let actions: Observable<any>;
const menuService = new MenuServiceStub();
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
providers: [ providers: [
NavbarEffects, NavbarEffects,
provideMockActions(() => actions), provideMockActions(() => actions),
{ provide: MenuService, useValue: menuService },
// other providers // other providers
], ],
}); });

View File

@@ -1,11 +1,17 @@
import { map } from 'rxjs/operators'; import { first, map, switchMap } from 'rxjs/operators';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects' import { Actions, Effect, ofType } from '@ngrx/effects'
import * as fromRouter from '@ngrx/router-store'; import * as fromRouter from '@ngrx/router-store';
import { HostWindowActionTypes } from '../shared/host-window.actions'; import { HostWindowActionTypes } from '../shared/host-window.actions';
import { CollapseMenuAction } from '../shared/menu/menu.actions'; import {
CollapseMenuAction,
ExpandMenuPreviewAction,
MenuActionTypes
} from '../shared/menu/menu.actions';
import { MenuID } from '../shared/menu/initial-menus-state'; import { MenuID } from '../shared/menu/initial-menus-state';
import { MenuService } from '../shared/menu/menu.service';
import { MenuState } from '../shared/menu/menu.reducer';
@Injectable() @Injectable()
export class NavbarEffects { export class NavbarEffects {
@@ -29,8 +35,27 @@ export class NavbarEffects {
ofType(fromRouter.ROUTER_NAVIGATION), ofType(fromRouter.ROUTER_NAVIGATION),
map(() => new CollapseMenuAction(this.menuID)) map(() => new CollapseMenuAction(this.menuID))
); );
/**
constructor(private actions$: Actions) { * Effect that collapses the public menu when the admin sidebar opens
* @type {Observable<CollapseMenuAction>}
*/
@Effect() openAdminSidebar$ = this.actions$
.pipe(
ofType(MenuActionTypes.EXPAND_MENU_PREVIEW),
switchMap((action: ExpandMenuPreviewAction) => {
return this.menuService.getMenu(action.menuID).pipe(
first(),
map((menu: MenuState) => {
if (menu.id === MenuID.ADMIN) {
if (!menu.previewCollapsed && menu.collapsed) {
return new CollapseMenuAction(MenuID.PUBLIC)
}
}
return { type: 'NO_ACTION' };
}));
})
);
constructor(private actions$: Actions, private menuService: MenuService) {
} }

View File

@@ -1 +1 @@
<a class="nav-item nav-link" [routerLink]="item.link">{{item.text | translate}}</a> <a class="nav-item nav-link" [routerLink]="getRouterLink()">{{item.text | translate}}</a>

View File

@@ -4,6 +4,7 @@ import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { LinkMenuItemComponent } from './link-menu-item.component'; import { LinkMenuItemComponent } from './link-menu-item.component';
import { RouterLinkDirectiveStub } from '../../testing/router-link-directive-stub'; import { RouterLinkDirectiveStub } from '../../testing/router-link-directive-stub';
import { GLOBAL_CONFIG } from '../../../../config';
describe('LinkMenuItemComponent', () => { describe('LinkMenuItemComponent', () => {
let component: LinkMenuItemComponent; let component: LinkMenuItemComponent;
@@ -11,12 +12,19 @@ describe('LinkMenuItemComponent', () => {
let debugElement: DebugElement; let debugElement: DebugElement;
const text = 'HELLO'; const text = 'HELLO';
const link = 'http://google.com'; const link = 'http://google.com';
const nameSpace = 'dspace.com/';
const globalConfig = {
ui: {
nameSpace: nameSpace
}
} as any;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()], imports: [TranslateModule.forRoot()],
declarations: [LinkMenuItemComponent, RouterLinkDirectiveStub], declarations: [LinkMenuItemComponent, RouterLinkDirectiveStub],
providers: [ providers: [
{ provide: 'itemModelProvider', useValue: { text: text, link: link } }, { provide: 'itemModelProvider', useValue: { text: text, link: link } },
{ provide: GLOBAL_CONFIG, useValue: globalConfig },
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
}) })
@@ -41,10 +49,9 @@ describe('LinkMenuItemComponent', () => {
it('should have the right routerLink attribute', () => { it('should have the right routerLink attribute', () => {
const linkDes = fixture.debugElement.queryAll(By.directive(RouterLinkDirectiveStub)); const linkDes = fixture.debugElement.queryAll(By.directive(RouterLinkDirectiveStub));
const routerLinkQuery = linkDes.map((de) => de.injector.get(RouterLinkDirectiveStub)); const routerLinkQuery = linkDes.map((de) => de.injector.get(RouterLinkDirectiveStub));
expect(routerLinkQuery.length).toBe(1); expect(routerLinkQuery.length).toBe(1);
expect(routerLinkQuery[0].routerLink).toBe(link); expect(routerLinkQuery[0].routerLink).toBe(nameSpace + link);
}); });
}); });

View File

@@ -2,6 +2,7 @@ import { Component, Inject, Input } from '@angular/core';
import { LinkMenuItemModel } from './models/link.model'; import { LinkMenuItemModel } from './models/link.model';
import { MenuItemType } from '../initial-menus-state'; import { MenuItemType } from '../initial-menus-state';
import { rendersMenuItemForType } from '../menu-item.decorator'; import { rendersMenuItemForType } from '../menu-item.decorator';
import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config';
/** /**
* Component that renders a menu section of type LINK * Component that renders a menu section of type LINK
@@ -13,7 +14,11 @@ import { rendersMenuItemForType } from '../menu-item.decorator';
@rendersMenuItemForType(MenuItemType.LINK) @rendersMenuItemForType(MenuItemType.LINK)
export class LinkMenuItemComponent { export class LinkMenuItemComponent {
item: LinkMenuItemModel; item: LinkMenuItemModel;
constructor(@Inject('itemModelProvider') item: LinkMenuItemModel) { constructor(@Inject('itemModelProvider') item: LinkMenuItemModel, @Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig) {
this.item = item; this.item = item;
} }
getRouterLink() {
return this.EnvConfig.ui.nameSpace + this.item.link;
}
} }

View File

@@ -1,12 +0,0 @@
import { ComponentFactory } from '@angular/core';
import { create } from 'domain';
export class ComponentInjectorStub {
resolveComponentFactory(): ComponentFactory<any> {
return {
create() {
return { hostView: {}, viewContainerParent: {}, }
}
} as any;
}
}

View File

@@ -20,4 +20,3 @@ export class CSSVariableServiceStub {
/**/ /**/
} }
} }