66156: Hide tabbox on single tab, merged filtered- and configuration-search-page into one component and added configuration option to tabs

This commit is contained in:
Kristof De Langhe
2019-11-19 14:42:58 +01:00
parent 52e6d5ca29
commit 87d468f9b9
12 changed files with 54 additions and 116 deletions

View File

@@ -1,6 +1,7 @@
<ds-filtered-search-page
<ds-configuration-search-page
[fixedFilterQuery]="fixedFilter"
[configuration]="configuration"
[configuration$]="configuration$"
[searchEnabled]="searchEnabled"
[sideBarWidth]="sideBarWidth">
</ds-filtered-search-page>
</ds-configuration-search-page>

View File

@@ -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);
}
}

View File

@@ -1,9 +1,10 @@
<ngb-tabset [destroyOnHide]="true" #tabs="ngbTabset">
<ngb-tab *ngFor="let relationType of relationTypes" title="{{'item.page.relationships.' + relationType | translate}}">
<ngb-tabset *ngIf="relationTypes.length > 1" [destroyOnHide]="true" #tabs="ngbTabset">
<ngb-tab *ngFor="let relationType of relationTypes" title="{{'item.page.relationships.' + relationType.label | translate}}">
<ng-template ngbTabContent>
<div class="mt-4">
<ds-related-entities-search [item]="item"
[relationType]="relationType"
[relationType]="relationType.filter"
[configuration]="relationType.configuration"
[searchEnabled]="searchEnabled"
[sideBarWidth]="sideBarWidth">
</ds-related-entities-search>
@@ -11,3 +12,11 @@
</ng-template>
</ngb-tab>
</ngb-tabset>
<div *ngIf="relationTypes.length === 1" class="mt-4">
<ds-related-entities-search *ngVar="relationTypes[0] as relationType" [item]="item"
[relationType]="relationType.filter"
[configuration]="relationType.configuration"
[searchEnabled]="searchEnabled"
[sideBarWidth]="sideBarWidth">
</ds-related-entities-search>
</div>

View File

@@ -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

View File

@@ -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
});
})
);
}

View File

@@ -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<FilteredSearchPageComponent>;
let searchConfigService: SearchConfigurationService;
beforeEach(async(() => {
configureSearchComponentTestingModule(FilteredSearchPageComponent);
}));
beforeEach(() => {
fixture = TestBed.createComponent(FilteredSearchPageComponent);
comp = fixture.componentInstance;
searchConfigService = (comp as any).searchConfigService;
fixture.detectChanges();
});
});

View File

@@ -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<PaginatedSearchOptions>}
*/
protected getSearchOptions(): Observable<PaginatedSearchOptions> {
return this.searchConfigService.paginatedSearchOptions.pipe(
map((options: PaginatedSearchOptions) => {
const filter = this.fixedFilterQuery || options.fixedFilter;
return Object.assign(options, { fixedFilter: filter });
})
);
}
}

View File

@@ -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
];

View File

@@ -37,7 +37,10 @@
</div>
<div class="mt-5 w-100">
<ds-tabbed-related-entities-search [item]="object"
[relationTypes]="['isJournalOfPublication']">
[relationTypes]="[{
label: 'isJournalOfPublication',
filter: 'isJournalOfPublication'
}]">
</ds-tabbed-related-entities-search>
</div>
</div>

View File

@@ -54,7 +54,10 @@
</div>
<div class="mt-5 w-100">
<ds-tabbed-related-entities-search [item]="object"
[relationTypes]="['isAuthorOfPublication']">
[relationTypes]="[{
label: 'isAuthorOfPublication',
filter: 'isAuthorOfPublication'
}]">
</ds-tabbed-related-entities-search>
</div>
</div>

View File

@@ -62,6 +62,9 @@
<h3 class="h2">{{"item.page.journal.search.title" | translate}}</h3>
</div>
<ds-tabbed-related-entities-search [item]="object"
[relationTypes]="['isJournalOfPublication']">
[relationTypes]="[{
label: 'isJournalOfPublication',
filter: 'isJournalOfPublication'
}]">
</ds-tabbed-related-entities-search>
</div>

View File

@@ -80,6 +80,9 @@
<h3 class="h2">{{"item.page.person.search.title" | translate}}</h3>
</div>
<ds-tabbed-related-entities-search [item]="object"
[relationTypes]="['isAuthorOfPublication']">
[relationTypes]="[{
label: 'isAuthorOfPublication',
filter: 'isAuthorOfPublication'
}]">
</ds-tabbed-related-entities-search>
</div>