[CST-3782] lookup click doesn't clear the plain value

This commit is contained in:
Alessandro Martelli
2021-04-13 09:51:05 +02:00
parent b537f70d7b
commit 31e4aa788e
3 changed files with 32 additions and 5 deletions

View File

@@ -37,6 +37,7 @@ import {
DynamicFormControl,
DynamicFormControlContainerComponent,
DynamicFormControlEvent,
DynamicFormControlEventType,
DynamicFormControlModel,
DynamicFormLayout,
DynamicFormLayoutService,
@@ -394,6 +395,24 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
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);
const modalComp = this.modalRef.componentInstance;

View File

@@ -38,6 +38,7 @@ describe('ExistingMetadataListElementComponent', () => {
let relatedSearchResult;
let submissionId;
let relationshipService;
let submissionServiceStub;
function init() {
uuid1 = '91ce578d-2e63-4093-8c73-3faafd716000';
@@ -64,6 +65,8 @@ describe('ExistingMetadataListElementComponent', () => {
relationship = Object.assign(new Relationship(), { leftItem: leftItemRD$, rightItem: rightItemRD$ });
submissionId = '1234';
reoRel = new ReorderableRelationship(relationship, true, {} as any, {} as any, submissionId);
submissionServiceStub = new SubmissionServiceStub();
submissionServiceStub.getSubmissionObject.and.returnValue(observableOf({}));
}
beforeEach(waitForAsync(() => {
@@ -81,7 +84,7 @@ describe('ExistingMetadataListElementComponent', () => {
providers: [
{ provide: SelectableListService, useValue: selectionService },
{ provide: Store, useValue: store },
{ provide: SubmissionService, useClass: SubmissionServiceStub },
{ provide: SubmissionService, useValue: submissionServiceStub },
],
schemas: [NO_ERRORS_SCHEMA]
})

View File

@@ -3,7 +3,7 @@ import { FormControl } from '@angular/forms';
import { DynamicFormArrayGroupModel } from '@ng-dynamic-forms/core';
import { Store } from '@ngrx/store';
import { BehaviorSubject, Subscription } from 'rxjs';
import { filter } from 'rxjs/operators';
import { filter, take } from 'rxjs/operators';
import { AppState } from '../../../../../app.reducer';
import { RelationshipService } from '../../../../../core/data/relationship.service';
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 { RemoveRelationshipAction } from '../relation-lookup-modal/relationship.actions';
import { SubmissionService } from '../../../../../submission/submission.service';
import { SubmissionObjectEntry } from '../../../../../submission/objects/submission-objects.reducer';
// tslint:disable:max-classes-per-file
/**
@@ -197,9 +198,13 @@ export class ExistingMetadataListElementComponent implements OnInit, OnChanges,
*/
removeSelection() {
this.submissionService.dispatchSave(this.submissionId);
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.remove.emit();
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.store.dispatch(new RemoveRelationshipAction(this.submissionItem, this.relatedItem, this.relationshipOptions.relationshipType, this.submissionId));
this.remove.emit();
});
}
/**