84367: Use DSONameService for ds-dso-selector names

This commit is contained in:
Yura
2021-10-21 10:33:17 +02:00
parent 931560ee26
commit 859ff4a2f5
3 changed files with 21 additions and 9 deletions

View File

@@ -14,6 +14,7 @@ import { RemoteData } from '../../../../core/data/remote-data';
import { hasValue } from '../../../empty.util'; import { hasValue } from '../../../empty.util';
import { NotificationsService } from '../../../notifications/notifications.service'; import { NotificationsService } from '../../../notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
@Component({ @Component({
selector: 'ds-authorized-collection-selector', selector: 'ds-authorized-collection-selector',
@@ -24,11 +25,14 @@ import { TranslateService } from '@ngx-translate/core';
* Component rendering a list of collections to select from * Component rendering a list of collections to select from
*/ */
export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent { export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent {
constructor(protected searchService: SearchService, constructor(
protected searchService: SearchService,
protected collectionDataService: CollectionDataService, protected collectionDataService: CollectionDataService,
protected notifcationsService: NotificationsService, protected notifcationsService: NotificationsService,
protected translate: TranslateService) { protected translate: TranslateService,
super(searchService, notifcationsService, translate); protected dsoNameService: DSONameService,
) {
super(searchService, notifcationsService, translate, dsoNameService);
} }
/** /**

View File

@@ -22,7 +22,7 @@
<button *ngFor="let listEntry of (listEntries$ | async)" <button *ngFor="let listEntry of (listEntries$ | async)"
class="list-group-item list-group-item-action border-0 list-entry" class="list-group-item list-group-item-action border-0 list-entry"
[ngClass]="{'bg-primary': listEntry.indexableObject.id === currentDSOId}" [ngClass]="{'bg-primary': listEntry.indexableObject.id === currentDSOId}"
title="{{ listEntry.indexableObject.name }}" title="{{ getName(listEntry) }}"
dsHoverClass="ds-hover" dsHoverClass="ds-hover"
(click)="onSelect.emit(listEntry.indexableObject)" #listEntryElement> (click)="onSelect.emit(listEntry.indexableObject)" #listEntryElement>
<ds-listable-object-component-loader [object]="listEntry" [viewMode]="viewMode" <ds-listable-object-component-loader [object]="listEntry" [viewMode]="viewMode"

View File

@@ -34,6 +34,7 @@ import { SearchResult } from '../../search/search-result.model';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { NotificationsService } from '../../notifications/notifications.service'; import { NotificationsService } from '../../notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
@Component({ @Component({
selector: 'ds-dso-selector', selector: 'ds-dso-selector',
@@ -126,9 +127,12 @@ export class DSOSelectorComponent implements OnInit, OnDestroy {
*/ */
public subs: Subscription[] = []; public subs: Subscription[] = [];
constructor(protected searchService: SearchService, constructor(
protected searchService: SearchService,
protected notifcationsService: NotificationsService, protected notifcationsService: NotificationsService,
protected translate: TranslateService) { protected translate: TranslateService,
protected dsoNameService: DSONameService,
) {
} }
/** /**
@@ -257,4 +261,8 @@ export class DSOSelectorComponent implements OnInit, OnDestroy {
ngOnDestroy(): void { ngOnDestroy(): void {
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe()); this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
} }
getName(searchResult: SearchResult<DSpaceObject>): string {
return this.dsoNameService.getName(searchResult.indexableObject);
}
} }