PR 545 Create relationships as an admin in edit item - feedback

This commit is contained in:
Samuel
2020-08-06 14:58:00 +02:00
parent cba71fc53f
commit 06163ce777
6 changed files with 54 additions and 28 deletions

View File

@@ -94,10 +94,18 @@ export class EditRelationshipListComponent implements OnInit {
*/
public getRelationshipMessageKey(): Observable<string> {
return this.getLabel().pipe(
map((label) => {
if (hasValue(label) && label.indexOf('Of') > -1) {
return `relationships.${label.substring(0, label.indexOf('Of') + 2)}`
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;
}
@@ -192,7 +200,9 @@ export class EditRelationshipListComponent implements OnInit {
this.selectableListService.deselectAll(this.listId);
this.updates$.pipe(
switchMap((updates) => observableCombineLatest(
switchMap((updates) =>
Object.values(updates).length > 0 ?
observableCombineLatest(
Object.values(updates)
.filter((update) => update.changeType !== FieldChangeType.REMOVE)
.map((update) => {
@@ -203,7 +213,8 @@ export class EditRelationshipListComponent implements OnInit {
return of(field.relatedItem);
}
})
)),
) : of([])
),
take(1),
map((items) => items.map((item) => {
const searchResult = new ItemSearchResult();
@@ -254,7 +265,6 @@ export class EditRelationshipListComponent implements OnInit {
}
ngOnInit(): void {
this.listId = 'edit-relationship-' + this.itemType.id;
this.relatedEntityType$ =
observableCombineLatest([
@@ -267,6 +277,12 @@ export class EditRelationshipListComponent implements OnInit {
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(
switchMap((relationships) =>
observableCombineLatest(

View File

@@ -129,7 +129,7 @@ export class ObjectUpdatesService {
*/
getFieldUpdatesExclusive(url: string, initialFields: Identifiable[]): Observable<FieldUpdates> {
const objectUpdates = this.getObjectEntry(url);
return objectUpdates.pipe(isNotEmptyOperator(), map((objectEntry) => {
return objectUpdates.pipe(map((objectEntry) => {
const fieldUpdates: FieldUpdates = {};
for (const object of initialFields) {
let fieldUpdate = objectEntry.fieldUpdates[object.uuid];

View File

@@ -51,6 +51,9 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
*/
@Input() showLabel = true;
/**
* The value to display for this element
*/
@Input() value: string;
/**

View File

@@ -24,6 +24,9 @@ export class AbstractListableElementComponent<T extends ListableObject> {
*/
@Input() listID: string;
/**
* The value to display for this element
*/
@Input() value: string;
/**

View File

@@ -2537,6 +2537,10 @@
"relationships.isAuthorOf": "Authors",
"relationships.isAuthorOf.Person": "Authors (persons)",
"relationships.isAuthorOf.OrgUnit": "Authors (organizational units)",
"relationships.isIssueOf": "Journal Issues",
"relationships.isJournalIssueOf": "Journal Issue",