applied feedback for submission upload section

This commit is contained in:
lotte
2021-04-01 12:23:26 +02:00
parent ff1014779e
commit 41e1d06594
2 changed files with 14 additions and 12 deletions

View File

@@ -24,7 +24,7 @@ import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-servic
import { createTestComponent } from '../../shared/testing/utils.test';
import { Item } from '../../core/shared/item.model';
import { TestScheduler } from 'rxjs/testing';
import { SectionsService } from '../sections/sections.service';
describe('SubmissionFormComponent Component', () => {
@@ -55,6 +55,7 @@ describe('SubmissionFormComponent Component', () => {
{ provide: AuthService, useClass: AuthServiceStub },
{ provide: HALEndpointService, useValue: new HALEndpointServiceStub('workspaceitems') },
{ provide: SubmissionService, useValue: submissionServiceStub },
{ provide: SectionsService, useValue: { isSectionAvailable: () => observableOf(true) } },
ChangeDetectorRef,
SubmissionFormComponent
],
@@ -115,7 +116,7 @@ describe('SubmissionFormComponent Component', () => {
expect(compAsAny.submissionSections).toBeUndefined();
expect(compAsAny.subs).toEqual([]);
expect(submissionServiceStub.startAutoSave).not.toHaveBeenCalled();
expect(comp.loading).toBeObservable(cold('(a|)', {a: true}));
expect(comp.loading).toBeObservable(cold('(a|)', { a: true }));
done();
});
@@ -140,7 +141,7 @@ describe('SubmissionFormComponent Component', () => {
});
scheduler.flush();
expect(comp.submissionSections).toBeObservable(cold('(a|)', {a: sectionsList}));
expect(comp.submissionSections).toBeObservable(cold('(a|)', { a: sectionsList }));
expect(submissionServiceStub.dispatchInit).toHaveBeenCalledWith(
collectionId,

View File

@@ -16,7 +16,7 @@ import { SectionDataObject } from '../sections/models/section-data.model';
import { SubmissionService } from '../submission.service';
import { Item } from '../../core/shared/item.model';
import { SectionsType } from '../sections/sections-type';
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
import { SectionsService } from '../sections/sections.service';
/**
* This component represents the submission form.
@@ -74,7 +74,7 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
/**
* Emits true when the submission config has bitstream uploading enabled in submission
*/
public uploadEnabled$ = new BehaviorSubject<boolean>(false);
public uploadEnabled$: Observable<boolean>;
/**
* Observable of the list of submission's sections
@@ -107,12 +107,14 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
* @param {ChangeDetectorRef} changeDetectorRef
* @param {HALEndpointService} halService
* @param {SubmissionService} submissionService
* @param {SectionsService} sectionsService
*/
constructor(
private authService: AuthService,
private changeDetectorRef: ChangeDetectorRef,
private halService: HALEndpointService,
private submissionService: SubmissionService) {
private submissionService: SubmissionService,
private sectionsService: SectionsService) {
this.isActive = true;
}
@@ -135,12 +137,11 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
} else {
return observableOf([]);
}
}),
tap((sectionList) => {
this.uploadEnabled$.next(isNotEmpty(sectionList) && sectionList.some(config => config.sectionType === SectionsType.Upload));
})
);
}));
debugger;
this.uploadEnabled$ = this.sectionsService.isSectionAvailable(this.submissionId, SectionsType.Upload);
this.uploadEnabled$.subscribe((t) => {console.log('this.uploadEnabled$', t)});
// check if is submission loading
this.loading = this.submissionService.getSubmissionObject(this.submissionId).pipe(
filter(() => this.isActive),