From ac58297cbf1d5d5b3d912a0b2c8cd30938773b13 Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Wed, 13 Nov 2019 17:23:28 +0100 Subject: [PATCH 1/6] 66156: Tabbed related entities search --- resources/i18n/en.json5 | 4 +++ src/app/+item-page/item-page.module.ts | 7 ++-- ...bed-related-entities-search.component.html | 13 +++++++ ...abbed-related-entities-search.component.ts | 36 +++++++++++++++++++ .../item-pages/journal/journal.component.html | 6 ++-- .../item-pages/person/person.component.html | 6 ++-- .../item-pages/journal/journal.component.html | 6 ++-- .../item-pages/person/person.component.html | 6 ++-- 8 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html create mode 100644 src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts diff --git a/resources/i18n/en.json5 b/resources/i18n/en.json5 index dfcb397f4f..b088ce5545 100644 --- a/resources/i18n/en.json5 +++ b/resources/i18n/en.json5 @@ -405,6 +405,10 @@ "item.page.link.full": "Full item page", "item.page.link.simple": "Simple item page", "item.page.person.search.title": "Articles by this author", + + "item.page.relationships.isAuthorOfPublication": "Publications", + "item.page.relationships.isJournalOfPublication": "Publications", + "item.page.subject": "Keywords", "item.page.uri": "URI", diff --git a/src/app/+item-page/item-page.module.ts b/src/app/+item-page/item-page.module.ts index 2a5d0b6da7..b4705f1e7c 100644 --- a/src/app/+item-page/item-page.module.ts +++ b/src/app/+item-page/item-page.module.ts @@ -26,6 +26,7 @@ import { MetadataRepresentationListComponent } from './simple/metadata-represent import { RelatedEntitiesSearchComponent } from './simple/related-entities/related-entities-search/related-entities-search.component'; import { MetadataValuesComponent } from './field-components/metadata-values/metadata-values.component'; import { MetadataFieldWrapperComponent } from './field-components/metadata-field-wrapper/metadata-field-wrapper.component'; +import { TabbedRelatedEntitiesSearchComponent } from './simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component'; @NgModule({ imports: [ @@ -53,7 +54,8 @@ import { MetadataFieldWrapperComponent } from './field-components/metadata-field ItemComponent, GenericItemPageFieldComponent, MetadataRepresentationListComponent, - RelatedEntitiesSearchComponent + RelatedEntitiesSearchComponent, + TabbedRelatedEntitiesSearchComponent ], exports: [ ItemComponent, @@ -63,7 +65,8 @@ import { MetadataFieldWrapperComponent } from './field-components/metadata-field RelatedEntitiesSearchComponent, RelatedItemsComponent, MetadataRepresentationListComponent, - ItemPageTitleFieldComponent + ItemPageTitleFieldComponent, + TabbedRelatedEntitiesSearchComponent ], entryComponents: [ PublicationComponent diff --git a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html new file mode 100644 index 0000000000..ea142a2337 --- /dev/null +++ b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html @@ -0,0 +1,13 @@ + + + +
+ + +
+
+
+
diff --git a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts new file mode 100644 index 0000000000..c424f2d765 --- /dev/null +++ b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts @@ -0,0 +1,36 @@ +import { Component, Input } from '@angular/core'; +import { Item } from '../../../../core/shared/item.model'; + +@Component({ + selector: 'ds-tabbed-related-entities-search', + templateUrl: './tabbed-related-entities-search.component.html' +}) +/** + * A component to show related items as search results, split into tabs by relationship-type + * Related items can be facetted, or queried using an + * optional search box. + */ +export class TabbedRelatedEntitiesSearchComponent { + /** + * The types of relationships to fetch items for + * e.g. 'isAuthorOfPublication' + */ + @Input() relationTypes: string[]; + + /** + * The item to render relationships for + */ + @Input() item: Item; + + /** + * Whether or not the search bar and title should be displayed (defaults to true) + * @type {boolean} + */ + @Input() searchEnabled = true; + + /** + * The ratio of the sidebar's width compared to the search results (1-12) (defaults to 4) + * @type {number} + */ + @Input() sideBarWidth = 4; +} diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html index a82d3c5df6..1f3fb2f159 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html @@ -35,8 +35,8 @@
- - + +
diff --git a/src/app/entity-groups/research-entities/item-pages/person/person.component.html b/src/app/entity-groups/research-entities/item-pages/person/person.component.html index 04d7b9e062..560f470ce5 100644 --- a/src/app/entity-groups/research-entities/item-pages/person/person.component.html +++ b/src/app/entity-groups/research-entities/item-pages/person/person.component.html @@ -51,8 +51,8 @@
- - + +
diff --git a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html index ef827af590..8d79669419 100644 --- a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html +++ b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html @@ -61,7 +61,7 @@

{{"item.page.journal.search.title" | translate}}

- - + + diff --git a/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html b/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html index 54d7962b97..88f0478a9a 100644 --- a/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html +++ b/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html @@ -79,7 +79,7 @@

{{"item.page.person.search.title" | translate}}

- - + + From 87d468f9b952dd1ac2b51ac45a9fda99b7f283c2 Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Tue, 19 Nov 2019 14:42:58 +0100 Subject: [PATCH 2/6] 66156: Hide tabbox on single tab, merged filtered- and configuration-search-page into one component and added configuration option to tabs --- .../related-entities-search.component.html | 5 +- .../related-entities-search.component.ts | 16 ++-- ...bed-related-entities-search.component.html | 15 +++- ...abbed-related-entities-search.component.ts | 6 +- .../configuration-search-page.component.ts | 12 ++- .../filtered-search-page.component.spec.ts | 21 ------ .../filtered-search-page.component.ts | 73 ------------------- src/app/+search-page/search-page.module.ts | 2 - .../item-pages/journal/journal.component.html | 5 +- .../item-pages/person/person.component.html | 5 +- .../item-pages/journal/journal.component.html | 5 +- .../item-pages/person/person.component.html | 5 +- 12 files changed, 54 insertions(+), 116 deletions(-) delete mode 100644 src/app/+search-page/filtered-search-page.component.spec.ts delete mode 100644 src/app/+search-page/filtered-search-page.component.ts diff --git a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.html b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.html index c7e1f77264..75f3b7aaad 100644 --- a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.html +++ b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.html @@ -1,6 +1,7 @@ - - + diff --git a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.ts b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.ts index 4c0b127925..8f65cb9858 100644 --- a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.ts +++ b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.ts @@ -22,18 +22,16 @@ export class RelatedEntitiesSearchComponent implements OnInit { */ @Input() relationType: string; + /** + * An optional configuration to use for the search options + */ + @Input() configuration: string; + /** * The item to render relationships for */ @Input() item: Item; - /** - * The entity type of the relationship items to be displayed - * e.g. 'publication' - * This determines the title of the search results (if search is enabled) - */ - @Input() relationEntityType: string; - /** * Whether or not the search bar and title should be displayed (defaults to true) * @type {boolean} @@ -56,8 +54,8 @@ export class RelatedEntitiesSearchComponent implements OnInit { if (isNotEmpty(this.relationType) && isNotEmpty(this.item)) { this.fixedFilter = this.fixedFilterService.getFilterByRelation(this.relationType, this.item.id); } - if (isNotEmpty(this.relationEntityType)) { - this.configuration$ = of(this.relationEntityType); + if (isNotEmpty(this.configuration)) { + this.configuration$ = of(this.configuration); } } diff --git a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html index ea142a2337..69670d8f51 100644 --- a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html +++ b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html @@ -1,9 +1,10 @@ - - + +
@@ -11,3 +12,11 @@ +
+ + +
diff --git a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts index c424f2d765..3b46300267 100644 --- a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts +++ b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts @@ -15,7 +15,11 @@ export class TabbedRelatedEntitiesSearchComponent { * The types of relationships to fetch items for * e.g. 'isAuthorOfPublication' */ - @Input() relationTypes: string[]; + @Input() relationTypes: Array<{ + label: string, + filter: string, + configuration?: string + }>; /** * The item to render relationships for diff --git a/src/app/+search-page/configuration-search-page.component.ts b/src/app/+search-page/configuration-search-page.component.ts index b1a94fc086..b36353584c 100644 --- a/src/app/+search-page/configuration-search-page.component.ts +++ b/src/app/+search-page/configuration-search-page.component.ts @@ -35,6 +35,12 @@ export class ConfigurationSearchPageComponent extends SearchPageComponent implem */ @Input() configuration: string; + /** + * The actual query for the fixed filter. + * If empty, the query will be determined by the route parameter called 'filter' + */ + @Input() fixedFilterQuery: string; + constructor(protected service: SearchService, protected sidebarService: SearchSidebarService, protected windowService: HostWindowService, @@ -64,7 +70,11 @@ export class ConfigurationSearchPageComponent extends SearchPageComponent implem return this.searchConfigService.paginatedSearchOptions.pipe( map((options: PaginatedSearchOptions) => { const config = this.configuration || options.configuration; - return Object.assign(options, { configuration: config }); + const filter = this.fixedFilterQuery || options.fixedFilter; + return Object.assign(options, { + configuration: config, + fixedFilter: filter + }); }) ); } diff --git a/src/app/+search-page/filtered-search-page.component.spec.ts b/src/app/+search-page/filtered-search-page.component.spec.ts deleted file mode 100644 index 59ab9d7b0d..0000000000 --- a/src/app/+search-page/filtered-search-page.component.spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { FilteredSearchPageComponent } from './filtered-search-page.component'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { configureSearchComponentTestingModule } from './search-page.component.spec'; -import { SearchConfigurationService } from './search-service/search-configuration.service'; - -describe('FilteredSearchPageComponent', () => { - let comp: FilteredSearchPageComponent; - let fixture: ComponentFixture; - let searchConfigService: SearchConfigurationService; - - beforeEach(async(() => { - configureSearchComponentTestingModule(FilteredSearchPageComponent); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(FilteredSearchPageComponent); - comp = fixture.componentInstance; - searchConfigService = (comp as any).searchConfigService; - fixture.detectChanges(); - }); -}); diff --git a/src/app/+search-page/filtered-search-page.component.ts b/src/app/+search-page/filtered-search-page.component.ts deleted file mode 100644 index 0bcc9e14e3..0000000000 --- a/src/app/+search-page/filtered-search-page.component.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { HostWindowService } from '../shared/host-window.service'; -import { SearchService } from './search-service/search.service'; -import { SearchSidebarService } from './search-sidebar/search-sidebar.service'; -import { SearchPageComponent } from './search-page.component'; -import { ChangeDetectionStrategy, Component, Inject, Input, OnInit } from '@angular/core'; -import { pushInOut } from '../shared/animations/push'; -import { SearchConfigurationService } from './search-service/search-configuration.service'; -import { Observable } from 'rxjs'; -import { PaginatedSearchOptions } from './paginated-search-options.model'; -import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component'; -import { map } from 'rxjs/operators'; -import { RouteService } from '../core/services/route.service'; - -/** - * This component renders a simple item page. - * The route parameter 'id' is used to request the item it represents. - * All fields of the item that should be displayed, are defined in its template. - */ -@Component({ - selector: 'ds-filtered-search-page', - styleUrls: ['./search-page.component.scss'], - templateUrl: './search-page.component.html', - changeDetection: ChangeDetectionStrategy.OnPush, - animations: [pushInOut], - providers: [ - { - provide: SEARCH_CONFIG_SERVICE, - useClass: SearchConfigurationService - } - ] -}) - -export class FilteredSearchPageComponent extends SearchPageComponent implements OnInit { - /** - * The actual query for the fixed filter. - * If empty, the query will be determined by the route parameter called 'filter' - */ - @Input() fixedFilterQuery: string; - - constructor(protected service: SearchService, - protected sidebarService: SearchSidebarService, - protected windowService: HostWindowService, - @Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService, - protected routeService: RouteService) { - super(service, sidebarService, windowService, searchConfigService, routeService); - } - - /** - * Listening to changes in the paginated search options - * If something changes, update the search results - * - * Listen to changes in the scope - * If something changes, update the list of scopes for the dropdown - */ - ngOnInit(): void { - super.ngOnInit(); - } - - /** - * Get the current paginated search options after updating the fixed filter using the fixedFilterQuery input - * This is to make sure the fixed filter is included in the paginated search options, as it is not part of any - * query or route parameters - * @returns {Observable} - */ - protected getSearchOptions(): Observable { - return this.searchConfigService.paginatedSearchOptions.pipe( - map((options: PaginatedSearchOptions) => { - const filter = this.fixedFilterQuery || options.fixedFilter; - return Object.assign(options, { fixedFilter: filter }); - }) - ); - } -} diff --git a/src/app/+search-page/search-page.module.ts b/src/app/+search-page/search-page.module.ts index f4c665d06e..efc647f086 100644 --- a/src/app/+search-page/search-page.module.ts +++ b/src/app/+search-page/search-page.module.ts @@ -32,7 +32,6 @@ import { SearchAuthorityFilterComponent } from './search-filters/search-filter/s import { SearchLabelComponent } from './search-labels/search-label/search-label.component'; import { ConfigurationSearchPageComponent } from './configuration-search-page.component'; import { ConfigurationSearchPageGuard } from './configuration-search-page.guard'; -import { FilteredSearchPageComponent } from './filtered-search-page.component'; const effects = [ SearchSidebarEffects @@ -59,7 +58,6 @@ const components = [ SearchFacetRangeOptionComponent, SearchSwitchConfigurationComponent, SearchAuthorityFilterComponent, - FilteredSearchPageComponent, ConfigurationSearchPageComponent ]; diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html index 562d4b44fc..e86ab35e0e 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html @@ -37,7 +37,10 @@
+ [relationTypes]="[{ + label: 'isJournalOfPublication', + filter: 'isJournalOfPublication' + }]">
diff --git a/src/app/entity-groups/research-entities/item-pages/person/person.component.html b/src/app/entity-groups/research-entities/item-pages/person/person.component.html index 538dd4a241..97a3cf416e 100644 --- a/src/app/entity-groups/research-entities/item-pages/person/person.component.html +++ b/src/app/entity-groups/research-entities/item-pages/person/person.component.html @@ -54,7 +54,10 @@
+ [relationTypes]="[{ + label: 'isAuthorOfPublication', + filter: 'isAuthorOfPublication' + }]">
diff --git a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html index 2ad6cbb0ff..089511804e 100644 --- a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html +++ b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html @@ -62,6 +62,9 @@

{{"item.page.journal.search.title" | translate}}

+ [relationTypes]="[{ + label: 'isJournalOfPublication', + filter: 'isJournalOfPublication' + }]"> diff --git a/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html b/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html index 6f22006164..1679f9354d 100644 --- a/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html +++ b/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html @@ -80,6 +80,9 @@

{{"item.page.person.search.title" | translate}}

+ [relationTypes]="[{ + label: 'isAuthorOfPublication', + filter: 'isAuthorOfPublication' + }]"> From 63257eac3d766f6e734b3ae83ae8af33128c6fac Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Thu, 21 Nov 2019 12:45:38 +0100 Subject: [PATCH 3/6] 66156: AoT build error fix --- .../related-entities-search.component.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts index 711e1b9d3d..7eeddf8e70 100644 --- a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts +++ b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts @@ -16,7 +16,7 @@ describe('RelatedEntitiesSearchComponent', () => { id: 'id1' }); const mockRelationType = 'publicationsOfAuthor'; - const mockRelationEntityType = 'publication'; + const mockConfiguration = 'publication'; const mockFilter= `f.${mockRelationType}=${mockItem.id}`; const fixedFilterServiceStub = { getFilterByRelation: () => mockFilter @@ -39,7 +39,7 @@ describe('RelatedEntitiesSearchComponent', () => { fixedFilterService = (comp as any).fixedFilterService; comp.relationType = mockRelationType; comp.item = mockItem; - comp.relationEntityType = mockRelationEntityType; + comp.configuration = mockConfiguration; fixture.detectChanges(); }); @@ -49,7 +49,7 @@ describe('RelatedEntitiesSearchComponent', () => { it('should create a configuration$', () => { comp.configuration$.subscribe((configuration) => { - expect(configuration).toEqual(mockRelationEntityType); + expect(configuration).toEqual(mockConfiguration); }) }); From 64c9d009a99a133bcbcd7c5e79c48386c6ad2a7e Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Thu, 21 Nov 2019 13:28:33 +0100 Subject: [PATCH 4/6] 66156: Active tab in URL for tabbed related entities search --- ...bed-related-entities-search.component.html | 4 +- ...-related-entities-search.component.spec.ts | 83 +++++++++++++++++++ ...abbed-related-entities-search.component.ts | 36 +++++++- 3 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.spec.ts diff --git a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html index 69670d8f51..d3690c74be 100644 --- a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html +++ b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html @@ -1,5 +1,5 @@ - - + +
{ + let comp: TabbedRelatedEntitiesSearchComponent; + let fixture: ComponentFixture; + + const mockItem = Object.assign(new Item(), { + id: 'id1' + }); + const mockRelationType = 'publications'; + const relationTypes = [ + { + label: mockRelationType, + filter: mockRelationType + } + ]; + + const router = new MockRouter(); + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [TranslateModule.forRoot(), NoopAnimationsModule, NgbModule.forRoot()], + declarations: [TabbedRelatedEntitiesSearchComponent, VarDirective], + providers: [ + { + provide: ActivatedRoute, + useValue: { + snapshot: { + queryParams: { + tab: mockRelationType + } + } + }, + }, + { provide: Router, useValue: router } + ], + schemas: [NO_ERRORS_SCHEMA] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TabbedRelatedEntitiesSearchComponent); + comp = fixture.componentInstance; + comp.item = mockItem; + comp.relationTypes = relationTypes; + fixture.detectChanges(); + }); + + it('should initialize the activeTab depending on the current query parameters', () => { + expect(comp.activeTab).toEqual(mockRelationType); + }); + + describe('onTabChange', () => { + const event = { + currentId: mockRelationType, + nextId: 'nextTab' + }; + + beforeEach(() => { + comp.onTabChange(event); + }); + + it('should call router natigate with the correct arguments', () => { + expect(router.navigate).toHaveBeenCalledWith([], { + relativeTo: (comp as any).route, + queryParams: { + tab: event.nextId + }, + queryParamsHandling: 'merge' + }); + }); + }); + +}); diff --git a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts index 3b46300267..9fc4e7ec34 100644 --- a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts +++ b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts @@ -1,5 +1,6 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { Item } from '../../../../core/shared/item.model'; +import { ActivatedRoute, Router } from '@angular/router'; @Component({ selector: 'ds-tabbed-related-entities-search', @@ -10,7 +11,7 @@ import { Item } from '../../../../core/shared/item.model'; * Related items can be facetted, or queried using an * optional search box. */ -export class TabbedRelatedEntitiesSearchComponent { +export class TabbedRelatedEntitiesSearchComponent implements OnInit { /** * The types of relationships to fetch items for * e.g. 'isAuthorOfPublication' @@ -37,4 +38,35 @@ export class TabbedRelatedEntitiesSearchComponent { * @type {number} */ @Input() sideBarWidth = 4; + + /** + * The active tab + */ + activeTab: string; + + constructor(private route: ActivatedRoute, + private router: Router) { + } + + /** + * If the url contains a "tab" query parameter, set this tab to be the active tab + */ + ngOnInit(): void { + this.activeTab = this.route.snapshot.queryParams.tab; + } + + /** + * Add a "tab" query parameter to the URL when changing tabs + * @param event + */ + onTabChange(event) { + this.router.navigate([], { + relativeTo: this.route, + queryParams: { + tab: event.nextId + }, + queryParamsHandling: 'merge' + }); + } + } From 757b9f9dcdb4f6c9b3919f36000ce635d64ad8ba Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Mon, 25 Nov 2019 14:18:21 +0100 Subject: [PATCH 5/6] 66156: Persons and Projects search tabs on OrgUnit pages + mantis fix --- resources/i18n/en.json5 | 6 ++++++ .../item-pages/org-unit/org-unit.component.html | 14 ++++++++++++++ .../org-unit.component.html} | 17 +++++++++++++++++ .../org-unit.component.scss} | 2 +- 4 files changed, 38 insertions(+), 1 deletion(-) rename themes/mantis/app/entity-groups/research-entities/item-pages/{orgunit/orgunit.component.html => org-unit/org-unit.component.html} (81%) rename themes/mantis/app/entity-groups/research-entities/item-pages/{orgunit/orgunit.component.scss => org-unit/org-unit.component.scss} (86%) diff --git a/resources/i18n/en.json5 b/resources/i18n/en.json5 index 80a7648476..da58d2010c 100644 --- a/resources/i18n/en.json5 +++ b/resources/i18n/en.json5 @@ -822,6 +822,10 @@ "item.page.relationships.isJournalOfPublication": "Publications", + "item.page.relationships.isOrgUnitOfPerson": "Persons", + + "item.page.relationships.isOrgUnitOfProject": "Projects", + "item.page.subject": "Keywords", "item.page.uri": "URI", @@ -1272,6 +1276,8 @@ "project.page.titleprefix": "Research Project: ", + "project.search.results.head": "Project Search Results", + "publication.listelement.badge": "Publication", diff --git a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html index 4d97868b58..c9227338eb 100644 --- a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html @@ -49,4 +49,18 @@
+
+ + +
diff --git a/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html b/themes/mantis/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html similarity index 81% rename from themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html rename to themes/mantis/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html index 15529a1bd5..4603b8d327 100644 --- a/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html +++ b/themes/mantis/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html @@ -74,3 +74,20 @@ +
+
+ + +
+
diff --git a/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.scss b/themes/mantis/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.scss similarity index 86% rename from themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.scss rename to themes/mantis/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.scss index 54651aede0..4a1d2516da 100644 --- a/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.scss +++ b/themes/mantis/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.scss @@ -1,4 +1,4 @@ -@import 'src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.scss'; +@import 'src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.scss'; :host { > * { From 1b978124d1ef7e44c0e6ab27d3809ae965834611 Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Wed, 27 Nov 2019 18:01:31 +0100 Subject: [PATCH 6/6] 66156: Removal of redundant fields, message update and aciveTab as observable --- resources/i18n/en.json5 | 4 ++-- .../tabbed-related-entities-search.component.html | 2 +- .../tabbed-related-entities-search.component.spec.ts | 11 +++++------ .../tabbed-related-entities-search.component.ts | 8 ++++++-- .../item-pages/org-unit/org-unit.component.html | 10 ---------- .../item-pages/org-unit/org-unit.component.html | 12 ------------ 6 files changed, 14 insertions(+), 33 deletions(-) diff --git a/resources/i18n/en.json5 b/resources/i18n/en.json5 index 7e250490fc..4a47434f21 100644 --- a/resources/i18n/en.json5 +++ b/resources/i18n/en.json5 @@ -822,9 +822,9 @@ "item.page.relationships.isJournalOfPublication": "Publications", - "item.page.relationships.isOrgUnitOfPerson": "Persons", + "item.page.relationships.isOrgUnitOfPerson": "Authors", - "item.page.relationships.isOrgUnitOfProject": "Projects", + "item.page.relationships.isOrgUnitOfProject": "Research Projects", "item.page.subject": "Keywords", diff --git a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html index d3690c74be..f9642d2c01 100644 --- a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html +++ b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html @@ -1,4 +1,4 @@ - +
diff --git a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.spec.ts b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.spec.ts index bc767476e1..2d2e682196 100644 --- a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.spec.ts +++ b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.spec.ts @@ -8,6 +8,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { MockRouter } from '../../../../shared/mocks/mock-router'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { VarDirective } from '../../../../shared/utils/var.directive'; +import { of as observableOf } from 'rxjs'; describe('TabbedRelatedEntitiesSearchComponent', () => { let comp: TabbedRelatedEntitiesSearchComponent; @@ -34,11 +35,7 @@ describe('TabbedRelatedEntitiesSearchComponent', () => { { provide: ActivatedRoute, useValue: { - snapshot: { - queryParams: { - tab: mockRelationType - } - } + queryParams: observableOf({ tab: mockRelationType }) }, }, { provide: Router, useValue: router } @@ -56,7 +53,9 @@ describe('TabbedRelatedEntitiesSearchComponent', () => { }); it('should initialize the activeTab depending on the current query parameters', () => { - expect(comp.activeTab).toEqual(mockRelationType); + comp.activeTab$.subscribe((activeTab) => { + expect(activeTab).toEqual(mockRelationType); + }); }); describe('onTabChange', () => { diff --git a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts index 9fc4e7ec34..b01eb70720 100644 --- a/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts +++ b/src/app/+item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts @@ -1,6 +1,8 @@ import { Component, Input, OnInit } from '@angular/core'; import { Item } from '../../../../core/shared/item.model'; import { ActivatedRoute, Router } from '@angular/router'; +import { Observable } from 'rxjs/internal/Observable'; +import { map } from 'rxjs/operators'; @Component({ selector: 'ds-tabbed-related-entities-search', @@ -42,7 +44,7 @@ export class TabbedRelatedEntitiesSearchComponent implements OnInit { /** * The active tab */ - activeTab: string; + activeTab$: Observable; constructor(private route: ActivatedRoute, private router: Router) { @@ -52,7 +54,9 @@ export class TabbedRelatedEntitiesSearchComponent implements OnInit { * If the url contains a "tab" query parameter, set this tab to be the active tab */ ngOnInit(): void { - this.activeTab = this.route.snapshot.queryParams.tab; + this.activeTab$ = this.route.queryParams.pipe( + map((params) => params.tab) + ); } /** diff --git a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html index c9227338eb..1b23d567f5 100644 --- a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html @@ -24,16 +24,6 @@
- - - -
- - - -