-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional collection home page and descriptive collection content
fields
- Loading branch information
1 parent
ee7e835
commit 53ca700
Showing
6 changed files
with
206 additions
and
1 deletion.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/app/collection-page/collection-home/collection-home-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<div class="container"> | ||
<div class="collection-page" | ||
*ngVar="(collectionRD$ | async) as collectionRD"> | ||
<div *ngIf="collectionRD?.hasSucceeded" @fadeInOut> | ||
<div *ngIf="collectionRD?.payload as collection"> | ||
<ds-view-tracker [object]="collection"></ds-view-tracker> | ||
<div class="d-flex flex-row border-bottom mb-4 pb-4"> | ||
<header class="comcol-header mr-auto"> | ||
<!-- Collection Name --> | ||
<ds-comcol-page-header | ||
[name]="dsoNameService.getName(collection)"> | ||
</ds-comcol-page-header> | ||
<!-- Collection logo --> | ||
<ds-comcol-page-logo *ngIf="logoRD$" | ||
[logo]="(logoRD$ | async)?.payload" | ||
[alternateText]="'collection.logo' | translate"> | ||
</ds-comcol-page-logo> | ||
|
||
<!-- Handle --> | ||
<ds-comcol-page-handle | ||
[content]="collection.handle" | ||
[title]="'collection.page.handle'"> | ||
</ds-comcol-page-handle> | ||
<!-- Introductory text --> | ||
<ds-comcol-page-content | ||
[content]="collection.introductoryText" | ||
[hasInnerHtml]="true"> | ||
</ds-comcol-page-content> | ||
<!-- News --> | ||
<ds-comcol-page-content | ||
[content]="collection.sidebarText" | ||
[hasInnerHtml]="true" | ||
[title]="'collection.page.news'"> | ||
</ds-comcol-page-content> | ||
</header> | ||
<ds-dso-edit-menu></ds-dso-edit-menu> | ||
</div> | ||
<section class="comcol-page-browse-section"> | ||
<!-- Browse-By Links --> | ||
<ds-comcol-page-browse-by | ||
[id]="collection.id" | ||
[contentType]="collection.type"> | ||
</ds-comcol-page-browse-by> | ||
|
||
<router-outlet></router-outlet> | ||
</section> | ||
<footer *ngIf="collection.copyrightText" class="border-top my-5 pt-4"> | ||
<!-- Copyright --> | ||
<ds-comcol-page-content | ||
[content]="collection.copyrightText" | ||
[hasInnerHtml]="true"> | ||
</ds-comcol-page-content> | ||
</footer> | ||
</div> | ||
</div> | ||
<ds-error *ngIf="collectionRD?.hasFailed" | ||
message="{{'error.collection' | translate}}"></ds-error> | ||
<ds-loading *ngIf="collectionRD?.isLoading" | ||
message="{{'loading.collection' | translate}}"></ds-loading> | ||
</div> | ||
</div> |
Empty file.
133 changes: 133 additions & 0 deletions
133
src/app/collection-page/collection-home/collection-home-page.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import { | ||
AsyncPipe, | ||
NgIf, | ||
} from '@angular/common'; | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
OnInit, | ||
} from '@angular/core'; | ||
import { | ||
ActivatedRoute, | ||
Router, | ||
RouterOutlet, | ||
} from '@angular/router'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { Observable } from 'rxjs'; | ||
import { | ||
filter, | ||
map, | ||
mergeMap, | ||
take, | ||
} from 'rxjs/operators'; | ||
|
||
import { AuthService } from '../../core/auth/auth.service'; | ||
import { DSONameService } from '../../core/breadcrumbs/dso-name.service'; | ||
import { SortOptions } from '../../core/cache/models/sort-options.model'; | ||
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service'; | ||
import { FeatureID } from '../../core/data/feature-authorization/feature-id'; | ||
import { RemoteData } from '../../core/data/remote-data'; | ||
import { redirectOn4xx } from '../../core/shared/authorized.operators'; | ||
import { Bitstream } from '../../core/shared/bitstream.model'; | ||
import { Collection } from '../../core/shared/collection.model'; | ||
import { getAllSucceededRemoteDataPayload } from '../../core/shared/operators'; | ||
import { | ||
fadeIn, | ||
fadeInOut, | ||
} from '../../shared/animations/fade'; | ||
import { ThemedComcolPageBrowseByComponent } from '../../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component'; | ||
import { ThemedComcolPageContentComponent } from '../../shared/comcol/comcol-page-content/themed-comcol-page-content.component'; | ||
import { ThemedComcolPageHandleComponent } from '../../shared/comcol/comcol-page-handle/themed-comcol-page-handle.component'; | ||
import { ComcolPageHeaderComponent } from '../../shared/comcol/comcol-page-header/comcol-page-header.component'; | ||
import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component'; | ||
import { DsoEditMenuComponent } from '../../shared/dso-page/dso-edit-menu/dso-edit-menu.component'; | ||
import { | ||
hasValue, | ||
isNotEmpty, | ||
} from '../../shared/empty.util'; | ||
import { ErrorComponent } from '../../shared/error/error.component'; | ||
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component'; | ||
import { ObjectCollectionComponent } from '../../shared/object-collection/object-collection.component'; | ||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; | ||
import { VarDirective } from '../../shared/utils/var.directive'; | ||
import { ViewTrackerComponent } from '../../statistics/angulartics/dspace/view-tracker.component'; | ||
import { getCollectionPageRoute } from '../collection-page-routing-paths'; | ||
|
||
@Component({ | ||
selector: 'ds-base-collection-home-page', | ||
styleUrls: ['./collection--home-page.component.scss'], | ||
templateUrl: './collection-home-page.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
animations: [ | ||
fadeIn, | ||
fadeInOut, | ||
], | ||
imports: [ | ||
ThemedComcolPageContentComponent, | ||
ErrorComponent, | ||
NgIf, | ||
ThemedLoadingComponent, | ||
TranslateModule, | ||
ViewTrackerComponent, | ||
VarDirective, | ||
AsyncPipe, | ||
ComcolPageHeaderComponent, | ||
ComcolPageLogoComponent, | ||
ThemedComcolPageHandleComponent, | ||
DsoEditMenuComponent, | ||
ThemedComcolPageBrowseByComponent, | ||
ObjectCollectionComponent, | ||
RouterOutlet, | ||
], | ||
standalone: true, | ||
}) | ||
export class CollectionHomePageComponent implements OnInit { | ||
collectionRD$: Observable<RemoteData<Collection>>; | ||
logoRD$: Observable<RemoteData<Bitstream>>; | ||
paginationConfig: PaginationComponentOptions; | ||
sortConfig: SortOptions; | ||
|
||
/** | ||
* Whether the current user is a Community admin | ||
*/ | ||
isCollectionAdmin$: Observable<boolean>; | ||
|
||
/** | ||
* Route to the community page | ||
*/ | ||
collectionPageRoute$: Observable<string>; | ||
|
||
constructor( | ||
protected route: ActivatedRoute, | ||
protected router: Router, | ||
protected authService: AuthService, | ||
protected authorizationDataService: AuthorizationDataService, | ||
public dsoNameService: DSONameService, | ||
) { | ||
} | ||
|
||
ngOnInit(): void { | ||
this.collectionRD$ = this.route.data.pipe( | ||
map((data) => data.dso as RemoteData<Collection>), | ||
redirectOn4xx(this.router, this.authService), | ||
take(1), | ||
); | ||
this.logoRD$ = this.collectionRD$.pipe( | ||
map((rd: RemoteData<Collection>) => rd.payload), | ||
filter((collection: Collection) => hasValue(collection)), | ||
mergeMap((collection: Collection) => collection.logo), | ||
); | ||
this.isCollectionAdmin$ = this.authorizationDataService.isAuthorized(FeatureID.IsCollectionAdmin); | ||
|
||
this.collectionPageRoute$ = this.collectionRD$.pipe( | ||
getAllSucceededRemoteDataPayload(), | ||
map((collection) => getCollectionPageRoute(collection.id)), | ||
); | ||
} | ||
|
||
isNotEmpty(object: any) { | ||
return isNotEmpty(object); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/shared/object-list/collection-list-element/collection-list-element.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters