From f4482c710c56adbeeb7ec9a5b8586aa76e280540 Mon Sep 17 00:00:00 2001 From: Yana De Pauw Date: Thu, 18 Oct 2018 16:48:17 +0200 Subject: [PATCH 01/32] 55959: Add subcommunities on community page --- resources/i18n/en.json | 5 ++ .../community-page.component.html | 1 + .../+community-page/community-page.module.ts | 2 + ...ty-page-sub-collection-list.component.html | 2 +- ...ity-page-sub-community-list.component.html | 15 ++++ ...ity-page-sub-community-list.component.scss | 1 + ...-page-sub-community-list.component.spec.ts | 78 +++++++++++++++++++ ...unity-page-sub-community-list.component.ts | 23 ++++++ src/app/core/shared/community.model.ts | 2 +- 9 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 src/app/+community-page/sub-community-list/community-page-sub-community-list.component.html create mode 100644 src/app/+community-page/sub-community-list/community-page-sub-community-list.component.scss create mode 100644 src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts create mode 100644 src/app/+community-page/sub-community-list/community-page-sub-community-list.component.ts diff --git a/resources/i18n/en.json b/resources/i18n/en.json index b6a23068d7..d084728fde 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -22,6 +22,9 @@ }, "sub-collection-list": { "head": "Collections of this Community" + }, + "sub-community-list": { + "head": "Communities of this Community" } }, "item": { @@ -209,6 +212,7 @@ "community": "Loading community...", "collection": "Loading collection...", "sub-collections": "Loading sub-collections...", + "sub-communities": "Loading sub-communities...", "recent-submissions": "Loading recent submissions...", "item": "Loading item...", "objects": "Loading...", @@ -221,6 +225,7 @@ "community": "Error fetching community", "collection": "Error fetching collection", "sub-collections": "Error fetching sub-collections", + "sub-communities": "Error fetching sub-communities", "recent-submissions": "Error fetching recent submissions", "item": "Error fetching item", "objects": "Error fetching objects", diff --git a/src/app/+community-page/community-page.component.html b/src/app/+community-page/community-page.component.html index 637e37af0c..a86a86c3da 100644 --- a/src/app/+community-page/community-page.component.html +++ b/src/app/+community-page/community-page.component.html @@ -24,6 +24,7 @@ [content]="communityPayload.copyrightText" [hasInnerHtml]="true"> + diff --git a/src/app/+community-page/community-page.module.ts b/src/app/+community-page/community-page.module.ts index e00c3910c5..d7f97755c2 100644 --- a/src/app/+community-page/community-page.module.ts +++ b/src/app/+community-page/community-page.module.ts @@ -6,6 +6,7 @@ import { SharedModule } from '../shared/shared.module'; import { CommunityPageComponent } from './community-page.component'; import { CommunityPageSubCollectionListComponent } from './sub-collection-list/community-page-sub-collection-list.component'; import { CommunityPageRoutingModule } from './community-page-routing.module'; +import {CommunityPageSubCommunityListComponent} from './sub-community-list/community-page-sub-community-list.component'; @NgModule({ imports: [ @@ -16,6 +17,7 @@ import { CommunityPageRoutingModule } from './community-page-routing.module'; declarations: [ CommunityPageComponent, CommunityPageSubCollectionListComponent, + CommunityPageSubCommunityListComponent, ] }) export class CommunityPageModule { diff --git a/src/app/+community-page/sub-collection-list/community-page-sub-collection-list.component.html b/src/app/+community-page/sub-collection-list/community-page-sub-collection-list.component.html index 12c2578d9c..9156a99b18 100644 --- a/src/app/+community-page/sub-collection-list/community-page-sub-collection-list.component.html +++ b/src/app/+community-page/sub-collection-list/community-page-sub-collection-list.component.html @@ -1,5 +1,5 @@ -
+

{{'community.sub-collection-list.head' | translate}}

  • diff --git a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.html b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.html new file mode 100644 index 0000000000..6cd62ba48d --- /dev/null +++ b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.html @@ -0,0 +1,15 @@ + +
    +

    {{'community.sub-community-list.head' | translate}}

    + +
    + + +
    diff --git a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.scss b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.scss new file mode 100644 index 0000000000..50be6f5ad0 --- /dev/null +++ b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.scss @@ -0,0 +1 @@ +@import '../../../styles/variables.scss'; diff --git a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts new file mode 100644 index 0000000000..b4203eb11a --- /dev/null +++ b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts @@ -0,0 +1,78 @@ +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {TranslateModule} from '@ngx-translate/core'; +import {NO_ERRORS_SCHEMA} from '@angular/core'; +import {CommunityPageSubCommunityListComponent} from './community-page-sub-community-list.component'; +import {Community} from '../../core/shared/community.model'; +import {Observable} from 'rxjs/Observable'; +import {RemoteData} from '../../core/data/remote-data'; +import {PaginatedList} from '../../core/data/paginated-list'; +import 'rxjs/add/observable/of'; +import {PageInfo} from '../../core/shared/page-info.model'; +import {SharedModule} from '../../shared/shared.module'; +import {RouterTestingModule} from '@angular/router/testing'; +import {NoopAnimationsModule} from '@angular/platform-browser/animations'; +import {By} from '@angular/platform-browser'; + +describe('SubCommunityList Component', () => { + let comp: CommunityPageSubCommunityListComponent; + let fixture: ComponentFixture; + + const subcommunities = [Object.assign(new Community(), { + name: 'SubCommunity 1', + id: '123456789-1', + metadata: [ + { + key: 'dc.title', + language: 'en_US', + value: 'SubCommunity 1' + }] + }), + Object.assign(new Community(), { + name: 'SubCommunity 2', + id: '123456789-2', + metadata: [ + { + key: 'dc.title', + language: 'en_US', + value: 'SubCommunity 2' + }] + }) + ]; + + const mockCommunity = Object.assign(new Community(), { + metadata: [ + { + key: 'dc.title', + language: 'en_US', + value: 'Test title' + }], + subcommunities: Observable.of(new RemoteData(true, true, true, + undefined, new PaginatedList(new PageInfo(), subcommunities))) + }) + ; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [TranslateModule.forRoot(), SharedModule, + RouterTestingModule.withRoutes([]), + NoopAnimationsModule], + declarations: [CommunityPageSubCommunityListComponent], + schemas: [NO_ERRORS_SCHEMA] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CommunityPageSubCommunityListComponent); + comp = fixture.componentInstance; + }); + + it('should display a list of subCommunities', () => { + comp.community = mockCommunity; + fixture.detectChanges(); + + const subComList = fixture.debugElement.queryAll(By.css('li')); + expect(subComList.length).toEqual(2); + expect(subComList[0].nativeElement.textContent).toContain('SubCommunity 1'); + expect(subComList[1].nativeElement.textContent).toContain('SubCommunity 2'); + }); +}); diff --git a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.ts b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.ts new file mode 100644 index 0000000000..da6135040c --- /dev/null +++ b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.ts @@ -0,0 +1,23 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; + +import { RemoteData } from '../../core/data/remote-data'; +import { Community } from '../../core/shared/community.model'; + +import { fadeIn } from '../../shared/animations/fade'; +import { PaginatedList } from '../../core/data/paginated-list'; + +@Component({ + selector: 'ds-community-page-sub-community-list', + styleUrls: ['./community-page-sub-community-list.component.scss'], + templateUrl: './community-page-sub-community-list.component.html', + animations:[fadeIn] +}) +export class CommunityPageSubCommunityListComponent implements OnInit { + @Input() community: Community; + subCommunitiesRDObs: Observable>>; + + ngOnInit(): void { + this.subCommunitiesRDObs = this.community.subcommunities; + } +} diff --git a/src/app/core/shared/community.model.ts b/src/app/core/shared/community.model.ts index 20bd50f4a9..d90742fa00 100644 --- a/src/app/core/shared/community.model.ts +++ b/src/app/core/shared/community.model.ts @@ -61,6 +61,6 @@ export class Community extends DSpaceObject { collections: Observable>>; - subcommunities: Observable>>; + subcommunities: Observable>>; } From 44c227ffff052225ad88990fe0c22d00b4cfed38 Mon Sep 17 00:00:00 2001 From: Yana De Pauw Date: Fri, 26 Oct 2018 10:55:27 +0200 Subject: [PATCH 02/32] 55959: Add additional test when no subcommunities When the subcommunity list is empty, the subcommunity section should be hidden. --- ...-page-sub-community-list.component.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts index b4203eb11a..a3efc2ebc5 100644 --- a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts +++ b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts @@ -39,6 +39,17 @@ describe('SubCommunityList Component', () => { }) ]; + const emptySubCommunitiesCommunity = Object.assign(new Community(), { + metadata: [ + { + key: 'dc.title', + language: 'en_US', + value: 'Test title' + }], + subcommunities: Observable.of(new RemoteData(true, true, true, + undefined, new PaginatedList(new PageInfo(), []))) + }); + const mockCommunity = Object.assign(new Community(), { metadata: [ { @@ -75,4 +86,12 @@ describe('SubCommunityList Component', () => { expect(subComList[0].nativeElement.textContent).toContain('SubCommunity 1'); expect(subComList[1].nativeElement.textContent).toContain('SubCommunity 2'); }); + + it('should not display the header when subCommunities are empty', () => { + comp.community = emptySubCommunitiesCommunity; + fixture.detectChanges(); + + const subComHead = fixture.debugElement.queryAll(By.css('h2')); + expect(subComHead.length).toEqual(0); + }); }); From 67619a2ba56296e36b8e09d5560dea85f4e3dfb0 Mon Sep 17 00:00:00 2001 From: Bram Luyten Date: Wed, 31 Oct 2018 23:06:38 +0100 Subject: [PATCH 03/32] issue 323 comcol page logo bottom padding --- .../shared/comcol-page-logo/comcol-page-logo.component.scss | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/shared/comcol-page-logo/comcol-page-logo.component.scss b/src/app/shared/comcol-page-logo/comcol-page-logo.component.scss index ad84b72f8c..ea0ae377b3 100644 --- a/src/app/shared/comcol-page-logo/comcol-page-logo.component.scss +++ b/src/app/shared/comcol-page-logo/comcol-page-logo.component.scss @@ -1 +1,5 @@ -@import '../../../styles/variables.scss'; \ No newline at end of file +@import '../../../styles/variables.scss'; + +.dso-logo { + padding-bottom: 1em; +} From 2af1d3b0421cab2f72a566261d2119ad8dc5cc99 Mon Sep 17 00:00:00 2001 From: lotte Date: Mon, 5 Nov 2018 16:34:03 +0100 Subject: [PATCH 04/32] 57053: started on menu --- resources/images/dspace-logo.svg | 37 +++++++++++++++ src/app/app.component.html | 1 + src/app/app.component.scss | 5 ++ src/app/app.effects.ts | 5 +- src/app/app.module.ts | 2 + src/app/app.reducer.ts | 12 +++-- src/app/header/header.component.html | 22 +++------ src/app/header/header.component.scss | 15 ++---- src/app/header/header.component.ts | 31 +------------ .../navbar.actions.ts} | 28 +++++------ src/app/navbar/navbar.component.html | 46 +++++++++++++++++++ src/app/navbar/navbar.component.scss | 18 ++++++++ .../navbar.component.spec.ts} | 28 +++++------ src/app/navbar/navbar.component.ts | 34 ++++++++++++++ .../navbar.effects.spec.ts} | 20 ++++---- .../navbar.effects.ts} | 8 ++-- .../navbar.reducer.spec.ts} | 42 ++++++++--------- .../navbar.reducer.ts} | 14 +++--- .../auth-nav-menu.component.html | 6 +-- src/styles/_custom_variables.scss | 4 ++ 20 files changed, 237 insertions(+), 141 deletions(-) create mode 100644 resources/images/dspace-logo.svg rename src/app/{header/header.actions.ts => navbar/navbar.actions.ts} (52%) create mode 100644 src/app/navbar/navbar.component.html create mode 100644 src/app/navbar/navbar.component.scss rename src/app/{header/header.component.spec.ts => navbar/navbar.component.spec.ts} (74%) create mode 100644 src/app/navbar/navbar.component.ts rename src/app/{header/header.effects.spec.ts => navbar/navbar.effects.spec.ts} (66%) rename src/app/{header/header.effects.ts => navbar/navbar.effects.ts} (71%) rename src/app/{header/header.reducer.spec.ts => navbar/navbar.reducer.spec.ts} (65%) rename src/app/{header/header.reducer.ts => navbar/navbar.reducer.ts} (54%) diff --git a/resources/images/dspace-logo.svg b/resources/images/dspace-logo.svg new file mode 100644 index 0000000000..60df1ed46d --- /dev/null +++ b/resources/images/dspace-logo.svg @@ -0,0 +1,37 @@ + + + + + + + + diff --git a/src/app/app.component.html b/src/app/app.component.html index 95db61ab5a..24ce6dc843 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,6 +1,7 @@
    + diff --git a/src/app/app.component.scss b/src/app/app.component.scss index e4c51ae37b..1b2a21b0c6 100644 --- a/src/app/app.component.scss +++ b/src/app/app.component.scss @@ -28,7 +28,12 @@ body { } .main-content { + z-index: $main-z-index; flex: 1 0 auto; margin-top: $content-spacing; margin-bottom: $content-spacing; } + +ds-navbar { + z-index: $nav-z-index; +} diff --git a/src/app/app.effects.ts b/src/app/app.effects.ts index 6a53d7b619..3ee483ccba 100644 --- a/src/app/app.effects.ts +++ b/src/app/app.effects.ts @@ -1,10 +1,9 @@ - -import { HeaderEffects } from './header/header.effects'; import { StoreEffects } from './store.effects'; import { NotificationsEffects } from './shared/notifications/notifications.effects'; +import { NavbarEffects } from './navbar/navbar.effects'; export const appEffects = [ StoreEffects, - HeaderEffects, + NavbarEffects, NotificationsEffects ]; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 528c84fd3b..987ce77dd1 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -31,6 +31,7 @@ import { DSpaceRouterStateSerializer } from './shared/ngrx/dspace-router-state-s import { NotificationsBoardComponent } from './shared/notifications/notifications-board/notifications-board.component'; import { NotificationComponent } from './shared/notifications/notification/notification.component'; import { SharedModule } from './shared/shared.module'; +import { NavbarComponent } from './navbar/navbar.component'; export function getConfig() { return ENV_CONFIG; @@ -87,6 +88,7 @@ if (!ENV_CONFIG.production) { declarations: [ AppComponent, HeaderComponent, + NavbarComponent, FooterComponent, PageNotFoundComponent, NotificationComponent, diff --git a/src/app/app.reducer.ts b/src/app/app.reducer.ts index 8dc82dfb6f..6bdb1a1f58 100644 --- a/src/app/app.reducer.ts +++ b/src/app/app.reducer.ts @@ -1,7 +1,5 @@ import { ActionReducerMap } from '@ngrx/store'; import * as fromRouter from '@ngrx/router-store'; - -import { headerReducer, HeaderState } from './header/header.reducer'; import { hostWindowReducer, HostWindowState } from './shared/host-window.reducer'; import { formReducer, FormState } from './shared/form/form.reducer'; import { @@ -12,13 +10,17 @@ import { filterReducer, SearchFiltersState } from './+search-page/search-filters/search-filter/search-filter.reducer'; -import { notificationsReducer, NotificationsState } from './shared/notifications/notifications.reducers'; +import { + notificationsReducer, + NotificationsState +} from './shared/notifications/notifications.reducers'; import { truncatableReducer, TruncatablesState } from './shared/truncatable/truncatable.reducer'; +import { navbarReducer, NavbarState } from './navbar/navbar.reducer'; export interface AppState { router: fromRouter.RouterReducerState; hostWindow: HostWindowState; - header: HeaderState; + navbar: NavbarState; forms: FormState; notifications: NotificationsState; searchSidebar: SearchSidebarState; @@ -29,7 +31,7 @@ export interface AppState { export const appReducers: ActionReducerMap = { router: fromRouter.routerReducer, hostWindow: hostWindowReducer, - header: headerReducer, + navbar: navbarReducer, forms: formReducer, notifications: notificationsReducer, searchSidebar: sidebarReducer, diff --git a/src/app/header/header.component.html b/src/app/header/header.component.html index f47696609c..22e2a307a5 100644 --- a/src/app/header/header.component.html +++ b/src/app/header/header.component.html @@ -1,18 +1,10 @@
    -
    diff --git a/src/app/header/header.component.scss b/src/app/header/header.component.scss index 81f6a809bf..627ce93c6c 100644 --- a/src/app/header/header.component.scss +++ b/src/app/header/header.component.scss @@ -1,14 +1,5 @@ @import '../../styles/variables.scss'; -header nav.navbar { - border-radius: 0; -} - -header nav.navbar .navbar-toggler:hover { - cursor: pointer; -} - -header nav.navbar .navbar-toggler .navbar-toggler-icon { - background-image: none !important; - line-height: 1.5; -} +.navbar-brand img { + height: $header-logo-height; +} \ No newline at end of file diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts index 93cb329f4f..8ccc779873 100644 --- a/src/app/header/header.component.ts +++ b/src/app/header/header.component.ts @@ -1,43 +1,16 @@ -import { Component, OnInit } from '@angular/core'; -import { createSelector, Store } from '@ngrx/store'; +import { Component } from '@angular/core'; import { Observable } from 'rxjs/Observable'; -import { RouterReducerState } from '@ngrx/router-store'; - -import { HeaderState } from './header.reducer'; -import { HeaderToggleAction } from './header.actions'; -import { AppState } from '../app.reducer'; -import { HostWindowService } from '../shared/host-window.service'; - -const headerStateSelector = (state: AppState) => state.header; -const navCollapsedSelector = createSelector(headerStateSelector, (header: HeaderState) => header.navCollapsed); @Component({ selector: 'ds-header', styleUrls: ['header.component.scss'], templateUrl: 'header.component.html', }) -export class HeaderComponent implements OnInit { +export class HeaderComponent { /** * Whether user is authenticated. * @type {Observable} */ public isAuthenticated: Observable; - public isNavBarCollapsed: Observable; public showAuth = false; - - constructor( - private store: Store, - private windowService: HostWindowService - ) { - } - - ngOnInit(): void { - // set loading - this.isNavBarCollapsed = this.store.select(navCollapsedSelector); - } - - public toggle(): void { - this.store.dispatch(new HeaderToggleAction()); - } - } diff --git a/src/app/header/header.actions.ts b/src/app/navbar/navbar.actions.ts similarity index 52% rename from src/app/header/header.actions.ts rename to src/app/navbar/navbar.actions.ts index 7176474a4a..c588c41f0c 100644 --- a/src/app/header/header.actions.ts +++ b/src/app/navbar/navbar.actions.ts @@ -10,23 +10,23 @@ import { type } from '../shared/ngrx/type'; * literal types and runs a simple check to guarantee all * action types in the application are unique. */ -export const HeaderActionTypes = { - COLLAPSE: type('dspace/header/COLLAPSE'), - EXPAND: type('dspace/header/EXPAND'), - TOGGLE: type('dspace/header/TOGGLE') +export const NavbarActionTypes = { + COLLAPSE: type('dspace/navbar/COLLAPSE'), + EXPAND: type('dspace/navbar/EXPAND'), + TOGGLE: type('dspace/navbar/TOGGLE') }; /* tslint:disable:max-classes-per-file */ -export class HeaderCollapseAction implements Action { - type = HeaderActionTypes.COLLAPSE; +export class NavbarCollapseAction implements Action { + type = NavbarActionTypes.COLLAPSE; } -export class HeaderExpandAction implements Action { - type = HeaderActionTypes.EXPAND; +export class NavbarExpandAction implements Action { + type = NavbarActionTypes.EXPAND; } -export class HeaderToggleAction implements Action { - type = HeaderActionTypes.TOGGLE; +export class NavbarToggleAction implements Action { + type = NavbarActionTypes.TOGGLE; } /* tslint:enable:max-classes-per-file */ @@ -34,7 +34,7 @@ export class HeaderToggleAction implements Action { * Export a type alias of all actions in this action group * so that reducers can easily compose action types */ -export type HeaderAction - = HeaderCollapseAction - | HeaderExpandAction - | HeaderToggleAction +export type NavbarAction + = NavbarCollapseAction + | NavbarExpandAction + | NavbarToggleAction diff --git a/src/app/navbar/navbar.component.html b/src/app/navbar/navbar.component.html new file mode 100644 index 0000000000..7c4de41098 --- /dev/null +++ b/src/app/navbar/navbar.component.html @@ -0,0 +1,46 @@ + diff --git a/src/app/navbar/navbar.component.scss b/src/app/navbar/navbar.component.scss new file mode 100644 index 0000000000..10e97834f3 --- /dev/null +++ b/src/app/navbar/navbar.component.scss @@ -0,0 +1,18 @@ +@import '../../styles/variables.scss'; + +nav.navbar { + border-bottom: 1px $gray-400 solid; +} + +nav.navbar .navbar-toggler .navbar-toggler-icon { + background-image: none !important; + line-height: 1.5; +} + +.dropdown-menu { + min-width: 100%; +} +.reset-padding { + margin-left: -$spacer/2; + margin-right: -$spacer/2; +} \ No newline at end of file diff --git a/src/app/header/header.component.spec.ts b/src/app/navbar/navbar.component.spec.ts similarity index 74% rename from src/app/header/header.component.spec.ts rename to src/app/navbar/navbar.component.spec.ts index 9d0dd04e40..0a0ed43716 100644 --- a/src/app/header/header.component.spec.ts +++ b/src/app/navbar/navbar.component.spec.ts @@ -1,4 +1,4 @@ -import { ComponentFixture, TestBed, async } from '@angular/core/testing'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { Store, StoreModule } from '@ngrx/store'; import { TranslateModule } from '@ngx-translate/core'; @@ -6,13 +6,7 @@ import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap'; import { Observable } from 'rxjs/Observable'; -import { HeaderComponent } from './header.component'; -import { HeaderState } from './header.reducer'; -import { HeaderToggleAction } from './header.actions'; -import { AuthNavMenuComponent } from '../shared/auth-nav-menu/auth-nav-menu.component'; -import { LogInComponent } from '../shared/log-in/log-in.component'; -import { LogOutComponent } from '../shared/log-out/log-out.component'; -import { LoadingComponent } from '../shared/loading/loading.component'; +import { NavbarComponent } from './navbar.component'; import { ReactiveFormsModule } from '@angular/forms'; import { HostWindowService } from '../shared/host-window.service'; import { HostWindowServiceStub } from '../shared/testing/host-window-service-stub'; @@ -20,12 +14,14 @@ import { RouterStub } from '../shared/testing/router-stub'; import { Router } from '@angular/router'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NO_ERRORS_SCHEMA } from '@angular/core'; +import { NavbarState } from './navbar.reducer'; +import { NavbarToggleAction } from './navbar.actions'; -let comp: HeaderComponent; -let fixture: ComponentFixture; -let store: Store; +let comp: NavbarComponent; +let fixture: ComponentFixture; +let store: Store; -describe('HeaderComponent', () => { +describe('NavbarComponent', () => { // async beforeEach beforeEach(async(() => { @@ -36,7 +32,7 @@ describe('HeaderComponent', () => { NgbCollapseModule.forRoot(), NoopAnimationsModule, ReactiveFormsModule], - declarations: [HeaderComponent], + declarations: [NavbarComponent], providers: [ { provide: HostWindowService, useValue: new HostWindowServiceStub(800) }, { provide: Router, useClass: RouterStub }, @@ -48,7 +44,7 @@ describe('HeaderComponent', () => { // synchronous beforeEach beforeEach(() => { - fixture = TestBed.createComponent(HeaderComponent); + fixture = TestBed.createComponent(NavbarComponent); comp = fixture.componentInstance; @@ -63,8 +59,8 @@ describe('HeaderComponent', () => { navbarToggler.triggerEventHandler('click', null); }); - it('should dispatch a HeaderToggleAction', () => { - expect(store.dispatch).toHaveBeenCalledWith(new HeaderToggleAction()); + it('should dispatch a NavbarToggleAction', () => { + expect(store.dispatch).toHaveBeenCalledWith(new NavbarToggleAction()); }); }); diff --git a/src/app/navbar/navbar.component.ts b/src/app/navbar/navbar.component.ts new file mode 100644 index 0000000000..e1f8d0bb82 --- /dev/null +++ b/src/app/navbar/navbar.component.ts @@ -0,0 +1,34 @@ +import { Component, OnInit } from '@angular/core'; +import { createSelector, Store } from '@ngrx/store'; +import { Observable } from 'rxjs/Observable'; + +import { NavbarState } from './navbar.reducer'; +import { NavbarToggleAction } from './navbar.actions'; +import { AppState } from '../app.reducer'; + +const navbarStateSelector = (state: AppState) => state.navbar; +const navCollapsedSelector = createSelector(navbarStateSelector, (navbar: NavbarState) => navbar.navCollapsed); + +@Component({ + selector: 'ds-navbar', + styleUrls: ['navbar.component.scss'], + templateUrl: 'navbar.component.html', +}) +export class NavbarComponent implements OnInit { + public isNavBarCollapsed: Observable; + + constructor( + private store: Store, + ) { + } + + ngOnInit(): void { + // set loading + this.isNavBarCollapsed = this.store.select(navCollapsedSelector); + } + + public toggle(): void { + this.store.dispatch(new NavbarToggleAction()); + } + +} diff --git a/src/app/header/header.effects.spec.ts b/src/app/navbar/navbar.effects.spec.ts similarity index 66% rename from src/app/header/header.effects.spec.ts rename to src/app/navbar/navbar.effects.spec.ts index e67043dcba..261d24a850 100644 --- a/src/app/header/header.effects.spec.ts +++ b/src/app/navbar/navbar.effects.spec.ts @@ -1,26 +1,26 @@ import { TestBed } from '@angular/core/testing'; -import { HeaderEffects } from './header.effects'; -import { HeaderCollapseAction } from './header.actions'; +import { NavbarEffects } from './navbar.effects'; +import { NavbarCollapseAction } from './navbar.actions'; import { HostWindowResizeAction } from '../shared/host-window.actions'; import { Observable } from 'rxjs/Observable'; import { provideMockActions } from '@ngrx/effects/testing'; import { cold, hot } from 'jasmine-marbles'; import * as fromRouter from '@ngrx/router-store'; -describe('HeaderEffects', () => { - let headerEffects: HeaderEffects; +describe('NavbarEffects', () => { + let navbarEffects: NavbarEffects; let actions: Observable; beforeEach(() => { TestBed.configureTestingModule({ providers: [ - HeaderEffects, + NavbarEffects, provideMockActions(() => actions), // other providers ], }); - headerEffects = TestBed.get(HeaderEffects); + navbarEffects = TestBed.get(NavbarEffects); }); describe('resize$', () => { @@ -28,9 +28,9 @@ describe('HeaderEffects', () => { it('should return a COLLAPSE action in response to a RESIZE action', () => { actions = hot('--a-', { a: new HostWindowResizeAction(800, 600) }); - const expected = cold('--b-', { b: new HeaderCollapseAction() }); + const expected = cold('--b-', { b: new NavbarCollapseAction() }); - expect(headerEffects.resize$).toBeObservable(expected); + expect(navbarEffects.resize$).toBeObservable(expected); }); }); @@ -40,9 +40,9 @@ describe('HeaderEffects', () => { it('should return a COLLAPSE action in response to an UPDATE_LOCATION action', () => { actions = hot('--a-', { a: { type: fromRouter.ROUTER_NAVIGATION } }); - const expected = cold('--b-', { b: new HeaderCollapseAction() }); + const expected = cold('--b-', { b: new NavbarCollapseAction() }); - expect(headerEffects.routeChange$).toBeObservable(expected); + expect(navbarEffects.routeChange$).toBeObservable(expected); }); }); diff --git a/src/app/header/header.effects.ts b/src/app/navbar/navbar.effects.ts similarity index 71% rename from src/app/header/header.effects.ts rename to src/app/navbar/navbar.effects.ts index e1d281958b..bc6cf876e1 100644 --- a/src/app/header/header.effects.ts +++ b/src/app/navbar/navbar.effects.ts @@ -3,18 +3,18 @@ import { Effect, Actions } from '@ngrx/effects' import * as fromRouter from '@ngrx/router-store'; import { HostWindowActionTypes } from '../shared/host-window.actions'; -import { HeaderCollapseAction } from './header.actions'; +import { NavbarCollapseAction } from './navbar.actions'; @Injectable() -export class HeaderEffects { +export class NavbarEffects { @Effect() resize$ = this.actions$ .ofType(HostWindowActionTypes.RESIZE) - .map(() => new HeaderCollapseAction()); + .map(() => new NavbarCollapseAction()); @Effect() routeChange$ = this.actions$ .ofType(fromRouter.ROUTER_NAVIGATION) - .map(() => new HeaderCollapseAction()); + .map(() => new NavbarCollapseAction()); constructor(private actions$: Actions) { diff --git a/src/app/header/header.reducer.spec.ts b/src/app/navbar/navbar.reducer.spec.ts similarity index 65% rename from src/app/header/header.reducer.spec.ts rename to src/app/navbar/navbar.reducer.spec.ts index b2630ec960..b9afbd743e 100644 --- a/src/app/header/header.reducer.spec.ts +++ b/src/app/navbar/navbar.reducer.spec.ts @@ -1,13 +1,9 @@ import * as deepFreeze from 'deep-freeze'; -import { headerReducer } from './header.reducer'; -import { - HeaderCollapseAction, - HeaderExpandAction, - HeaderToggleAction -} from './header.actions'; +import { navbarReducer } from './navbar.reducer'; +import { NavbarCollapseAction, NavbarExpandAction, NavbarToggleAction } from './navbar.actions'; -class NullAction extends HeaderCollapseAction { +class NullAction extends NavbarCollapseAction { type = null; constructor() { @@ -15,18 +11,18 @@ class NullAction extends HeaderCollapseAction { } } -describe('headerReducer', () => { +describe('navbarReducer', () => { it('should return the current state when no valid actions have been made', () => { const state = { navCollapsed: false }; const action = new NullAction(); - const newState = headerReducer(state, action); + const newState = navbarReducer(state, action); expect(newState).toEqual(state); }); it('should start with navCollapsed = true', () => { const action = new NullAction(); - const initialState = headerReducer(undefined, action); + const initialState = navbarReducer(undefined, action); // The navigation starts collapsed expect(initialState.navCollapsed).toEqual(true); @@ -34,8 +30,8 @@ describe('headerReducer', () => { it('should set navCollapsed to true in response to the COLLAPSE action', () => { const state = { navCollapsed: false }; - const action = new HeaderCollapseAction(); - const newState = headerReducer(state, action); + const action = new NavbarCollapseAction(); + const newState = navbarReducer(state, action); expect(newState.navCollapsed).toEqual(true); }); @@ -44,8 +40,8 @@ describe('headerReducer', () => { const state = { navCollapsed: false }; deepFreeze(state); - const action = new HeaderCollapseAction(); - headerReducer(state, action); + const action = new NavbarCollapseAction(); + navbarReducer(state, action); // no expect required, deepFreeze will ensure an exception is thrown if the state // is mutated, and any uncaught exception will cause the test to fail @@ -53,8 +49,8 @@ describe('headerReducer', () => { it('should set navCollapsed to false in response to the EXPAND action', () => { const state = { navCollapsed: true }; - const action = new HeaderExpandAction(); - const newState = headerReducer(state, action); + const action = new NavbarExpandAction(); + const newState = navbarReducer(state, action); expect(newState.navCollapsed).toEqual(false); }); @@ -63,16 +59,16 @@ describe('headerReducer', () => { const state = { navCollapsed: true }; deepFreeze(state); - const action = new HeaderExpandAction(); - headerReducer(state, action); + const action = new NavbarExpandAction(); + navbarReducer(state, action); }); it('should flip the value of navCollapsed in response to the TOGGLE action', () => { const state1 = { navCollapsed: true }; - const action = new HeaderToggleAction(); + const action = new NavbarToggleAction(); - const state2 = headerReducer(state1, action); - const state3 = headerReducer(state2, action); + const state2 = navbarReducer(state1, action); + const state3 = navbarReducer(state2, action); expect(state2.navCollapsed).toEqual(false); expect(state3.navCollapsed).toEqual(true); @@ -82,8 +78,8 @@ describe('headerReducer', () => { const state = { navCollapsed: true }; deepFreeze(state); - const action = new HeaderToggleAction(); - headerReducer(state, action); + const action = new NavbarToggleAction(); + navbarReducer(state, action); }); }); diff --git a/src/app/header/header.reducer.ts b/src/app/navbar/navbar.reducer.ts similarity index 54% rename from src/app/header/header.reducer.ts rename to src/app/navbar/navbar.reducer.ts index 2c8a89249b..c3edc80115 100644 --- a/src/app/header/header.reducer.ts +++ b/src/app/navbar/navbar.reducer.ts @@ -1,30 +1,30 @@ -import { HeaderAction, HeaderActionTypes } from './header.actions'; +import { NavbarAction, NavbarActionTypes } from './navbar.actions'; -export interface HeaderState { +export interface NavbarState { navCollapsed: boolean; } -const initialState: HeaderState = { +const initialState: NavbarState = { navCollapsed: true }; -export function headerReducer(state = initialState, action: HeaderAction): HeaderState { +export function navbarReducer(state = initialState, action: NavbarAction): NavbarState { switch (action.type) { - case HeaderActionTypes.COLLAPSE: { + case NavbarActionTypes.COLLAPSE: { return Object.assign({}, state, { navCollapsed: true }); } - case HeaderActionTypes.EXPAND: { + case NavbarActionTypes.EXPAND: { return Object.assign({}, state, { navCollapsed: false }); } - case HeaderActionTypes.TOGGLE: { + case NavbarActionTypes.TOGGLE: { return Object.assign({}, state, { navCollapsed: !state.navCollapsed }); diff --git a/src/app/shared/auth-nav-menu/auth-nav-menu.component.html b/src/app/shared/auth-nav-menu/auth-nav-menu.component.html index cc9b8c410b..217b731e0c 100644 --- a/src/app/shared/auth-nav-menu/auth-nav-menu.component.html +++ b/src/app/shared/auth-nav-menu/auth-nav-menu.component.html @@ -1,6 +1,6 @@
  • diff --git a/src/app/shared/chips/chips.component.spec.ts b/src/app/shared/chips/chips.component.spec.ts index d7940303c0..84efe2b86e 100644 --- a/src/app/shared/chips/chips.component.spec.ts +++ b/src/app/shared/chips/chips.component.spec.ts @@ -10,6 +10,7 @@ import { SortablejsModule } from 'angular-sortablejs'; import { By } from '@angular/platform-browser'; import { FormFieldMetadataValueObject } from '../form/builder/models/form-field-metadata-value.model'; import { createTestComponent, hasClass } from '../testing/utils'; +import { TranslateModule } from '@ngx-translate/core'; describe('ChipsComponent test suite', () => { @@ -27,6 +28,7 @@ describe('ChipsComponent test suite', () => { imports: [ NgbModule.forRoot(), SortablejsModule.forRoot({animation: 150}), + TranslateModule.forRoot() ], declarations: [ ChipsComponent, diff --git a/src/app/shared/menu/menu.reducer.spec.ts b/src/app/shared/menu/menu.reducer.spec.ts index c3968d098a..ac56bed1f0 100644 --- a/src/app/shared/menu/menu.reducer.spec.ts +++ b/src/app/shared/menu/menu.reducer.spec.ts @@ -54,7 +54,7 @@ describe('menusReducer', () => { visible: true, model: { type: 0, - text: 'admin.sidebar.section.new' + text: 'menu.section.new' }, icon: 'plus-circle', index: 0 @@ -66,7 +66,7 @@ describe('menusReducer', () => { visible: true, model: { type: 1, - text: 'admin.sidebar.section.new_item', + text: 'menu.section.new_item', link: '/items/submission' } }, @@ -77,7 +77,7 @@ describe('menusReducer', () => { visible: true, model: { type: 1, - text: 'admin.sidebar.section.new_community', + text: 'menu.section.new_community', link: '/communities/submission' } }, @@ -87,7 +87,7 @@ describe('menusReducer', () => { visible: true, model: { type: 0, - text: 'admin.sidebar.section.access_control' + text: 'menu.section.access_control' }, icon: 'key', index: 4 @@ -99,7 +99,7 @@ describe('menusReducer', () => { visible: true, model: { type: 1, - text: 'admin.sidebar.section.access_control_people', + text: 'menu.section.access_control_people', link: '#' } }, @@ -110,7 +110,7 @@ describe('menusReducer', () => { visible: true, model: { type: 1, - text: 'admin.sidebar.section.access_control_groups', + text: 'menu.section.access_control_groups', link: '#' } }, @@ -121,7 +121,7 @@ describe('menusReducer', () => { visible: true, model: { type: 1, - text: 'admin.sidebar.section.new_collection', + text: 'menu.section.new_collection', link: '/collections/submission' } } From 67e2a78a264f98f82050d99b844e1dae5367e5ee Mon Sep 17 00:00:00 2001 From: lotte Date: Wed, 19 Dec 2018 14:15:34 +0100 Subject: [PATCH 29/32] applied more feedback --- .../+search-page/search-sidebar/search-sidebar.component.html | 2 +- src/app/header/header.component.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/+search-page/search-sidebar/search-sidebar.component.html b/src/app/+search-page/search-sidebar/search-sidebar.component.html index a9a958cffa..5ff1e3c8fa 100644 --- a/src/app/+search-page/search-sidebar/search-sidebar.component.html +++ b/src/app/+search-page/search-sidebar/search-sidebar.component.html @@ -4,7 +4,7 @@
diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts index 336acc35df..8f2da69f0d 100644 --- a/src/app/header/header.component.ts +++ b/src/app/header/header.component.ts @@ -3,6 +3,9 @@ import { Observable } from 'rxjs/internal/Observable'; import { MenuService } from '../shared/menu/menu.service'; import { MenuID } from '../shared/menu/initial-menus-state'; +/** + * Represents the header with the logo and simple navigation + */ @Component({ selector: 'ds-header', styleUrls: ['header.component.scss'], From b4d21d88b5cd9efbefb2f07f29ae5b799eb52c1b Mon Sep 17 00:00:00 2001 From: courtneypattison Date: Wed, 19 Dec 2018 15:15:35 -0800 Subject: [PATCH 30/32] Changed search filter cursor to pointer --- .../search-filter/search-filter.component.scss | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/app/+search-page/search-filters/search-filter/search-filter.component.scss b/src/app/+search-page/search-filters/search-filter/search-filter.component.scss index 6e49172a48..4e45f49468 100644 --- a/src/app/+search-page/search-filters/search-filter/search-filter.component.scss +++ b/src/app/+search-page/search-filters/search-filter/search-filter.component.scss @@ -2,11 +2,12 @@ @import '../../../../styles/mixins.scss'; :host { - border: 1px solid map-get($theme-colors, light); - .search-filter-wrapper.closed { - overflow: hidden; - } - .filter-toggle { - line-height: $line-height-base; - } -} \ No newline at end of file + border: 1px solid map-get($theme-colors, light); + cursor: pointer; + .search-filter-wrapper.closed { + overflow: hidden; + } + .filter-toggle { + line-height: $line-height-base; + } +} From 8ae08fc1fdb3723fad564f98d8da8a2d2da9f28d Mon Sep 17 00:00:00 2001 From: lotte Date: Thu, 20 Dec 2018 14:09:41 +0100 Subject: [PATCH 31/32] added title to admin sidebar section icon --- .../admin-sidebar-section/admin-sidebar-section.component.html | 2 +- .../admin-sidebar-section.component.spec.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html b/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html index ac2f3338d0..e72a17aac1 100644 --- a/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html +++ b/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html @@ -1,6 +1,6 @@