Skip to content
Open
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 @@ -241,7 +241,8 @@ describe('SubmissionSectionCcLicensesComponent', () => {
});

it('should have section status incomplete', () => {
expect(component.getSectionStatus()).toBeObservable(cold('(a|)', { a: false }));
component.required$.next(true);
expect(component.getSectionStatus()).toBeObservable(cold('(a)', { a: false }));
});

describe('when all options have a value selected', () => {
Expand Down Expand Up @@ -271,7 +272,13 @@ describe('SubmissionSectionCcLicensesComponent', () => {
});

it('should have section status incomplete', () => {
expect(component.getSectionStatus()).toBeObservable(cold('(a|)', { a: false }));
component.required$.next(true);
expect(component.getSectionStatus()).toBeObservable(cold('(a)', { a: false }));
});

it('should have section status complete if not required', () => {
component.required$.next(false);
expect(component.getSectionStatus()).toBeObservable(cold('(a)', { a: true }));
});

describe('when the cc license is accepted', () => {
Expand All @@ -282,7 +289,8 @@ describe('SubmissionSectionCcLicensesComponent', () => {
});

it('should have section status complete', () => {
expect(component.getSectionStatus()).toBeObservable(cold('(a|)', { a: true }));
component.required$.next(false);
expect(component.getSectionStatus()).toBeObservable(cold('(a)', { a: true })); // first true is because the section is not required
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
import { TranslateModule } from '@ngx-translate/core';
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
import {
BehaviorSubject,
Observable,
of,
Subscription,
Expand Down Expand Up @@ -155,6 +156,11 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent

ccLicenseLink$: Observable<string>;

/**
* Is the section required
*/
public required$ = new BehaviorSubject<boolean>(false);

constructor(
protected modalService: NgbModal,
protected sectionService: SectionsService,
Expand All @@ -179,6 +185,7 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
if (hasNoValue(this.ccLicenseLink$)) {
this.ccLicenseLink$ = this.getCcLicenseLink$();
}
this.required$.next(this.sectionData.mandatory);
}

ngOnChanges(changes: SimpleChanges): void {
Expand Down Expand Up @@ -311,7 +318,10 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
* the section status
*/
getSectionStatus(): Observable<boolean> {
return of(this.accepted);
return this.required$.pipe(
map((required) => !required || this.accepted),
distinctUntilChanged(),
);
}

/**
Expand Down
Loading