Fix hardcoded submission section IDs

This commit is contained in:
Yura Bondarenko
2021-06-18 11:57:36 +02:00
parent 0ee451f3d3
commit 32003a72fd
4 changed files with 29 additions and 16 deletions

View File

@@ -328,6 +328,22 @@ export class SectionsService {
distinctUntilChanged());
}
/**
* Check if given section id is of a given section type
* @param submissionId
* @param sectionId
* @param sectionType
*/
public isSectionType(submissionId: string, sectionId: string, sectionType: SectionsType): Observable<boolean> {
return this.store.select(submissionObjectFromIdSelector(submissionId)).pipe(
filter((submissionState: SubmissionObjectEntry) => isNotUndefined(submissionState)),
map((submissionState: SubmissionObjectEntry) => {
return isNotUndefined(submissionState.sections) && isNotUndefined(submissionState.sections[sectionId]
&& submissionState.sections[sectionId].sectionType === sectionType );
}),
distinctUntilChanged());
}
/**
* Dispatch a new [EnableSectionAction] to add a new section and move page target to it
*