mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
PR 545 Create relationships as an admin in edit item - feedback
This commit is contained in:
@@ -22,5 +22,5 @@
|
|||||||
<div *ngIf="updateValues.length === 0">{{"item.edit.relationships.no-relationships" | translate}}</div>
|
<div *ngIf="updateValues.length === 0">{{"item.edit.relationships.no-relationships" | translate}}</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ds-loading *ngIf="!updates"></ds-loading>
|
<ds-loading *ngIf="!updates"></ds-loading>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@@ -94,10 +94,18 @@ export class EditRelationshipListComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
public getRelationshipMessageKey(): Observable<string> {
|
public getRelationshipMessageKey(): Observable<string> {
|
||||||
|
|
||||||
return this.getLabel().pipe(
|
return observableCombineLatest(
|
||||||
map((label) => {
|
this.getLabel(),
|
||||||
if (hasValue(label) && label.indexOf('Of') > -1) {
|
this.relatedEntityType$,
|
||||||
return `relationships.${label.substring(0, label.indexOf('Of') + 2)}`
|
).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 {
|
} else {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
@@ -192,18 +200,21 @@ export class EditRelationshipListComponent implements OnInit {
|
|||||||
|
|
||||||
this.selectableListService.deselectAll(this.listId);
|
this.selectableListService.deselectAll(this.listId);
|
||||||
this.updates$.pipe(
|
this.updates$.pipe(
|
||||||
switchMap((updates) => observableCombineLatest(
|
switchMap((updates) =>
|
||||||
Object.values(updates)
|
Object.values(updates).length > 0 ?
|
||||||
.filter((update) => update.changeType !== FieldChangeType.REMOVE)
|
observableCombineLatest(
|
||||||
.map((update) => {
|
Object.values(updates)
|
||||||
const field = update.field as RelationshipIdentifiable;
|
.filter((update) => update.changeType !== FieldChangeType.REMOVE)
|
||||||
if (field.relationship) {
|
.map((update) => {
|
||||||
return this.getRelatedItem(field.relationship);
|
const field = update.field as RelationshipIdentifiable;
|
||||||
} else {
|
if (field.relationship) {
|
||||||
return of(field.relatedItem);
|
return this.getRelatedItem(field.relationship);
|
||||||
}
|
} else {
|
||||||
})
|
return of(field.relatedItem);
|
||||||
)),
|
}
|
||||||
|
})
|
||||||
|
) : of([])
|
||||||
|
),
|
||||||
take(1),
|
take(1),
|
||||||
map((items) => items.map((item) => {
|
map((items) => items.map((item) => {
|
||||||
const searchResult = new ItemSearchResult();
|
const searchResult = new ItemSearchResult();
|
||||||
@@ -254,7 +265,6 @@ export class EditRelationshipListComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.listId = 'edit-relationship-' + this.itemType.id;
|
|
||||||
|
|
||||||
this.relatedEntityType$ =
|
this.relatedEntityType$ =
|
||||||
observableCombineLatest([
|
observableCombineLatest([
|
||||||
@@ -267,6 +277,12 @@ export class EditRelationshipListComponent implements OnInit {
|
|||||||
map((relatedTypes) => relatedTypes.find((relatedType) => relatedType.uuid !== this.itemType.uuid)),
|
map((relatedTypes) => relatedTypes.find((relatedType) => relatedType.uuid !== this.itemType.uuid)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.relatedEntityType$.pipe(
|
||||||
|
take(1)
|
||||||
|
).subscribe(
|
||||||
|
(relatedEntityType) => this.listId = `edit-relationship-${this.itemType.id}-${relatedEntityType.id}`
|
||||||
|
);
|
||||||
|
|
||||||
this.updates$ = this.getItemRelationships().pipe(
|
this.updates$ = this.getItemRelationships().pipe(
|
||||||
switchMap((relationships) =>
|
switchMap((relationships) =>
|
||||||
observableCombineLatest(
|
observableCombineLatest(
|
||||||
@@ -274,15 +290,15 @@ export class EditRelationshipListComponent implements OnInit {
|
|||||||
).pipe(
|
).pipe(
|
||||||
defaultIfEmpty([]),
|
defaultIfEmpty([]),
|
||||||
map((isLeftItemArray) => isLeftItemArray.map((isLeftItem, index) => {
|
map((isLeftItemArray) => isLeftItemArray.map((isLeftItem, index) => {
|
||||||
const relationship = relationships[index];
|
const relationship = relationships[index];
|
||||||
const nameVariant = isLeftItem ? relationship.rightwardValue : relationship.leftwardValue;
|
const nameVariant = isLeftItem ? relationship.rightwardValue : relationship.leftwardValue;
|
||||||
return {
|
return {
|
||||||
uuid: relationship.id,
|
uuid: relationship.id,
|
||||||
type: this.relationshipType,
|
type: this.relationshipType,
|
||||||
relationship,
|
relationship,
|
||||||
nameVariant,
|
nameVariant,
|
||||||
} as RelationshipIdentifiable
|
} as RelationshipIdentifiable
|
||||||
})),
|
})),
|
||||||
)),
|
)),
|
||||||
switchMap((initialFields) => this.objectUpdatesService.getFieldUpdates(this.url, initialFields).pipe(
|
switchMap((initialFields) => this.objectUpdatesService.getFieldUpdates(this.url, initialFields).pipe(
|
||||||
map((fieldUpdates) => {
|
map((fieldUpdates) => {
|
||||||
|
@@ -129,7 +129,7 @@ export class ObjectUpdatesService {
|
|||||||
*/
|
*/
|
||||||
getFieldUpdatesExclusive(url: string, initialFields: Identifiable[]): Observable<FieldUpdates> {
|
getFieldUpdatesExclusive(url: string, initialFields: Identifiable[]): Observable<FieldUpdates> {
|
||||||
const objectUpdates = this.getObjectEntry(url);
|
const objectUpdates = this.getObjectEntry(url);
|
||||||
return objectUpdates.pipe(isNotEmptyOperator(), map((objectEntry) => {
|
return objectUpdates.pipe(map((objectEntry) => {
|
||||||
const fieldUpdates: FieldUpdates = {};
|
const fieldUpdates: FieldUpdates = {};
|
||||||
for (const object of initialFields) {
|
for (const object of initialFields) {
|
||||||
let fieldUpdate = objectEntry.fieldUpdates[object.uuid];
|
let fieldUpdate = objectEntry.fieldUpdates[object.uuid];
|
||||||
|
@@ -51,6 +51,9 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
@Input() showLabel = true;
|
@Input() showLabel = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value to display for this element
|
||||||
|
*/
|
||||||
@Input() value: string;
|
@Input() value: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -24,6 +24,9 @@ export class AbstractListableElementComponent<T extends ListableObject> {
|
|||||||
*/
|
*/
|
||||||
@Input() listID: string;
|
@Input() listID: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value to display for this element
|
||||||
|
*/
|
||||||
@Input() value: string;
|
@Input() value: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -2537,6 +2537,10 @@
|
|||||||
|
|
||||||
"relationships.isAuthorOf": "Authors",
|
"relationships.isAuthorOf": "Authors",
|
||||||
|
|
||||||
|
"relationships.isAuthorOf.Person": "Authors (persons)",
|
||||||
|
|
||||||
|
"relationships.isAuthorOf.OrgUnit": "Authors (organizational units)",
|
||||||
|
|
||||||
"relationships.isIssueOf": "Journal Issues",
|
"relationships.isIssueOf": "Journal Issues",
|
||||||
|
|
||||||
"relationships.isJournalIssueOf": "Journal Issue",
|
"relationships.isJournalIssueOf": "Journal Issue",
|
||||||
|
Reference in New Issue
Block a user