mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #1092 from 4Science/CST-3782-final-adjustments
Repeatable fields with look up still broken in some cases
This commit is contained in:
@@ -37,6 +37,7 @@ import {
|
|||||||
DynamicFormControl,
|
DynamicFormControl,
|
||||||
DynamicFormControlContainerComponent,
|
DynamicFormControlContainerComponent,
|
||||||
DynamicFormControlEvent,
|
DynamicFormControlEvent,
|
||||||
|
DynamicFormControlEventType,
|
||||||
DynamicFormControlModel,
|
DynamicFormControlModel,
|
||||||
DynamicFormLayout,
|
DynamicFormLayout,
|
||||||
DynamicFormLayoutService,
|
DynamicFormLayoutService,
|
||||||
@@ -395,9 +396,25 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (hasValue(this.model.value)) {
|
if (hasValue(this.model.value)) {
|
||||||
this.submissionService.dispatchSave(this.model.submissionId);
|
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;
|
const modalComp = this.modalRef.componentInstance;
|
||||||
|
|
||||||
if (hasValue(this.model.value) && !this.model.readOnly) {
|
if (hasValue(this.model.value) && !this.model.readOnly) {
|
||||||
@@ -427,6 +444,9 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
const path = this.formBuilderService.getPath(arrayContext);
|
const path = this.formBuilderService.getPath(arrayContext);
|
||||||
const formArrayControl = this.group.root.get(path) as FormArray;
|
const formArrayControl = this.group.root.get(path) as FormArray;
|
||||||
this.formBuilderService.removeFormArrayGroup(this.context.index, formArrayControl, arrayContext);
|
this.formBuilderService.removeFormArrayGroup(this.context.index, formArrayControl, arrayContext);
|
||||||
|
if (this.model.parent.context.groups.length === 0) {
|
||||||
|
this.formBuilderService.addFormArrayGroup(formArrayControl, arrayContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -16,6 +16,8 @@ import { ItemSearchResult } from '../../../../object-collection/shared/item-sear
|
|||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
import { TranslateLoaderMock } from '../../../../testing/translate-loader.mock';
|
import { TranslateLoaderMock } from '../../../../testing/translate-loader.mock';
|
||||||
|
import { SubmissionService } from '../../../../../submission/submission.service';
|
||||||
|
import { SubmissionServiceStub } from '../../../../testing/submission-service.stub';
|
||||||
|
|
||||||
describe('ExistingMetadataListElementComponent', () => {
|
describe('ExistingMetadataListElementComponent', () => {
|
||||||
let component: ExistingMetadataListElementComponent;
|
let component: ExistingMetadataListElementComponent;
|
||||||
@@ -36,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';
|
||||||
@@ -62,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(() => {
|
||||||
@@ -79,6 +84,7 @@ describe('ExistingMetadataListElementComponent', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: SelectableListService, useValue: selectionService },
|
{ provide: SelectableListService, useValue: selectionService },
|
||||||
{ provide: Store, useValue: store },
|
{ provide: Store, useValue: store },
|
||||||
|
{ 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';
|
||||||
@@ -19,6 +19,8 @@ import { FormFieldMetadataValueObject } from '../../models/form-field-metadata-v
|
|||||||
import { RelationshipOptions } from '../../models/relationship-options.model';
|
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 { SubmissionObjectEntry } from '../../../../../submission/objects/submission-objects.reducer';
|
||||||
|
|
||||||
// tslint:disable:max-classes-per-file
|
// tslint:disable:max-classes-per-file
|
||||||
/**
|
/**
|
||||||
@@ -155,7 +157,8 @@ export class ExistingMetadataListElementComponent implements OnInit, OnChanges,
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private selectableListService: SelectableListService,
|
private selectableListService: SelectableListService,
|
||||||
private store: Store<AppState>
|
private store: Store<AppState>,
|
||||||
|
private submissionService: SubmissionService
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,9 +197,14 @@ export class ExistingMetadataListElementComponent implements OnInit, OnChanges,
|
|||||||
* Removes the selected relationship from the list
|
* Removes the selected relationship from the list
|
||||||
*/
|
*/
|
||||||
removeSelection() {
|
removeSelection() {
|
||||||
|
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();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -12,6 +12,8 @@ import { ItemSearchResult } from '../../../../object-collection/shared/item-sear
|
|||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
import { ReorderableRelationship } from '../existing-metadata-list-element/existing-metadata-list-element.component';
|
import { ReorderableRelationship } from '../existing-metadata-list-element/existing-metadata-list-element.component';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../../remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../../remote-data.utils';
|
||||||
|
import { SubmissionService } from '../../../../../submission/submission.service';
|
||||||
|
import { SubmissionServiceStub } from '../../../../testing/submission-service.stub';
|
||||||
|
|
||||||
describe('ExistingRelationListElementComponent', () => {
|
describe('ExistingRelationListElementComponent', () => {
|
||||||
let component: ExistingRelationListElementComponent;
|
let component: ExistingRelationListElementComponent;
|
||||||
@@ -67,6 +69,7 @@ describe('ExistingRelationListElementComponent', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: SelectableListService, useValue: selectionService },
|
{ provide: SelectableListService, useValue: selectionService },
|
||||||
{ provide: Store, useValue: store },
|
{ provide: Store, useValue: store },
|
||||||
|
{ provide: SubmissionService, useClass: SubmissionServiceStub },
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
})
|
})
|
||||||
|
@@ -12,6 +12,7 @@ import { RelationshipOptions } from '../../models/relationship-options.model';
|
|||||||
import { RemoveRelationshipAction } from '../relation-lookup-modal/relationship.actions';
|
import { RemoveRelationshipAction } from '../relation-lookup-modal/relationship.actions';
|
||||||
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
import { ReorderableRelationship } from '../existing-metadata-list-element/existing-metadata-list-element.component';
|
import { ReorderableRelationship } from '../existing-metadata-list-element/existing-metadata-list-element.component';
|
||||||
|
import { SubmissionService } from '../../../../../submission/submission.service';
|
||||||
|
|
||||||
// tslint:disable:max-classes-per-file
|
// tslint:disable:max-classes-per-file
|
||||||
/**
|
/**
|
||||||
@@ -72,6 +73,7 @@ export class ExistingRelationListElementComponent implements OnInit, OnChanges,
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private selectableListService: SelectableListService,
|
private selectableListService: SelectableListService,
|
||||||
|
private submissionService: SubmissionService,
|
||||||
private store: Store<AppState>
|
private store: Store<AppState>
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
@@ -102,6 +104,7 @@ export class ExistingRelationListElementComponent implements OnInit, OnChanges,
|
|||||||
* Removes the selected relationship from the list
|
* Removes the selected relationship from the list
|
||||||
*/
|
*/
|
||||||
removeSelection() {
|
removeSelection() {
|
||||||
|
this.submissionService.dispatchSave(this.submissionId);
|
||||||
this.selectableListService.deselectSingle(this.listId, Object.assign(new ItemSearchResult(), { indexableObject: this.relatedItem$.getValue() }));
|
this.selectableListService.deselectSingle(this.listId, Object.assign(new ItemSearchResult(), { indexableObject: this.relatedItem$.getValue() }));
|
||||||
this.store.dispatch(new RemoveRelationshipAction(this.submissionItem, this.relatedItem$.getValue(), this.relationshipOptions.relationshipType, this.submissionId));
|
this.store.dispatch(new RemoveRelationshipAction(this.submissionItem, this.relatedItem$.getValue(), this.relationshipOptions.relationshipType, this.submissionId));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user