mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
Merge branch 'metadata-and-relationships-combined-in-submission' into w2p-70237_entities-orgunit-submission-fix
This commit is contained in:
@@ -49,7 +49,9 @@
|
||||
[listId]="listId"
|
||||
[metadataFields]="model.metadataFields"
|
||||
[submissionId]="model.submissionId"
|
||||
[relationshipOptions]="model.relationship">
|
||||
[relationshipOptions]="model.relationship"
|
||||
(remove)="onRemove()"
|
||||
>
|
||||
</ds-existing-metadata-list-element>
|
||||
<ds-existing-relation-list-element
|
||||
*ngIf="!model.hasSelectableMetadata"
|
||||
|
@@ -17,7 +17,7 @@ import {
|
||||
ViewChild,
|
||||
ViewContainerRef
|
||||
} from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { FormGroup, FormArray } from '@angular/forms';
|
||||
|
||||
import {
|
||||
DYNAMIC_FORM_CONTROL_TYPE_ARRAY,
|
||||
@@ -38,7 +38,7 @@ import {
|
||||
DynamicFormLayout,
|
||||
DynamicFormLayoutService, DynamicFormRelationService,
|
||||
DynamicFormValidationService,
|
||||
DynamicTemplateDirective,
|
||||
DynamicTemplateDirective, DynamicFormArrayGroupModel, DynamicFormArrayModel,
|
||||
} from '@ng-dynamic-forms/core';
|
||||
import {
|
||||
DynamicNGBootstrapCalendarComponent,
|
||||
@@ -107,6 +107,8 @@ import { SubmissionService } from '../../../../submission/submission.service';
|
||||
import { followLink } from '../../../utils/follow-link-config.model';
|
||||
import { paginatedRelationsToItems } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
import { RelationshipOptions } from '../models/relationship-options.model';
|
||||
import { FormBuilderService } from '../form-builder.service';
|
||||
import { modalConfigDefaults } from 'ngx-bootstrap/modal/modal-options.class';
|
||||
|
||||
export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type<DynamicFormControl> | null {
|
||||
switch (model.type) {
|
||||
@@ -234,6 +236,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
private submissionObjectService: SubmissionObjectDataService,
|
||||
private ref: ChangeDetectorRef,
|
||||
private formService: FormService,
|
||||
private formBuilderService: FormBuilderService,
|
||||
private submissionService: SubmissionService
|
||||
) {
|
||||
super(componentFactoryResolver, layoutService, validationService, dynamicFormComponentService, relationService);
|
||||
@@ -312,7 +315,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes && !this.isRelationship) {
|
||||
if (changes && !this.isRelationship && hasValue(this.group.get(this.model.id))) {
|
||||
super.ngOnChanges(changes);
|
||||
if (this.model && this.model.placeholder) {
|
||||
this.model.placeholder = this.translateService.instant(this.model.placeholder);
|
||||
@@ -381,6 +384,19 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
modalComp.item = this.item;
|
||||
modalComp.collection = this.collection;
|
||||
modalComp.submissionId = this.model.submissionId;
|
||||
modalComp.selectEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for the remove event,
|
||||
* remove the current control from its array
|
||||
*/
|
||||
onRemove(): void {
|
||||
const arrayContext: DynamicFormArrayModel = (this.context as DynamicFormArrayGroupModel).context;
|
||||
const path = this.formBuilderService.getPath(arrayContext);
|
||||
const formArrayControl = this.group.root.get(path) as FormArray;
|
||||
|
||||
this.formBuilderService.removeFormArrayGroup(this.context.index, formArrayControl, arrayContext);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,12 +1,19 @@
|
||||
import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
|
||||
import { AbstractControl, FormControl } from '@angular/forms';
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Output
|
||||
} from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { DynamicFormArrayGroupModel, DynamicFormControlEvent } from '@ng-dynamic-forms/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { BehaviorSubject, Observable, of as observableOf, Subject, Subscription } from 'rxjs';
|
||||
import { filter, switchMap } from 'rxjs/operators';
|
||||
import { BehaviorSubject, Subscription } from 'rxjs';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { AppState } from '../../../../../app.reducer';
|
||||
import { RelationshipService } from '../../../../../core/data/relationship.service';
|
||||
import { RemoteData } from '../../../../../core/data/remote-data';
|
||||
import { Relationship } from '../../../../../core/shared/item-relationships/relationship.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { ItemMetadataRepresentation } from '../../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
||||
@@ -14,8 +21,7 @@ import { MetadataRepresentation } from '../../../../../core/shared/metadata-repr
|
||||
import { MetadataValue } from '../../../../../core/shared/metadata.models';
|
||||
import {
|
||||
getAllSucceededRemoteData,
|
||||
getRemoteDataPayload,
|
||||
getSucceededRemoteData
|
||||
getRemoteDataPayload
|
||||
} from '../../../../../core/shared/operators';
|
||||
import { hasValue, isNotEmpty } from '../../../../empty.util';
|
||||
import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model';
|
||||
@@ -24,8 +30,6 @@ import { FormFieldMetadataValueObject } from '../../models/form-field-metadata-v
|
||||
import { RelationshipOptions } from '../../models/relationship-options.model';
|
||||
import { DynamicConcatModel } from '../models/ds-dynamic-concat.model';
|
||||
import { RemoveRelationshipAction, UpdateRelationshipAction } from '../relation-lookup-modal/relationship.actions';
|
||||
import { SubmissionObject } from '../../../../../core/submission/models/submission-object.model';
|
||||
import { SaveSubmissionFormAction } from '../../../../../submission/objects/submission-objects.actions';
|
||||
|
||||
// tslint:disable:max-classes-per-file
|
||||
/**
|
||||
@@ -154,7 +158,7 @@ export class ExistingMetadataListElementComponent implements OnInit, OnChanges,
|
||||
@Input() submissionId: string;
|
||||
metadataRepresentation$: BehaviorSubject<MetadataRepresentation> = new BehaviorSubject<MetadataRepresentation>(undefined);
|
||||
relatedItem: Item;
|
||||
|
||||
@Output() remove: EventEmitter<any> = new EventEmitter();
|
||||
/**
|
||||
* List of subscriptions to unsubscribe from
|
||||
*/
|
||||
@@ -186,6 +190,7 @@ export class ExistingMetadataListElementComponent implements OnInit, OnChanges,
|
||||
const relationMD: MetadataValue = this.submissionItem.firstMetadata(this.relationshipOptions.metadataField, { value: this.relatedItem.uuid });
|
||||
if (hasValue(relationMD)) {
|
||||
const metadataRepresentationMD: MetadataValue = this.submissionItem.firstMetadata(this.metadataFields, { authority: relationMD.authority });
|
||||
|
||||
const nextValue = Object.assign(
|
||||
new ItemMetadataRepresentation(metadataRepresentationMD),
|
||||
this.relatedItem
|
||||
@@ -201,7 +206,8 @@ export class ExistingMetadataListElementComponent implements OnInit, OnChanges,
|
||||
*/
|
||||
removeSelection() {
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -13,6 +13,7 @@ import {
|
||||
} from '@ng-dynamic-forms/core';
|
||||
import { Relationship } from '../../../../../../core/shared/item-relationships/relationship.model';
|
||||
import { DynamicRowArrayModel } from '../ds-dynamic-row-array-model';
|
||||
import { hasValue } from '../../../../../empty.util';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-dynamic-form-array',
|
||||
@@ -45,16 +46,19 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent {
|
||||
this.model.moveGroup(event.previousIndex, event.currentIndex - event.previousIndex);
|
||||
const prevIndex = event.previousIndex - 1;
|
||||
const index = event.currentIndex - 1;
|
||||
const $event = {
|
||||
$event: { previousIndex: prevIndex },
|
||||
context: { index },
|
||||
control: (this.control as any).controls[index],
|
||||
group: this.group,
|
||||
model: this.model.groups[index].group[0],
|
||||
type: DynamicFormControlEventType.Change
|
||||
};
|
||||
|
||||
this.onChange($event);
|
||||
if (hasValue(this.model.groups[index]) && hasValue((this.control as any).controls[index])) {
|
||||
const $event = {
|
||||
$event: { previousIndex: prevIndex },
|
||||
context: { index },
|
||||
control: (this.control as any).controls[index],
|
||||
group: this.group,
|
||||
model: this.model.groups[index].group[0],
|
||||
type: DynamicFormControlEventType.Change
|
||||
};
|
||||
|
||||
this.onChange($event);
|
||||
}
|
||||
}
|
||||
|
||||
update(event: any, index: number) {
|
||||
@@ -62,8 +66,6 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent {
|
||||
context: { index: index - 1}
|
||||
});
|
||||
|
||||
console.log('$event', $event);
|
||||
|
||||
this.onChange($event)
|
||||
}
|
||||
}
|
||||
|
@@ -119,6 +119,7 @@ export class DsDynamicScrollableDropdownComponent extends DynamicFormControlComp
|
||||
|
||||
onSelect(event) {
|
||||
this.group.markAsDirty();
|
||||
console.log('onSelect event', event);
|
||||
this.model.valueUpdates.next(event);
|
||||
this.change.emit(event);
|
||||
this.setCurrentValue(event);
|
||||
|
Reference in New Issue
Block a user