mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
[CST-3782] lookup click doesn't clear the plain value
This commit is contained in:
@@ -37,6 +37,7 @@ import {
|
|||||||
DynamicFormControl,
|
DynamicFormControl,
|
||||||
DynamicFormControlContainerComponent,
|
DynamicFormControlContainerComponent,
|
||||||
DynamicFormControlEvent,
|
DynamicFormControlEvent,
|
||||||
|
DynamicFormControlEventType,
|
||||||
DynamicFormControlModel,
|
DynamicFormControlModel,
|
||||||
DynamicFormLayout,
|
DynamicFormLayout,
|
||||||
DynamicFormLayoutService,
|
DynamicFormLayoutService,
|
||||||
@@ -394,6 +395,24 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
size: 'lg'
|
size: 'lg'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (hasValue(this.model.value)) {
|
||||||
|
this.focus.emit({
|
||||||
|
$event: new Event('focus'),
|
||||||
|
context: this.context,
|
||||||
|
control: this.control,
|
||||||
|
model: this.model,
|
||||||
|
type: DynamicFormControlEventType.Focus
|
||||||
|
} as DynamicFormControlEvent);
|
||||||
|
|
||||||
|
this.change.emit({
|
||||||
|
$event: new Event('change'),
|
||||||
|
context: this.context,
|
||||||
|
control: this.control,
|
||||||
|
model: this.model,
|
||||||
|
type: DynamicFormControlEventType.Change
|
||||||
|
} as DynamicFormControlEvent);
|
||||||
|
}
|
||||||
|
|
||||||
this.submissionService.dispatchSave(this.model.submissionId);
|
this.submissionService.dispatchSave(this.model.submissionId);
|
||||||
|
|
||||||
const modalComp = this.modalRef.componentInstance;
|
const modalComp = this.modalRef.componentInstance;
|
||||||
|
@@ -38,6 +38,7 @@ describe('ExistingMetadataListElementComponent', () => {
|
|||||||
let relatedSearchResult;
|
let relatedSearchResult;
|
||||||
let submissionId;
|
let submissionId;
|
||||||
let relationshipService;
|
let relationshipService;
|
||||||
|
let submissionServiceStub;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
uuid1 = '91ce578d-2e63-4093-8c73-3faafd716000';
|
uuid1 = '91ce578d-2e63-4093-8c73-3faafd716000';
|
||||||
@@ -64,6 +65,8 @@ describe('ExistingMetadataListElementComponent', () => {
|
|||||||
relationship = Object.assign(new Relationship(), { leftItem: leftItemRD$, rightItem: rightItemRD$ });
|
relationship = Object.assign(new Relationship(), { leftItem: leftItemRD$, rightItem: rightItemRD$ });
|
||||||
submissionId = '1234';
|
submissionId = '1234';
|
||||||
reoRel = new ReorderableRelationship(relationship, true, {} as any, {} as any, submissionId);
|
reoRel = new ReorderableRelationship(relationship, true, {} as any, {} as any, submissionId);
|
||||||
|
submissionServiceStub = new SubmissionServiceStub();
|
||||||
|
submissionServiceStub.getSubmissionObject.and.returnValue(observableOf({}));
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
@@ -81,7 +84,7 @@ describe('ExistingMetadataListElementComponent', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: SelectableListService, useValue: selectionService },
|
{ provide: SelectableListService, useValue: selectionService },
|
||||||
{ provide: Store, useValue: store },
|
{ provide: Store, useValue: store },
|
||||||
{ provide: SubmissionService, useClass: SubmissionServiceStub },
|
{ provide: SubmissionService, useValue: submissionServiceStub },
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
})
|
})
|
||||||
|
@@ -3,7 +3,7 @@ import { FormControl } from '@angular/forms';
|
|||||||
import { DynamicFormArrayGroupModel } from '@ng-dynamic-forms/core';
|
import { DynamicFormArrayGroupModel } from '@ng-dynamic-forms/core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { BehaviorSubject, Subscription } from 'rxjs';
|
import { BehaviorSubject, Subscription } from 'rxjs';
|
||||||
import { filter } from 'rxjs/operators';
|
import { filter, take } from 'rxjs/operators';
|
||||||
import { AppState } from '../../../../../app.reducer';
|
import { AppState } from '../../../../../app.reducer';
|
||||||
import { RelationshipService } from '../../../../../core/data/relationship.service';
|
import { RelationshipService } from '../../../../../core/data/relationship.service';
|
||||||
import { Relationship } from '../../../../../core/shared/item-relationships/relationship.model';
|
import { Relationship } from '../../../../../core/shared/item-relationships/relationship.model';
|
||||||
@@ -20,6 +20,7 @@ import { RelationshipOptions } from '../../models/relationship-options.model';
|
|||||||
import { DynamicConcatModel } from '../models/ds-dynamic-concat.model';
|
import { DynamicConcatModel } from '../models/ds-dynamic-concat.model';
|
||||||
import { RemoveRelationshipAction } from '../relation-lookup-modal/relationship.actions';
|
import { RemoveRelationshipAction } from '../relation-lookup-modal/relationship.actions';
|
||||||
import { SubmissionService } from '../../../../../submission/submission.service';
|
import { SubmissionService } from '../../../../../submission/submission.service';
|
||||||
|
import { SubmissionObjectEntry } from '../../../../../submission/objects/submission-objects.reducer';
|
||||||
|
|
||||||
// tslint:disable:max-classes-per-file
|
// tslint:disable:max-classes-per-file
|
||||||
/**
|
/**
|
||||||
@@ -197,9 +198,13 @@ export class ExistingMetadataListElementComponent implements OnInit, OnChanges,
|
|||||||
*/
|
*/
|
||||||
removeSelection() {
|
removeSelection() {
|
||||||
this.submissionService.dispatchSave(this.submissionId);
|
this.submissionService.dispatchSave(this.submissionId);
|
||||||
|
this.submissionService.getSubmissionObject(this.submissionId).pipe(
|
||||||
|
filter((state: SubmissionObjectEntry) => !state.savePending && !state.isLoading),
|
||||||
|
take(1)).subscribe(() => {
|
||||||
this.selectableListService.deselectSingle(this.listId, Object.assign(new ItemSearchResult(), { indexableObject: this.relatedItem }));
|
this.selectableListService.deselectSingle(this.listId, Object.assign(new ItemSearchResult(), { indexableObject: this.relatedItem }));
|
||||||
this.store.dispatch(new RemoveRelationshipAction(this.submissionItem, this.relatedItem, this.relationshipOptions.relationshipType, this.submissionId));
|
this.store.dispatch(new RemoveRelationshipAction(this.submissionItem, this.relatedItem, this.relationshipOptions.relationshipType, this.submissionId));
|
||||||
this.remove.emit();
|
this.remove.emit();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user