Skip to content

Commit

Permalink
Fixed circular dependency by extracting BrowseByDataType to a separat…
Browse files Browse the repository at this point in the history
…e file
  • Loading branch information
alexandrevryghem committed Dec 12, 2023
1 parent e6bf2f0 commit a5b7e2a
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/app/browse-by/abstract-browse-by-type.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnDestroy } from '@angular/core';
import { BrowseByDataType } from './browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from './browse-by-switcher/browse-by-data-type';
import { Context } from '../core/shared/context.model';
import { Subscription } from 'rxjs';
import { hasValue } from '../shared/empty.util';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { APP_CONFIG, AppConfig } from '../../../config/app-config.interface';
import { RemoteData } from '../../core/data/remote-data';
import { Item } from '../../core/shared/item.model';
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
import { rendersBrowseBy, BrowseByDataType } from '../browse-by-switcher/browse-by-decorator';
import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';

@Component({
selector: 'ds-browse-by-date-page',
Expand Down
2 changes: 1 addition & 1 deletion src/app/browse-by/browse-by-guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { first } from 'rxjs/operators';
import { BrowseByGuard } from './browse-by-guard';
import { of as observableOf } from 'rxjs';
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
import { BrowseByDataType } from './browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from './browse-by-switcher/browse-by-data-type';
import { ValueListBrowseDefinition } from '../core/shared/value-list-browse-definition.model';
import { DSONameServiceMock } from '../shared/mocks/dso-name.service.mock';
import { DSONameService } from '../core/breadcrumbs/dso-name.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import { Collection } from '../../core/shared/collection.model';
import { Community } from '../../core/shared/community.model';
import { APP_CONFIG, AppConfig } from '../../../config/app-config.interface';
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
import { rendersBrowseBy, BrowseByDataType } from '../browse-by-switcher/browse-by-decorator';
import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
import { AbstractBrowseByTypeComponent } from '../abstract-browse-by-type.component';
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';

export const BBM_PAGINATION_ID = 'bbm';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { ActivatedRoute } from '@angular/router';
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
import { ThemeService } from '../../shared/theme-support/theme.service';
import { rendersBrowseBy, BrowseByDataType } from '../browse-by-switcher/browse-by-decorator';
import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
import { Component } from '@angular/core';
import { AbstractBrowseByTypeComponent } from '../abstract-browse-by-type.component';
import { BrowseDefinition } from '../../core/shared/browse-definition.model';
import { By } from '@angular/platform-browser';
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';

@rendersBrowseBy('BrowseByPageComponent' as BrowseByDataType)
@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { map } from 'rxjs/operators';
import { BrowseDefinition } from '../../core/shared/browse-definition.model';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { BrowseByDataType } from '../browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';

@Component({
selector: 'ds-browse-by-page',
Expand Down
6 changes: 6 additions & 0 deletions src/app/browse-by/browse-by-switcher/browse-by-data-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum BrowseByDataType {
Title = 'title',
Metadata = 'text',
Date = 'date',
Hierarchy = 'hierarchy',
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BrowseByDataType, rendersBrowseBy } from './browse-by-decorator';
import { BrowseByDataType } from './browse-by-data-type';
import { rendersBrowseBy } from './browse-by-decorator';

describe('BrowseByDecorator', () => {
const titleDecorator = rendersBrowseBy(BrowseByDataType.Title);
Expand Down
14 changes: 1 addition & 13 deletions src/app/browse-by/browse-by-switcher/browse-by-decorator.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
import { hasNoValue } from '../../shared/empty.util';
import { InjectionToken } from '@angular/core';
import { DEFAULT_THEME, resolveTheme } from '../../shared/object-collection/shared/listable-object/listable-object.decorator';
import { AbstractBrowseByTypeComponent } from '../abstract-browse-by-type.component';
import { Context } from '../../core/shared/context.model';
import { GenericConstructor } from '../../core/shared/generic-constructor';

export enum BrowseByDataType {
Title = 'title',
Metadata = 'text',
Date = 'date',
Hierarchy = 'hierarchy',
}
import { BrowseByDataType } from './browse-by-data-type';

export const DEFAULT_BROWSE_BY_TYPE = BrowseByDataType.Metadata;
export const DEFAULT_BROWSE_BY_CONTEXT = Context.Any;

export const BROWSE_BY_COMPONENT_FACTORY = new InjectionToken<(browseByType: BrowseByDataType, context: Context, theme: string) => GenericConstructor<AbstractBrowseByTypeComponent>>('getComponentByBrowseByType', {
providedIn: 'root',
factory: () => getComponentByBrowseByType
});

const map: Map<BrowseByDataType, Map<Context, Map<string, GenericConstructor<AbstractBrowseByTypeComponent>>>> = new Map();

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { BrowseBySwitcherComponent } from './browse-by-switcher.component';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { SimpleChange, Component } from '@angular/core';
import { BrowseByDataType, rendersBrowseBy } from './browse-by-decorator';
import { rendersBrowseBy } from './browse-by-decorator';
import { ThemeService } from '../../shared/theme-support/theme.service';
import { FlatBrowseDefinition } from '../../core/shared/flat-browse-definition.model';
import { ValueListBrowseDefinition } from '../../core/shared/value-list-browse-definition.model';
import { NonHierarchicalBrowseDefinition } from '../../core/shared/non-hierarchical-browse-definition';
import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
import { DynamicComponentLoaderDirective } from '../../shared/abstract-component-loader/dynamic-component-loader.directive';
import { AbstractBrowseByTypeComponent } from '../abstract-browse-by-type.component';
import { BrowseByDataType } from './browse-by-data-type';

@rendersBrowseBy('BrowseBySwitcherComponent' as BrowseByDataType)
@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, Input } from '@angular/core';
import { getComponentByBrowseByType, BrowseByDataType } from './browse-by-decorator';
import { getComponentByBrowseByType } from './browse-by-decorator';
import { GenericConstructor } from '../../core/shared/generic-constructor';
import { AbstractComponentLoaderComponent } from '../../shared/abstract-component-loader/abstract-component-loader.component';
import { AbstractBrowseByTypeComponent } from '../abstract-browse-by-type.component';
import { BrowseByDataType } from './browse-by-data-type';

@Component({
selector: 'ds-browse-by-switcher',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { VocabularyEntryDetail } from '../../core/submission/vocabularies/models
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { BrowseDefinition } from '../../core/shared/browse-definition.model';
import { rendersBrowseBy, BrowseByDataType } from '../browse-by-switcher/browse-by-decorator';
import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
import { map } from 'rxjs/operators';
import { HierarchicalBrowseDefinition } from '../../core/shared/hierarchical-browse-definition.model';
import { AbstractBrowseByTypeComponent } from '../abstract-browse-by-type.component';
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';

@Component({
selector: 'ds-browse-by-taxonomy-page',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { map } from 'rxjs/operators';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface';
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
import { rendersBrowseBy, BrowseByDataType } from '../browse-by-switcher/browse-by-decorator';
import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';

@Component({
selector: 'ds-browse-by-title-page',
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/shared/browse-definition.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { autoserialize } from 'cerialize';
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-data-type';

/**
* Base class for BrowseDefinition models
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/shared/flat-browse-definition.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FLAT_BROWSE_DEFINITION } from './flat-browse-definition.resource-type';
import { ResourceType } from './resource-type';
import { NonHierarchicalBrowseDefinition } from './non-hierarchical-browse-definition';
import { HALLink } from './hal-link.model';
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-data-type';

/**
* BrowseDefinition model for browses of type 'flatBrowse'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HIERARCHICAL_BROWSE_DEFINITION } from './hierarchical-browse-definition
import { HALLink } from './hal-link.model';
import { ResourceType } from './resource-type';
import { BrowseDefinition } from './browse-definition.model';
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-data-type';

/**
* BrowseDefinition model for browses of type 'hierarchicalBrowse'
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/shared/non-hierarchical-browse-definition.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize';
import { SortOption } from './sort-option.model';
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-data-type';
import { BrowseDefinition } from './browse-definition.model';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/shared/value-list-browse-definition.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { VALUE_LIST_BROWSE_DEFINITION } from './value-list-browse-definition.res
import { ResourceType } from './resource-type';
import { NonHierarchicalBrowseDefinition } from './non-hierarchical-browse-definition';
import { HALLink } from './hal-link.model';
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-data-type';

/**
* BrowseDefinition model for browses of type 'valueList'
Expand Down
2 changes: 1 addition & 1 deletion src/app/navbar/navbar.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { BrowseService } from '../core/browse/browse.service';
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
import { buildPaginatedList } from '../core/data/paginated-list.model';
import { BrowseByDataType } from '../browse-by/browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../browse-by/browse-by-switcher/browse-by-data-type';
import { Item } from '../core/shared/item.model';
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
import { ThemeService } from '../shared/theme-support/theme.service';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { BrowseByDatePageComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-date-page/browse-by-date-page.component';
import { rendersBrowseBy, BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
import { Context } from '../../../../../app/core/shared/context.model';

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { BrowseByMetadataPageComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component';
import { rendersBrowseBy, BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
import { Context } from '../../../../../app/core/shared/context.model';

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { BrowseByTaxonomyPageComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-taxonomy-page/browse-by-taxonomy-page.component';
import { rendersBrowseBy, BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
import { Context } from '../../../../../app/core/shared/context.model';

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { BrowseByTitlePageComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-title-page/browse-by-title-page.component';
import { rendersBrowseBy, BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
import { Context } from '../../../../../app/core/shared/context.model';

@Component({
Expand Down

0 comments on commit a5b7e2a

Please sign in to comment.