mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CST-3782] repeatable with lookup fixes
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
[metadataFields]="model.metadataFields"
|
||||
[submissionId]="model.submissionId"
|
||||
[relationshipOptions]="model.relationship"
|
||||
[canRemove]="canRemove()"
|
||||
(remove)="onRemove()"
|
||||
>
|
||||
</ds-existing-metadata-list-element>
|
||||
@@ -66,6 +67,7 @@
|
||||
[metadataFields]="model.metadataFields"
|
||||
[submissionId]="model.submissionId"
|
||||
[relationshipOptions]="model.relationship"
|
||||
[canRemove]="canRemove()"
|
||||
>
|
||||
</ds-existing-relation-list-element>
|
||||
<small *ngIf="hasHint && (model.repeatable === false || context?.index === context?.context?.groups?.length - 1) && (!showErrorMessages || errorMessages.length === 0)"
|
||||
|
@@ -394,9 +394,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
size: 'lg'
|
||||
});
|
||||
|
||||
if (hasValue(this.model.value)) {
|
||||
this.submissionService.dispatchSave(this.model.submissionId);
|
||||
}
|
||||
this.submissionService.dispatchSave(this.model.submissionId);
|
||||
|
||||
const modalComp = this.modalRef.componentInstance;
|
||||
|
||||
@@ -442,6 +440,10 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
return isNotEmpty(this.model.hint) && this.model.hint !== ' ';
|
||||
}
|
||||
|
||||
canRemove() {
|
||||
return this.model.parent.context.groups.length > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize this.item$ based on this.model.submissionId
|
||||
*/
|
||||
|
@@ -9,6 +9,7 @@
|
||||
</span>
|
||||
<button type="button" class="btn btn-secondary"
|
||||
title="{{'form.remove' | translate}}"
|
||||
[disabled]="!canRemove"
|
||||
(click)="removeSelection()">
|
||||
<i class="fas fa-trash" aria-hidden="true"></i>
|
||||
</button>
|
||||
|
@@ -16,6 +16,8 @@ import { ItemSearchResult } from '../../../../object-collection/shared/item-sear
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
import { TranslateLoaderMock } from '../../../../testing/translate-loader.mock';
|
||||
import { SubmissionService } from '../../../../../submission/submission.service';
|
||||
import { SubmissionServiceStub } from '../../../../testing/submission-service.stub';
|
||||
|
||||
describe('ExistingMetadataListElementComponent', () => {
|
||||
let component: ExistingMetadataListElementComponent;
|
||||
@@ -79,6 +81,7 @@ describe('ExistingMetadataListElementComponent', () => {
|
||||
providers: [
|
||||
{ provide: SelectableListService, useValue: selectionService },
|
||||
{ provide: Store, useValue: store },
|
||||
{ provide: SubmissionService, useClass: SubmissionServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
|
@@ -19,6 +19,7 @@ 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 } from '../relation-lookup-modal/relationship.actions';
|
||||
import { SubmissionService } from '../../../../../submission/submission.service';
|
||||
|
||||
// tslint:disable:max-classes-per-file
|
||||
/**
|
||||
@@ -145,6 +146,7 @@ export class ExistingMetadataListElementComponent implements OnInit, OnChanges,
|
||||
@Input() metadataFields: string[];
|
||||
@Input() relationshipOptions: RelationshipOptions;
|
||||
@Input() submissionId: string;
|
||||
@Input() canRemove = true;
|
||||
metadataRepresentation$: BehaviorSubject<MetadataRepresentation> = new BehaviorSubject<MetadataRepresentation>(undefined);
|
||||
relatedItem: Item;
|
||||
@Output() remove: EventEmitter<any> = new EventEmitter();
|
||||
@@ -155,7 +157,8 @@ export class ExistingMetadataListElementComponent implements OnInit, OnChanges,
|
||||
|
||||
constructor(
|
||||
private selectableListService: SelectableListService,
|
||||
private store: Store<AppState>
|
||||
private store: Store<AppState>,
|
||||
private submissionService: SubmissionService
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -194,6 +197,7 @@ export class ExistingMetadataListElementComponent implements OnInit, OnChanges,
|
||||
* Removes the selected relationship from the list
|
||||
*/
|
||||
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();
|
||||
|
@@ -8,6 +8,7 @@
|
||||
</ng-container>
|
||||
</span>
|
||||
<button type="button" class="btn btn-secondary"
|
||||
[disabled]="canRemove"
|
||||
(click)="removeSelection()">
|
||||
<i class="fas fa-trash" aria-hidden="true"></i>
|
||||
</button>
|
||||
|
@@ -12,6 +12,8 @@ import { ItemSearchResult } from '../../../../object-collection/shared/item-sear
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { ReorderableRelationship } from '../existing-metadata-list-element/existing-metadata-list-element.component';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../remote-data.utils';
|
||||
import { SubmissionService } from '../../../../../submission/submission.service';
|
||||
import { SubmissionServiceStub } from '../../../../testing/submission-service.stub';
|
||||
|
||||
describe('ExistingRelationListElementComponent', () => {
|
||||
let component: ExistingRelationListElementComponent;
|
||||
@@ -67,6 +69,7 @@ describe('ExistingRelationListElementComponent', () => {
|
||||
providers: [
|
||||
{ provide: SelectableListService, useValue: selectionService },
|
||||
{ provide: Store, useValue: store },
|
||||
{ provide: SubmissionService, useClass: SubmissionServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
|
@@ -12,6 +12,7 @@ import { RelationshipOptions } from '../../models/relationship-options.model';
|
||||
import { RemoveRelationshipAction } from '../relation-lookup-modal/relationship.actions';
|
||||
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||
import { ReorderableRelationship } from '../existing-metadata-list-element/existing-metadata-list-element.component';
|
||||
import { SubmissionService } from '../../../../../submission/submission.service';
|
||||
|
||||
// tslint:disable:max-classes-per-file
|
||||
/**
|
||||
@@ -61,6 +62,7 @@ export class ExistingRelationListElementComponent implements OnInit, OnChanges,
|
||||
@Input() metadataFields: string[];
|
||||
@Input() relationshipOptions: RelationshipOptions;
|
||||
@Input() submissionId: string;
|
||||
@Input() canRemove = true;
|
||||
relatedItem$: BehaviorSubject<Item> = new BehaviorSubject<Item>(undefined);
|
||||
viewType = ViewMode.ListElement;
|
||||
@Output() remove: EventEmitter<any> = new EventEmitter();
|
||||
@@ -72,6 +74,7 @@ export class ExistingRelationListElementComponent implements OnInit, OnChanges,
|
||||
|
||||
constructor(
|
||||
private selectableListService: SelectableListService,
|
||||
private submissionService: SubmissionService,
|
||||
private store: Store<AppState>
|
||||
) {
|
||||
}
|
||||
@@ -102,6 +105,7 @@ export class ExistingRelationListElementComponent implements OnInit, OnChanges,
|
||||
* Removes the selected relationship from the list
|
||||
*/
|
||||
removeSelection() {
|
||||
this.submissionService.dispatchSave(this.submissionId);
|
||||
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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user