mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Added name variant dialog
This commit is contained in:
@@ -786,6 +786,9 @@
|
|||||||
"submission.sections.describe.relationship-lookup.selection-tab.title.Journal": "Selected Journals",
|
"submission.sections.describe.relationship-lookup.selection-tab.title.Journal": "Selected Journals",
|
||||||
"submission.sections.describe.relationship-lookup.selection-tab.title.Journal Volume": "Selected Journal Volume",
|
"submission.sections.describe.relationship-lookup.selection-tab.title.Journal Volume": "Selected Journal Volume",
|
||||||
"submission.sections.describe.relationship-lookup.selection-tab.title.Journal Issue": "Selected Issue",
|
"submission.sections.describe.relationship-lookup.selection-tab.title.Journal Issue": "Selected Issue",
|
||||||
|
"submission.sections.describe.relationship-lookup.name-variant.notification.content": "Would you like to save \"{{ value }}\" as a name variant for this person so you and others can reuse it for future submissions? If you don\'t you can still use it for this submission.",
|
||||||
|
"submission.sections.describe.relationship-lookup.name-variant.notification.confirm": "Save a new name variant",
|
||||||
|
"submission.sections.describe.relationship-lookup.name-variant.notification.decline": "Use only for this submission",
|
||||||
"submission.sections.general.add-more": "Add more",
|
"submission.sections.general.add-more": "Add more",
|
||||||
"submission.sections.general.collection": "Collection",
|
"submission.sections.general.collection": "Collection",
|
||||||
"submission.sections.general.deposit_error_notice": "There was an issue when submitting the item, please try again later.",
|
"submission.sections.general.deposit_error_notice": "There was an issue when submitting the item, please try again later.",
|
||||||
|
12
src/app/core/cache/object-cache.service.ts
vendored
12
src/app/core/cache/object-cache.service.ts
vendored
@@ -99,13 +99,13 @@ export class ObjectCacheService {
|
|||||||
getObjectBySelfLink<T extends CacheableObject>(selfLink: string): Observable<NormalizedObject<T>> {
|
getObjectBySelfLink<T extends CacheableObject>(selfLink: string): Observable<NormalizedObject<T>> {
|
||||||
return this.getBySelfLink(selfLink).pipe(
|
return this.getBySelfLink(selfLink).pipe(
|
||||||
map((entry: ObjectCacheEntry) => {
|
map((entry: ObjectCacheEntry) => {
|
||||||
// if (isNotEmpty(entry.patches)) {
|
if (isNotEmpty(entry.patches)) {
|
||||||
// const flatPatch: Operation[] = [].concat(...entry.patches.map((patch) => patch.operations));
|
const flatPatch: Operation[] = [].concat(...entry.patches.map((patch) => patch.operations));
|
||||||
// const patchedData = applyPatch(entry.data, flatPatch, undefined, false).newDocument;
|
const patchedData = applyPatch(entry.data, flatPatch, undefined, false).newDocument;
|
||||||
// return Object.assign({}, entry, { data: patchedData });
|
return Object.assign({}, entry, { data: patchedData });
|
||||||
// } else {
|
} else {
|
||||||
return entry;
|
return entry;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
map((entry: ObjectCacheEntry) => {
|
map((entry: ObjectCacheEntry) => {
|
||||||
|
@@ -22,6 +22,7 @@ import { PersonItemMetadataListElementComponent } from './metadata-representatio
|
|||||||
import { OrgUnitItemMetadataListElementComponent } from './metadata-representations/org-unit/org-unit-item-metadata-list-element.component';
|
import { OrgUnitItemMetadataListElementComponent } from './metadata-representations/org-unit/org-unit-item-metadata-list-element.component';
|
||||||
import { PersonSearchResultListSubmissionElementComponent } from './submission/item-list-elements/person/person-search-result-list-submission-element.component';
|
import { PersonSearchResultListSubmissionElementComponent } from './submission/item-list-elements/person/person-search-result-list-submission-element.component';
|
||||||
import { PersonInputSuggestionsComponent } from './submission/item-list-elements/person/person-suggestions/person-input-suggestions.component';
|
import { PersonInputSuggestionsComponent } from './submission/item-list-elements/person/person-suggestions/person-input-suggestions.component';
|
||||||
|
import { NameVariantModalComponent } from './submission/item-list-elements/person/name-variant-modal/name-variant-modal.component';
|
||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
OrgUnitComponent,
|
OrgUnitComponent,
|
||||||
@@ -42,7 +43,8 @@ const ENTRY_COMPONENTS = [
|
|||||||
OrgUnitSearchResultGridElementComponent,
|
OrgUnitSearchResultGridElementComponent,
|
||||||
ProjectSearchResultGridElementComponent,
|
ProjectSearchResultGridElementComponent,
|
||||||
PersonSearchResultListSubmissionElementComponent,
|
PersonSearchResultListSubmissionElementComponent,
|
||||||
PersonInputSuggestionsComponent
|
PersonInputSuggestionsComponent,
|
||||||
|
NameVariantModalComponent
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -53,7 +55,7 @@ const ENTRY_COMPONENTS = [
|
|||||||
ItemPageModule
|
ItemPageModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
...ENTRY_COMPONENTS
|
...ENTRY_COMPONENTS,
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
...ENTRY_COMPONENTS
|
...ENTRY_COMPONENTS
|
||||||
|
@@ -0,0 +1,13 @@
|
|||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title">New name variant</h4>
|
||||||
|
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
{{'submission.sections.describe.relationship-lookup.name-variant.notification.content' | translate: { value: value } }}
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-light" (click)="modal.close()">{{'submission.sections.describe.relationship-lookup.name-variant.notification.confirm' | translate }}</button>
|
||||||
|
<button type="button" class="btn btn-light" (click)="modal.dismiss()">{{'submission.sections.describe.relationship-lookup.name-variant.notification.decline' | translate }}</button>
|
||||||
|
</div>
|
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { NameVariantModalComponent } from './name-variant-modal.component';
|
||||||
|
|
||||||
|
describe('NameVariantModalComponent', () => {
|
||||||
|
let component: NameVariantModalComponent;
|
||||||
|
let fixture: ComponentFixture<NameVariantModalComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ NameVariantModalComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(NameVariantModalComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,20 @@
|
|||||||
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
|
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'name-variant-modal',
|
||||||
|
templateUrl: './name-variant-modal.component.html',
|
||||||
|
styleUrls: ['./name-variant-modal.component.scss']
|
||||||
|
})
|
||||||
|
export class NameVariantModalComponent implements OnInit {
|
||||||
|
@Input() value: string;
|
||||||
|
|
||||||
|
constructor(private modalService: NgbModal,
|
||||||
|
public modal: NgbActiveModal) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,10 +1,6 @@
|
|||||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||||
<ds-truncatable [id]="dso.id">
|
<ds-truncatable [id]="dso.id">
|
||||||
<ds-person-input-suggestions [suggestions]="suggestions" (typeSuggestion)="filter($event)" [(ngModel)]="selected" (clickSuggestion)="select($event)" (submitSuggestion)="select($event)"></ds-person-input-suggestions>
|
<ds-person-input-suggestions [suggestions]="suggestions" (typeSuggestion)="filter($event)" [(ngModel)]="selected" (clickSuggestion)="select($event)" (submitSuggestion)="selectCustom($event)"></ds-person-input-suggestions>
|
||||||
<!-- <select>-->
|
|
||||||
<!-- <option [value]="firstMetadataValue('person.familyName') + ', ' + firstMetadataValue('person.givenName')" [innerHTML]="firstMetadataValue('person.familyName') + ', ' + firstMetadataValue('person.givenName')"></option>-->
|
|
||||||
<!-- <option *ngFor="let value of allMetadataValues('dc.title.alternative')" [value]="value" [innerHTML]="value"></option>-->
|
|
||||||
<!-- </select>-->
|
|
||||||
<span class="text-muted">
|
<span class="text-muted">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||||
<span *ngIf="dso.allMetadata(['person.jobTitle']).length > 0"
|
<span *ngIf="dso.allMetadata(['person.jobTitle']).length > 0"
|
||||||
|
@@ -8,6 +8,18 @@ import { Context } from '../../../../../core/shared/context.model';
|
|||||||
import { RelationshipService } from '../../../../../core/data/relationship.service';
|
import { RelationshipService } from '../../../../../core/data/relationship.service';
|
||||||
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
|
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { DsDynamicLookupRelationModalComponent } from '../../../../../shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component';
|
||||||
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { NameVariantModalComponent } from './name-variant-modal/name-variant-modal.component';
|
||||||
|
import { Community } from '../../../../../core/shared/community.model';
|
||||||
|
import { MetadataValue } from '../../../../../core/shared/metadata.models';
|
||||||
|
import { ItemDataService } from '../../../../../core/data/item-data.service';
|
||||||
|
|
||||||
|
const NOTIFICATION_CONTENT_KEY = 'submission.sections.describe.relationship-lookup.name-variant.notification.content';
|
||||||
|
const NOTIFICATION_CONFIRM_KEY = 'submission.sections.describe.relationship-lookup.name-variant.notification.confirm';
|
||||||
|
const NOTIFICATION_DECLINE_KEY = 'submission.sections.describe.relationship-lookup.name-variant.notification.decline';
|
||||||
|
|
||||||
@listableObjectComponent('PersonSearchResult', ViewMode.ListElement, Context.Workspace)
|
@listableObjectComponent('PersonSearchResult', ViewMode.ListElement, Context.Workspace)
|
||||||
@Component({
|
@Component({
|
||||||
@@ -15,6 +27,7 @@ import { take } from 'rxjs/operators';
|
|||||||
styleUrls: ['./person-search-result-list-submission-element.component.scss'],
|
styleUrls: ['./person-search-result-list-submission-element.component.scss'],
|
||||||
templateUrl: './person-search-result-list-submission-element.component.html'
|
templateUrl: './person-search-result-list-submission-element.component.html'
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The component for displaying a list element for an item search result of the type Person
|
* The component for displaying a list element for an item search result of the type Person
|
||||||
*/
|
*/
|
||||||
@@ -22,15 +35,21 @@ export class PersonSearchResultListSubmissionElementComponent extends SearchResu
|
|||||||
suggestions: string[];
|
suggestions: string[];
|
||||||
allSuggestions: string[];
|
allSuggestions: string[];
|
||||||
selected: string;
|
selected: string;
|
||||||
|
alternativeField = 'dc.title.alternative';
|
||||||
|
|
||||||
constructor(protected truncatableService: TruncatableService, private relationshipService: RelationshipService) {
|
constructor(protected truncatableService: TruncatableService,
|
||||||
|
private relationshipService: RelationshipService,
|
||||||
|
private notificationsService: NotificationsService,
|
||||||
|
private translateService: TranslateService,
|
||||||
|
private modalService: NgbModal,
|
||||||
|
private itemDataService: ItemDataService) {
|
||||||
super(truncatableService);
|
super(truncatableService);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
const defaultValue = this.firstMetadataValue('person.familyName') + ', ' + this.firstMetadataValue('person.givenName');
|
const defaultValue = this.firstMetadataValue('person.familyName') + ', ' + this.firstMetadataValue('person.givenName');
|
||||||
const alternatives = this.allMetadataValues('dc.title.alternative');
|
const alternatives = this.allMetadataValues(this.alternativeField);
|
||||||
this.allSuggestions = [defaultValue, ...alternatives];
|
this.allSuggestions = [defaultValue, ...alternatives];
|
||||||
this.suggestions = this.allSuggestions;
|
this.suggestions = this.allSuggestions;
|
||||||
|
|
||||||
@@ -38,7 +57,8 @@ export class PersonSearchResultListSubmissionElementComponent extends SearchResu
|
|||||||
.pipe(take(1))
|
.pipe(take(1))
|
||||||
.subscribe((nameVariant: string) => {
|
.subscribe((nameVariant: string) => {
|
||||||
this.selected = nameVariant || defaultValue;
|
this.selected = nameVariant || defaultValue;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
filter(query) {
|
filter(query) {
|
||||||
@@ -48,4 +68,34 @@ export class PersonSearchResultListSubmissionElementComponent extends SearchResu
|
|||||||
select(value) {
|
select(value) {
|
||||||
this.relationshipService.setNameVariant(this.listID, this.dso.uuid, value);
|
this.relationshipService.setNameVariant(this.listID, this.dso.uuid, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectCustom(value) {
|
||||||
|
if (!this.allSuggestions.includes(value)) {
|
||||||
|
this.openModal(value)
|
||||||
|
.then(() => {
|
||||||
|
|
||||||
|
const newName: MetadataValue = new MetadataValue();
|
||||||
|
newName.value = value;
|
||||||
|
|
||||||
|
const existingNames: MetadataValue[] = this.dso.metadata[this.alternativeField] || [];
|
||||||
|
const alternativeNames = { [this.alternativeField]: [...existingNames, newName] };
|
||||||
|
const updatedItem =
|
||||||
|
Object.assign({}, this.dso, {
|
||||||
|
metadata: {
|
||||||
|
...this.dso.metadata,
|
||||||
|
...alternativeNames
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.itemDataService.update(updatedItem).pipe(take(1)).subscribe();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.select(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
openModal(value): Promise<any> {
|
||||||
|
const modalRef = this.modalService.open(NameVariantModalComponent, { size: 'lg' });
|
||||||
|
const modalComp = modalRef.componentInstance;
|
||||||
|
modalComp.value = value;
|
||||||
|
return modalRef.result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user