mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[DURACOM-191] fix edit item relationships
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<h2 class="h4">
|
<h2 class="h4">
|
||||||
{{getRelationshipMessageKey() | async | translate}}
|
{{getRelationshipMessageKey$ | async | translate}}
|
||||||
<button class="ml-2 btn btn-success" [disabled]="(hasChanges | async)" (click)="openLookup()">
|
<button class="ml-2 btn btn-success" [disabled]="(hasChanges | async)" (click)="openLookup()">
|
||||||
<i class="fas fa-plus"></i>
|
<i class="fas fa-plus"></i>
|
||||||
<span class="d-none d-sm-inline"> {{"item.edit.relationships.edit.buttons.add" | translate}}</span>
|
<span class="d-none d-sm-inline"> {{"item.edit.relationships.edit.buttons.add" | translate}}</span>
|
||||||
|
@@ -9,9 +9,7 @@ import {
|
|||||||
Observable,
|
Observable,
|
||||||
Subscription
|
Subscription
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import {
|
import { RelationshipIdentifiable } from '../../../../core/data/object-updates/object-updates.reducer';
|
||||||
RelationshipIdentifiable
|
|
||||||
} from '../../../../core/data/object-updates/object-updates.reducer';
|
|
||||||
import { RelationshipDataService } from '../../../../core/data/relationship-data.service';
|
import { RelationshipDataService } from '../../../../core/data/relationship-data.service';
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { defaultIfEmpty, map, mergeMap, startWith, switchMap, take, tap, toArray } from 'rxjs/operators';
|
import { defaultIfEmpty, map, mergeMap, startWith, switchMap, take, tap, toArray } from 'rxjs/operators';
|
||||||
@@ -25,7 +23,9 @@ import {
|
|||||||
getRemoteDataPayload,
|
getRemoteDataPayload,
|
||||||
} from '../../../../core/shared/operators';
|
} from '../../../../core/shared/operators';
|
||||||
import { ItemType } from '../../../../core/shared/item-relationships/item-type.model';
|
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 { RelationshipOptions } from '../../../../shared/form/builder/models/relationship-options.model';
|
||||||
import { SelectableListService } from '../../../../shared/object-list/selectable-list/selectable-list.service';
|
import { SelectableListService } from '../../../../shared/object-list/selectable-list/selectable-list.service';
|
||||||
import { SearchResult } from '../../../../shared/search/models/search-result.model';
|
import { SearchResult } from '../../../../shared/search/models/search-result.model';
|
||||||
@@ -114,6 +114,8 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private relatedEntityType$: Observable<ItemType>;
|
private relatedEntityType$: Observable<ItemType>;
|
||||||
|
|
||||||
|
getRelationshipMessageKey$: Observable<string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list ID to save selected entities under
|
* The list ID to save selected entities under
|
||||||
*/
|
*/
|
||||||
@@ -178,30 +180,6 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
|
|||||||
this.fetchThumbnail = this.appConfig.browseBy.showThumbnails;
|
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
|
* 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
|
// initialize the pagination options
|
||||||
this.paginationConfig = new PaginationComponentOptions();
|
this.paginationConfig = new PaginationComponentOptions();
|
||||||
|
Reference in New Issue
Block a user