mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #1987 from mspalti/relation-submisssion-thumb
Fix for related item thumbnail images.
This commit is contained in:
@@ -79,6 +79,8 @@ import { FormService } from '../../form.service';
|
||||
import { SubmissionService } from '../../../../submission/submission.service';
|
||||
import { FormBuilderService } from '../form-builder.service';
|
||||
import { NgxMaskModule } from 'ngx-mask';
|
||||
import { APP_CONFIG } from '../../../../../config/app-config.interface';
|
||||
import { environment } from '../../../../../environments/environment';
|
||||
|
||||
function getMockDsDynamicTypeBindRelationService(): DsDynamicTypeBindRelationService {
|
||||
return jasmine.createSpyObj('DsDynamicTypeBindRelationService', {
|
||||
@@ -230,7 +232,8 @@ describe('DsDynamicFormControlContainerComponent test suite', () => {
|
||||
findById: () => observableOf(createSuccessfulRemoteDataObject(testWSI))
|
||||
}
|
||||
},
|
||||
{ provide: NgZone, useValue: new NgZone({}) }
|
||||
{ provide: NgZone, useValue: new NgZone({}) },
|
||||
{ provide: APP_CONFIG, useValue: environment }
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
}).compileComponents().then(() => {
|
||||
|
@@ -4,7 +4,7 @@ import {
|
||||
Component,
|
||||
ComponentFactoryResolver,
|
||||
ContentChildren,
|
||||
EventEmitter,
|
||||
EventEmitter, Inject,
|
||||
Input,
|
||||
NgZone,
|
||||
OnChanges,
|
||||
@@ -118,6 +118,8 @@ import { RelationshipOptions } from '../models/relationship-options.model';
|
||||
import { FormBuilderService } from '../form-builder.service';
|
||||
import { DYNAMIC_FORM_CONTROL_TYPE_RELATION_GROUP } from './ds-dynamic-form-constants';
|
||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||
import { APP_CONFIG, AppConfig } from '../../../../../config/app-config.interface';
|
||||
import { itemLinksToFollow } from '../../../utils/relation-query.utils';
|
||||
|
||||
export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type<DynamicFormControl> | null {
|
||||
switch (model.type) {
|
||||
@@ -231,6 +233,11 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
|
||||
private showErrorMessagesPreviousStage: boolean;
|
||||
|
||||
/**
|
||||
* Determines whether to request embedded thumbnail.
|
||||
*/
|
||||
fetchThumbnail: boolean;
|
||||
|
||||
get componentType(): Type<DynamicFormControl> | null {
|
||||
return dsDynamicFormControlMapFn(this.model);
|
||||
}
|
||||
@@ -253,9 +260,11 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
private ref: ChangeDetectorRef,
|
||||
private formService: FormService,
|
||||
private formBuilderService: FormBuilderService,
|
||||
private submissionService: SubmissionService
|
||||
private submissionService: SubmissionService,
|
||||
@Inject(APP_CONFIG) protected appConfig: AppConfig,
|
||||
) {
|
||||
super(ref, componentFactoryResolver, layoutService, validationService, dynamicFormComponentService, relationService);
|
||||
this.fetchThumbnail = this.appConfig.browseBy.showThumbnails;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,7 +294,6 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
followLink('rightItem'),
|
||||
followLink('relationshipType')
|
||||
);
|
||||
|
||||
relationshipsRD$.pipe(
|
||||
getFirstSucceededRemoteDataPayload(),
|
||||
getPaginatedListPayload()
|
||||
@@ -317,8 +325,10 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
}
|
||||
|
||||
if (hasValue(this.value) && this.value.isVirtual) {
|
||||
const relationship$ = this.relationshipService.findById(this.value.virtualValue, true, true, followLink('leftItem'), followLink('rightItem'), followLink('relationshipType'))
|
||||
.pipe(
|
||||
const relationship$ = this.relationshipService.findById(this.value.virtualValue,
|
||||
true,
|
||||
true,
|
||||
... itemLinksToFollow(this.fetchThumbnail)).pipe(
|
||||
getAllSucceededRemoteData(),
|
||||
getRemoteDataPayload());
|
||||
this.relationshipValue$ = observableCombineLatest([this.item$.pipe(take(1)), relationship$]).pipe(
|
||||
|
@@ -1,3 +1 @@
|
||||
span.text-contents{
|
||||
padding: var(--bs-btn-padding-y) 0;
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
<div class="d-flex">
|
||||
<span class="mr-auto text-contents">
|
||||
<div class="flex-grow-1 mr-auto">
|
||||
<ng-container *ngIf="!(relatedItem$ | async)">
|
||||
<ds-themed-loading [showMessage]="false"></ds-themed-loading>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="(relatedItem$ | async)">
|
||||
<ds-listable-object-component-loader [showLabel]="false" [viewMode]="viewType" [object]="(relatedItem$ | async)"></ds-listable-object-component-loader>
|
||||
</ng-container>
|
||||
</span>
|
||||
</div>
|
||||
<button type="button" class="btn btn-secondary"
|
||||
(click)="removeSelection()">
|
||||
<i class="fas fa-trash" aria-hidden="true"></i>
|
||||
|
@@ -69,7 +69,7 @@ describe('ExistingRelationListElementComponent', () => {
|
||||
providers: [
|
||||
{ provide: SelectableListService, useValue: selectionService },
|
||||
{ provide: Store, useValue: store },
|
||||
{ provide: SubmissionService, useClass: SubmissionServiceStub },
|
||||
{ provide: SubmissionService, useClass: SubmissionServiceStub }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
|
Reference in New Issue
Block a user