Skip to content

Commit 938d71c

Browse files
[DURACOM-508] add inline documentation
1 parent b19be46 commit 938d71c

24 files changed

Lines changed: 238 additions & 22 deletions

src/app/core/data/paginated-list.model.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ export class PaginatedList<T> extends CacheableObject {
103103
prev?: HALLink;
104104
next?: HALLink;
105105
last?: HALLink;
106-
missing?: HALLink;
107-
more?: HALLink;
108106
};
109107

110108
get elementsPerPage(): number {

src/app/core/data/section-data.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export class SectionDataService extends IdentifiableDataService<Section> {
4747
}
4848

4949
/**
50-
* Find all the configured sections.
50+
* Finds all sections configured to be visible in the top navigation bar.
51+
* Uses the 'visibleTopBarSections' search endpoint on the backend.
5152
*/
5253
findVisibleSections(): Observable<RemoteData<PaginatedList<Section>>> {
5354
return this.searchData.searchBy('visibleTopBarSections');

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,59 +46,110 @@ export class Section extends CacheableObject {
4646

4747
}
4848

49+
/**
50+
* Base interface for all section component configurations returned by the REST API.
51+
*/
4952
export interface SectionComponent {
53+
/** The type discriminator identifying which component to render. */
5054
componentType: string;
55+
/** CSS classes applied to the section container (e.g., Bootstrap grid classes). */
5156
style: string;
5257
}
5358

59+
/**
60+
* Configuration for a browse section that displays links to browse indices.
61+
*/
5462
export interface BrowseSection extends SectionComponent {
63+
/** List of browse index names to render as navigation links. */
5564
browseNames: string[];
5665
componentType: 'browse';
5766
}
5867

68+
/**
69+
* Configuration for a top section that displays the most recent/popular items
70+
* from a discovery configuration.
71+
*/
5972
export interface TopSection extends SectionComponent {
73+
/** Name of the discovery configuration to query. */
6074
discoveryConfigurationName: string;
75+
/** Metadata field to sort results by. */
6176
sortField: string;
77+
/** Sort direction ('ASC' or 'DESC'). */
6278
order: string;
79+
/** i18n key for the section title. */
6380
titleKey: string;
6481
componentType: 'top';
82+
/** Maximum number of items to display. */
6583
numberOfItems: number;
84+
/** Whether to show item thumbnails. */
6685
showThumbnails: boolean;
86+
/** Template type to use for rendering the items. */
6787
template: TopSectionTemplateType;
6888
}
6989

90+
/**
91+
* Configuration for an advanced search section with multiple query statements and filter fields.
92+
*/
7093
export interface SearchSection extends SectionComponent {
94+
/** Name of the discovery configuration providing available filters. */
7195
discoveryConfigurationName: string;
7296
componentType: 'search';
97+
/** Type of search interface to render. */
7398
searchType: string;
99+
/** Number of query statement rows to display initially. */
74100
initialStatements: number;
101+
/** Whether to display the section title. */
75102
displayTitle: boolean;
76103
}
77104

105+
/**
106+
* Configuration for a section displaying search facets from a discovery configuration.
107+
*/
78108
export interface FacetSection extends SectionComponent {
109+
/** Name of the discovery configuration to fetch facet values from. */
79110
discoveryConfigurationName: string;
80111
componentType: 'facet';
112+
/** Number of facet boxes to display per row in the grid. */
81113
facetsPerRow: number;
82114
}
83115

116+
/**
117+
* Configuration for a text content section that renders static or metadata-based content.
118+
*/
84119
export interface TextRowSection extends SectionComponent {
120+
/** The content string (can be a metadata key or raw content depending on contentType). */
85121
content: string;
122+
/** The type of content: e.g., 'text-metadata' for metadata lookups or 'text-raw' for static content. */
86123
contentType: string;
87124
componentType: 'text-row';
88125
}
89126

127+
/**
128+
* Configuration for a table-like section showing top items with multiple metadata columns.
129+
*/
90130
export interface MultiColumnTopSection extends SectionComponent {
131+
/** Name of the discovery configuration to query. */
91132
discoveryConfigurationName: string;
133+
/** Metadata field to sort results by. */
92134
sortField: string;
135+
/** Sort direction ('ASC' or 'DESC'). */
93136
order: string;
137+
/** i18n key for the section title. */
94138
titleKey: string;
139+
/** List of column definitions specifying which metadata fields to display. */
95140
columnList: TopSectionColumn[];
96141
componentType: 'multi-column-top';
97142
}
98143

144+
/**
145+
* Column configuration for {@link MultiColumnTopSection} defining which metadata to display.
146+
*/
99147
export interface TopSectionColumn {
148+
/** CSS classes for column width styling. */
100149
style: string;
150+
/** Metadata field to extract the column value from. */
101151
metadataField: string;
152+
/** i18n key for the column header. */
102153
titleKey: string;
103154
}
104155

src/app/explore-page/explore-i18n-breadcrumb.resolver.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import { hasNoValue } from '../utils/empty.util';
1212

1313

1414
/**
15-
* This class resolves a BreadcrumbConfig object with an i18n key string for a route
16-
* It adds the metadata field of the current explore page
15+
* Resolves a BreadcrumbConfig object with an i18n key string for an explore route.
16+
* Extends the base breadcrumb key with the explore page's ID route parameter
17+
* (e.g., 'explore' becomes 'explore.publications') to provide page-specific breadcrumb labels.
1718
*/
1819
export const exploreI18nBreadcrumbResolver: ResolveFn<BreadcrumbConfig<string>> = (
1920
route: ActivatedRouteSnapshot,

src/app/explore-page/explore-page.component.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ import { ThemedTextSectionComponent } from '../shared/explore/section-component/
2424
import { ThemedTopSectionComponent } from '../shared/explore/section-component/top-section/themed-top-section.component';
2525

2626
/**
27-
* Component representing the explore section.
27+
* Main container component for dynamic explore pages.
28+
*
29+
* Fetches section configuration from the backend based on the current route parameter
30+
* and renders the configured sections as a responsive grid of section components.
31+
* Supported section types include: top, browse, search, facet, text-row, and counters.
2832
*/
2933
@Component({
3034
selector: 'ds-explore',
@@ -43,13 +47,14 @@ import { ThemedTopSectionComponent } from '../shared/explore/section-component/t
4347
export class ExplorePageComponent implements OnInit {
4448

4549
/**
46-
* The id of the current section.
47-
*/
50+
* Identifier for the current explore section, derived from the ':id' route parameter.
51+
*/
4852
sectionId: string;
4953

5054
/**
51-
* Resolved section components splitted in rows.
52-
*/
55+
* Observable emitting a 2D array of section components organized in rows for grid layout.
56+
* Each inner array represents a row of components to be rendered side-by-side.
57+
*/
5358
sectionComponentRows: Observable<SectionComponent[][]>;
5459

5560
constructor(
@@ -61,10 +66,11 @@ export class ExplorePageComponent implements OnInit {
6166
}
6267

6368
/**
64-
* Setup the section components of the explore page based on the section id.
65-
*
66-
* @param params the route params
67-
*/
69+
* Fetches the section configuration from the backend and resolves
70+
* the section's component rows into the {@link sectionComponentRows} observable.
71+
*
72+
* @param params the route params containing the explore section 'id'
73+
*/
6874
setupSectionComponents( params: Params ) {
6975
this.sectionId = params.id;
7076
this.sectionComponentRows = this.sectionDataService.findById(params.id ).pipe(
@@ -74,8 +80,11 @@ export class ExplorePageComponent implements OnInit {
7480
}
7581

7682
/**
77-
* Check if style contains 'col' or 'col-x'
78-
* @param style the style of the cell (a list of classes separated by space)
83+
* Checks if a style string already contains a Bootstrap column class (e.g. 'col' or 'col-*').
84+
* Used to determine whether a default column class should be applied to a grid cell.
85+
*
86+
* @param style the style of the cell (a space-separated list of CSS classes)
87+
* @returns true if the style contains a Bootstrap column class
7988
*/
8089
hasColClass(style) {
8190
return style?.split(' ').filter((c) => (c === 'col' || c.startsWith('col-'))).length > 0;

src/app/explore-page/explore-routes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Route definitions for the explore module.
3+
* Maps ':id' paths to the {@link ExplorePageComponent}, resolving breadcrumbs
4+
* via {@link exploreI18nBreadcrumbResolver} and guarding access with the end-user agreement.
5+
*/
16
import { Route } from '@angular/router';
27

38
import { endUserAgreementCurrentUserGuard } from '../core/end-user-agreement/end-user-agreement-current-user.guard';

src/app/home-page/home-page.component.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ import { ThemedHomeNewsComponent } from './home-news/themed-home-news.component'
6262
import { RecentItemListComponent } from './recent-item-list/recent-item-list.component';
6363
import { ThemedTopLevelCommunityListComponent } from './top-level-community-list/themed-top-level-community-list.component';
6464

65+
/**
66+
* The home page component.
67+
*
68+
* Supports both a static layout and a dynamic layout driven by section configurations
69+
* fetched from the REST API. When dynamic layout is enabled (via `enableDynamicLayout` config),
70+
* it renders section components similar to the explore page (top, browse, search, facet, text-row, counters).
71+
* Also handles COAR Notify inbox link headers and site metadata rendering.
72+
*/
6573
@Component({
6674
selector: 'ds-base-home-page',
6775
styleUrls: ['./home-page.component.scss'],
@@ -92,16 +100,23 @@ export class HomePageComponent implements OnInit, OnDestroy {
92100
recentSubmissionspageSize: number;
93101
showDiscoverFilters: boolean;
94102
homeHeaderMetadataValue$: Observable<string>;
103+
104+
/** Whether the dynamic section-based home page layout is enabled via app config. */
95105
isDynamicHomePageEnabled: boolean;
106+
107+
/** The section identifier used when fetching the home page layout ('site'). */
96108
sectionId = 'site';
97109

98110
/**
99-
* Two-dimensional array (rows and columns) of section components
111+
* Observable emitting a 2D array (rows × columns) of section components
112+
* to render when dynamic home page layout is enabled.
100113
*/
101114
sectionComponents: Observable<SectionComponent[][]>;
102115

116+
/** Whether the site has a home header metadata value in the current language. */
103117
hasHomeHeaderMetadata: boolean;
104118

119+
/** Default text-row section configuration for the home header CMS metadata. */
105120
homeHeaderSection: TextRowSection = {
106121
content: 'cris.cms.home-header',
107122
contentType: 'text-metadata',
@@ -173,6 +188,13 @@ export class HomePageComponent implements OnInit, OnDestroy {
173188
);
174189
}
175190

191+
/**
192+
* Returns Bootstrap column classes for a section component.
193+
* If the section's style already contains a 'col' class, uses it as-is;
194+
* otherwise defaults to 'col-12' prepended to any existing style.
195+
*
196+
* @param sectionComponent the section component to compute classes for
197+
*/
176198
componentClass(sectionComponent: SectionComponent) {
177199
const defaultCol = 'col-12';
178200
return (isNotEmpty(sectionComponent.style) && sectionComponent.style.includes('col')) ?

src/app/shared/browse-most-elements/abstract-browse-elements.component.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ import {
3434
import { CollectionElementLinkType } from '../object-collection/collection-element-link.type';
3535

3636

37+
/**
38+
* Abstract base class for browse elements components.
39+
*
40+
* Handles searching via the {@link SearchManager} and rendering paginated search results.
41+
* Subclasses must specify whether to follow thumbnail links by setting {@link followThumbnailLink}.
42+
*/
3743
@Component({
3844
template: '',
3945
})
@@ -77,10 +83,13 @@ export abstract class AbstractBrowseElementsComponent implements OnInit, OnChang
7783

7884
public collectionElementLinkTypeEnum = CollectionElementLinkType;
7985

86+
/** BehaviorSubject emitting the current search options, triggers re-search on change. */
8087
paginatedSearchOptions$: BehaviorSubject<PaginatedSearchOptions>;
8188

89+
/** Observable of the raw paginated search results from the SearchManager. */
8290
searchResults$: Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>>;
8391

92+
/** Observable emitting the flat array of DSpaceObjects extracted from search results. */
8493
searchResultArray$: Observable<DSpaceObject[]>;
8594

8695
ngOnChanges() {
@@ -116,6 +125,11 @@ export abstract class AbstractBrowseElementsComponent implements OnInit, OnChang
116125
);
117126
}
118127

128+
/**
129+
* Returns the route path for an item's detail page.
130+
*
131+
* @param item the DSpaceObject (item) to generate a route for
132+
*/
119133
getItemPageRoute(item: DSpaceObject | Item) {
120134
return getItemPageRoute(item as Item);
121135
}

src/app/shared/browse-most-elements/browse-most-elements.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import {
1818
import { Context } from '../../core/shared/context.model';
1919
import { ThemedDefaultBrowseElementsComponent } from './default-browse-elements/themed-default-browse-elements.component';
2020

21+
/**
22+
* Container component that delegates rendering of browse elements to the appropriate
23+
* template component based on the {@link TopSection} configuration.
24+
* Currently supports the default template via {@link DefaultBrowseElementsComponent}.
25+
*/
2126
@Component({
2227
selector: 'ds-base-browse-most-elements',
2328
styleUrls: ['./browse-most-elements.component.scss'],
@@ -66,8 +71,10 @@ export class BrowseMostElementsComponent implements OnInit, OnChanges {
6671
*/
6772
@Input() topSection: TopSection;
6873

74+
/** BehaviorSubject re-emitting paginatedSearchOptions to trigger child component updates. */
6975
paginatedSearchOptions$ = new BehaviorSubject<PaginatedSearchOptions>(null);
7076

77+
/** The resolved template type determining which child component renders the results. */
7178
sectionTemplateType: TopSectionTemplateType;
7279

7380
ngOnInit(): void {

src/app/shared/browse-most-elements/default-browse-elements/default-browse-elements.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import { ThemedLoadingComponent } from '../../loading/themed-loading.component';
1010
import { ListableObjectComponentLoaderComponent } from '../../object-collection/shared/listable-object/listable-object-component-loader.component';
1111
import { AbstractBrowseElementsComponent } from '../abstract-browse-elements.component';
1212

13+
/**
14+
* Default template implementation for browsing top elements.
15+
* Extends {@link AbstractBrowseElementsComponent} using the standard DSpace
16+
* listable object rendering with optional thumbnail support.
17+
*/
1318
@Component({
1419
selector: 'ds-base-default-browse-elements',
1520
templateUrl: './default-browse-elements.component.html',

0 commit comments

Comments
 (0)