mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
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:
@@ -1,6 +1,7 @@
|
|||||||
<ds-filtered-search-page
|
<ds-configuration-search-page
|
||||||
[fixedFilterQuery]="fixedFilter"
|
[fixedFilterQuery]="fixedFilter"
|
||||||
|
[configuration]="configuration"
|
||||||
[configuration$]="configuration$"
|
[configuration$]="configuration$"
|
||||||
[searchEnabled]="searchEnabled"
|
[searchEnabled]="searchEnabled"
|
||||||
[sideBarWidth]="sideBarWidth">
|
[sideBarWidth]="sideBarWidth">
|
||||||
</ds-filtered-search-page>
|
</ds-configuration-search-page>
|
||||||
|
@@ -22,18 +22,16 @@ export class RelatedEntitiesSearchComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
@Input() relationType: string;
|
@Input() relationType: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional configuration to use for the search options
|
||||||
|
*/
|
||||||
|
@Input() configuration: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The item to render relationships for
|
* The item to render relationships for
|
||||||
*/
|
*/
|
||||||
@Input() item: Item;
|
@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)
|
* Whether or not the search bar and title should be displayed (defaults to true)
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@@ -56,8 +54,8 @@ export class RelatedEntitiesSearchComponent implements OnInit {
|
|||||||
if (isNotEmpty(this.relationType) && isNotEmpty(this.item)) {
|
if (isNotEmpty(this.relationType) && isNotEmpty(this.item)) {
|
||||||
this.fixedFilter = this.fixedFilterService.getFilterByRelation(this.relationType, this.item.id);
|
this.fixedFilter = this.fixedFilterService.getFilterByRelation(this.relationType, this.item.id);
|
||||||
}
|
}
|
||||||
if (isNotEmpty(this.relationEntityType)) {
|
if (isNotEmpty(this.configuration)) {
|
||||||
this.configuration$ = of(this.relationEntityType);
|
this.configuration$ = of(this.configuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
<ngb-tabset [destroyOnHide]="true" #tabs="ngbTabset">
|
<ngb-tabset *ngIf="relationTypes.length > 1" [destroyOnHide]="true" #tabs="ngbTabset">
|
||||||
<ngb-tab *ngFor="let relationType of relationTypes" title="{{'item.page.relationships.' + relationType | translate}}">
|
<ngb-tab *ngFor="let relationType of relationTypes" title="{{'item.page.relationships.' + relationType.label | translate}}">
|
||||||
<ng-template ngbTabContent>
|
<ng-template ngbTabContent>
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<ds-related-entities-search [item]="item"
|
<ds-related-entities-search [item]="item"
|
||||||
[relationType]="relationType"
|
[relationType]="relationType.filter"
|
||||||
|
[configuration]="relationType.configuration"
|
||||||
[searchEnabled]="searchEnabled"
|
[searchEnabled]="searchEnabled"
|
||||||
[sideBarWidth]="sideBarWidth">
|
[sideBarWidth]="sideBarWidth">
|
||||||
</ds-related-entities-search>
|
</ds-related-entities-search>
|
||||||
@@ -11,3 +12,11 @@
|
|||||||
</ng-template>
|
</ng-template>
|
||||||
</ngb-tab>
|
</ngb-tab>
|
||||||
</ngb-tabset>
|
</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>
|
||||||
|
@@ -15,7 +15,11 @@ export class TabbedRelatedEntitiesSearchComponent {
|
|||||||
* The types of relationships to fetch items for
|
* The types of relationships to fetch items for
|
||||||
* e.g. 'isAuthorOfPublication'
|
* e.g. 'isAuthorOfPublication'
|
||||||
*/
|
*/
|
||||||
@Input() relationTypes: string[];
|
@Input() relationTypes: Array<{
|
||||||
|
label: string,
|
||||||
|
filter: string,
|
||||||
|
configuration?: string
|
||||||
|
}>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The item to render relationships for
|
* The item to render relationships for
|
||||||
|
@@ -35,6 +35,12 @@ export class ConfigurationSearchPageComponent extends SearchPageComponent implem
|
|||||||
*/
|
*/
|
||||||
@Input() configuration: string;
|
@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,
|
constructor(protected service: SearchService,
|
||||||
protected sidebarService: SearchSidebarService,
|
protected sidebarService: SearchSidebarService,
|
||||||
protected windowService: HostWindowService,
|
protected windowService: HostWindowService,
|
||||||
@@ -64,7 +70,11 @@ export class ConfigurationSearchPageComponent extends SearchPageComponent implem
|
|||||||
return this.searchConfigService.paginatedSearchOptions.pipe(
|
return this.searchConfigService.paginatedSearchOptions.pipe(
|
||||||
map((options: PaginatedSearchOptions) => {
|
map((options: PaginatedSearchOptions) => {
|
||||||
const config = this.configuration || options.configuration;
|
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
|
||||||
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -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();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -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 });
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -32,7 +32,6 @@ import { SearchAuthorityFilterComponent } from './search-filters/search-filter/s
|
|||||||
import { SearchLabelComponent } from './search-labels/search-label/search-label.component';
|
import { SearchLabelComponent } from './search-labels/search-label/search-label.component';
|
||||||
import { ConfigurationSearchPageComponent } from './configuration-search-page.component';
|
import { ConfigurationSearchPageComponent } from './configuration-search-page.component';
|
||||||
import { ConfigurationSearchPageGuard } from './configuration-search-page.guard';
|
import { ConfigurationSearchPageGuard } from './configuration-search-page.guard';
|
||||||
import { FilteredSearchPageComponent } from './filtered-search-page.component';
|
|
||||||
|
|
||||||
const effects = [
|
const effects = [
|
||||||
SearchSidebarEffects
|
SearchSidebarEffects
|
||||||
@@ -59,7 +58,6 @@ const components = [
|
|||||||
SearchFacetRangeOptionComponent,
|
SearchFacetRangeOptionComponent,
|
||||||
SearchSwitchConfigurationComponent,
|
SearchSwitchConfigurationComponent,
|
||||||
SearchAuthorityFilterComponent,
|
SearchAuthorityFilterComponent,
|
||||||
FilteredSearchPageComponent,
|
|
||||||
ConfigurationSearchPageComponent
|
ConfigurationSearchPageComponent
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -37,7 +37,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-5 w-100">
|
<div class="mt-5 w-100">
|
||||||
<ds-tabbed-related-entities-search [item]="object"
|
<ds-tabbed-related-entities-search [item]="object"
|
||||||
[relationTypes]="['isJournalOfPublication']">
|
[relationTypes]="[{
|
||||||
|
label: 'isJournalOfPublication',
|
||||||
|
filter: 'isJournalOfPublication'
|
||||||
|
}]">
|
||||||
</ds-tabbed-related-entities-search>
|
</ds-tabbed-related-entities-search>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -54,7 +54,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-5 w-100">
|
<div class="mt-5 w-100">
|
||||||
<ds-tabbed-related-entities-search [item]="object"
|
<ds-tabbed-related-entities-search [item]="object"
|
||||||
[relationTypes]="['isAuthorOfPublication']">
|
[relationTypes]="[{
|
||||||
|
label: 'isAuthorOfPublication',
|
||||||
|
filter: 'isAuthorOfPublication'
|
||||||
|
}]">
|
||||||
</ds-tabbed-related-entities-search>
|
</ds-tabbed-related-entities-search>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -62,6 +62,9 @@
|
|||||||
<h3 class="h2">{{"item.page.journal.search.title" | translate}}</h3>
|
<h3 class="h2">{{"item.page.journal.search.title" | translate}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<ds-tabbed-related-entities-search [item]="object"
|
<ds-tabbed-related-entities-search [item]="object"
|
||||||
[relationTypes]="['isJournalOfPublication']">
|
[relationTypes]="[{
|
||||||
|
label: 'isJournalOfPublication',
|
||||||
|
filter: 'isJournalOfPublication'
|
||||||
|
}]">
|
||||||
</ds-tabbed-related-entities-search>
|
</ds-tabbed-related-entities-search>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -80,6 +80,9 @@
|
|||||||
<h3 class="h2">{{"item.page.person.search.title" | translate}}</h3>
|
<h3 class="h2">{{"item.page.person.search.title" | translate}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<ds-tabbed-related-entities-search [item]="object"
|
<ds-tabbed-related-entities-search [item]="object"
|
||||||
[relationTypes]="['isAuthorOfPublication']">
|
[relationTypes]="[{
|
||||||
|
label: 'isAuthorOfPublication',
|
||||||
|
filter: 'isAuthorOfPublication'
|
||||||
|
}]">
|
||||||
</ds-tabbed-related-entities-search>
|
</ds-tabbed-related-entities-search>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user