diff --git a/resources/i18n/en.json5 b/resources/i18n/en.json5 index 0ad08652b5..dfcb397f4f 100644 --- a/resources/i18n/en.json5 +++ b/resources/i18n/en.json5 @@ -161,6 +161,7 @@ "collection.page.browse.recent.head": "Recent Submissions", "collection.page.browse.recent.empty": "No items to show", + "collection.page.handle": "Permanent URI for this collection", "collection.page.license": "License", "collection.page.news": "News", @@ -184,8 +185,10 @@ "community.form.rights": "Copyright text (HTML)", "community.form.tableofcontents": "News (HTML)", "community.form.title": "Name", + "community.page.handle": "Permanent URI for this community", "community.page.license": "License", "community.page.news": "News", + "community.all-lists.head": "Subcommunities and Collections", "community.sub-collection-list.head": "Collections of this Community", "community.sub-community-list.head": "Communities of this Community", diff --git a/src/app/+browse-by/+browse-by-date-page/browse-by-date-page.component.spec.ts b/src/app/+browse-by/+browse-by-date-page/browse-by-date-page.component.spec.ts index 78f5d52511..a507e8e585 100644 --- a/src/app/+browse-by/+browse-by-date-page/browse-by-date-page.component.spec.ts +++ b/src/app/+browse-by/+browse-by-date-page/browse-by-date-page.component.spec.ts @@ -19,6 +19,7 @@ import { ENV_CONFIG, GLOBAL_CONFIG } from '../../../config'; import { BrowseEntrySearchOptions } from '../../core/browse/browse-entry-search-options.model'; import { toRemoteData } from '../+browse-by-metadata-page/browse-by-metadata-page.component.spec'; import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { VarDirective } from '../../shared/utils/var.directive'; describe('BrowseByDatePageComponent', () => { let comp: BrowseByDatePageComponent; @@ -69,7 +70,7 @@ describe('BrowseByDatePageComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()], - declarations: [BrowseByDatePageComponent, EnumKeysPipe], + declarations: [BrowseByDatePageComponent, EnumKeysPipe, VarDirective], providers: [ { provide: GLOBAL_CONFIG, useValue: ENV_CONFIG }, { provide: ActivatedRoute, useValue: activatedRouteStub }, diff --git a/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.html b/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.html index c589c543d4..45f2ef3b2a 100644 --- a/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.html +++ b/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.html @@ -1,7 +1,31 @@
-
+ + +
+ + + + + + + + + + + + +
+ + +
+ +
+ +
+ + +
+
+ + + + +
+
+
+
diff --git a/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.spec.ts b/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.spec.ts index 927effd303..553bd00f56 100644 --- a/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.spec.ts +++ b/src/app/+browse-by/+browse-by-metadata-page/browse-by-metadata-page.component.spec.ts @@ -23,6 +23,7 @@ import { MockRouter } from '../../shared/mocks/mock-router'; import { ResourceType } from '../../core/shared/resource-type'; import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; import { BrowseEntry } from '../../core/shared/browse-entry.model'; +import { VarDirective } from '../../shared/utils/var.directive'; describe('BrowseByMetadataPageComponent', () => { let comp: BrowseByMetadataPageComponent; @@ -86,7 +87,7 @@ describe('BrowseByMetadataPageComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()], - declarations: [BrowseByMetadataPageComponent, EnumKeysPipe], + declarations: [BrowseByMetadataPageComponent, EnumKeysPipe, VarDirective], providers: [ { provide: ActivatedRoute, useValue: activatedRouteStub }, { provide: BrowseService, useValue: mockBrowseService }, diff --git a/src/app/+browse-by/+browse-by-title-page/browse-by-title-page.component.spec.ts b/src/app/+browse-by/+browse-by-title-page/browse-by-title-page.component.spec.ts index 3bc69e5fcb..90623eb3c7 100644 --- a/src/app/+browse-by/+browse-by-title-page/browse-by-title-page.component.spec.ts +++ b/src/app/+browse-by/+browse-by-title-page/browse-by-title-page.component.spec.ts @@ -18,6 +18,7 @@ import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.serv import { BrowseService } from '../../core/browse/browse.service'; import { MockRouter } from '../../shared/mocks/mock-router'; import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { VarDirective } from '../../shared/utils/var.directive'; describe('BrowseByTitlePageComponent', () => { let comp: BrowseByTitlePageComponent; @@ -64,7 +65,7 @@ describe('BrowseByTitlePageComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()], - declarations: [BrowseByTitlePageComponent, EnumKeysPipe], + declarations: [BrowseByTitlePageComponent, EnumKeysPipe, VarDirective], providers: [ { provide: ActivatedRoute, useValue: activatedRouteStub }, { provide: BrowseService, useValue: mockBrowseService }, diff --git a/src/app/+collection-page/collection-page.component.html b/src/app/+collection-page/collection-page.component.html index 2b16bc1ca6..436cd351a0 100644 --- a/src/app/+collection-page/collection-page.component.html +++ b/src/app/+collection-page/collection-page.component.html @@ -3,18 +3,22 @@ *ngVar="(collectionRD$ | async) as collectionRD">
+
+ + + [alternateText]="'Collection Logo'"> + - - - - - - + + + + @@ -23,23 +27,20 @@ + [title]="'collection.page.news'"> - - - - - - -
-
+ + +
+ + + + -
-

{{'collection.page.browse.recent.head' | translate}}

+
+

{{'collection.page.browse.recent.head' | translate}}

-
- - +
+ +
+ + + diff --git a/src/app/+community-page/community-page.component.html b/src/app/+community-page/community-page.component.html index e429d224f2..05d0bd1d0e 100644 --- a/src/app/+community-page/community-page.component.html +++ b/src/app/+community-page/community-page.component.html @@ -1,33 +1,38 @@
- - - - - - - - - - - - - - - - - - +
+ + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
+ + + +
diff --git a/src/app/shared/browse-by/browse-by.component.html b/src/app/shared/browse-by/browse-by.component.html index f7cd7e0d35..09d3cd3d60 100644 --- a/src/app/shared/browse-by/browse-by.component.html +++ b/src/app/shared/browse-by/browse-by.component.html @@ -1,5 +1,5 @@ -

{{title | translate}}

+

{{title | translate}}

diff --git a/src/app/shared/browse-by/browse-by.component.ts b/src/app/shared/browse-by/browse-by.component.ts index 6c4bc78213..230b0bc136 100644 --- a/src/app/shared/browse-by/browse-by.component.ts +++ b/src/app/shared/browse-by/browse-by.component.ts @@ -26,6 +26,10 @@ export class BrowseByComponent implements OnInit { */ @Input() title: string; + /** + * The parent name + */ + @Input() parentname: string; /** * The list of objects to display */ diff --git a/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.html b/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.html index 1c73fbb3df..504d9f4bcd 100644 --- a/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.html +++ b/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.html @@ -1,6 +1,24 @@ -

{{'browse.comcol.head' | translate}}

- +

{{'browse.comcol.head' | translate}}

+ diff --git a/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.scss b/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.ts b/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.ts index dcc7840bb4..1bc83d74a5 100644 --- a/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.ts +++ b/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.ts @@ -1,6 +1,27 @@ -import { Component, Inject, Input, OnInit } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + Inject, + Input, NgZone, + OnDestroy, + OnInit +} from '@angular/core'; +import { Observable } from 'rxjs/internal/Observable'; +import { Subscription } from 'rxjs/internal/Subscription'; +import { filter, map, startWith, tap } from 'rxjs/operators'; +import { getCollectionPageRoute } from '../../+collection-page/collection-page-routing.module'; +import { getCommunityPageRoute } from '../../+community-page/community-page-routing.module'; import { GLOBAL_CONFIG, GlobalConfig } from '../../../config'; +import { Router, ActivatedRoute, RouterModule, UrlSegment } from '@angular/router'; import { BrowseByTypeConfig } from '../../../config/browse-by-type-config.interface'; +import { hasValue } from '../empty.util'; + +export interface ComColPageNavOption { + id: string; + label: string, + routerLink: string + params?: any; +}; /** * A component to display the "Browse By" section of a Community or Collection page @@ -8,24 +29,63 @@ import { BrowseByTypeConfig } from '../../../config/browse-by-type-config.interf */ @Component({ selector: 'ds-comcol-page-browse-by', - templateUrl: './comcol-page-browse-by.component.html', + styleUrls: ['./comcol-page-browse-by.component.scss'], + templateUrl: './comcol-page-browse-by.component.html' }) export class ComcolPageBrowseByComponent implements OnInit { /** * The ID of the Community or Collection */ @Input() id: string; - + @Input() contentType: string; /** * List of currently active browse configurations */ types: BrowseByTypeConfig[]; - constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig) { + allOptions: ComColPageNavOption[]; + + currentOptionId$: Observable; + + constructor( + @Inject(GLOBAL_CONFIG) public config: GlobalConfig, + private route: ActivatedRoute, + private router: Router) { } ngOnInit(): void { - this.types = this.config.browseBy.types; + this.allOptions = this.config.browseBy.types + .map((config: BrowseByTypeConfig) => ({ + id: config.id, + label: `browse.comcol.by.${config.id}`, + routerLink: `/browse/${config.id}`, + params: { scope: this.id } + })); + + if (this.contentType === 'collection') { + this.allOptions = [ { + id: this.id, + label: 'collection.page.browse.recent.head', + routerLink: getCollectionPageRoute(this.id) + }, ...this.allOptions ]; + } else if (this.contentType === 'community') { + this.allOptions = [{ + id: this.id, + label: 'community.all-lists.head', + routerLink: getCommunityPageRoute(this.id) + }, ...this.allOptions ]; + } + + this.currentOptionId$ = this.route.url.pipe( + filter((urlSegments: UrlSegment[]) => hasValue(urlSegments)), + map((urlSegments: UrlSegment[]) => urlSegments[urlSegments.length - 1].path) + ); } + onSelectChange(newId: string) { + const selectedOption = this.allOptions + .find((option: ComColPageNavOption) => option.id === newId); + + this.router.navigate([selectedOption.routerLink], { queryParams: selectedOption.params }); + } } diff --git a/src/app/shared/comcol-page-handle/comcol-page-handle.component.html b/src/app/shared/comcol-page-handle/comcol-page-handle.component.html new file mode 100644 index 0000000000..b3ca75bf94 --- /dev/null +++ b/src/app/shared/comcol-page-handle/comcol-page-handle.component.html @@ -0,0 +1,4 @@ +
+

{{ title | translate }}

+ +
diff --git a/src/app/shared/comcol-page-handle/comcol-page-handle.component.scss b/src/app/shared/comcol-page-handle/comcol-page-handle.component.scss new file mode 100644 index 0000000000..5d7bac26c7 --- /dev/null +++ b/src/app/shared/comcol-page-handle/comcol-page-handle.component.scss @@ -0,0 +1,5 @@ +div { + word-break: break-word; + word-wrap: break-word; + overflow-wrap: break-word; +} diff --git a/src/app/shared/comcol-page-handle/comcol-page-handle.component.ts b/src/app/shared/comcol-page-handle/comcol-page-handle.component.ts new file mode 100644 index 0000000000..3a2ab307be --- /dev/null +++ b/src/app/shared/comcol-page-handle/comcol-page-handle.component.ts @@ -0,0 +1,29 @@ +import { Component, Input, Inject, Injectable } from '@angular/core'; +import { GlobalConfig } from '../../../config/global-config.interface'; +import { GLOBAL_CONFIG } from '../../../config'; +import { UIURLCombiner } from '../../core/url-combiner/ui-url-combiner'; +/** + * This component builds a URL from the value of "handle" + */ + +@Component({ + selector: 'ds-comcol-page-handle', + styleUrls: ['./comcol-page-handle.component.scss'], + templateUrl: './comcol-page-handle.component.html' +}) + +@Injectable() +export class ComcolPageHandleComponent { + + // Optional title + @Input() title: string; + + // The value of "handle" + @Input() content: string; + + constructor(@Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig) { + } + public getHandle(): string { + return new UIURLCombiner(this.EnvConfig, '/handle/', this.content).toString(); + } +} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 10d7e0bfd6..8a8a84b5e3 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -30,6 +30,7 @@ import { AbstractListableElementComponent } from './object-collection/shared/obj import { ObjectGridComponent } from './object-grid/object-grid.component'; import { ObjectCollectionComponent } from './object-collection/object-collection.component'; import { ComcolPageContentComponent } from './comcol-page-content/comcol-page-content.component'; +import { ComcolPageHandleComponent } from './comcol-page-handle/comcol-page-handle.component'; import { ComcolPageHeaderComponent } from './comcol-page-header/comcol-page-header.component'; import { ComcolPageLogoComponent } from './comcol-page-logo/comcol-page-logo.component'; import { ErrorComponent } from './error/error.component'; @@ -192,6 +193,7 @@ const COMPONENTS = [ UserMenuComponent, ChipsComponent, ComcolPageContentComponent, + ComcolPageHandleComponent, ComcolPageHeaderComponent, ComcolPageLogoComponent, ComColFormComponent,