Skip to content

Commit 3bf4d73

Browse files
authored
Merge pull request #498 from TAMULib/470-export-section-people
470 export section people
2 parents acc12dd + 1edd38a commit 3bf4d73

File tree

4 files changed

+70
-5
lines changed

4 files changed

+70
-5
lines changed

src/app/+display/section/section.component.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
<div class="card-header font-weight-bold text-primary text-capitalize">
2-
<span>{{ section.name }}</span>
3-
<div class="float-right" *ngIf="section.shared">
2+
<div *ngIf="queryParams | async; let queryParams">
3+
<div class="container mt-2" >
4+
<div class="headers-row row flex-column-reverse flex-md-row">
5+
<div class="col-md-8">
6+
<span id="sidebar-title">{{ section.name }}</span>
7+
</div>
8+
<div class="col-md-4 text-right">
9+
<span *ngIf="hasExport(section)" class="column-export">
10+
<a [href]="getSectionExportUrl(queryParams, section)" download class="btn">
11+
<span class="fa fa-share" [attr.aria-hidden]="true"></span>
12+
<span>{{ 'DIRECTORY.EXPORT' | translate }}</span>
13+
</a>
14+
</span>
15+
</div>
16+
</div>
17+
</div>
18+
</div>
19+
<div class="float-right" *ngIf="section.shared">
420
<div class="embed-dropdown d-inline-block" placement="bottom-right" ngbDropdown>
521
<i class="fa fa-lg fa-share-alt" ngbDropdownToggle ></i>
622
<div class="dropdown-menu" ngbDropdownMenu>

src/app/+display/section/section.component.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
:host {
2+
width: 100%;
3+
.headers-row {
4+
.column-export {
5+
.btn {
6+
color: var(--sidebar-button-color);
7+
background-color: var(--sidebar-button-background-color);
8+
border: 1px solid var(--sidebar-button-border-color);
9+
font-size: 0.9em;
10+
padding: 5px 10px 4px;
11+
.fa {
12+
padding-right: 0.3em;
13+
}
14+
}
15+
.btn:active,
16+
.btn:hover {
17+
color: var(--sidebar-button-hover-color);
18+
background-color: var(--sidebar-button-hover-background-color);
19+
}
20+
.btn:focus {
21+
box-shadow: 0 0 0 0.2rem var(--sidebar-button-focus-shadow-color);
22+
}
23+
}
24+
}
225
.embed-dropdown {
326
.dropdown-menu {
427
min-width: 450px;

src/app/+display/section/section.component.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ import { AfterViewInit, Component, Inject, Input, OnDestroy, OnInit, PLATFORM_ID
22
import { ActivatedRoute, NavigationStart, Params, Router } from '@angular/router';
33
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
44
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
5+
import { Store, select } from '@ngrx/store';
56
import { filter, map } from 'rxjs/operators';
67

78
import { APP_CONFIG, AppConfig } from '../../app.config';
89
import { Individual } from '../../core/model/discovery';
910
import { SdrPage } from '../../core/model/sdr';
1011
import { DisplayTabSectionView, Sort } from '../../core/model/view';
11-
import { getResourcesPage, getSubsectionResources, loadBadges } from '../../shared/utilities/view.utility';
12+
import { AppState } from '../../core/store';
13+
import { selectRouterQueryParams } from '../../core/store/router';
14+
import { addExportToQueryParams, getResourcesPage, getSubsectionResources,hasExport, loadBadges } from '../../shared/utilities/view.utility';
1215

1316
@Component({
1417
selector: 'scholars-section',
@@ -34,9 +37,12 @@ export class SectionComponent implements AfterViewInit, OnInit, OnDestroy {
3437

3538
private subscriptions: Subscription[];
3639

40+
public queryParams: Observable<Params>;
41+
3742
constructor(
3843
@Inject(APP_CONFIG) private appConfig: AppConfig,
3944
@Inject(PLATFORM_ID) private platformId: string,
45+
private store: Store<AppState>,
4046
private router: Router,
4147
private route: ActivatedRoute
4248
) {
@@ -51,11 +57,13 @@ export class SectionComponent implements AfterViewInit, OnInit, OnDestroy {
5157
}
5258

5359
ngOnInit() {
60+
this.queryParams = this.store.pipe(select(selectRouterQueryParams));
5461
if (this.section.paginated) {
5562
this.subscriptions.push(
5663
this.router.events.pipe(filter((event) => event instanceof NavigationStart)).subscribe(() => loadBadges(this.platformId))
5764
);
5865
const resources = getSubsectionResources(this.individual[this.section.field], this.section.filters);
66+
5967
this.page = this.route.queryParams.pipe(
6068
map((params: Params) => {
6169
const pageSize = params[`${this.section.name}.size`] ? Number(params[`${this.section.name}.size`]) : this.section.pageSize;
@@ -92,4 +100,22 @@ export class SectionComponent implements AfterViewInit, OnInit, OnDestroy {
92100
setTimeout(() => tooltip.close(), 2000);
93101
}
94102

103+
public hasExport(section: DisplayTabSectionView): boolean {
104+
return hasExport(section);
105+
}
106+
107+
public getSectionExportUrl(params: Params, section: DisplayTabSectionView): string {
108+
const queryParams: Params = { ...params };
109+
queryParams.facets = null;
110+
queryParams.collection = null;
111+
addExportToQueryParams(queryParams, section);
112+
const tree = this.router.createUrlTree([''], { queryParams });
113+
const query = tree.toString().substring(1);
114+
if (!this.individual?.id) {
115+
return;
116+
}
117+
118+
return `${this.appConfig.serviceUrl}/individual/${this.individual.id}/export${query}&view=${section.field}`;
119+
}
120+
95121
}

src/app/core/model/view/display-view.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { View } from './';
1+
import { CollectionView, View } from './';
22
import { ExportView } from './export-view';
33
import { FieldView } from './field-view';
44

@@ -13,7 +13,7 @@ export interface DisplaySubsectionView extends FieldView {
1313
templateFunction?: (individual: any) => string;
1414
}
1515

16-
export interface DisplayTabSectionView extends FieldView {
16+
export interface DisplayTabSectionView extends FieldView, CollectionView {
1717
readonly hidden: boolean;
1818
readonly shared: boolean;
1919
readonly paginated: boolean;

0 commit comments

Comments
 (0)