1
0

added TypeDoc

This commit is contained in:
lotte
2019-10-16 11:21:25 +02:00
parent 7ca88021c9
commit d962e40c58
84 changed files with 479 additions and 93 deletions

View File

@@ -10,7 +10,7 @@ import { ItemPageFieldComponent } from '../item-page-field.component';
/** /**
* This component can be used to represent metadata on a simple item page. * This component can be used to represent metadata on a simple item page.
* It is the most generic way of displaying metadata values * It is the most generic way of displaying metadata values
* It expects 4 parameters: The item, a seperator, the metadata keys and an i18n key * It expects 4 parameters: The item, a separator, the metadata keys and an i18n key
*/ */
export class GenericItemPageFieldComponent extends ItemPageFieldComponent { export class GenericItemPageFieldComponent extends ItemPageFieldComponent {

View File

@@ -1,19 +1,16 @@
import { map } from 'rxjs/operators';
import { mergeMap, filter, map, take, tap } from 'rxjs/operators';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ItemDataService } from '../../core/data/item-data.service'; import { ItemDataService } from '../../core/data/item-data.service';
import { RemoteData } from '../../core/data/remote-data'; import { RemoteData } from '../../core/data/remote-data';
import { Bitstream } from '../../core/shared/bitstream.model';
import { Item } from '../../core/shared/item.model'; import { Item } from '../../core/shared/item.model';
import { MetadataService } from '../../core/metadata/metadata.service'; import { MetadataService } from '../../core/metadata/metadata.service';
import { fadeInOut } from '../../shared/animations/fade'; import { fadeInOut } from '../../shared/animations/fade';
import { hasValue } from '../../shared/empty.util';
import { redirectToPageNotFoundOn404 } from '../../core/shared/operators'; import { redirectToPageNotFoundOn404 } from '../../core/shared/operators';
import { ViewMode } from '../../core/shared/view-mode.model'; import { ViewMode } from '../../core/shared/view-mode.model';
@@ -53,6 +50,9 @@ export class ItemPageComponent implements OnInit {
private metadataService: MetadataService, private metadataService: MetadataService,
) { } ) { }
/**
* Initialize instance variables
*/
ngOnInit(): void { ngOnInit(): void {
this.itemRD$ = this.route.data.pipe( this.itemRD$ = this.route.data.pipe(
map((data) => data.item as RemoteData<Item>), map((data) => data.item as RemoteData<Item>),

View File

@@ -7,6 +7,10 @@ import { getRelatedItemsByTypeLabel } from '../shared/item-relationships-utils';
import { ViewMode } from '../../../../core/shared/view-mode.model'; import { ViewMode } from '../../../../core/shared/view-mode.model';
import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator';
/**
* Component that represents a publication Item page
*/
@listableObjectComponent('Publication', ViewMode.StandalonePage) @listableObjectComponent('Publication', ViewMode.StandalonePage)
@listableObjectComponent(Item, ViewMode.StandalonePage) @listableObjectComponent(Item, ViewMode.StandalonePage)
@Component({ @Component({
@@ -36,6 +40,9 @@ export class PublicationComponent extends ItemComponent implements OnInit {
*/ */
journalIssues$: Observable<Item[]>; journalIssues$: Observable<Item[]>;
/**
* Initialize instance variables
*/
ngOnInit(): void { ngOnInit(): void {
super.ngOnInit(); super.ngOnInit();

View File

@@ -1,6 +1,5 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model'; import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model';
import { ViewMode } from '../../../core/shared/view-mode.model';
@Component({ @Component({
selector: 'ds-metadata-representation-list', selector: 'ds-metadata-representation-list',

View File

@@ -25,6 +25,9 @@ import { SearchResult } from '../../+search-page/search-result.model';
templateUrl: './my-dspace-new-submission.component.html' templateUrl: './my-dspace-new-submission.component.html'
}) })
export class MyDSpaceNewSubmissionComponent implements OnDestroy, OnInit { export class MyDSpaceNewSubmissionComponent implements OnDestroy, OnInit {
/**
* Output that emits the workspace item when the upload has completed
*/
@Output() uploadEnd = new EventEmitter<Array<SearchResult<DSpaceObject>>>(); @Output() uploadEnd = new EventEmitter<Array<SearchResult<DSpaceObject>>>();
/** /**

View File

@@ -43,8 +43,6 @@ const components = [
SearchResultsComponent, SearchResultsComponent,
SearchSidebarComponent, SearchSidebarComponent,
SearchSettingsComponent, SearchSettingsComponent,
CollectionSearchResultGridElementComponent,
CommunitySearchResultGridElementComponent,
SearchFiltersComponent, SearchFiltersComponent,
SearchFilterComponent, SearchFilterComponent,
SearchFacetFilterComponent, SearchFacetFilterComponent,
@@ -83,8 +81,6 @@ const components = [
SearchConfigurationService SearchConfigurationService
], ],
entryComponents: [ entryComponents: [
CollectionSearchResultGridElementComponent,
CommunitySearchResultGridElementComponent,
SearchFacetFilterComponent, SearchFacetFilterComponent,
SearchRangeFilterComponent, SearchRangeFilterComponent,
SearchTextFilterComponent, SearchTextFilterComponent,

View File

@@ -17,6 +17,9 @@ export class SearchResult<T extends DSpaceObject> implements ListableObject {
*/ */
hitHighlights: MetadataMap; hitHighlights: MetadataMap;
/**
* Method that returns as which type of object this object should be rendered
*/
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> { getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
return [this.constructor as GenericConstructor<ListableObject>]; return [this.constructor as GenericConstructor<ListableObject>];
} }

View File

@@ -25,6 +25,9 @@ import { CollectionElementLinkType } from '../../shared/object-collection/collec
export class SearchResultsComponent { export class SearchResultsComponent {
hasNoValue = hasNoValue; hasNoValue = hasNoValue;
/**
* The link type of the listed search results
*/
@Input() linkType: CollectionElementLinkType; @Input() linkType: CollectionElementLinkType;
/** /**

View File

@@ -18,7 +18,6 @@ export function searchResultFor(domainConstructor: GenericConstructor<ListableOb
return; return;
} }
searchResultMap.set(domainConstructor, searchResult); searchResultMap.set(domainConstructor, searchResult);
}; };
} }

View File

@@ -1,7 +1,6 @@
import { autoserialize, deserialize, inheritSerialization } from 'cerialize'; import { autoserialize, deserialize, inheritSerialization } from 'cerialize';
import { CacheableObject } from '../../cache/object-cache.reducer'; import { CacheableObject } from '../../cache/object-cache.reducer';
import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model';
import { NormalizedDSpaceObject } from '../../cache/models/normalized-dspace-object.model'; import { NormalizedDSpaceObject } from '../../cache/models/normalized-dspace-object.model';
import { EPerson } from './eperson.model'; import { EPerson } from './eperson.model';
import { mapsTo, relationship } from '../../cache/builders/build-decorators'; import { mapsTo, relationship } from '../../cache/builders/build-decorators';

View File

@@ -1,7 +1,6 @@
import { autoserialize, deserialize, inheritSerialization } from 'cerialize'; import { autoserialize, deserialize, inheritSerialization } from 'cerialize';
import { CacheableObject } from '../../cache/object-cache.reducer'; import { CacheableObject } from '../../cache/object-cache.reducer';
import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model';
import { NormalizedDSpaceObject } from '../../cache/models/normalized-dspace-object.model'; import { NormalizedDSpaceObject } from '../../cache/models/normalized-dspace-object.model';
import { mapsTo, relationship } from '../../cache/builders/build-decorators'; import { mapsTo, relationship } from '../../cache/builders/build-decorators';
import { Group } from './group.model'; import { Group } from './group.model';

View File

@@ -52,6 +52,9 @@ export class MetadataField implements ListableObject {
return key; return key;
} }
/**
* Method that returns as which type of object this object should be rendered
*/
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> { getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
return [this.constructor as GenericConstructor<ListableObject>]; return [this.constructor as GenericConstructor<ListableObject>];
} }

View File

@@ -28,6 +28,9 @@ export class MetadataSchema implements ListableObject {
*/ */
namespace: string; namespace: string;
/**
* Method that returns as which type of object this object should be rendered
*/
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> { getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
return [this.constructor as GenericConstructor<ListableObject>]; return [this.constructor as GenericConstructor<ListableObject>];
} }

View File

@@ -30,6 +30,9 @@ export class BrowseEntry implements ListableObject {
*/ */
count: number; count: number;
/**
* Method that returns as which type of object this object should be rendered
*/
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> { getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
return [this.constructor as GenericConstructor<ListableObject>]; return [this.constructor as GenericConstructor<ListableObject>];
} }

View File

@@ -110,7 +110,7 @@ export class DSpaceObject implements CacheableObject, ListableObject {
* Like [[firstMetadata]], but only returns a string value, or `undefined`. * Like [[firstMetadata]], but only returns a string value, or `undefined`.
* *
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]]. * @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
* @param {MetadataValueFilter} filter The value filter to use. If unspecified, no filtering will be done. * @param {MetadataValueFilter} valueFilter The value filter to use. If unspecified, no filtering will be done.
* @returns {string} the first matching string value, or `undefined`. * @returns {string} the first matching string value, or `undefined`.
*/ */
firstMetadataValue(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter): string { firstMetadataValue(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter): string {
@@ -147,6 +147,9 @@ export class DSpaceObject implements CacheableObject, ListableObject {
}); });
} }
/**
* Method that returns as which type of object this object should be rendered
*/
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> { getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
return [this.constructor as GenericConstructor<ListableObject>]; return [this.constructor as GenericConstructor<ListableObject>];
} }

View File

@@ -14,6 +14,9 @@ import { GenericConstructor } from './generic-constructor';
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
import { DEFAULT_ENTITY_TYPE } from '../../shared/metadata-representation/metadata-representation.decorator'; import { DEFAULT_ENTITY_TYPE } from '../../shared/metadata-representation/metadata-representation.decorator';
/**
* Class representing a DSpace Item
*/
export class Item extends DSpaceObject { export class Item extends DSpaceObject {
static type = new ResourceType('item'); static type = new ResourceType('item');
@@ -113,6 +116,9 @@ export class Item extends DSpaceObject {
})); }));
} }
/**
* Method that returns as which type of object this object should be rendered
*/
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> { getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
let entityType = this.firstMetadataValue('relationship.type'); let entityType = this.firstMetadataValue('relationship.type');
if (isEmpty(entityType)) { if (isEmpty(entityType)) {

View File

@@ -1,5 +1,4 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { focusShadow } from '../../../../shared/animations/focus';
import { ViewMode } from '../../../../core/shared/view-mode.model'; import { ViewMode } from '../../../../core/shared/view-mode.model';
import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator';
import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component';

View File

@@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model';
animations: [focusShadow] animations: [focusShadow]
}) })
/** /**
* The component for displaying a grid element for an item of the type Journal Issue * The component for displaying a grid element for an item search result of the type Journal Issue
*/ */
export class JournalIssueSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> { export class JournalIssueSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -14,7 +14,7 @@ import { focusShadow } from '../../../../../shared/animations/focus';
animations: [focusShadow] animations: [focusShadow]
}) })
/** /**
* The component for displaying a grid element for an item of the type Journal Volume * The component for displaying a grid element for an item search result of the type Journal Volume
*/ */
export class JournalVolumeSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> { export class JournalVolumeSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model';
animations: [focusShadow] animations: [focusShadow]
}) })
/** /**
* The component for displaying a grid element for an item of the type Journal * The component for displaying a grid element for an item search result of the type Journal
*/ */
export class JournalSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> { export class JournalSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -12,7 +12,7 @@ import { Item } from '../../../../../core/shared/item.model';
templateUrl: './journal-issue-search-result-list-element.component.html' templateUrl: './journal-issue-search-result-list-element.component.html'
}) })
/** /**
* The component for displaying a list element for an item of the type Journal Issue * The component for displaying a list element for an item search result of the type Journal Issue
*/ */
export class JournalIssueSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> { export class JournalIssueSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -12,7 +12,7 @@ import { ViewMode } from '../../../../../core/shared/view-mode.model';
templateUrl: './journal-volume-search-result-list-element.component.html' templateUrl: './journal-volume-search-result-list-element.component.html'
}) })
/** /**
* The component for displaying a list element for an item of the type Journal Volume * The component for displaying a list element for an item search result of the type Journal Volume
*/ */
export class JournalVolumeSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> { export class JournalVolumeSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -12,7 +12,7 @@ import { ViewMode } from '../../../../../core/shared/view-mode.model';
templateUrl: './journal-search-result-list-element.component.html' templateUrl: './journal-search-result-list-element.component.html'
}) })
/** /**
* The component for displaying a list element for an item of the type Journal * The component for displaying a list element for an item search result of the type Journal
*/ */
export class JournalSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> { export class JournalSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -27,6 +27,9 @@ export class JournalIssueComponent extends ItemComponent {
*/ */
publications$: Observable<Item[]>; publications$: Observable<Item[]>;
/**
* Initialize the instance variables
*/
ngOnInit(): void { ngOnInit(): void {
super.ngOnInit(); super.ngOnInit();

View File

@@ -27,6 +27,9 @@ export class JournalVolumeComponent extends ItemComponent {
*/ */
issues$: Observable<Item[]>; issues$: Observable<Item[]>;
/**
* Initialize the instance variables
*/
ngOnInit(): void { ngOnInit(): void {
super.ngOnInit(); super.ngOnInit();

View File

@@ -22,6 +22,9 @@ export class JournalComponent extends ItemComponent {
*/ */
volumes$: Observable<Item[]>; volumes$: Observable<Item[]>;
/**
* Initialize the instance variables
*/
ngOnInit(): void { ngOnInit(): void {
super.ngOnInit(); super.ngOnInit();

View File

@@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model';
animations: [focusShadow] animations: [focusShadow]
}) })
/** /**
* The component for displaying a grid element for an item of the type Organisation Unit * The component for displaying a grid element for an item search result of the type Organisation Unit
*/ */
export class OrgunitSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> { export class OrgunitSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model';
animations: [focusShadow] animations: [focusShadow]
}) })
/** /**
* The component for displaying a grid element for an item of the type Person * The component for displaying a grid element for an item search result of the type Person
*/ */
export class PersonSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> { export class PersonSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -14,7 +14,7 @@ import { focusShadow } from '../../../../../shared/animations/focus';
animations: [focusShadow] animations: [focusShadow]
}) })
/** /**
* The component for displaying a grid element for an item of the type Project * The component for displaying a grid element for an item search result of the type Project
*/ */
export class ProjectSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> { export class ProjectSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -9,7 +9,7 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep
templateUrl: './orgunit-item-page-list-element.component.html' templateUrl: './orgunit-item-page-list-element.component.html'
}) })
/** /**
* The component for displaying a list element for an item of the type OrgUnit * The component for displaying an item of the type OrgUnit as a metadata field
*/ */
export class OrgunitItemPageListElementComponent { export class OrgunitItemPageListElementComponent {
metadataRepresentation: ItemMetadataRepresentation; metadataRepresentation: ItemMetadataRepresentation;

View File

@@ -12,8 +12,8 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep
templateUrl: './person-item-page-list-element.component.html' templateUrl: './person-item-page-list-element.component.html'
}) })
/** /**
* The component for displaying a list element for an item of the type Person * The component for displaying an item of the type Person as a metadata field
*/ */
export class PersonItemPageListElementComponent { export class PersonItemPageListElementComponent {
metadataRepresentation: ItemMetadataRepresentation; metadataRepresentation: ItemMetadataRepresentation;
} }

View File

@@ -12,7 +12,7 @@ import { Item } from '../../../../../core/shared/item.model';
templateUrl: './orgunit-search-result-list-element.component.html' templateUrl: './orgunit-search-result-list-element.component.html'
}) })
/** /**
* The component for displaying a list element for an item of the type Organisation Unit * The component for displaying a list element for an item search result of the type Organisation Unit
*/ */
export class OrgunitSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> { export class OrgunitSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -12,7 +12,7 @@ import { Item } from '../../../../../core/shared/item.model';
templateUrl: './person-search-result-list-element.component.html' templateUrl: './person-search-result-list-element.component.html'
}) })
/** /**
* The component for displaying a list element for an item of the type Person * The component for displaying a list element for an item search result of the type Person
*/ */
export class PersonSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> { export class PersonSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -12,7 +12,7 @@ import { ViewMode } from '../../../../../core/shared/view-mode.model';
templateUrl: './project-search-result-list-element.component.html' templateUrl: './project-search-result-list-element.component.html'
}) })
/** /**
* The component for displaying a list element for an item of the type Project * The component for displaying a list element for an item search result of the type Project
*/ */
export class ProjectSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> { export class ProjectSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -32,6 +32,9 @@ import { ViewMode } from '../../../core/shared/view-mode.model';
* The user can search the list by using the input field * The user can search the list by using the input field
*/ */
export class DSOSelectorComponent implements OnInit { export class DSOSelectorComponent implements OnInit {
/**
* The view mode of the listed objects
*/
viewMode = ViewMode.ListElement; viewMode = ViewMode.ListElement;
/** /**
* The initially selected DSO's uuid * The initially selected DSO's uuid

View File

@@ -24,8 +24,16 @@ import { CollectionElementLinkType } from '../../object-collection/collection-el
* Component representing a form with a autocomplete functionality for DSpaceObjects * Component representing a form with a autocomplete functionality for DSpaceObjects
*/ */
export class DsoInputSuggestionsComponent extends InputSuggestionsComponent { export class DsoInputSuggestionsComponent extends InputSuggestionsComponent {
/**
* The view mode of the listed object suggestions
*/
viewMode = ViewMode.ListElement; viewMode = ViewMode.ListElement;
/**
* The available link types
*/
linkTypes = CollectionElementLinkType; linkTypes = CollectionElementLinkType;
/** /**
* The suggestions that should be shown * The suggestions that should be shown
*/ */

View File

@@ -12,19 +12,30 @@ import { MetadataRepresentationDirective } from './metadata-representation.direc
templateUrl: './metadata-representation-loader.component.html' templateUrl: './metadata-representation-loader.component.html'
}) })
/** /**
* Component for determining what component to use depending on the item's relationship type (relationship.type) * Component for determining what component to use depending on the item's relationship type (relationship.type), its metadata representation and, optionally, its context
*/ */
export class MetadataRepresentationLoaderComponent implements OnInit { export class MetadataRepresentationLoaderComponent implements OnInit {
/** /**
* The item or metadata to determine the component for * The item or metadata to determine the component for
*/ */
@Input() mdRepresentation: MetadataRepresentation; @Input() mdRepresentation: MetadataRepresentation;
/**
* The optional context
*/
@Input() context: Context; @Input() context: Context;
/**
* Directive to determine where the dynamic child component is located
*/
@ViewChild(MetadataRepresentationDirective) mdRepDirective: MetadataRepresentationDirective; @ViewChild(MetadataRepresentationDirective) mdRepDirective: MetadataRepresentationDirective;
constructor(private componentFactoryResolver: ComponentFactoryResolver) { constructor(private componentFactoryResolver: ComponentFactoryResolver) {
} }
/**
* Set up the dynamic child component
*/
ngOnInit(): void { ngOnInit(): void {
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent()); const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent());
@@ -36,7 +47,7 @@ export class MetadataRepresentationLoaderComponent implements OnInit {
} }
/** /**
* Fetch the component depending on the item's relationship type * Fetch the component depending on the item's relationship type, metadata representation type and context
* @returns {string} * @returns {string}
*/ */
private getComponent(): GenericConstructor<MetadataRepresentationListElementComponent> { private getComponent(): GenericConstructor<MetadataRepresentationListElementComponent> {

View File

@@ -8,6 +8,13 @@ export const DEFAULT_ENTITY_TYPE = 'Publication';
export const DEFAULT_REPRESENTATION_TYPE = MetadataRepresentationType.PlainText; export const DEFAULT_REPRESENTATION_TYPE = MetadataRepresentationType.PlainText;
export const DEFAULT_CONTEXT = Context.Undefined; export const DEFAULT_CONTEXT = Context.Undefined;
/**
* Decorator function to store metadata representation mapping
* @param entityType The entity type the component represents
* @param mdRepresentationType The metadata representation type the component represents
* @param context The optional context the component represents
*/
export function metadataRepresentationComponent(entityType: string, mdRepresentationType: MetadataRepresentationType, context: Context = DEFAULT_CONTEXT) { export function metadataRepresentationComponent(entityType: string, mdRepresentationType: MetadataRepresentationType, context: Context = DEFAULT_CONTEXT) {
return function decorator(component: any) { return function decorator(component: any) {
if (hasNoValue(map.get(entityType))) { if (hasNoValue(map.get(entityType))) {
@@ -24,6 +31,12 @@ export function metadataRepresentationComponent(entityType: string, mdRepresenta
} }
} }
/**
* Getter to retrieve a matching component by entity type, metadata representation and context
* @param entityType The entity type to match
* @param mdRepresentationType The metadata representation to match
* @param context The context to match
*/
export function getMetadataRepresentationComponent(entityType: string, mdRepresentationType: MetadataRepresentationType, context: Context = DEFAULT_CONTEXT) { export function getMetadataRepresentationComponent(entityType: string, mdRepresentationType: MetadataRepresentationType, context: Context = DEFAULT_CONTEXT) {
const mapForEntity = map.get(entityType); const mapForEntity = map.get(entityType);
if (hasValue(mapForEntity)) { if (hasValue(mapForEntity)) {

View File

@@ -3,6 +3,9 @@ import { Directive, ViewContainerRef } from '@angular/core';
@Directive({ @Directive({
selector: '[dsMetadataRepresentation]', selector: '[dsMetadataRepresentation]',
}) })
/**
* Directive used as a hook to know where to inject the dynamic metadata representation component
*/
export class MetadataRepresentationDirective { export class MetadataRepresentationDirective {
constructor(public viewContainerRef: ViewContainerRef) { } constructor(public viewContainerRef: ViewContainerRef) { }
} }

View File

@@ -1,3 +1,9 @@
/**
* Enumeration used to render links in listable elements
* None: Don't render the link as a link, but as plain text
* Link: Render the link as a simple link
* ExternalLink: Render the link as a link that opens in a new tab
*/
export enum CollectionElementLinkType { export enum CollectionElementLinkType {
None, Link, ExternalLink None, Link, ExternalLink
} }

View File

@@ -15,21 +15,55 @@ import { CollectionElementLinkType } from './collection-element-link.type';
import { PaginatedList } from '../../core/data/paginated-list'; import { PaginatedList } from '../../core/data/paginated-list';
import { Context } from '../../core/shared/context.model'; import { Context } from '../../core/shared/context.model';
/**
* Component that can render a list of listable objects in different view modes
*/
@Component({ @Component({
selector: 'ds-viewable-collection', selector: 'ds-viewable-collection',
styleUrls: ['./object-collection.component.scss'], styleUrls: ['./object-collection.component.scss'],
templateUrl: './object-collection.component.html', templateUrl: './object-collection.component.html',
}) })
export class ObjectCollectionComponent implements OnInit { export class ObjectCollectionComponent implements OnInit {
/**
* The list of listable objects to render in this component
*/
@Input() objects: RemoteData<PaginatedList<ListableObject>>; @Input() objects: RemoteData<PaginatedList<ListableObject>>;
/**
* The current pagination configuration
*/
@Input() config?: PaginationComponentOptions; @Input() config?: PaginationComponentOptions;
/**
* The current sorting configuration
*/
@Input() sortConfig: SortOptions; @Input() sortConfig: SortOptions;
/**
* Whether or not the list elements have a border or not
*/
@Input() hasBorder = false; @Input() hasBorder = false;
/**
* Whether or not to hide the gear to change the sort and pagination configuration
*/
@Input() hideGear = false; @Input() hideGear = false;
/**
* The link type of the rendered list elements
*/
@Input() linkType: CollectionElementLinkType; @Input() linkType: CollectionElementLinkType;
/**
* The context of the rendered list elements
*/
@Input() context: Context; @Input() context: Context;
/**
* the page info of the list
*/
pageInfo: Observable<PageInfo>; pageInfo: Observable<PageInfo>;
/** /**
* An event fired when the page is changed. * An event fired when the page is changed.
* Event's payload equals to the newly selected page. * Event's payload equals to the newly selected page.
@@ -48,6 +82,9 @@ export class ObjectCollectionComponent implements OnInit {
*/ */
@Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter<SortDirection>(); @Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter<SortDirection>();
/**
* An event fired one of the pagination parameters is changed
*/
@Output() paginationChange: EventEmitter<SortDirection> = new EventEmitter<any>(); @Output() paginationChange: EventEmitter<SortDirection> = new EventEmitter<any>();
/** /**
@@ -55,8 +92,15 @@ export class ObjectCollectionComponent implements OnInit {
* Event's payload equals to the newly selected sort field. * Event's payload equals to the newly selected sort field.
*/ */
@Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>(); @Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>();
data: any = {};
/**
* Emits the current view mode
*/
currentMode$: Observable<ViewMode>; currentMode$: Observable<ViewMode>;
/**
* The available view modes
*/
viewModeEnum = ViewMode; viewModeEnum = ViewMode;
ngOnInit(): void { ngOnInit(): void {
@@ -83,22 +127,39 @@ export class ObjectCollectionComponent implements OnInit {
private router: Router) { private router: Router) {
} }
/**
* Updates the page
* @param event The new page number
*/
onPageChange(event) { onPageChange(event) {
this.pageChange.emit(event); this.pageChange.emit(event);
} }
/**
* Updates the page size
* @param event The new page size
*/
onPageSizeChange(event) { onPageSizeChange(event) {
this.pageSizeChange.emit(event); this.pageSizeChange.emit(event);
} }
/**
* Updates the sort direction
* @param event The new sort direction
*/
onSortDirectionChange(event) { onSortDirectionChange(event) {
this.sortDirectionChange.emit(event); this.sortDirectionChange.emit(event);
} }
/**
* Updates the sort field
* @param event The new sort field
*/
onSortFieldChange(event) { onSortFieldChange(event) {
this.sortFieldChange.emit(event); this.sortFieldChange.emit(event);
} }
/**
* Updates the pagination
* @param event The new pagination
*/
onPaginationChange(event) { onPaginationChange(event) {
this.paginationChange.emit(event); this.paginationChange.emit(event);
} }

View File

@@ -1,6 +1,5 @@
import { ClaimedTask } from '../../../core/tasks/models/claimed-task-object.model'; import { ClaimedTask } from '../../../core/tasks/models/claimed-task-object.model';
import { SearchResult } from '../../../+search-page/search-result.model'; import { SearchResult } from '../../../+search-page/search-result.model';
import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspace-configuration-value-type';
import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator'; import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator';
/** /**

View File

@@ -3,10 +3,13 @@ import { Item } from '../../../core/shared/item.model';
import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator'; import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator';
import { GenericConstructor } from '../../../core/shared/generic-constructor'; import { GenericConstructor } from '../../../core/shared/generic-constructor';
import { ListableObject } from './listable-object.model'; import { ListableObject } from './listable-object.model';
import { isEmpty } from '../../empty.util';
@searchResultFor(Item) @searchResultFor(Item)
export class ItemSearchResult extends SearchResult<Item> { export class ItemSearchResult extends SearchResult<Item> {
/**
* Method that returns as which type of object this object should be rendered
*/
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> { getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
return this.indexableObject.getRenderTypes().map((type) => { return this.indexableObject.getRenderTypes().map((type) => {
if (typeof type === 'string') { if (typeof type === 'string') {

View File

@@ -2,5 +2,9 @@ import { TypedObject } from '../../../core/cache/object-cache.reducer';
import { GenericConstructor } from '../../../core/shared/generic-constructor'; import { GenericConstructor } from '../../../core/shared/generic-constructor';
export interface ListableObject extends TypedObject { export interface ListableObject extends TypedObject {
/**
* Method that returns as which type of object this object should be rendered
*/
getRenderTypes(): Array<string | GenericConstructor<ListableObject>>; getRenderTypes(): Array<string | GenericConstructor<ListableObject>>;
} }

View File

@@ -21,20 +21,37 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
*/ */
@Input() object: ListableObject; @Input() object: ListableObject;
// TODO DO SOMETHING WITH THIS /**
* The index of the object in the list
*/
@Input() index: number; @Input() index: number;
/** /**
* The preferred view-mode to display * The preferred view-mode to display
*/ */
@Input() viewMode: ViewMode; @Input() viewMode: ViewMode;
/**
* The context of listable object
*/
@Input() context: Context; @Input() context: Context;
/**
* The type of link used to render the links inside the listable object
*/
@Input() linkType: CollectionElementLinkType; @Input() linkType: CollectionElementLinkType;
/**
* Directive hook used to place the dynamic child component
*/
@ViewChild(ListableObjectDirective) listableObjectDirective: ListableObjectDirective; @ViewChild(ListableObjectDirective) listableObjectDirective: ListableObjectDirective;
constructor(private componentFactoryResolver: ComponentFactoryResolver) { constructor(private componentFactoryResolver: ComponentFactoryResolver) {
} }
/**
* Setup the dynamic child component
*/
ngOnInit(): void { ngOnInit(): void {
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent()); const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent());
@@ -48,8 +65,8 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
} }
/** /**
* Fetch the component depending on the item's relationship type * Fetch the component depending on the item's relationship type, view mode and context
* @returns {string} * @returns {GenericConstructor<Component>}
*/ */
private getComponent(): GenericConstructor<Component> { private getComponent(): GenericConstructor<Component> {
return getListableObjectComponent(this.object.getRenderTypes(), this.viewMode, this.context) return getListableObjectComponent(this.object.getRenderTypes(), this.viewMode, this.context)

View File

@@ -10,9 +10,10 @@ export const DEFAULT_VIEW_MODE = ViewMode.ListElement;
const map = new Map(); const map = new Map();
/** /**
* Decorator used for rendering simple item pages by type and viewMode (and optionally a representationType) * Decorator used for rendering a listable object
* @param type * @param type The object type or entity type the component represents
* @param viewMode * @param viewMode The view mode the component represents
* @param context The optional context the component represents
*/ */
export function listableObjectComponent(objectType: string | GenericConstructor<ListableObject>, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { export function listableObjectComponent(objectType: string | GenericConstructor<ListableObject>, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) {
return function decorator(component: any) { return function decorator(component: any) {
@@ -29,6 +30,12 @@ export function listableObjectComponent(objectType: string | GenericConstructor<
}; };
} }
/**
* Getter to retrieve the matching listable object component
* @param types The types of which one should match the listable component
* @param viewMode The view mode that should match the components
* @param context The context that should match the components
*/
export function getListableObjectComponent(types: Array<string | GenericConstructor<ListableObject>>, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) { export function getListableObjectComponent(types: Array<string | GenericConstructor<ListableObject>>, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) {
let bestMatch; let bestMatch;
let bestMatchValue = 0; let bestMatchValue = 0;

View File

@@ -3,6 +3,9 @@ import { Directive, ViewContainerRef } from '@angular/core';
@Directive({ @Directive({
selector: '[dsListableObject]', selector: '[dsListableObject]',
}) })
/**
* Directive used as a hook to know where to inject the dynamic listable object component
*/
export class ListableObjectDirective { export class ListableObjectDirective {
constructor(public viewContainerRef: ViewContainerRef) { } constructor(public viewContainerRef: ViewContainerRef) { }
} }

View File

@@ -7,7 +7,18 @@ import { CollectionElementLinkType } from '../../collection-element-link.type';
template: ``, template: ``,
}) })
export class AbstractListableElementComponent<T extends ListableObject> { export class AbstractListableElementComponent<T extends ListableObject> {
/**
* The object to render in this list element
*/
@Input() object: T; @Input() object: T;
/**
* The link type to determine the type of link rendered in this element
*/
@Input() linkType: CollectionElementLinkType; @Input() linkType: CollectionElementLinkType;
/**
* The available link types
*/
linkTypes = CollectionElementLinkType; linkTypes = CollectionElementLinkType;
} }

View File

@@ -1,6 +1,5 @@
import { PoolTask } from '../../../core/tasks/models/pool-task-object.model'; import { PoolTask } from '../../../core/tasks/models/pool-task-object.model';
import { SearchResult } from '../../../+search-page/search-result.model'; import { SearchResult } from '../../../+search-page/search-result.model';
import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspace-configuration-value-type';
import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator'; import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator';
/** /**

View File

@@ -15,7 +15,7 @@ import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claim
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
/** /**
* This component renders claimed task object for the mydspace result in the detail view. * This component renders claimed task object for the search result in the detail view.
*/ */
@Component({ @Component({
selector: 'ds-claimed-task-search-result-detail-element', selector: 'ds-claimed-task-search-result-detail-element',

View File

@@ -19,7 +19,7 @@ export class ItemDetailPreviewFieldComponent {
@Input() item: Item; @Input() item: Item;
/** /**
* The mydspace result object * The search result object
*/ */
@Input() object: SearchResult<any>; @Input() object: SearchResult<any>;

View File

@@ -25,7 +25,7 @@ export class ItemDetailPreviewComponent {
@Input() item: Item; @Input() item: Item;
/** /**
* The mydspace result object * The search result object
*/ */
@Input() object: SearchResult<any>; @Input() object: SearchResult<any>;

View File

@@ -8,7 +8,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
/** /**
* This component renders item object for the mydspace result in the detail view. * This component renders item object for the search result in the detail view.
*/ */
@Component({ @Component({
selector: 'ds-item-search-result-detail-element', selector: 'ds-item-search-result-detail-element',
@@ -16,13 +16,7 @@ import { ItemSearchResult } from '../../../object-collection/shared/item-search-
templateUrl: './item-search-result-detail-element.component.html' templateUrl: './item-search-result-detail-element.component.html'
}) })
@listableObjectComponent('PublicationSearchResult', ViewMode.DetailedListElement) @listableObjectComponent(Item, ViewMode.DetailedListElement)
@listableObjectComponent('OrgUnitSearchResult', ViewMode.DetailedListElement)
@listableObjectComponent('PersonSearchResult', ViewMode.DetailedListElement)
@listableObjectComponent('JournalSearchResult', ViewMode.DetailedListElement)
@listableObjectComponent('JournalIssueSearchResult', ViewMode.DetailedListElement)
@listableObjectComponent('JournalVolumeSearchResult', ViewMode.DetailedListElement)
@listableObjectComponent('ProjectSearchResult', ViewMode.DetailedListElement)
export class ItemSearchResultDetailElementComponent extends SearchResultDetailElementComponent<ItemSearchResult, Item> { export class ItemSearchResultDetailElementComponent extends SearchResultDetailElementComponent<ItemSearchResult, Item> {
/** /**

View File

@@ -1,4 +1,4 @@
import { Component, Inject } from '@angular/core'; import { Component } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { find } from 'rxjs/operators'; import { find } from 'rxjs/operators';
@@ -11,7 +11,6 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo
import { ViewMode } from '../../../../core/shared/view-mode.model'; import { ViewMode } from '../../../../core/shared/view-mode.model';
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model';
import { Item } from '../../../../core/shared/item.model';
/** /**
* This component renders pool task object for the mydspace result in the detail view. * This component renders pool task object for the mydspace result in the detail view.
@@ -40,10 +39,6 @@ export class PoolSearchResultDetailElementComponent extends SearchResultDetailEl
*/ */
public workflowitem: WorkflowItem; public workflowitem: WorkflowItem;
constructor() {
super();
}
/** /**
* Initialize all instance variables * Initialize all instance variables
*/ */

View File

@@ -6,6 +6,9 @@ import { Metadata } from '../../../core/shared/metadata.utils';
import { SearchResult } from '../../../+search-page/search-result.model'; import { SearchResult } from '../../../+search-page/search-result.model';
import { hasValue } from '../../empty.util'; import { hasValue } from '../../empty.util';
/**
* Component representing Search Results with ViewMode.DetailedElement
*/
@Component({ @Component({
selector: 'ds-search-result-detail-element', selector: 'ds-search-result-detail-element',
template: `` template: ``
@@ -17,6 +20,9 @@ export class SearchResultDetailElementComponent<T extends SearchResult<K>, K ext
*/ */
dso: K; dso: K;
/**
* Initialize instance variables
*/
ngOnInit(): void { ngOnInit(): void {
if (hasValue(this.object)) { if (hasValue(this.object)) {
this.dso = this.object.indexableObject; this.dso = this.object.indexableObject;

View File

@@ -13,7 +13,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model'; import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model';
/** /**
* This component renders workflowitem object for the mydspace result in the detail view. * This component renders workflowitem object for the search result in the detail view.
*/ */
@Component({ @Component({
selector: 'ds-workflow-item-search-result-detail-element', selector: 'ds-workflow-item-search-result-detail-element',

View File

@@ -14,7 +14,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
import { WorkspaceItemSearchResult } from '../../../object-collection/shared/workspaceitem-search-result.model'; import { WorkspaceItemSearchResult } from '../../../object-collection/shared/workspaceitem-search-result.model';
/** /**
* This component renders workspaceitem object for the mydspace result in the detail view. * This component renders workspace item object for the search result in the detail view.
*/ */
@Component({ @Component({
selector: 'ds-workspace-item-search-result-detail-element', selector: 'ds-workspace-item-search-result-detail-element',

View File

@@ -31,6 +31,9 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme
animations: [fadeIn] animations: [fadeIn]
}) })
export class ObjectDetailComponent { export class ObjectDetailComponent {
/**
* The view mode of this component
*/
viewMode = ViewMode.DetailedListElement; viewMode = ViewMode.DetailedListElement;
/** /**
@@ -52,7 +55,15 @@ export class ObjectDetailComponent {
* A boolean representing if to hide pagination when there is only a page * A boolean representing if to hide pagination when there is only a page
*/ */
@Input() hidePagerWhenSinglePage = true; @Input() hidePagerWhenSinglePage = true;
/**
* The link type of the rendered listable elements
*/
@Input() linkType: CollectionElementLinkType; @Input() linkType: CollectionElementLinkType;
/**
* The context of the rendered listable elements
*/
@Input() context: Context; @Input() context: Context;
/** /**

View File

@@ -5,6 +5,9 @@ import { AbstractListableElementComponent } from '../../object-collection/shared
import { ViewMode } from '../../../core/shared/view-mode.model'; import { ViewMode } from '../../../core/shared/view-mode.model';
import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator';
/**
* Component representing a grid element for collection
*/
@Component({ @Component({
selector: 'ds-collection-grid-element', selector: 'ds-collection-grid-element',
styleUrls: ['./collection-grid-element.component.scss'], styleUrls: ['./collection-grid-element.component.scss'],

View File

@@ -5,6 +5,9 @@ import { AbstractListableElementComponent } from '../../object-collection/shared
import { ViewMode } from '../../../core/shared/view-mode.model'; import { ViewMode } from '../../../core/shared/view-mode.model';
import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator'; import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator';
/**
* Component representing a grid element for a community
*/
@Component({ @Component({
selector: 'ds-community-grid-element', selector: 'ds-community-grid-element',
styleUrls: ['./community-grid-element.component.scss'], styleUrls: ['./community-grid-element.component.scss'],

View File

@@ -34,20 +34,57 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme
}) })
export class ObjectGridComponent implements OnInit { export class ObjectGridComponent implements OnInit {
/**
* The view mode of the this component
*/
viewMode = ViewMode.GridElement; viewMode = ViewMode.GridElement;
/**
* The current pagination configuration
*/
@Input() config: PaginationComponentOptions; @Input() config: PaginationComponentOptions;
/**
* The current sort configuration
*/
@Input() sortConfig: SortOptions; @Input() sortConfig: SortOptions;
/**
* The whether or not the gear is hidden
*/
@Input() hideGear = false; @Input() hideGear = false;
/**
* Whether or not the pager is visible when there is only a single page of results
*/
@Input() hidePagerWhenSinglePage = true; @Input() hidePagerWhenSinglePage = true;
/**
* The link type of the listable elements
*/
@Input() linkType: CollectionElementLinkType; @Input() linkType: CollectionElementLinkType;
/**
* The context of the listable elements
*/
@Input() context: Context; @Input() context: Context;
/**
* Behavior subject to output the current listable objects
*/
private _objects$: BehaviorSubject<RemoteData<PaginatedList<ListableObject>>>; private _objects$: BehaviorSubject<RemoteData<PaginatedList<ListableObject>>>;
/**
* Setter to make sure the observable is turned into an observable
* @param objects The new objects to output
*/
@Input() set objects(objects: RemoteData<PaginatedList<ListableObject>>) { @Input() set objects(objects: RemoteData<PaginatedList<ListableObject>>) {
this._objects$.next(objects); this._objects$.next(objects);
} }
/**
* Getter to return the current objects
*/
get objects() { get objects() {
return this._objects$.getValue(); return this._objects$.getValue();
} }
@@ -82,7 +119,10 @@ export class ObjectGridComponent implements OnInit {
*/ */
@Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter<SortDirection>(); @Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter<SortDirection>();
@Output() paginationChange: EventEmitter<SortDirection> = new EventEmitter<any>(); /**
* An event fired when on of the pagination parameters changes
*/
@Output() paginationChange: EventEmitter<any> = new EventEmitter<any>();
/** /**
* An event fired when the sort field is changed. * An event fired when the sort field is changed.
@@ -96,6 +136,9 @@ export class ObjectGridComponent implements OnInit {
this._objects$ = new BehaviorSubject(undefined); this._objects$ = new BehaviorSubject(undefined);
} }
/**
* Initialize the instance variables
*/
ngOnInit(): void { ngOnInit(): void {
const nbColumns$ = this.hostWindow.widthCategory.pipe( const nbColumns$ = this.hostWindow.widthCategory.pipe(
map((widthCat: WidthCategory) => { map((widthCat: WidthCategory) => {
@@ -139,22 +182,40 @@ export class ObjectGridComponent implements OnInit {
})); }));
} }
/**
* Emits the current page when it changes
* @param event The new page
*/
onPageChange(event) { onPageChange(event) {
this.pageChange.emit(event); this.pageChange.emit(event);
} }
/**
* Emits the current page size when it changes
* @param event The new page size
*/
onPageSizeChange(event) { onPageSizeChange(event) {
this.pageSizeChange.emit(event); this.pageSizeChange.emit(event);
} }
/**
* Emits the current sort direction when it changes
* @param event The new sort direction
*/
onSortDirectionChange(event) { onSortDirectionChange(event) {
this.sortDirectionChange.emit(event); this.sortDirectionChange.emit(event);
} }
/**
* Emits the current sort field when it changes
* @param event The new sort field
*/
onSortFieldChange(event) { onSortFieldChange(event) {
this.sortFieldChange.emit(event); this.sortFieldChange.emit(event);
} }
/**
* Emits the current pagination when it changes
* @param event The new pagination
*/
onPaginationChange(event) { onPaginationChange(event) {
this.paginationChange.emit(event); this.paginationChange.emit(event);
} }

View File

@@ -11,6 +11,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
styleUrls: ['../search-result-grid-element.component.scss', 'collection-search-result-grid-element.component.scss'], styleUrls: ['../search-result-grid-element.component.scss', 'collection-search-result-grid-element.component.scss'],
templateUrl: 'collection-search-result-grid-element.component.html' templateUrl: 'collection-search-result-grid-element.component.html'
}) })
/**
* Component representing a grid element for a collection search result
*/
@listableObjectComponent(CollectionSearchResult, ViewMode.GridElement) @listableObjectComponent(CollectionSearchResult, ViewMode.GridElement)
export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent<CollectionSearchResult, Collection> {} export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent<CollectionSearchResult, Collection> {}

View File

@@ -10,8 +10,9 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
styleUrls: ['../search-result-grid-element.component.scss', 'community-search-result-grid-element.component.scss'], styleUrls: ['../search-result-grid-element.component.scss', 'community-search-result-grid-element.component.scss'],
templateUrl: 'community-search-result-grid-element.component.html' templateUrl: 'community-search-result-grid-element.component.html'
}) })
/**
* Component representing a grid element for a community search result
*/
@listableObjectComponent(CommunitySearchResult, ViewMode.GridElement) @listableObjectComponent(CommunitySearchResult, ViewMode.GridElement)
export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent<CommunitySearchResult, Community> { export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent<CommunitySearchResult, Community> {
} }

View File

@@ -14,7 +14,7 @@ import { ItemSearchResult } from '../../../../object-collection/shared/item-sear
animations: [focusShadow] animations: [focusShadow]
}) })
/** /**
* The component for displaying a grid element for an item of the type Publication * The component for displaying a grid element for an item search result of the type Publication
*/ */
export class PublicationSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> { export class PublicationSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -14,7 +14,14 @@ import { hasValue } from '../../empty.util';
}) })
export class SearchResultGridElementComponent<T extends SearchResult<K>, K extends DSpaceObject> extends AbstractListableElementComponent<T> implements OnInit { export class SearchResultGridElementComponent<T extends SearchResult<K>, K extends DSpaceObject> extends AbstractListableElementComponent<T> implements OnInit {
/**
* The DSpaceObject of the search result
*/
dso: K; dso: K;
/**
* Whether or not the grid element is currently collapsed
*/
isCollapsed$: Observable<boolean>; isCollapsed$: Observable<boolean>;
public constructor(protected truncatableService: TruncatableService) { public constructor(protected truncatableService: TruncatableService) {
@@ -24,6 +31,9 @@ export class SearchResultGridElementComponent<T extends SearchResult<K>, K exten
} }
} }
/**
* Retrieve the dso from the search result
*/
ngOnInit(): void { ngOnInit(): void {
if (hasValue(this.object)) { if (hasValue(this.object)) {
this.dso = this.object.indexableObject; this.dso = this.object.indexableObject;

View File

@@ -10,6 +10,8 @@ import { listableObjectComponent } from '../../object-collection/shared/listable
styleUrls: ['./collection-list-element.component.scss'], styleUrls: ['./collection-list-element.component.scss'],
templateUrl: './collection-list-element.component.html' templateUrl: './collection-list-element.component.html'
}) })
/**
* Component representing list element for a collection
*/
@listableObjectComponent(Collection, ViewMode.ListElement) @listableObjectComponent(Collection, ViewMode.ListElement)
export class CollectionListElementComponent extends AbstractListableElementComponent<Collection> {} export class CollectionListElementComponent extends AbstractListableElementComponent<Collection> {}

View File

@@ -10,6 +10,8 @@ import { listableObjectComponent } from '../../object-collection/shared/listable
styleUrls: ['./community-list-element.component.scss'], styleUrls: ['./community-list-element.component.scss'],
templateUrl: './community-list-element.component.html' templateUrl: './community-list-element.component.html'
}) })
/**
* Component representing a list element for a community
*/
@listableObjectComponent(Community, ViewMode.ListElement) @listableObjectComponent(Community, ViewMode.ListElement)
export class CommunityListElementComponent extends AbstractListableElementComponent<Community> {} export class CommunityListElementComponent extends AbstractListableElementComponent<Community> {}

View File

@@ -7,6 +7,12 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model';
selector: 'ds-item-type-badge', selector: 'ds-item-type-badge',
templateUrl: './item-type-badge.component.html' templateUrl: './item-type-badge.component.html'
}) })
/**
* Component rendering the type of an item as a badge
*/
export class ItemTypeBadgeComponent { export class ItemTypeBadgeComponent {
/**
* The component used to retrieve the type from
*/
@Input() object: DSpaceObject; @Input() object: DSpaceObject;
} }

View File

@@ -17,7 +17,7 @@ import { metadataRepresentationComponent } from '../../../metadata-representatio
export class ItemMetadataListElementComponent extends MetadataRepresentationListElementComponent { export class ItemMetadataListElementComponent extends MetadataRepresentationListElementComponent {
/** /**
* The view-mode we're currently on * The view-mode we're currently on
* @type {ElementViewMode} * @type {ViewMode}
*/ */
viewMode = ViewMode.ListElement; viewMode = ViewMode.ListElement;
} }

View File

@@ -9,5 +9,8 @@ import { MetadataRepresentation } from '../../../core/shared/metadata-representa
* An abstract class for displaying a single MetadataRepresentation * An abstract class for displaying a single MetadataRepresentation
*/ */
export class MetadataRepresentationListElementComponent { export class MetadataRepresentationListElementComponent {
/**
* The metadata representation of this component
*/
metadataRepresentation: MetadataRepresentation; metadataRepresentation: MetadataRepresentation;
} }

View File

@@ -13,10 +13,9 @@ import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspa
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model';
import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
import { Item } from '../../../../core/shared/item.model';
/** /**
* This component renders claimed task object for the mydspace result in the list view. * This component renders claimed task object for the search result in the list view.
*/ */
@Component({ @Component({
selector: 'ds-claimed-search-result-list-element', selector: 'ds-claimed-search-result-list-element',

View File

@@ -22,7 +22,7 @@ export class ItemListPreviewComponent {
@Input() item: Item; @Input() item: Item;
/** /**
* The mydspace result object * The search result object
*/ */
@Input() object: SearchResult<any>; @Input() object: SearchResult<any>;

View File

@@ -9,7 +9,7 @@ import { ItemSearchResult } from '../../../object-collection/shared/item-search-
import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
/** /**
* This component renders item object for the mydspace result in the list view. * This component renders item object for the search result in the list view for submission.
*/ */
@Component({ @Component({
selector: 'ds-item-search-result-list-element-submission', selector: 'ds-item-search-result-list-element-submission',

View File

@@ -1,4 +1,4 @@
import { Component, Inject, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { find } from 'rxjs/operators'; import { find } from 'rxjs/operators';
@@ -13,10 +13,9 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model';
import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
import { TruncatableService } from '../../../truncatable/truncatable.service'; import { TruncatableService } from '../../../truncatable/truncatable.service';
import { Item } from '../../../../core/shared/item.model';
/** /**
* This component renders pool task object for the mydspace result in the list view. * This component renders pool task object for the search result in the list view.
*/ */
@Component({ @Component({
selector: 'ds-pool-search-result-list-element', selector: 'ds-pool-search-result-list-element',
@@ -42,6 +41,9 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
*/ */
public workflowitem: WorkflowItem; public workflowitem: WorkflowItem;
/**
* The index of this list element
*/
public index: number; public index: number;
constructor(protected truncatableService: TruncatableService) { constructor(protected truncatableService: TruncatableService) {

View File

@@ -14,7 +14,7 @@ import { WorkflowItemSearchResult } from '../../../object-collection/shared/work
import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
/** /**
* This component renders workflowitem object for the mydspace result in the list view. * This component renders workflowitem object for the search result in the list view.
*/ */
@Component({ @Component({
selector: 'ds-workflow-item-my-dspace-result-list-element', selector: 'ds-workflow-item-my-dspace-result-list-element',

View File

@@ -14,7 +14,7 @@ import { WorkspaceItemSearchResult } from '../../../object-collection/shared/wor
import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
/** /**
* This component renders workspaceitem object for the mydspace result in the list view. * This component renders workspaceitem object for the search result in the list view.
*/ */
@Component({ @Component({
selector: 'ds-workspace-item-search-result-list-element', selector: 'ds-workspace-item-search-result-list-element',

View File

@@ -25,19 +25,63 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme
animations: [fadeIn] animations: [fadeIn]
}) })
export class ObjectListComponent { export class ObjectListComponent {
/**
* The view mode of the this component
*/
viewMode = ViewMode.ListElement; viewMode = ViewMode.ListElement;
/**
* The current pagination configuration
*/
@Input() config: PaginationComponentOptions; @Input() config: PaginationComponentOptions;
/**
* The current sort configuration
*/
@Input() sortConfig: SortOptions; @Input() sortConfig: SortOptions;
/**
* Whether or not the list elements have a border
*/
@Input() hasBorder = false; @Input() hasBorder = false;
/**
* The whether or not the gear is hidden
*/
@Input() hideGear = false; @Input() hideGear = false;
/**
* Whether or not the pager is visible when there is only a single page of results
*/
@Input() hidePagerWhenSinglePage = true; @Input() hidePagerWhenSinglePage = true;
/**
* The link type of the listable elements
*/
@Input() linkType: CollectionElementLinkType; @Input() linkType: CollectionElementLinkType;
/**
* The context of the listable elements
*/
@Input() context: Context; @Input() context: Context;
/**
* The current listable objects
*/
private _objects: RemoteData<PaginatedList<ListableObject>>; private _objects: RemoteData<PaginatedList<ListableObject>>;
/**
* Setter for the objects
* @param objects The new objects
*/
@Input() set objects(objects: RemoteData<PaginatedList<ListableObject>>) { @Input() set objects(objects: RemoteData<PaginatedList<ListableObject>>) {
this._objects = objects; this._objects = objects;
} }
/**
* Getter to return the current objects
*/
get objects() { get objects() {
return this._objects; return this._objects;
} }
@@ -72,6 +116,9 @@ export class ObjectListComponent {
*/ */
@Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter<SortDirection>(); @Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter<SortDirection>();
/**
* An event fired when on of the pagination parameters changes
*/
@Output() paginationChange: EventEmitter<SortDirection> = new EventEmitter<any>(); @Output() paginationChange: EventEmitter<SortDirection> = new EventEmitter<any>();
/** /**
@@ -79,24 +126,42 @@ export class ObjectListComponent {
* Event's payload equals to the newly selected sort field. * Event's payload equals to the newly selected sort field.
*/ */
@Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>(); @Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>();
data: any = {};
/**
* Emits the current page when it changes
* @param event The new page
*/
onPageChange(event) { onPageChange(event) {
this.pageChange.emit(event); this.pageChange.emit(event);
} }
/**
* Emits the current page size when it changes
* @param event The new page size
*/
onPageSizeChange(event) { onPageSizeChange(event) {
this.pageSizeChange.emit(event); this.pageSizeChange.emit(event);
} }
/**
* Emits the current sort direction when it changes
* @param event The new sort direction
*/
onSortDirectionChange(event) { onSortDirectionChange(event) {
this.sortDirectionChange.emit(event); this.sortDirectionChange.emit(event);
} }
/**
* Emits the current sort field when it changes
* @param event The new sort field
*/
onSortFieldChange(event) { onSortFieldChange(event) {
this.sortFieldChange.emit(event); this.sortFieldChange.emit(event);
} }
/**
* Emits the current pagination when it changes
* @param event The new pagination
*/
onPaginationChange(event) { onPaginationChange(event) {
this.paginationChange.emit(event); this.paginationChange.emit(event);
} }

View File

@@ -10,6 +10,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
styleUrls: ['../search-result-list-element.component.scss', 'collection-search-result-list-element.component.scss'], styleUrls: ['../search-result-list-element.component.scss', 'collection-search-result-list-element.component.scss'],
templateUrl: 'collection-search-result-list-element.component.html' templateUrl: 'collection-search-result-list-element.component.html'
}) })
/**
* Component representing a collection search result in list view
*/
@listableObjectComponent(CollectionSearchResult, ViewMode.ListElement) @listableObjectComponent(CollectionSearchResult, ViewMode.ListElement)
export class CollectionSearchResultListElementComponent extends SearchResultListElementComponent<CollectionSearchResult, Collection> {} export class CollectionSearchResultListElementComponent extends SearchResultListElementComponent<CollectionSearchResult, Collection> {}

View File

@@ -10,7 +10,9 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
styleUrls: ['../search-result-list-element.component.scss', 'community-search-result-list-element.component.scss'], styleUrls: ['../search-result-list-element.component.scss', 'community-search-result-list-element.component.scss'],
templateUrl: 'community-search-result-list-element.component.html' templateUrl: 'community-search-result-list-element.component.html'
}) })
/**
* Component representing a community search result in list view
*/
@listableObjectComponent(CommunitySearchResult, ViewMode.ListElement) @listableObjectComponent(CommunitySearchResult, ViewMode.ListElement)
export class CommunitySearchResultListElementComponent extends SearchResultListElementComponent<CommunitySearchResult, Community> { export class CommunitySearchResultListElementComponent extends SearchResultListElementComponent<CommunitySearchResult, Community> {

View File

@@ -13,7 +13,7 @@ import { Item } from '../../../../../../core/shared/item.model';
templateUrl: './publication-search-result-list-element.component.html' templateUrl: './publication-search-result-list-element.component.html'
}) })
/** /**
* The component for displaying a list element for an item of the type Publication * The component for displaying a list element for an item search result of the type Publication
*/ */
export class PublicationSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> { export class PublicationSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
} }

View File

@@ -7,7 +7,6 @@ import { hasValue } from '../../empty.util';
import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component';
import { TruncatableService } from '../../truncatable/truncatable.service'; import { TruncatableService } from '../../truncatable/truncatable.service';
import { Metadata } from '../../../core/shared/metadata.utils'; import { Metadata } from '../../../core/shared/metadata.utils';
import { MetadataMap } from '../../../core/shared/metadata.models';
@Component({ @Component({
selector: 'ds-search-result-list-element', selector: 'ds-search-result-list-element',
@@ -15,13 +14,18 @@ import { MetadataMap } from '../../../core/shared/metadata.models';
}) })
export class SearchResultListElementComponent<T extends SearchResult<K>, K extends DSpaceObject> extends AbstractListableElementComponent<T> implements OnInit { export class SearchResultListElementComponent<T extends SearchResult<K>, K extends DSpaceObject> extends AbstractListableElementComponent<T> implements OnInit {
/**
* The DSpaceObject of the search result
*/
dso: K; dso: K;
metadata: MetadataMap;
public constructor(protected truncatableService: TruncatableService) { public constructor(protected truncatableService: TruncatableService) {
super(); super();
} }
/**
* Retrieve the dso from the search result
*/
ngOnInit(): void { ngOnInit(): void {
if (hasValue(this.object)) { if (hasValue(this.object)) {
this.dso = this.object.indexableObject; this.dso = this.object.indexableObject;
@@ -48,6 +52,9 @@ export class SearchResultListElementComponent<T extends SearchResult<K>, K exten
return Metadata.firstValue([this.object.hitHighlights, this.dso.metadata], keyOrKeys); return Metadata.firstValue([this.object.hitHighlights, this.dso.metadata], keyOrKeys);
} }
/**
* Emits if the list element is currently collapsed or not
*/
isCollapsed(): Observable<boolean> { isCollapsed(): Observable<boolean> {
return this.truncatableService.isCollapsed(this.dso.id); return this.truncatableService.isCollapsed(this.dso.id);
} }

View File

@@ -139,6 +139,8 @@ import { ListableObjectComponentLoaderComponent } from './object-collection/shar
import { PublicationSearchResultListElementComponent } from './object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component'; import { PublicationSearchResultListElementComponent } from './object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component';
import { PublicationSearchResultGridElementComponent } from './object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component'; import { PublicationSearchResultGridElementComponent } from './object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component';
import { ListableObjectDirective } from './object-collection/shared/listable-object/listable-object.directive'; import { ListableObjectDirective } from './object-collection/shared/listable-object/listable-object.directive';
import { CommunitySearchResultGridElementComponent } from './object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component';
import { CollectionSearchResultGridElementComponent } from './object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component';
const MODULES = [ const MODULES = [
// Do NOT include UniversalModule, HttpModule, or JsonpModule here // Do NOT include UniversalModule, HttpModule, or JsonpModule here
@@ -253,7 +255,13 @@ const COMPONENTS = [
EditItemSelectorComponent, EditItemSelectorComponent,
CommunitySearchResultListElementComponent, CommunitySearchResultListElementComponent,
CollectionSearchResultListElementComponent, CollectionSearchResultListElementComponent,
CommunitySearchResultGridElementComponent,
CollectionSearchResultGridElementComponent,
ListableObjectComponentLoaderComponent, ListableObjectComponentLoaderComponent,
CollectionListElementComponent,
CommunityListElementComponent,
CollectionGridElementComponent,
CommunityGridElementComponent,
BrowseByComponent, BrowseByComponent,
ItemTypeBadgeComponent, ItemTypeBadgeComponent,
MetadataRepresentationLoaderComponent MetadataRepresentationLoaderComponent
@@ -268,6 +276,8 @@ const ENTRY_COMPONENTS = [
CollectionSearchResultListElementComponent, CollectionSearchResultListElementComponent,
CollectionGridElementComponent, CollectionGridElementComponent,
CommunityGridElementComponent, CommunityGridElementComponent,
CommunitySearchResultGridElementComponent,
CollectionSearchResultGridElementComponent,
SearchResultGridElementComponent, SearchResultGridElementComponent,
PublicationListElementComponent, PublicationListElementComponent,
PublicationGridElementComponent, PublicationGridElementComponent,

View File

@@ -22,13 +22,23 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy {
*/ */
@Input() inPlaceSearch; @Input() inPlaceSearch;
/**
* The current view mode
*/
currentMode: ViewMode = ViewMode.ListElement; currentMode: ViewMode = ViewMode.ListElement;
/**
* All available view modes
*/
viewModeEnum = ViewMode; viewModeEnum = ViewMode;
private sub: Subscription; private sub: Subscription;
constructor(private searchService: SearchService) { constructor(private searchService: SearchService) {
} }
/**
* Initialize the instance variables
*/
ngOnInit(): void { ngOnInit(): void {
if (isEmpty(this.viewModeList)) { if (isEmpty(this.viewModeList)) {
this.viewModeList = [ViewMode.ListElement, ViewMode.GridElement]; this.viewModeList = [ViewMode.ListElement, ViewMode.GridElement];
@@ -39,6 +49,10 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy {
}); });
} }
/**
* Switch view modes
* @param viewMode The new view mode
*/
switchViewTo(viewMode: ViewMode) { switchViewTo(viewMode: ViewMode) {
this.searchService.setViewMode(viewMode, this.getSearchLinkParts()); this.searchService.setViewMode(viewMode, this.getSearchLinkParts());
} }
@@ -49,6 +63,10 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy {
} }
} }
/**
* Whether or not to show a certain view mode
* @param viewMode The view mode to check for
*/
isToShow(viewMode: ViewMode) { isToShow(viewMode: ViewMode) {
return this.viewModeList && this.viewModeList.includes(viewMode); return this.viewModeList && this.viewModeList.includes(viewMode);
} }

View File

@@ -117,7 +117,7 @@ export function createMockApi() {
const id = req.params.item_id; const id = req.params.item_id;
try { try {
req.item_id = id; req.item_id = id;
req.object = ITEMS.items.find((item) => { req.item = ITEMS.items.find((item) => {
return item.id === id; return item.id === id;
}); });
next(); next();
@@ -127,7 +127,7 @@ export function createMockApi() {
}); });
router.route('/items/:item_id').get((req, res) => { router.route('/items/:item_id').get((req, res) => {
res.json(toHALResponse(req, req.object)); res.json(toHALResponse(req, req.item));
}); });
router.route('/bundles').get((req, res) => { router.route('/bundles').get((req, res) => {