mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
79730: Replace component ID with unique number
This commit is contained in:
@@ -162,6 +162,7 @@ import { UsageReport } from './statistics/models/usage-report.model';
|
|||||||
import { RootDataService } from './data/root-data.service';
|
import { RootDataService } from './data/root-data.service';
|
||||||
import { Root } from './data/root.model';
|
import { Root } from './data/root.model';
|
||||||
import { SearchConfig } from './shared/search/search-filters/search-config.model';
|
import { SearchConfig } from './shared/search/search-filters/search-config.model';
|
||||||
|
import { SequenceService } from './shared/sequence.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When not in production, endpoint responses can be mocked for testing purposes
|
* When not in production, endpoint responses can be mocked for testing purposes
|
||||||
@@ -282,7 +283,8 @@ const PROVIDERS = [
|
|||||||
FilteredDiscoveryPageResponseParsingService,
|
FilteredDiscoveryPageResponseParsingService,
|
||||||
{ provide: NativeWindowService, useFactory: NativeWindowFactory },
|
{ provide: NativeWindowService, useFactory: NativeWindowFactory },
|
||||||
VocabularyService,
|
VocabularyService,
|
||||||
VocabularyTreeviewService
|
VocabularyTreeviewService,
|
||||||
|
SequenceService,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
24
src/app/core/shared/sequence.service.ts
Normal file
24
src/app/core/shared/sequence.service.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
/**
|
||||||
|
* Provides unique sequential numbers
|
||||||
|
*/
|
||||||
|
export class SequenceService {
|
||||||
|
private value: number;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public next(): number {
|
||||||
|
return ++this.value;
|
||||||
|
}
|
||||||
|
}
|
@@ -12,6 +12,7 @@ import { SearchFilterConfig } from '../../search-filter-config.model';
|
|||||||
import { FilterType } from '../../filter-type.model';
|
import { FilterType } from '../../filter-type.model';
|
||||||
import { SearchConfigurationServiceStub } from '../../../testing/search-configuration-service.stub';
|
import { SearchConfigurationServiceStub } from '../../../testing/search-configuration-service.stub';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../../../../+my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../../../../+my-dspace-page/my-dspace-page.component';
|
||||||
|
import { SequenceService } from '../../../../core/shared/sequence.service';
|
||||||
|
|
||||||
describe('SearchFilterComponent', () => {
|
describe('SearchFilterComponent', () => {
|
||||||
let comp: SearchFilterComponent;
|
let comp: SearchFilterComponent;
|
||||||
@@ -65,7 +66,8 @@ describe('SearchFilterComponent', () => {
|
|||||||
provide: SearchFilterService,
|
provide: SearchFilterService,
|
||||||
useValue: mockFilterService
|
useValue: mockFilterService
|
||||||
},
|
},
|
||||||
{ provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() }
|
{ provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() },
|
||||||
|
{ provide: SequenceService, useValue: new SequenceService() },
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(SearchFilterComponent, {
|
}).overrideComponent(SearchFilterComponent, {
|
||||||
|
@@ -10,6 +10,7 @@ import { isNotEmpty } from '../../../empty.util';
|
|||||||
import { SearchService } from '../../../../core/shared/search/search.service';
|
import { SearchService } from '../../../../core/shared/search/search.service';
|
||||||
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../../../../+my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../../../../+my-dspace-page/my-dspace-page.component';
|
||||||
|
import { SequenceService } from '../../../../core/shared/sequence.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-filter',
|
selector: 'ds-search-filter',
|
||||||
@@ -62,10 +63,15 @@ export class SearchFilterComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
active$: Observable<boolean>;
|
active$: Observable<boolean>;
|
||||||
|
|
||||||
|
private readonly sequenceId: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private filterService: SearchFilterService,
|
private filterService: SearchFilterService,
|
||||||
private searchService: SearchService,
|
private searchService: SearchService,
|
||||||
@Inject(SEARCH_CONFIG_SERVICE) private searchConfigService: SearchConfigurationService) {
|
@Inject(SEARCH_CONFIG_SERVICE) private searchConfigService: SearchConfigurationService,
|
||||||
|
private sequenceService: SequenceService,
|
||||||
|
) {
|
||||||
|
this.sequenceId = this.sequenceService.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -141,13 +147,11 @@ export class SearchFilterComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get regionId(): string {
|
get regionId(): string {
|
||||||
// tslint:disable-next-line:no-string-literal
|
return `search-filter-region-${this.sequenceId}`;
|
||||||
return `search-filter-region-${this.constructor['ɵcmp'].id}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get toggleId(): string {
|
get toggleId(): string {
|
||||||
// tslint:disable-next-line:no-string-literal
|
return `search-filter-toggle-${this.sequenceId}`;
|
||||||
return `search-filter-toggle-${this.constructor['ɵcmp'].id}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user