mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
added TypeDoc
This commit is contained in:
@@ -10,7 +10,7 @@ import { ItemPageFieldComponent } from '../item-page-field.component';
|
||||
/**
|
||||
* This component can be used to represent metadata on a simple item page.
|
||||
* 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 {
|
||||
|
||||
|
@@ -1,19 +1,16 @@
|
||||
|
||||
import { mergeMap, filter, map, take, tap } from 'rxjs/operators';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { ItemDataService } from '../../core/data/item-data.service';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { Bitstream } from '../../core/shared/bitstream.model';
|
||||
|
||||
import { Item } from '../../core/shared/item.model';
|
||||
|
||||
import { MetadataService } from '../../core/metadata/metadata.service';
|
||||
|
||||
import { fadeInOut } from '../../shared/animations/fade';
|
||||
import { hasValue } from '../../shared/empty.util';
|
||||
import { redirectToPageNotFoundOn404 } from '../../core/shared/operators';
|
||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
|
||||
@@ -53,6 +50,9 @@ export class ItemPageComponent implements OnInit {
|
||||
private metadataService: MetadataService,
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Initialize instance variables
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.itemRD$ = this.route.data.pipe(
|
||||
map((data) => data.item as RemoteData<Item>),
|
||||
|
@@ -7,6 +7,10 @@ import { getRelatedItemsByTypeLabel } from '../shared/item-relationships-utils';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator';
|
||||
|
||||
/**
|
||||
* Component that represents a publication Item page
|
||||
*/
|
||||
|
||||
@listableObjectComponent('Publication', ViewMode.StandalonePage)
|
||||
@listableObjectComponent(Item, ViewMode.StandalonePage)
|
||||
@Component({
|
||||
@@ -36,6 +40,9 @@ export class PublicationComponent extends ItemComponent implements OnInit {
|
||||
*/
|
||||
journalIssues$: Observable<Item[]>;
|
||||
|
||||
/**
|
||||
* Initialize instance variables
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
super.ngOnInit();
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model';
|
||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-metadata-representation-list',
|
||||
|
@@ -25,6 +25,9 @@ import { SearchResult } from '../../+search-page/search-result.model';
|
||||
templateUrl: './my-dspace-new-submission.component.html'
|
||||
})
|
||||
export class MyDSpaceNewSubmissionComponent implements OnDestroy, OnInit {
|
||||
/**
|
||||
* Output that emits the workspace item when the upload has completed
|
||||
*/
|
||||
@Output() uploadEnd = new EventEmitter<Array<SearchResult<DSpaceObject>>>();
|
||||
|
||||
/**
|
||||
|
@@ -43,8 +43,6 @@ const components = [
|
||||
SearchResultsComponent,
|
||||
SearchSidebarComponent,
|
||||
SearchSettingsComponent,
|
||||
CollectionSearchResultGridElementComponent,
|
||||
CommunitySearchResultGridElementComponent,
|
||||
SearchFiltersComponent,
|
||||
SearchFilterComponent,
|
||||
SearchFacetFilterComponent,
|
||||
@@ -83,8 +81,6 @@ const components = [
|
||||
SearchConfigurationService
|
||||
],
|
||||
entryComponents: [
|
||||
CollectionSearchResultGridElementComponent,
|
||||
CommunitySearchResultGridElementComponent,
|
||||
SearchFacetFilterComponent,
|
||||
SearchRangeFilterComponent,
|
||||
SearchTextFilterComponent,
|
||||
|
@@ -17,6 +17,9 @@ export class SearchResult<T extends DSpaceObject> implements ListableObject {
|
||||
*/
|
||||
hitHighlights: MetadataMap;
|
||||
|
||||
/**
|
||||
* Method that returns as which type of object this object should be rendered
|
||||
*/
|
||||
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
|
||||
return [this.constructor as GenericConstructor<ListableObject>];
|
||||
}
|
||||
|
@@ -25,6 +25,9 @@ import { CollectionElementLinkType } from '../../shared/object-collection/collec
|
||||
export class SearchResultsComponent {
|
||||
hasNoValue = hasNoValue;
|
||||
|
||||
/**
|
||||
* The link type of the listed search results
|
||||
*/
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,6 @@ export function searchResultFor(domainConstructor: GenericConstructor<ListableOb
|
||||
return;
|
||||
}
|
||||
searchResultMap.set(domainConstructor, searchResult);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { autoserialize, deserialize, inheritSerialization } from 'cerialize';
|
||||
|
||||
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 { EPerson } from './eperson.model';
|
||||
import { mapsTo, relationship } from '../../cache/builders/build-decorators';
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { autoserialize, deserialize, inheritSerialization } from 'cerialize';
|
||||
|
||||
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 { mapsTo, relationship } from '../../cache/builders/build-decorators';
|
||||
import { Group } from './group.model';
|
||||
|
@@ -52,6 +52,9 @@ export class MetadataField implements ListableObject {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that returns as which type of object this object should be rendered
|
||||
*/
|
||||
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
|
||||
return [this.constructor as GenericConstructor<ListableObject>];
|
||||
}
|
||||
|
@@ -28,6 +28,9 @@ export class MetadataSchema implements ListableObject {
|
||||
*/
|
||||
namespace: string;
|
||||
|
||||
/**
|
||||
* Method that returns as which type of object this object should be rendered
|
||||
*/
|
||||
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
|
||||
return [this.constructor as GenericConstructor<ListableObject>];
|
||||
}
|
||||
|
@@ -30,6 +30,9 @@ export class BrowseEntry implements ListableObject {
|
||||
*/
|
||||
count: number;
|
||||
|
||||
/**
|
||||
* Method that returns as which type of object this object should be rendered
|
||||
*/
|
||||
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
|
||||
return [this.constructor as GenericConstructor<ListableObject>];
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ export class DSpaceObject implements CacheableObject, ListableObject {
|
||||
* 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 {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`.
|
||||
*/
|
||||
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>> {
|
||||
return [this.constructor as GenericConstructor<ListableObject>];
|
||||
}
|
||||
|
@@ -14,6 +14,9 @@ import { GenericConstructor } from './generic-constructor';
|
||||
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
|
||||
import { DEFAULT_ENTITY_TYPE } from '../../shared/metadata-representation/metadata-representation.decorator';
|
||||
|
||||
/**
|
||||
* Class representing a DSpace Item
|
||||
*/
|
||||
export class Item extends DSpaceObject {
|
||||
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>> {
|
||||
let entityType = this.firstMetadataValue('relationship.type');
|
||||
if (isEmpty(entityType)) {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { focusShadow } from '../../../../shared/animations/focus';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
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';
|
||||
|
@@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
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> {
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ import { focusShadow } from '../../../../../shared/animations/focus';
|
||||
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> {
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
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> {
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
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> {
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||
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> {
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||
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> {
|
||||
}
|
||||
|
@@ -27,6 +27,9 @@ export class JournalIssueComponent extends ItemComponent {
|
||||
*/
|
||||
publications$: Observable<Item[]>;
|
||||
|
||||
/**
|
||||
* Initialize the instance variables
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
super.ngOnInit();
|
||||
|
||||
|
@@ -27,6 +27,9 @@ export class JournalVolumeComponent extends ItemComponent {
|
||||
*/
|
||||
issues$: Observable<Item[]>;
|
||||
|
||||
/**
|
||||
* Initialize the instance variables
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
super.ngOnInit();
|
||||
|
||||
|
@@ -22,6 +22,9 @@ export class JournalComponent extends ItemComponent {
|
||||
*/
|
||||
volumes$: Observable<Item[]>;
|
||||
|
||||
/**
|
||||
* Initialize the instance variables
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
super.ngOnInit();
|
||||
|
||||
|
@@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
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> {
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
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> {
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ import { focusShadow } from '../../../../../shared/animations/focus';
|
||||
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> {
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep
|
||||
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 {
|
||||
metadataRepresentation: ItemMetadataRepresentation;
|
||||
|
@@ -12,8 +12,8 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep
|
||||
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 {
|
||||
metadataRepresentation: ItemMetadataRepresentation;
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
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> {
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
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> {
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||
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> {
|
||||
}
|
||||
|
@@ -32,6 +32,9 @@ import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
* The user can search the list by using the input field
|
||||
*/
|
||||
export class DSOSelectorComponent implements OnInit {
|
||||
/**
|
||||
* The view mode of the listed objects
|
||||
*/
|
||||
viewMode = ViewMode.ListElement;
|
||||
/**
|
||||
* The initially selected DSO's uuid
|
||||
|
@@ -24,8 +24,16 @@ import { CollectionElementLinkType } from '../../object-collection/collection-el
|
||||
* Component representing a form with a autocomplete functionality for DSpaceObjects
|
||||
*/
|
||||
export class DsoInputSuggestionsComponent extends InputSuggestionsComponent {
|
||||
/**
|
||||
* The view mode of the listed object suggestions
|
||||
*/
|
||||
viewMode = ViewMode.ListElement;
|
||||
|
||||
/**
|
||||
* The available link types
|
||||
*/
|
||||
linkTypes = CollectionElementLinkType;
|
||||
|
||||
/**
|
||||
* The suggestions that should be shown
|
||||
*/
|
||||
|
@@ -12,19 +12,30 @@ import { MetadataRepresentationDirective } from './metadata-representation.direc
|
||||
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 {
|
||||
/**
|
||||
* The item or metadata to determine the component for
|
||||
*/
|
||||
@Input() mdRepresentation: MetadataRepresentation;
|
||||
|
||||
/**
|
||||
* The optional context
|
||||
*/
|
||||
@Input() context: Context;
|
||||
|
||||
/**
|
||||
* Directive to determine where the dynamic child component is located
|
||||
*/
|
||||
@ViewChild(MetadataRepresentationDirective) mdRepDirective: MetadataRepresentationDirective;
|
||||
|
||||
constructor(private componentFactoryResolver: ComponentFactoryResolver) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the dynamic child component
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
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}
|
||||
*/
|
||||
private getComponent(): GenericConstructor<MetadataRepresentationListElementComponent> {
|
||||
|
@@ -8,6 +8,13 @@ export const DEFAULT_ENTITY_TYPE = 'Publication';
|
||||
export const DEFAULT_REPRESENTATION_TYPE = MetadataRepresentationType.PlainText;
|
||||
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) {
|
||||
return function decorator(component: any) {
|
||||
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) {
|
||||
const mapForEntity = map.get(entityType);
|
||||
if (hasValue(mapForEntity)) {
|
||||
|
@@ -3,6 +3,9 @@ import { Directive, ViewContainerRef } from '@angular/core';
|
||||
@Directive({
|
||||
selector: '[dsMetadataRepresentation]',
|
||||
})
|
||||
/**
|
||||
* Directive used as a hook to know where to inject the dynamic metadata representation component
|
||||
*/
|
||||
export class MetadataRepresentationDirective {
|
||||
constructor(public viewContainerRef: ViewContainerRef) { }
|
||||
}
|
||||
|
@@ -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 {
|
||||
None, Link, ExternalLink
|
||||
}
|
||||
|
@@ -15,21 +15,55 @@ import { CollectionElementLinkType } from './collection-element-link.type';
|
||||
import { PaginatedList } from '../../core/data/paginated-list';
|
||||
import { Context } from '../../core/shared/context.model';
|
||||
|
||||
/**
|
||||
* Component that can render a list of listable objects in different view modes
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ds-viewable-collection',
|
||||
styleUrls: ['./object-collection.component.scss'],
|
||||
templateUrl: './object-collection.component.html',
|
||||
})
|
||||
export class ObjectCollectionComponent implements OnInit {
|
||||
|
||||
/**
|
||||
* The list of listable objects to render in this component
|
||||
*/
|
||||
@Input() objects: RemoteData<PaginatedList<ListableObject>>;
|
||||
|
||||
/**
|
||||
* The current pagination configuration
|
||||
*/
|
||||
@Input() config?: PaginationComponentOptions;
|
||||
|
||||
/**
|
||||
* The current sorting configuration
|
||||
*/
|
||||
@Input() sortConfig: SortOptions;
|
||||
|
||||
/**
|
||||
* Whether or not the list elements have a border or not
|
||||
*/
|
||||
@Input() hasBorder = false;
|
||||
|
||||
/**
|
||||
* Whether or not to hide the gear to change the sort and pagination configuration
|
||||
*/
|
||||
@Input() hideGear = false;
|
||||
|
||||
/**
|
||||
* The link type of the rendered list elements
|
||||
*/
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
|
||||
/**
|
||||
* The context of the rendered list elements
|
||||
*/
|
||||
@Input() context: Context;
|
||||
|
||||
/**
|
||||
* the page info of the list
|
||||
*/
|
||||
pageInfo: Observable<PageInfo>;
|
||||
|
||||
/**
|
||||
* An event fired when the page is changed.
|
||||
* 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>();
|
||||
|
||||
/**
|
||||
* An event fired one of the pagination parameters is changed
|
||||
*/
|
||||
@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.
|
||||
*/
|
||||
@Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>();
|
||||
data: any = {};
|
||||
|
||||
/**
|
||||
* Emits the current view mode
|
||||
*/
|
||||
currentMode$: Observable<ViewMode>;
|
||||
|
||||
/**
|
||||
* The available view modes
|
||||
*/
|
||||
viewModeEnum = ViewMode;
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -83,22 +127,39 @@ export class ObjectCollectionComponent implements OnInit {
|
||||
private router: Router) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the page
|
||||
* @param event The new page number
|
||||
*/
|
||||
onPageChange(event) {
|
||||
this.pageChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the page size
|
||||
* @param event The new page size
|
||||
*/
|
||||
onPageSizeChange(event) {
|
||||
this.pageSizeChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the sort direction
|
||||
* @param event The new sort direction
|
||||
*/
|
||||
onSortDirectionChange(event) {
|
||||
this.sortDirectionChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the sort field
|
||||
* @param event The new sort field
|
||||
*/
|
||||
onSortFieldChange(event) {
|
||||
this.sortFieldChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the pagination
|
||||
* @param event The new pagination
|
||||
*/
|
||||
onPaginationChange(event) {
|
||||
this.paginationChange.emit(event);
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { ClaimedTask } from '../../../core/tasks/models/claimed-task-object.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';
|
||||
|
||||
/**
|
||||
|
@@ -3,10 +3,13 @@ import { Item } from '../../../core/shared/item.model';
|
||||
import { searchResultFor } from '../../../+search-page/search-service/search-result-element-decorator';
|
||||
import { GenericConstructor } from '../../../core/shared/generic-constructor';
|
||||
import { ListableObject } from './listable-object.model';
|
||||
import { isEmpty } from '../../empty.util';
|
||||
|
||||
@searchResultFor(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>> {
|
||||
return this.indexableObject.getRenderTypes().map((type) => {
|
||||
if (typeof type === 'string') {
|
||||
|
@@ -2,5 +2,9 @@ import { TypedObject } from '../../../core/cache/object-cache.reducer';
|
||||
import { GenericConstructor } from '../../../core/shared/generic-constructor';
|
||||
|
||||
export interface ListableObject extends TypedObject {
|
||||
|
||||
/**
|
||||
* Method that returns as which type of object this object should be rendered
|
||||
*/
|
||||
getRenderTypes(): Array<string | GenericConstructor<ListableObject>>;
|
||||
}
|
||||
|
@@ -21,20 +21,37 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
|
||||
*/
|
||||
@Input() object: ListableObject;
|
||||
|
||||
// TODO DO SOMETHING WITH THIS
|
||||
/**
|
||||
* The index of the object in the list
|
||||
*/
|
||||
@Input() index: number;
|
||||
|
||||
/**
|
||||
* The preferred view-mode to display
|
||||
*/
|
||||
@Input() viewMode: ViewMode;
|
||||
|
||||
/**
|
||||
* The context of listable object
|
||||
*/
|
||||
@Input() context: Context;
|
||||
|
||||
/**
|
||||
* The type of link used to render the links inside the listable object
|
||||
*/
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
|
||||
/**
|
||||
* Directive hook used to place the dynamic child component
|
||||
*/
|
||||
@ViewChild(ListableObjectDirective) listableObjectDirective: ListableObjectDirective;
|
||||
|
||||
constructor(private componentFactoryResolver: ComponentFactoryResolver) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the dynamic child component
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
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
|
||||
* @returns {string}
|
||||
* Fetch the component depending on the item's relationship type, view mode and context
|
||||
* @returns {GenericConstructor<Component>}
|
||||
*/
|
||||
private getComponent(): GenericConstructor<Component> {
|
||||
return getListableObjectComponent(this.object.getRenderTypes(), this.viewMode, this.context)
|
||||
|
@@ -10,9 +10,10 @@ export const DEFAULT_VIEW_MODE = ViewMode.ListElement;
|
||||
const map = new Map();
|
||||
|
||||
/**
|
||||
* Decorator used for rendering simple item pages by type and viewMode (and optionally a representationType)
|
||||
* @param type
|
||||
* @param viewMode
|
||||
* Decorator used for rendering a listable object
|
||||
* @param type The object type or entity type the component represents
|
||||
* @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) {
|
||||
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) {
|
||||
let bestMatch;
|
||||
let bestMatchValue = 0;
|
||||
|
@@ -3,6 +3,9 @@ import { Directive, ViewContainerRef } from '@angular/core';
|
||||
@Directive({
|
||||
selector: '[dsListableObject]',
|
||||
})
|
||||
/**
|
||||
* Directive used as a hook to know where to inject the dynamic listable object component
|
||||
*/
|
||||
export class ListableObjectDirective {
|
||||
constructor(public viewContainerRef: ViewContainerRef) { }
|
||||
}
|
||||
|
@@ -7,7 +7,18 @@ import { CollectionElementLinkType } from '../../collection-element-link.type';
|
||||
template: ``,
|
||||
})
|
||||
export class AbstractListableElementComponent<T extends ListableObject> {
|
||||
/**
|
||||
* The object to render in this list element
|
||||
*/
|
||||
@Input() object: T;
|
||||
|
||||
/**
|
||||
* The link type to determine the type of link rendered in this element
|
||||
*/
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
|
||||
/**
|
||||
* The available link types
|
||||
*/
|
||||
linkTypes = CollectionElementLinkType;
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { PoolTask } from '../../../core/tasks/models/pool-task-object.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';
|
||||
|
||||
/**
|
||||
|
@@ -15,7 +15,7 @@ import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claim
|
||||
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({
|
||||
selector: 'ds-claimed-task-search-result-detail-element',
|
||||
|
@@ -19,7 +19,7 @@ export class ItemDetailPreviewFieldComponent {
|
||||
@Input() item: Item;
|
||||
|
||||
/**
|
||||
* The mydspace result object
|
||||
* The search result object
|
||||
*/
|
||||
@Input() object: SearchResult<any>;
|
||||
|
||||
|
@@ -25,7 +25,7 @@ export class ItemDetailPreviewComponent {
|
||||
@Input() item: Item;
|
||||
|
||||
/**
|
||||
* The mydspace result object
|
||||
* The search result object
|
||||
*/
|
||||
@Input() object: SearchResult<any>;
|
||||
|
||||
|
@@ -8,7 +8,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
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({
|
||||
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'
|
||||
})
|
||||
|
||||
@listableObjectComponent('PublicationSearchResult', 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)
|
||||
@listableObjectComponent(Item, ViewMode.DetailedListElement)
|
||||
export class ItemSearchResultDetailElementComponent extends SearchResultDetailElementComponent<ItemSearchResult, Item> {
|
||||
|
||||
/**
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
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 { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
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.
|
||||
@@ -40,10 +39,6 @@ export class PoolSearchResultDetailElementComponent extends SearchResultDetailEl
|
||||
*/
|
||||
public workflowitem: WorkflowItem;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize all instance variables
|
||||
*/
|
||||
|
@@ -6,6 +6,9 @@ import { Metadata } from '../../../core/shared/metadata.utils';
|
||||
import { SearchResult } from '../../../+search-page/search-result.model';
|
||||
import { hasValue } from '../../empty.util';
|
||||
|
||||
/**
|
||||
* Component representing Search Results with ViewMode.DetailedElement
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ds-search-result-detail-element',
|
||||
template: ``
|
||||
@@ -17,6 +20,9 @@ export class SearchResultDetailElementComponent<T extends SearchResult<K>, K ext
|
||||
*/
|
||||
dso: K;
|
||||
|
||||
/**
|
||||
* Initialize instance variables
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
if (hasValue(this.object)) {
|
||||
this.dso = this.object.indexableObject;
|
||||
|
@@ -13,7 +13,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
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({
|
||||
selector: 'ds-workflow-item-search-result-detail-element',
|
||||
|
@@ -14,7 +14,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
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({
|
||||
selector: 'ds-workspace-item-search-result-detail-element',
|
||||
|
@@ -31,6 +31,9 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme
|
||||
animations: [fadeIn]
|
||||
})
|
||||
export class ObjectDetailComponent {
|
||||
/**
|
||||
* The view mode of this component
|
||||
*/
|
||||
viewMode = ViewMode.DetailedListElement;
|
||||
|
||||
/**
|
||||
@@ -52,7 +55,15 @@ export class ObjectDetailComponent {
|
||||
* A boolean representing if to hide pagination when there is only a page
|
||||
*/
|
||||
@Input() hidePagerWhenSinglePage = true;
|
||||
|
||||
/**
|
||||
* The link type of the rendered listable elements
|
||||
*/
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
|
||||
/**
|
||||
* The context of the rendered listable elements
|
||||
*/
|
||||
@Input() context: Context;
|
||||
|
||||
/**
|
||||
|
@@ -5,6 +5,9 @@ import { AbstractListableElementComponent } from '../../object-collection/shared
|
||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
|
||||
/**
|
||||
* Component representing a grid element for collection
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ds-collection-grid-element',
|
||||
styleUrls: ['./collection-grid-element.component.scss'],
|
||||
|
@@ -5,6 +5,9 @@ import { AbstractListableElementComponent } from '../../object-collection/shared
|
||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
|
||||
/**
|
||||
* Component representing a grid element for a community
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ds-community-grid-element',
|
||||
styleUrls: ['./community-grid-element.component.scss'],
|
||||
|
@@ -34,20 +34,57 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme
|
||||
})
|
||||
|
||||
export class ObjectGridComponent implements OnInit {
|
||||
/**
|
||||
* The view mode of the this component
|
||||
*/
|
||||
viewMode = ViewMode.GridElement;
|
||||
|
||||
/**
|
||||
* The current pagination configuration
|
||||
*/
|
||||
@Input() config: PaginationComponentOptions;
|
||||
|
||||
/**
|
||||
* The current sort configuration
|
||||
*/
|
||||
@Input() sortConfig: SortOptions;
|
||||
|
||||
/**
|
||||
* The whether or not the gear is hidden
|
||||
*/
|
||||
@Input() hideGear = false;
|
||||
|
||||
/**
|
||||
* Whether or not the pager is visible when there is only a single page of results
|
||||
*/
|
||||
@Input() hidePagerWhenSinglePage = true;
|
||||
|
||||
/**
|
||||
* The link type of the listable elements
|
||||
*/
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
|
||||
/**
|
||||
* The context of the listable elements
|
||||
*/
|
||||
@Input() context: Context;
|
||||
|
||||
/**
|
||||
* Behavior subject to output the current listable objects
|
||||
*/
|
||||
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>>) {
|
||||
this._objects$.next(objects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter to return the current objects
|
||||
*/
|
||||
get objects() {
|
||||
return this._objects$.getValue();
|
||||
}
|
||||
@@ -82,7 +119,10 @@ export class ObjectGridComponent implements OnInit {
|
||||
*/
|
||||
@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.
|
||||
@@ -96,6 +136,9 @@ export class ObjectGridComponent implements OnInit {
|
||||
this._objects$ = new BehaviorSubject(undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the instance variables
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
const nbColumns$ = this.hostWindow.widthCategory.pipe(
|
||||
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) {
|
||||
this.pageChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits the current page size when it changes
|
||||
* @param event The new page size
|
||||
*/
|
||||
onPageSizeChange(event) {
|
||||
this.pageSizeChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits the current sort direction when it changes
|
||||
* @param event The new sort direction
|
||||
*/
|
||||
onSortDirectionChange(event) {
|
||||
this.sortDirectionChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits the current sort field when it changes
|
||||
* @param event The new sort field
|
||||
*/
|
||||
onSortFieldChange(event) {
|
||||
this.sortFieldChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits the current pagination when it changes
|
||||
* @param event The new pagination
|
||||
*/
|
||||
onPaginationChange(event) {
|
||||
this.paginationChange.emit(event);
|
||||
}
|
||||
|
@@ -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'],
|
||||
templateUrl: 'collection-search-result-grid-element.component.html'
|
||||
})
|
||||
|
||||
/**
|
||||
* Component representing a grid element for a collection search result
|
||||
*/
|
||||
@listableObjectComponent(CollectionSearchResult, ViewMode.GridElement)
|
||||
export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent<CollectionSearchResult, Collection> {}
|
||||
|
@@ -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'],
|
||||
templateUrl: 'community-search-result-grid-element.component.html'
|
||||
})
|
||||
|
||||
/**
|
||||
* Component representing a grid element for a community search result
|
||||
*/
|
||||
@listableObjectComponent(CommunitySearchResult, ViewMode.GridElement)
|
||||
export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent<CommunitySearchResult, Community> {
|
||||
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ import { ItemSearchResult } from '../../../../object-collection/shared/item-sear
|
||||
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> {
|
||||
}
|
||||
|
@@ -14,7 +14,14 @@ import { hasValue } from '../../empty.util';
|
||||
})
|
||||
|
||||
export class SearchResultGridElementComponent<T extends SearchResult<K>, K extends DSpaceObject> extends AbstractListableElementComponent<T> implements OnInit {
|
||||
/**
|
||||
* The DSpaceObject of the search result
|
||||
*/
|
||||
dso: K;
|
||||
|
||||
/**
|
||||
* Whether or not the grid element is currently collapsed
|
||||
*/
|
||||
isCollapsed$: Observable<boolean>;
|
||||
|
||||
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 {
|
||||
if (hasValue(this.object)) {
|
||||
this.dso = this.object.indexableObject;
|
||||
|
@@ -10,6 +10,8 @@ import { listableObjectComponent } from '../../object-collection/shared/listable
|
||||
styleUrls: ['./collection-list-element.component.scss'],
|
||||
templateUrl: './collection-list-element.component.html'
|
||||
})
|
||||
|
||||
/**
|
||||
* Component representing list element for a collection
|
||||
*/
|
||||
@listableObjectComponent(Collection, ViewMode.ListElement)
|
||||
export class CollectionListElementComponent extends AbstractListableElementComponent<Collection> {}
|
||||
|
@@ -10,6 +10,8 @@ import { listableObjectComponent } from '../../object-collection/shared/listable
|
||||
styleUrls: ['./community-list-element.component.scss'],
|
||||
templateUrl: './community-list-element.component.html'
|
||||
})
|
||||
|
||||
/**
|
||||
* Component representing a list element for a community
|
||||
*/
|
||||
@listableObjectComponent(Community, ViewMode.ListElement)
|
||||
export class CommunityListElementComponent extends AbstractListableElementComponent<Community> {}
|
||||
|
@@ -7,6 +7,12 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
selector: 'ds-item-type-badge',
|
||||
templateUrl: './item-type-badge.component.html'
|
||||
})
|
||||
/**
|
||||
* Component rendering the type of an item as a badge
|
||||
*/
|
||||
export class ItemTypeBadgeComponent {
|
||||
/**
|
||||
* The component used to retrieve the type from
|
||||
*/
|
||||
@Input() object: DSpaceObject;
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ import { metadataRepresentationComponent } from '../../../metadata-representatio
|
||||
export class ItemMetadataListElementComponent extends MetadataRepresentationListElementComponent {
|
||||
/**
|
||||
* The view-mode we're currently on
|
||||
* @type {ElementViewMode}
|
||||
* @type {ViewMode}
|
||||
*/
|
||||
viewMode = ViewMode.ListElement;
|
||||
}
|
||||
|
@@ -9,5 +9,8 @@ import { MetadataRepresentation } from '../../../core/shared/metadata-representa
|
||||
* An abstract class for displaying a single MetadataRepresentation
|
||||
*/
|
||||
export class MetadataRepresentationListElementComponent {
|
||||
/**
|
||||
* The metadata representation of this component
|
||||
*/
|
||||
metadataRepresentation: MetadataRepresentation;
|
||||
}
|
||||
|
@@ -13,10 +13,9 @@ import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspa
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model';
|
||||
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({
|
||||
selector: 'ds-claimed-search-result-list-element',
|
||||
|
@@ -22,7 +22,7 @@ export class ItemListPreviewComponent {
|
||||
@Input() item: Item;
|
||||
|
||||
/**
|
||||
* The mydspace result object
|
||||
* The search result object
|
||||
*/
|
||||
@Input() object: SearchResult<any>;
|
||||
|
||||
|
@@ -9,7 +9,7 @@ import { ItemSearchResult } from '../../../object-collection/shared/item-search-
|
||||
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({
|
||||
selector: 'ds-item-search-result-list-element-submission',
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
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 { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
|
||||
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({
|
||||
selector: 'ds-pool-search-result-list-element',
|
||||
@@ -42,6 +41,9 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
|
||||
*/
|
||||
public workflowitem: WorkflowItem;
|
||||
|
||||
/**
|
||||
* The index of this list element
|
||||
*/
|
||||
public index: number;
|
||||
|
||||
constructor(protected truncatableService: TruncatableService) {
|
||||
|
@@ -14,7 +14,7 @@ import { WorkflowItemSearchResult } from '../../../object-collection/shared/work
|
||||
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({
|
||||
selector: 'ds-workflow-item-my-dspace-result-list-element',
|
||||
|
@@ -14,7 +14,7 @@ import { WorkspaceItemSearchResult } from '../../../object-collection/shared/wor
|
||||
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({
|
||||
selector: 'ds-workspace-item-search-result-list-element',
|
||||
|
@@ -25,19 +25,63 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme
|
||||
animations: [fadeIn]
|
||||
})
|
||||
export class ObjectListComponent {
|
||||
/**
|
||||
* The view mode of the this component
|
||||
*/
|
||||
viewMode = ViewMode.ListElement;
|
||||
|
||||
/**
|
||||
* The current pagination configuration
|
||||
*/
|
||||
@Input() config: PaginationComponentOptions;
|
||||
|
||||
/**
|
||||
* The current sort configuration
|
||||
*/
|
||||
@Input() sortConfig: SortOptions;
|
||||
|
||||
/**
|
||||
* Whether or not the list elements have a border
|
||||
*/
|
||||
@Input() hasBorder = false;
|
||||
|
||||
/**
|
||||
* The whether or not the gear is hidden
|
||||
*/
|
||||
@Input() hideGear = false;
|
||||
|
||||
/**
|
||||
* Whether or not the pager is visible when there is only a single page of results
|
||||
*/
|
||||
@Input() hidePagerWhenSinglePage = true;
|
||||
|
||||
/**
|
||||
* The link type of the listable elements
|
||||
*/
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
|
||||
/**
|
||||
* The context of the listable elements
|
||||
*/
|
||||
@Input() context: Context;
|
||||
|
||||
/**
|
||||
* The current listable objects
|
||||
*/
|
||||
private _objects: RemoteData<PaginatedList<ListableObject>>;
|
||||
|
||||
|
||||
/**
|
||||
* Setter for the objects
|
||||
* @param objects The new objects
|
||||
*/
|
||||
@Input() set objects(objects: RemoteData<PaginatedList<ListableObject>>) {
|
||||
this._objects = objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter to return the current objects
|
||||
*/
|
||||
get objects() {
|
||||
return this._objects;
|
||||
}
|
||||
@@ -72,6 +116,9 @@ export class ObjectListComponent {
|
||||
*/
|
||||
@Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter<SortDirection>();
|
||||
|
||||
/**
|
||||
* An event fired when on of the pagination parameters changes
|
||||
*/
|
||||
@Output() paginationChange: EventEmitter<SortDirection> = new EventEmitter<any>();
|
||||
|
||||
/**
|
||||
@@ -79,24 +126,42 @@ export class ObjectListComponent {
|
||||
* Event's payload equals to the newly selected sort field.
|
||||
*/
|
||||
@Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>();
|
||||
data: any = {};
|
||||
|
||||
/**
|
||||
* Emits the current page when it changes
|
||||
* @param event The new page
|
||||
*/
|
||||
onPageChange(event) {
|
||||
this.pageChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits the current page size when it changes
|
||||
* @param event The new page size
|
||||
*/
|
||||
onPageSizeChange(event) {
|
||||
this.pageSizeChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits the current sort direction when it changes
|
||||
* @param event The new sort direction
|
||||
*/
|
||||
onSortDirectionChange(event) {
|
||||
this.sortDirectionChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits the current sort field when it changes
|
||||
* @param event The new sort field
|
||||
*/
|
||||
onSortFieldChange(event) {
|
||||
this.sortFieldChange.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits the current pagination when it changes
|
||||
* @param event The new pagination
|
||||
*/
|
||||
onPaginationChange(event) {
|
||||
this.paginationChange.emit(event);
|
||||
}
|
||||
|
@@ -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'],
|
||||
templateUrl: 'collection-search-result-list-element.component.html'
|
||||
})
|
||||
|
||||
/**
|
||||
* Component representing a collection search result in list view
|
||||
*/
|
||||
@listableObjectComponent(CollectionSearchResult, ViewMode.ListElement)
|
||||
export class CollectionSearchResultListElementComponent extends SearchResultListElementComponent<CollectionSearchResult, Collection> {}
|
||||
|
@@ -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'],
|
||||
templateUrl: 'community-search-result-list-element.component.html'
|
||||
})
|
||||
|
||||
/**
|
||||
* Component representing a community search result in list view
|
||||
*/
|
||||
@listableObjectComponent(CommunitySearchResult, ViewMode.ListElement)
|
||||
export class CommunitySearchResultListElementComponent extends SearchResultListElementComponent<CommunitySearchResult, Community> {
|
||||
|
||||
|
@@ -13,7 +13,7 @@ import { Item } from '../../../../../../core/shared/item.model';
|
||||
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> {
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ import { hasValue } from '../../empty.util';
|
||||
import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component';
|
||||
import { TruncatableService } from '../../truncatable/truncatable.service';
|
||||
import { Metadata } from '../../../core/shared/metadata.utils';
|
||||
import { MetadataMap } from '../../../core/shared/metadata.models';
|
||||
|
||||
@Component({
|
||||
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 {
|
||||
/**
|
||||
* The DSpaceObject of the search result
|
||||
*/
|
||||
dso: K;
|
||||
metadata: MetadataMap;
|
||||
|
||||
public constructor(protected truncatableService: TruncatableService) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the dso from the search result
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
if (hasValue(this.object)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits if the list element is currently collapsed or not
|
||||
*/
|
||||
isCollapsed(): Observable<boolean> {
|
||||
return this.truncatableService.isCollapsed(this.dso.id);
|
||||
}
|
||||
|
@@ -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 { 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 { 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 = [
|
||||
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
||||
@@ -253,7 +255,13 @@ const COMPONENTS = [
|
||||
EditItemSelectorComponent,
|
||||
CommunitySearchResultListElementComponent,
|
||||
CollectionSearchResultListElementComponent,
|
||||
CommunitySearchResultGridElementComponent,
|
||||
CollectionSearchResultGridElementComponent,
|
||||
ListableObjectComponentLoaderComponent,
|
||||
CollectionListElementComponent,
|
||||
CommunityListElementComponent,
|
||||
CollectionGridElementComponent,
|
||||
CommunityGridElementComponent,
|
||||
BrowseByComponent,
|
||||
ItemTypeBadgeComponent,
|
||||
MetadataRepresentationLoaderComponent
|
||||
@@ -268,6 +276,8 @@ const ENTRY_COMPONENTS = [
|
||||
CollectionSearchResultListElementComponent,
|
||||
CollectionGridElementComponent,
|
||||
CommunityGridElementComponent,
|
||||
CommunitySearchResultGridElementComponent,
|
||||
CollectionSearchResultGridElementComponent,
|
||||
SearchResultGridElementComponent,
|
||||
PublicationListElementComponent,
|
||||
PublicationGridElementComponent,
|
||||
|
@@ -22,13 +22,23 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
@Input() inPlaceSearch;
|
||||
|
||||
/**
|
||||
* The current view mode
|
||||
*/
|
||||
currentMode: ViewMode = ViewMode.ListElement;
|
||||
|
||||
/**
|
||||
* All available view modes
|
||||
*/
|
||||
viewModeEnum = ViewMode;
|
||||
private sub: Subscription;
|
||||
|
||||
constructor(private searchService: SearchService) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the instance variables
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
if (isEmpty(this.viewModeList)) {
|
||||
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) {
|
||||
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) {
|
||||
return this.viewModeList && this.viewModeList.includes(viewMode);
|
||||
}
|
||||
|
@@ -117,7 +117,7 @@ export function createMockApi() {
|
||||
const id = req.params.item_id;
|
||||
try {
|
||||
req.item_id = id;
|
||||
req.object = ITEMS.items.find((item) => {
|
||||
req.item = ITEMS.items.find((item) => {
|
||||
return item.id === id;
|
||||
});
|
||||
next();
|
||||
@@ -127,7 +127,7 @@ export function createMockApi() {
|
||||
});
|
||||
|
||||
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) => {
|
||||
|
Reference in New Issue
Block a user