mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 13:03:04 +00:00
[CST-3782] repeatable with lookup fixes
This commit is contained in:
@@ -54,6 +54,7 @@
|
|||||||
[metadataFields]="model.metadataFields"
|
[metadataFields]="model.metadataFields"
|
||||||
[submissionId]="model.submissionId"
|
[submissionId]="model.submissionId"
|
||||||
[relationshipOptions]="model.relationship"
|
[relationshipOptions]="model.relationship"
|
||||||
|
[canRemove]="canRemove()"
|
||||||
(remove)="onRemove()"
|
(remove)="onRemove()"
|
||||||
>
|
>
|
||||||
</ds-existing-metadata-list-element>
|
</ds-existing-metadata-list-element>
|
||||||
@@ -66,6 +67,7 @@
|
|||||||
[metadataFields]="model.metadataFields"
|
[metadataFields]="model.metadataFields"
|
||||||
[submissionId]="model.submissionId"
|
[submissionId]="model.submissionId"
|
||||||
[relationshipOptions]="model.relationship"
|
[relationshipOptions]="model.relationship"
|
||||||
|
[canRemove]="canRemove()"
|
||||||
>
|
>
|
||||||
</ds-existing-relation-list-element>
|
</ds-existing-relation-list-element>
|
||||||
<small *ngIf="hasHint && (model.repeatable === false || context?.index === context?.context?.groups?.length - 1) && (!showErrorMessages || errorMessages.length === 0)"
|
<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'
|
size: 'lg'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (hasValue(this.model.value)) {
|
this.submissionService.dispatchSave(this.model.submissionId);
|
||||||
this.submissionService.dispatchSave(this.model.submissionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
const modalComp = this.modalRef.componentInstance;
|
const modalComp = this.modalRef.componentInstance;
|
||||||
|
|
||||||
@@ -442,6 +440,10 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
return isNotEmpty(this.model.hint) && this.model.hint !== ' ';
|
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
|
* Initialize this.item$ based on this.model.submissionId
|
||||||
*/
|
*/
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<button type="button" class="btn btn-secondary"
|
<button type="button" class="btn btn-secondary"
|
||||||
title="{{'form.remove' | translate}}"
|
title="{{'form.remove' | translate}}"
|
||||||
|
[disabled]="!canRemove"
|
||||||
(click)="removeSelection()">
|
(click)="removeSelection()">
|
||||||
<i class="fas fa-trash" aria-hidden="true"></i>
|
<i class="fas fa-trash" aria-hidden="true"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@@ -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;
|
||||||
@@ -79,6 +81,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 },
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
})
|
})
|
||||||
|
@@ -19,6 +19,7 @@ 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';
|
||||||
|
|
||||||
// tslint:disable:max-classes-per-file
|
// tslint:disable:max-classes-per-file
|
||||||
/**
|
/**
|
||||||
@@ -145,6 +146,7 @@ export class ExistingMetadataListElementComponent implements OnInit, OnChanges,
|
|||||||
@Input() metadataFields: string[];
|
@Input() metadataFields: string[];
|
||||||
@Input() relationshipOptions: RelationshipOptions;
|
@Input() relationshipOptions: RelationshipOptions;
|
||||||
@Input() submissionId: string;
|
@Input() submissionId: string;
|
||||||
|
@Input() canRemove = true;
|
||||||
metadataRepresentation$: BehaviorSubject<MetadataRepresentation> = new BehaviorSubject<MetadataRepresentation>(undefined);
|
metadataRepresentation$: BehaviorSubject<MetadataRepresentation> = new BehaviorSubject<MetadataRepresentation>(undefined);
|
||||||
relatedItem: Item;
|
relatedItem: Item;
|
||||||
@Output() remove: EventEmitter<any> = new EventEmitter();
|
@Output() remove: EventEmitter<any> = new EventEmitter();
|
||||||
@@ -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,6 +197,7 @@ 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.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();
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
</span>
|
</span>
|
||||||
<button type="button" class="btn btn-secondary"
|
<button type="button" class="btn btn-secondary"
|
||||||
|
[disabled]="canRemove"
|
||||||
(click)="removeSelection()">
|
(click)="removeSelection()">
|
||||||
<i class="fas fa-trash" aria-hidden="true"></i>
|
<i class="fas fa-trash" aria-hidden="true"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@@ -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
|
||||||
/**
|
/**
|
||||||
@@ -61,6 +62,7 @@ export class ExistingRelationListElementComponent implements OnInit, OnChanges,
|
|||||||
@Input() metadataFields: string[];
|
@Input() metadataFields: string[];
|
||||||
@Input() relationshipOptions: RelationshipOptions;
|
@Input() relationshipOptions: RelationshipOptions;
|
||||||
@Input() submissionId: string;
|
@Input() submissionId: string;
|
||||||
|
@Input() canRemove = true;
|
||||||
relatedItem$: BehaviorSubject<Item> = new BehaviorSubject<Item>(undefined);
|
relatedItem$: BehaviorSubject<Item> = new BehaviorSubject<Item>(undefined);
|
||||||
viewType = ViewMode.ListElement;
|
viewType = ViewMode.ListElement;
|
||||||
@Output() remove: EventEmitter<any> = new EventEmitter();
|
@Output() remove: EventEmitter<any> = new EventEmitter();
|
||||||
@@ -72,6 +74,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 +105,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