forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomcol-search-section.component.ts
More file actions
66 lines (59 loc) · 1.87 KB
/
comcol-search-section.component.ts
File metadata and controls
66 lines (59 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { AsyncPipe } from '@angular/common';
import {
Component,
Inject,
OnInit,
} from '@angular/core';
import {
ActivatedRoute,
Data,
} from '@angular/router';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import {
APP_CONFIG,
AppConfig,
} from '../../../../../config/app-config.interface';
import { RemoteData } from '../../../../core/data/remote-data';
import { Collection } from '../../../../core/shared/collection.model';
import { Community } from '../../../../core/shared/community.model';
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-configuration.service';
import { hasValue } from '../../../empty.util';
import { ThemedSearchComponent } from '../../../search/themed-search.component';
/**
* The search tab on community & collection pages
*/
@Component({
selector: 'ds-comcol-search-section',
templateUrl: './comcol-search-section.component.html',
styleUrls: ['./comcol-search-section.component.scss'],
providers: [
{
provide: SEARCH_CONFIG_SERVICE,
useClass: SearchConfigurationService,
},
],
imports: [
ThemedSearchComponent,
AsyncPipe,
],
standalone: true,
})
export class ComcolSearchSectionComponent implements OnInit {
comcol$: Observable<Community | Collection>;
showSidebar$: Observable<boolean>;
constructor(
@Inject(APP_CONFIG) public appConfig: AppConfig,
protected route: ActivatedRoute,
) {
}
ngOnInit(): void {
this.comcol$ = this.route.parent.data.pipe(
map((data: Data) => (data.dso as RemoteData<Community | Collection>).payload),
);
this.showSidebar$ = this.comcol$.pipe(
map((comcol: Community | Collection) => hasValue(comcol) && this.appConfig[comcol.type as any].searchSection.showSidebar),
);
}
}