mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[DURACOM-191] fix edit item relationships
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<h2 class="h4">
|
||||
{{getRelationshipMessageKey() | async | translate}}
|
||||
{{getRelationshipMessageKey$ | async | translate}}
|
||||
<button class="ml-2 btn btn-success" [disabled]="(hasChanges | async)" (click)="openLookup()">
|
||||
<i class="fas fa-plus"></i>
|
||||
<span class="d-none d-sm-inline"> {{"item.edit.relationships.edit.buttons.add" | translate}}</span>
|
||||
|
@@ -9,9 +9,7 @@ import {
|
||||
Observable,
|
||||
Subscription
|
||||
} from 'rxjs';
|
||||
import {
|
||||
RelationshipIdentifiable
|
||||
} from '../../../../core/data/object-updates/object-updates.reducer';
|
||||
import { RelationshipIdentifiable } from '../../../../core/data/object-updates/object-updates.reducer';
|
||||
import { RelationshipDataService } from '../../../../core/data/relationship-data.service';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { defaultIfEmpty, map, mergeMap, startWith, switchMap, take, tap, toArray } from 'rxjs/operators';
|
||||
@@ -25,7 +23,9 @@ import {
|
||||
getRemoteDataPayload,
|
||||
} from '../../../../core/shared/operators';
|
||||
import { ItemType } from '../../../../core/shared/item-relationships/item-type.model';
|
||||
import { DsDynamicLookupRelationModalComponent } from '../../../../shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component';
|
||||
import {
|
||||
DsDynamicLookupRelationModalComponent
|
||||
} from '../../../../shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component';
|
||||
import { RelationshipOptions } from '../../../../shared/form/builder/models/relationship-options.model';
|
||||
import { SelectableListService } from '../../../../shared/object-list/selectable-list/selectable-list.service';
|
||||
import { SearchResult } from '../../../../shared/search/models/search-result.model';
|
||||
@@ -114,6 +114,8 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
|
||||
|
||||
private relatedEntityType$: Observable<ItemType>;
|
||||
|
||||
getRelationshipMessageKey$: Observable<string>;
|
||||
|
||||
/**
|
||||
* The list ID to save selected entities under
|
||||
*/
|
||||
@@ -178,30 +180,6 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
|
||||
this.fetchThumbnail = this.appConfig.browseBy.showThumbnails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the i18n message key for this relationship type
|
||||
*/
|
||||
public getRelationshipMessageKey(): Observable<string> {
|
||||
|
||||
return observableCombineLatest(
|
||||
this.getLabel(),
|
||||
this.relatedEntityType$,
|
||||
).pipe(
|
||||
map(([label, relatedEntityType]) => {
|
||||
if (hasValue(label) && label.indexOf('is') > -1 && label.indexOf('Of') > -1) {
|
||||
const relationshipLabel = `${label.substring(2, label.indexOf('Of'))}`;
|
||||
if (relationshipLabel !== relatedEntityType.label) {
|
||||
return `relationships.is${relationshipLabel}Of.${relatedEntityType.label}`;
|
||||
} else {
|
||||
return `relationships.is${relationshipLabel}Of`;
|
||||
}
|
||||
} else {
|
||||
return label;
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the relevant label for this relationship type
|
||||
*/
|
||||
@@ -497,6 +475,24 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
|
||||
})
|
||||
);
|
||||
|
||||
this.getRelationshipMessageKey$ = observableCombineLatest(
|
||||
this.getLabel(),
|
||||
this.relatedEntityType$,
|
||||
).pipe(
|
||||
map(([label, relatedEntityType]) => {
|
||||
if (hasValue(label) && label.indexOf('is') > -1 && label.indexOf('Of') > -1) {
|
||||
const relationshipLabel = `${label.substring(2, label.indexOf('Of'))}`;
|
||||
if (relationshipLabel !== relatedEntityType.label) {
|
||||
return `relationships.is${relationshipLabel}Of.${relatedEntityType.label}`;
|
||||
} else {
|
||||
return `relationships.is${relationshipLabel}Of`;
|
||||
}
|
||||
} else {
|
||||
return label;
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
// initialize the pagination options
|
||||
this.paginationConfig = new PaginationComponentOptions();
|
||||
|
Reference in New Issue
Block a user