Skip to content
Snippets Groups Projects
Commit 3f98fed0 authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

57557: Added JSDocs

parent 7b6665d3
No related branches found
No related tags found
No related merge requests found
Showing
with 158 additions and 11 deletions
......@@ -11,6 +11,10 @@ import { getRemoteDataPayload } from '../../../../core/shared/operators';
import { hasValue } from '../../../../shared/empty.util';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component';
/**
* Operator for comparing arrays using a mapping function
* @param mapFn Function for mapping the arrays
*/
const compareArraysUsing = <T>(mapFn: (t: T) => any) =>
(a: T[], b: T[]): boolean => {
if (!Array.isArray(a) || ! Array.isArray(b)) {
......@@ -25,6 +29,9 @@ const compareArraysUsing = <T>(mapFn: (t: T) => any) =>
bIds.every((e) => aIds.includes(e));
};
/**
* Operator for comparing arrays using the object's ids
*/
const compareArraysUsingIds = <T extends { id: string }>() =>
compareArraysUsing((t: T) => hasValue(t) ? t.id : undefined);
......
......@@ -18,12 +18,6 @@ import { SearchConfigurationService } from './search-service/search-configuratio
import { getSucceededRemoteData } from '../core/shared/operators';
import { RouteService } from '../shared/services/route.service';
/**
* This component renders a simple item page.
* The route parameter 'id' is used to request the item it represents.
* All fields of the item that should be displayed, are defined in its template.
*/
@Component({
selector: 'ds-search-page',
styleUrls: ['./search-page.component.scss'],
......@@ -34,6 +28,7 @@ import { RouteService } from '../shared/services/route.service';
/**
* This component represents the whole search page
* It renders search results depending on the current search options
*/
export class SearchPageComponent implements OnInit {
......
......@@ -9,11 +9,6 @@ import { SearchResult } from '../search-result.model';
import { PaginatedList } from '../../core/data/paginated-list';
import { hasValue, isNotEmpty } from '../../shared/empty.util';
/**
* This component renders a simple item page.
* The route parameter 'id' is used to request the item it represents.
* All fields of the item that should be displayed, are defined in its template.
*/
@Component({
selector: 'ds-search-results',
templateUrl: './search-results.component.html',
......
......@@ -5,16 +5,28 @@ import { mapsTo } from '../../builders/build-decorators';
import { NormalizedObject } from '../normalized-object.model';
import { IDToUUIDSerializer } from '../../id-to-uuid-serializer';
/**
* Normalized model class for a DSpace EntityType
*/
@mapsTo(EntityType)
@inheritSerialization(NormalizedObject)
export class NormalizedEntityType extends NormalizedObject {
/**
* The label that describes the ResourceType of the Entity
*/
@autoserialize
label: string;
/**
* The identifier of this EntityType
*/
@autoserialize
id: string;
/**
* The universally unique identifier of this EntityType
*/
@autoserializeAs(new IDToUUIDSerializer(ResourceType.EntityType), 'id')
uuid: string;
}
......@@ -6,12 +6,22 @@ import { NormalizedDSpaceObject } from '../normalized-dspace-object.model';
import { NormalizedObject } from '../normalized-object.model';
import { IDToUUIDSerializer } from '../../id-to-uuid-serializer';
/**
* Normalized model class for a DSpace RelationshipType
*/
@mapsTo(RelationshipType)
@inheritSerialization(NormalizedDSpaceObject)
export class NormalizedRelationshipType extends NormalizedObject {
/**
* The identifier of this RelationshipType
*/
@autoserialize
id: string;
/**
* The label that describes the Relation to the left of this RelationshipType
*/
@autoserialize
leftLabel: string;
......@@ -21,6 +31,9 @@ export class NormalizedRelationshipType extends NormalizedObject {
@autoserialize
leftMinCardinality: number;
/**
* The label that describes the Relation to the right of this RelationshipType
*/
@autoserialize
rightLabel: string;
......@@ -30,14 +43,23 @@ export class NormalizedRelationshipType extends NormalizedObject {
@autoserialize
rightMinCardinality: number;
/**
* The type of Entity found to the left of this RelationshipType
*/
@autoserialize
@relationship(ResourceType.EntityType, false)
leftType: string;
/**
* The type of Entity found to the right of this RelationshipType
*/
@autoserialize
@relationship(ResourceType.EntityType, false)
rightType: string;
/**
* The universally unique identifier of this RelationshipType
*/
@autoserializeAs(new IDToUUIDSerializer(ResourceType.RelationshipType), 'id')
uuid: string;
}
......@@ -5,26 +5,44 @@ import { mapsTo, relationship } from '../../builders/build-decorators';
import { NormalizedObject } from '../normalized-object.model';
import { IDToUUIDSerializer } from '../../id-to-uuid-serializer';
/**
* Normalized model class for a DSpace Relationship
*/
@mapsTo(Relationship)
@inheritSerialization(NormalizedObject)
export class NormalizedRelationship extends NormalizedObject {
/**
* The identifier of this Relationship
*/
@autoserialize
id: string;
/**
* The identifier of the Relationship to the left side of this Relationship
*/
@autoserialize
leftId: string;
@autoserialize
place: number;
/**
* The identifier of the Relationship to the right side of this Relationship
*/
@autoserialize
rightId: string;
/**
* The type of Relationship
*/
@autoserialize
@relationship(ResourceType.RelationshipType, false)
relationshipType: string;
/**
* The universally unique identifier of this Relationship
*/
@autoserializeAs(new IDToUUIDSerializer(ResourceType.Relationship), 'id')
uuid: string;
}
......@@ -8,6 +8,10 @@ import { ObjectCacheService } from '../cache/object-cache.service';
import { GlobalConfig } from '../../../config/global-config.interface';
import { GLOBAL_CONFIG } from '../../../config';
/**
* A ResponseParsingService used to parse DSpaceRESTV2Response coming from the REST API to a discovery query (string)
* wrapped in a FilteredDiscoveryQueryResponse
*/
@Injectable()
export class FilteredDiscoveryPageResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
objectFactory = {};
......@@ -17,6 +21,13 @@ export class FilteredDiscoveryPageResponseParsingService extends BaseResponsePar
protected objectCache: ObjectCacheService,
) { super();
}
/**
* Parses data from the REST API to a discovery query wrapped in a FilteredDiscoveryQueryResponse
* @param {RestRequest} request
* @param {DSpaceRESTV2Response} data
* @returns {RestResponse}
*/
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
const query = data.payload['discovery-query'];
return new FilteredDiscoveryQueryResponse(query, data.statusCode);
......
......@@ -2,8 +2,23 @@ import { CacheableObject } from '../../cache/object-cache.reducer';
import { ResourceType } from '../resource-type';
export class EntityType implements CacheableObject {
/**
* The identifier of this EntityType
*/
id: string;
/**
* The link to the rest endpoint where this object can be found
*/
self: string;
/**
* The type of Resource this is
*/
type: ResourceType;
/**
* The universally unique identifier of this EntityType
*/
uuid: string;
}
......@@ -5,29 +5,56 @@ import { ResourceType } from '../resource-type';
import { EntityType } from './entity-type.model';
export class RelationshipType implements CacheableObject {
/**
* The link to the rest endpoint where this object can be found
*/
self: string;
/**
* The type of Resource this is
*/
type: ResourceType;
/**
* The label that describes this RelationshipType
*/
label: string;
/**
* The identifier of this RelationshipType
*/
id: string;
/**
* The universally unique identifier of this RelationshipType
*/
uuid: string;
/**
* The label that describes the Relation to the left of this RelationshipType
*/
leftLabel: string;
leftMaxCardinality: number;
leftMinCardinality: number;
/**
* The label that describes the Relation to the right of this RelationshipType
*/
rightLabel: string;
rightMaxCardinality: number;
rightMinCardinality: number;
/**
* The type of Entity found to the left of this RelationshipType
*/
leftType: Observable<RemoteData<EntityType>>;
/**
* The type of Entity found to the right of this RelationshipType
*/
rightType: Observable<RemoteData<EntityType>>;
}
......@@ -5,19 +5,40 @@ import { ResourceType } from '../resource-type';
import { RelationshipType } from './relationship-type.model';
export class Relationship implements CacheableObject {
/**
* The link to the rest endpoint where this object can be found
*/
self: string;
/**
* The type of Resource this is
*/
type: ResourceType;
/**
* The universally unique identifier of this Relationship
*/
uuid: string;
/**
* The identifier of this Relationship
*/
id: string;
/**
* The identifier of the Relationship to the left side of this Relationship
*/
leftId: string;
place: string;
/**
* The identifier of the Relationship to the right side of this Relationship
*/
rightId: string;
/**
* The type of Relationship
*/
relationshipType: Observable<RemoteData<RelationshipType>>;
}
......@@ -4,6 +4,12 @@ import { ElementViewMode } from '../view-mode';
export const DEFAULT_ENTITY_TYPE = 'Default';
const map = new Map();
/**
* Decorator used for rendering simple item pages for an Entity by type and viewMode
* @param type
* @param viewMode
*/
export function rendersEntityType(type: string, viewMode: ElementViewMode) {
return function decorator(component: any) {
if (hasNoValue(map.get(viewMode))) {
......@@ -16,6 +22,11 @@ export function rendersEntityType(type: string, viewMode: ElementViewMode) {
};
}
/**
* Get the component used for rendering an entity by type and viewMode
* @param type
* @param viewMode
*/
export function getComponentByEntityType(type: string, viewMode: ElementViewMode) {
let component = map.get(viewMode).get(type);
if (hasNoValue(component)) {
......
/**
* Enum used for defining the view-mode of a set of elements
* List Display the elements in a (vertical) list
* Grid Display the elements in a grid
*/
export enum SetViewMode {
List = 'list',
Grid = 'grid'
}
/**
* Enum used for defining the view-mode of a single element
* Full Display the full element
* SetElement Display the element as part of a set
*/
export enum ElementViewMode {
Full,
SetElement
}
/**
* ViewMode refers to either a SetViewMode or ElementViewMode
*/
export type ViewMode = SetViewMode | ElementViewMode;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment