101623: Add HierarchicalBrowseDefinition model + base BrowseDefinition class

This commit is contained in:
Nona Luypaert
2023-05-10 11:01:15 +02:00
parent c10e660e0b
commit c2f2cb5b3a
4 changed files with 72 additions and 1 deletions

View File

@@ -0,0 +1,10 @@
/**
* Base class for BrowseDefinition models
*/
export abstract class BrowseDefinition {
/**
* Get the render type of the BrowseDefinition model
*/
abstract getRenderType(): string;
}

View File

@@ -7,9 +7,10 @@ import { ResourceType } from './resource-type';
import { SortOption } from './sort-option.model'; import { SortOption } from './sort-option.model';
import { CacheableObject } from '../cache/cacheable-object.model'; import { CacheableObject } from '../cache/cacheable-object.model';
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-decorator'; import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-decorator';
import { BrowseDefinition } from './browse-definition';
@typedObject @typedObject
export class FlatBrowseDefinition extends CacheableObject { export class FlatBrowseDefinition extends CacheableObject implements BrowseDefinition {
static type = FLAT_BROWSE_DEFINITION; static type = FLAT_BROWSE_DEFINITION;
/** /**
@@ -46,4 +47,8 @@ export class FlatBrowseDefinition extends CacheableObject {
entries: HALLink; entries: HALLink;
items: HALLink; items: HALLink;
}; };
getRenderType(): string {
return this.dataType;
}
} }

View File

@@ -0,0 +1,47 @@
import { autoserialize, autoserializeAs, deserialize } from 'cerialize';
import { typedObject } from '../cache/builders/build-decorators';
import { excludeFromEquals } from '../utilities/equals.decorators';
import { HIERARCHICAL_BROWSE_DEFINITION } from './hierarchical-browse-definition.resource-type';
import { HALLink } from './hal-link.model';
import { ResourceType } from './resource-type';
import { CacheableObject } from '../cache/cacheable-object.model';
import { BrowseDefinition } from './browse-definition';
@typedObject
export class HierarchicalBrowseDefinition extends CacheableObject implements BrowseDefinition {
static type = HIERARCHICAL_BROWSE_DEFINITION;
/**
* The object type
*/
@excludeFromEquals
type: ResourceType = HIERARCHICAL_BROWSE_DEFINITION;
@autoserialize
id: string;
@autoserialize
facetType: string;
@autoserialize
vocabulary: string;
@autoserializeAs('metadata')
metadataKeys: string[];
get self(): string {
return this._links.self.href;
}
@deserialize
_links: {
self: HALLink;
entries: HALLink;
items: HALLink;
vocabulary: HALLink;
};
getRenderType(): string {
return 'hierarchy';
}
}

View File

@@ -0,0 +1,9 @@
import { ResourceType } from './resource-type';
/**
* The resource type for HierarchicalBrowseDefinition
*
* Needs to be in a separate file to prevent circular
* dependencies in webpack.
*/
export const HIERARCHICAL_BROWSE_DEFINITION = new ResourceType('hierarchicalBrowse');