Revert "Submission dropzone issues"

This commit is contained in:
Tim Donohue
2021-04-02 16:28:40 -05:00
committed by GitHub
parent 335d6fb339
commit d7bd3f6f54
7 changed files with 69 additions and 186 deletions

View File

@@ -1,4 +1,4 @@
import { TestBed, waitForAsync } from '@angular/core/testing';
import { waitForAsync, TestBed } from '@angular/core/testing';
import { cold, getTestScheduler } from 'jasmine-marbles';
import { of as observableOf } from 'rxjs';
@@ -17,8 +17,7 @@ import { SectionsService } from './sections.service';
import {
mockSectionsData,
mockSectionsErrors,
mockSubmissionState,
mockSubmissionStateWithoutUpload
mockSubmissionState
} from '../../shared/mocks/submission.mock';
import {
DisableSectionAction,
@@ -28,7 +27,11 @@ import {
SectionStatusChangeAction,
UpdateSectionDataAction
} from '../objects/submission-objects.actions';
import { FormAddError, FormClearErrorsAction, FormRemoveErrorAction } from '../../shared/form/form.actions';
import {
FormAddError,
FormClearErrorsAction,
FormRemoveErrorAction
} from '../../shared/form/form.actions';
import parseSectionErrors from '../utils/parseSectionErrors';
import { SubmissionScopeType } from '../../core/submission/submission-scope-type';
import { SubmissionSectionError } from '../objects/submission-objects.reducer';
@@ -49,7 +52,6 @@ describe('SectionsService test suite', () => {
const sectionErrors: any = parseSectionErrors(mockSectionsErrors);
const sectionData: any = mockSectionsData;
const submissionState: any = Object.assign({}, mockSubmissionState[submissionId]);
const submissionStateWithoutUpload: any = Object.assign({}, mockSubmissionStateWithoutUpload[submissionId]);
const sectionState: any = Object.assign({}, mockSubmissionState['826'].sections[sectionId]);
const store: any = jasmine.createSpyObj('store', {
@@ -312,28 +314,6 @@ describe('SectionsService test suite', () => {
});
});
describe('isSectionTypeAvailable', () => {
it('should return an observable of true when section is available', () => {
store.select.and.returnValue(observableOf(submissionState));
const expected = cold('(b|)', {
b: true
});
expect(service.isSectionTypeAvailable(submissionId, SectionsType.Upload)).toBeObservable(expected);
});
it('should return an observable of false when section is not available', () => {
store.select.and.returnValue(observableOf(submissionStateWithoutUpload));
const expected = cold('(b|)', {
b: false
});
expect(service.isSectionAvailable(submissionId, SectionsType.Upload)).toBeObservable(expected);
});
});
describe('addSection', () => {
it('should dispatch a new EnableSectionAction a move target to new section', () => {

View File

@@ -5,7 +5,7 @@ import { distinctUntilChanged, filter, map, take } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { TranslateService } from '@ngx-translate/core';
import { ScrollToConfigOptions, ScrollToService } from '@nicky-lenaers/ngx-scroll-to';
import { findKey, isEqual } from 'lodash';
import { isEqual } from 'lodash';
import { SubmissionState } from '../submission.reducers';
import { hasValue, isEmpty, isNotEmpty, isNotUndefined } from '../../shared/empty.util';
@@ -291,14 +291,14 @@ export class SectionsService {
}
/**
* Check if a given section id is present in the list of sections
* Check if a given section is a read only available
*
* @param submissionId
* The submission id
* @param sectionId
* The section id
* @return Observable<boolean>
* Emits true whenever a given section id should be available
* Emits true whenever a given section should be available
*/
public isSectionAvailable(submissionId: string, sectionId: string): Observable<boolean> {
return this.store.select(submissionObjectFromIdSelector(submissionId)).pipe(
@@ -309,25 +309,6 @@ export class SectionsService {
distinctUntilChanged());
}
/**
* Check if a given section type is present in the list of sections
*
* @param submissionId
* The submission id
* @param sectionType
* The section type
* @return Observable<boolean>
* Emits true whenever a given section type should be available
*/
public isSectionTypeAvailable(submissionId: 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(findKey(submissionState.sections, {sectionType: sectionType}));
}),
distinctUntilChanged());
}
/**
* Dispatch a new [EnableSectionAction] to add a new section and move page target to it
*