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

View File

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