Skip to content

Commit 8291e3e

Browse files
[DURACOM-507] add inline documentation
1 parent 34762b7 commit 8291e3e

18 files changed

Lines changed: 242 additions & 20 deletions
Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,170 @@
1+
/**
2+
* Defines a metadata group within a layout field, grouping related metadata entries.
3+
*/
14
export interface MetadataGroup {
5+
/** The leading metadata key that acts as the group heading. */
26
leading: string;
7+
/** Array of layout fields within this group. */
38
elements: LayoutField[];
49
}
510

11+
/**
12+
* Configuration for bitstream-related rendering in a layout field.
13+
*/
614
export interface LayoutBitstream {
15+
/** The bundle name to filter bitstreams from. */
716
bundle: string;
17+
/** The metadata field used to identify the bitstream. */
818
metadataField: string;
19+
/** The metadata value to match for selecting the bitstream. */
920
metadataValue: string;
1021
}
1122

23+
/**
24+
* Enum of layout field types that determine how a field is rendered.
25+
*/
1226
export enum LayoutFieldType {
1327
METADATA = 'METADATA',
1428
METADATAGROUP = 'METADATAGROUP',
1529
BITSTREAM = 'BITSTREAM'
1630
}
1731

32+
/**
33+
* Describes a single renderable field within a metadata box row.
34+
* Contains the metadata key, rendering type, and styling options.
35+
*/
1836
export interface LayoutField {
37+
/** The metadata key to display (e.g., 'dc.title', 'dc.contributor.author'). */
1938
metadata?: string;
39+
/** Bitstream configuration if this field renders a bitstream. */
2040
bitstream?: LayoutBitstream;
41+
/** i18n label key for the field. */
2142
label?: string;
43+
/** The rendering type identifier (e.g., 'text', 'link', 'date', 'thumbnail'). */
2244
rendering: string;
45+
/** The field type discriminator. */
2346
fieldType: LayoutFieldType | string;
47+
/** CSS classes for the overall field container. */
2448
style?: string;
49+
/** CSS classes for the label column. */
2550
styleLabel?: string;
51+
/** CSS classes for the value column. */
2652
styleValue?: string;
53+
/** Nested metadata group configuration if fieldType is METADATAGROUP. */
2754
metadataGroup?: MetadataGroup;
55+
/** Whether to render the label as a heading element. */
2856
labelAsHeading: boolean;
57+
/** Whether to render multiple values inline (comma-separated) rather than stacked. */
2958
valuesInline: boolean;
3059
}
3160

61+
/**
62+
* Configuration for a metadata-type box containing rows of metadata fields.
63+
*/
3264
export interface MetadataBoxConfiguration extends BoxConfiguration {
65+
/** Unique identifier for this box configuration. */
3366
id: string;
67+
/** Array of rows within the metadata box. */
3468
rows: MetadataBoxRow[];
3569
}
3670

71+
/**
72+
* Base interface for all box configurations.
73+
*/
3774
export interface BoxConfiguration {
75+
/** The box type discriminator. */
3876
type: string;
3977
}
4078

79+
/**
80+
* Configuration for a relation-type box that displays related items via a discovery search.
81+
*/
4182
export interface RelationBoxConfiguration extends BoxConfiguration {
83+
/** The discovery configuration name used to find related items. */
4284
'discovery-configuration': string;
4385
}
4486

87+
/**
88+
* Configuration for a metrics-type box displaying item-level metrics.
89+
*/
4590
export interface MetricsBoxConfiguration extends BoxConfiguration {
91+
/** Maximum number of columns for metrics display (null for unlimited). */
4692
maxColumns: null;
93+
/** Array of metric type identifiers to display. */
4794
metrics: string[];
4895
}
4996

97+
/**
98+
* A cell within a metadata box row, containing layout fields.
99+
*/
50100
export interface MetadataBoxCell {
101+
/** CSS classes applied to the cell element. */
51102
style: string;
103+
/** Array of fields rendered within this cell. */
52104
fields: LayoutField[];
53105
}
54106

107+
/**
108+
* A row within a metadata box configuration.
109+
*/
55110
export interface MetadataBoxRow {
111+
/** CSS classes applied to the row element. */
56112
style: string;
113+
/** Array of cells within this row. */
57114
cells: MetadataBoxCell[];
58115
}
59116

60117
/**
61-
* Describes the DynamicLayoutBox model
118+
* Model representing a box in the dynamic layout system.
119+
*
120+
* A box is a configurable content container within a tab's cell. It defines what type of
121+
* content to render (metadata, relations, metrics, collections, IIIF viewer, versioning)
122+
* and provides styling, security, and collapsibility settings.
62123
*/
63124
export class DynamicLayoutBox {
64125

65126
/**
66-
* The identifier of this DynamicLayoutBox
127+
* The numeric identifier of this box.
67128
*/
68129
id: number;
69130

131+
/** Short identifier name for this box. */
70132
shortname: string;
71133

134+
/** i18n key or plain text for the box header. */
72135
header: string;
73136

137+
/** The entity type this box belongs to. */
74138
entityType: string;
75139

140+
/** Whether the box starts collapsed. */
76141
collapsed: boolean;
77142

143+
/** Whether this box is a minor box (can be filtered out by TabDataService). */
78144
minor: boolean;
79145

146+
/** CSS classes applied to the box container. */
80147
style: string;
81148

149+
/** Whether to insert a clear element after this box. */
82150
clear: boolean;
83151

152+
/** Maximum number of columns for this box's content. */
84153
maxColumn: number;
85154

155+
/** Whether this box acts as a container for other elements. */
86156
container: boolean;
87157

158+
/** Metadata fields that have security restrictions. */
88159
metadataSecurityFields?: string[];
89160

161+
/** Security level required to view this box. */
90162
security: number;
91163

164+
/** The box type discriminator (METADATA, RELATION, METRICS, etc.). */
92165
boxType: string;
93166

167+
/** Type-specific configuration for the box content. */
94168
configuration?: RelationBoxConfiguration | MetadataBoxConfiguration | MetricsBoxConfiguration;
95169

96170
}

src/app/core/layout/models/tab.model.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import { DynamicLayoutBox } from './box.model';
1414
import { TAB } from './tab.resource-type';
1515

1616
/**
17-
* Describes a type of DynamicLayoutTab
17+
* Model representing a layout tab in the dynamic item page system.
18+
*
19+
* A tab defines a named section of an item's detail page. Tabs contain rows and cells
20+
* forming a grid layout, and may be marked as "leading" (rendered above the main content).
21+
* Tabs are fetched from the REST API via the `/tabs` endpoint.
1822
*/
1923
@typedObject
2024
export class DynamicLayoutTab extends CacheableObject {
@@ -85,13 +89,23 @@ export class DynamicLayoutTab extends CacheableObject {
8589
}
8690

8791

92+
/**
93+
* A row within a tab's layout grid. Contains cells arranged horizontally.
94+
*/
8895
export interface DynamicLayoutRow {
96+
/** CSS classes applied to the row element (e.g., Bootstrap grid row classes). */
8997
style: string;
98+
/** Array of cells within this row. */
9099
cells: DynamicLayoutCell[];
91100
}
92101

102+
/**
103+
* A cell within a layout row. Contains one or more boxes.
104+
*/
93105
export interface DynamicLayoutCell {
106+
/** CSS classes applied to the cell element (e.g., Bootstrap column classes). */
94107
style: string;
108+
/** Array of boxes rendered within this cell. */
95109
boxes: DynamicLayoutBox[];
96110
}
97111

src/app/core/layout/tab-data.service.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import {
2525
} from './models/tab.model';
2626

2727
/**
28-
* A service responsible for fetching data from the REST API on the tabs endpoint
28+
* A service responsible for fetching layout tabs from the REST API's `/tabs` endpoint.
29+
*
30+
* Provides methods to find tabs by item UUID or entity type, with support for
31+
* filtering out tabs that contain only minor (secondary) boxes.
2932
*/
3033
@Injectable({ providedIn: 'root' })
3134
export class TabDataService extends IdentifiableDataService<DynamicLayoutTab> {
@@ -68,16 +71,20 @@ export class TabDataService extends IdentifiableDataService<DynamicLayoutTab> {
6871
}
6972

7073
/**
71-
* @param tabs
72-
* @returns Tabs which contains non minor element
74+
* Filters out tabs where every box is marked as minor.
75+
*
76+
* @param tabs the full list of tabs to filter
77+
* @returns tabs that contain at least one non-minor box
7378
*/
7479
filterTabWithOnlyMinor(tabs: DynamicLayoutTab[]): DynamicLayoutTab[] {
7580
return tabs.filter(tab => !this.hasTabOnlyMinor(tab));
7681
}
7782

7883
/**
79-
* @param tab Contains a tab data which has rows, cells and boxes
80-
* @returns Boolean based on cells has minor or not
84+
* Checks whether all boxes within a tab are minor.
85+
*
86+
* @param tab the tab to inspect
87+
* @returns true if every box in every cell in every row is minor
8188
*/
8289
hasTabOnlyMinor(tab: DynamicLayoutTab): boolean {
8390
if (hasNoValue(tab?.rows)) {

src/app/dynamic-item-page/dynamic-item-page.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import { fadeInOut } from '../shared/animations/fade';
1818
import { ThemedLoadingComponent } from '../shared/loading/themed-loading.component';
1919

2020
/**
21-
* This component is the entry point for the page that renders items.
21+
* Entry point component for the dynamic item page.
22+
*
23+
* Resolves the item from route data and passes it to {@link DynamicLayoutComponent},
24+
* which handles tab resolution and layout rendering. Also checks admin authorization
25+
* for displaying admin-specific UI elements.
2226
*/
2327
@Component({
2428
selector: 'ds-dynamic-item-page',

src/app/dynamic-layout/decorators/dynamic-layout-box.decorator.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ import { DynamicLayoutMetadataBoxComponent } from '../dynamic-layout-matrix/dyna
88
import { DynamicLayoutRelationBoxComponent } from '../dynamic-layout-matrix/dynamic-layout-box-container/boxes/relation/dynamic-layout-relation-box.component';
99
import { LayoutBox } from '../enums/layout-box.enum';
1010

11+
/**
12+
* Render options for a dynamic layout box component, specifying its Angular component
13+
* reference and whether it manages its own accordion container.
14+
*/
1115
export interface DynamicLayoutBoxRenderOptions {
16+
/** The component class to instantiate for this box type. */
1217
componentRef: GenericConstructor<Component>;
18+
/** If true, the box provides its own container; the parent won't wrap it in an accordion. */
1319
hasOwnContainer: boolean;
1420
}
1521

22+
/**
23+
* Static registry mapping {@link LayoutBox} types to their rendering component and container options.
24+
*/
1625
const layoutBoxesMap = new Map<LayoutBox, DynamicLayoutBoxRenderOptions>([
1726
[ LayoutBox.COLLECTIONS, { componentRef: DynamicLayoutCollectionBoxComponent, hasOwnContainer: false } as DynamicLayoutBoxRenderOptions ],
1827
[ LayoutBox.IIIFVIEWER, { componentRef: DynamicLayoutIiifViewerBoxComponent, hasOwnContainer: false } as DynamicLayoutBoxRenderOptions ],
@@ -21,6 +30,12 @@ const layoutBoxesMap = new Map<LayoutBox, DynamicLayoutBoxRenderOptions>([
2130
[ LayoutBox.VERSIONING, { componentRef: ItemVersionsComponent, hasOwnContainer: false } as DynamicLayoutBoxRenderOptions ],
2231
]);
2332

33+
/**
34+
* Resolves the rendering options (component + container flag) for a given box type.
35+
*
36+
* @param boxType the layout box type to look up
37+
* @returns the render options for the box type, or undefined if not registered
38+
*/
2439
export function getDynamicLayoutBox(boxType: LayoutBox): DynamicLayoutBoxRenderOptions {
2540
return layoutBoxesMap.get(boxType);
2641
}

src/app/dynamic-layout/decorators/dynamic-layout-page.decorator.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import {
88
LayoutPage,
99
} from '../enums/layout-page.enum';
1010

11+
/**
12+
* Static registry mapping {@link LayoutPage} orientation types to their page component.
13+
*/
1114
const layoutPageMap = new Map<LayoutPage, GenericConstructor<DynamicLayoutHorizontalComponent|DynamicLayoutVerticalComponent>>([
1215
[ LayoutPage.HORIZONTAL, DynamicLayoutHorizontalComponent ],
1316
[ LayoutPage.VERTICAL, DynamicLayoutVerticalComponent ],
@@ -16,6 +19,13 @@ const layoutPageMap = new Map<LayoutPage, GenericConstructor<DynamicLayoutHorizo
1619
layoutPageMap.set(LayoutPage.HORIZONTAL, DynamicLayoutHorizontalComponent);
1720
layoutPageMap.set(LayoutPage.VERTICAL, DynamicLayoutVerticalComponent);
1821

22+
/**
23+
* Resolves the page layout component for the given orientation.
24+
* Falls back to {@link DEFAULT_LAYOUT_PAGE} if orientation is null or not registered.
25+
*
26+
* @param orientation the layout page orientation (horizontal or vertical)
27+
* @returns the component constructor for the requested orientation
28+
*/
1929
export function getDynamicLayoutPage(orientation: LayoutPage): any {
2030
let componentLayout;
2131
if (hasNoValue(orientation) || hasNoValue(layoutPageMap.get(orientation))) {

src/app/dynamic-layout/dynamic-layout-leading/dynamic-layout-leading.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import { Item } from '../../core/shared/item.model';
99
import { DsoEditMenuComponent } from '../../shared/dso-page/dso-edit-menu/dso-edit-menu.component';
1010
import { DynamicLayoutMatrixComponent } from '../dynamic-layout-matrix/dynamic-layout-matrix.component';
1111

12+
/**
13+
* Component that renders leading tabs (summary/overview panels displayed above the main tabbed content).
14+
* Delegates box rendering to {@link DynamicLayoutMatrixComponent} and optionally shows the edit menu.
15+
*/
1216
@Component({
1317
selector: 'ds-dynamic-layout-leading',
1418
templateUrl: './dynamic-layout-leading.component.html',

src/app/dynamic-layout/dynamic-layout-loader/dynamic-layout-horizontal/dynamic-layout-horizontal.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import { DsoEditMenuComponent } from '../../../shared/dso-page/dso-edit-menu/dso
1111
import { DynamicLayoutMatrixComponent } from '../../dynamic-layout-matrix/dynamic-layout-matrix.component';
1212
import { DynamicLayoutNavbarComponent } from './dynamic-layout-navbar/dynamic-layout-navbar.component';
1313

14+
/**
15+
* Horizontal layout page component for the dynamic item page.
16+
* Renders tabs as a horizontal top navbar, with the selected tab's content
17+
* displayed below via {@link DynamicLayoutMatrixComponent}.
18+
*/
1419
@Component({
1520
selector: 'ds-dynamic-layout-horizontal',
1621
templateUrl: './dynamic-layout-horizontal.component.html',

src/app/dynamic-layout/dynamic-layout-loader/dynamic-layout-loader.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ import { getDynamicLayoutPage } from '../decorators/dynamic-layout-page.decorato
2020
import { DynamicLayoutLoaderDirective } from '../directives/dynamic-layout-loader.directive';
2121
import { LayoutPage } from '../enums/layout-page.enum';
2222

23+
/**
24+
* Loader component that dynamically instantiates the correct layout page component
25+
* (horizontal or vertical) based on the entity type's configuration in the app config.
26+
*
27+
* Uses the {@link DynamicLayoutLoaderDirective} as a ViewChild anchor to place the
28+
* dynamically created component, passing the item, tabs, and context menu settings.
29+
*/
2330
@Component({
2431
selector: 'ds-dynamic-layout-loader',
2532
templateUrl: './dynamic-layout-loader.component.html',
@@ -46,7 +53,7 @@ export class DynamicLayoutLoaderComponent implements OnInit, OnDestroy {
4653
@Input() showContextMenu: boolean;
4754

4855
/**
49-
* Configuration layout form the environment
56+
* Layout type configuration (orientation) resolved from the app config for the item's entity type.
5057
*/
5158
layoutConfiguration: DynamicLayoutTypeConfig;
5259

src/app/dynamic-layout/dynamic-layout-loader/dynamic-layout-vertical/dynamic-layout-vertical.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import { DynamicLayoutMatrixComponent } from '../../dynamic-layout-matrix/dynami
1616
import { DynamicLayoutNavbarComponent } from '../dynamic-layout-horizontal/dynamic-layout-navbar/dynamic-layout-navbar.component';
1717
import { DynamicLayoutSidebarComponent } from './dynamic-layout-sidebar/dynamic-layout-sidebar.component';
1818

19+
/**
20+
* Vertical layout page component for the dynamic item page.
21+
* Renders tabs as a vertical sidebar on larger screens (falling back to a horizontal
22+
* navbar on small screens), with the selected tab's content displayed alongside.
23+
*/
1924
@Component({
2025
selector: 'ds-dynamic-layout-vertical',
2126
templateUrl: './dynamic-layout-vertical.component.html',

0 commit comments

Comments
 (0)