Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Component,
ComponentFactoryResolver,
ContentChildren,
EventEmitter,
EventEmitter, Inject,
Input,
NgZone,
OnChanges,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -285,7 +294,6 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
followLink('rightItem'),
followLink('relationshipType')
);

relationshipsRD$.pipe(
getFirstSucceededRemoteDataPayload(),
getPaginatedListPayload()
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
span.text-contents{
padding: var(--bs-btn-padding-y) 0;
}

Original file line number Diff line number Diff line change
@@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
})
Expand Down