mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge remote-tracking branch 'upstream/main' into iiif-mirador
This commit is contained in:
@@ -1101,91 +1101,6 @@ export const mockSubmissionState: SubmissionObjectState = Object.assign({}, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const mockSubmissionStateWithoutUpload: SubmissionObjectState = Object.assign({}, {
|
|
||||||
826: {
|
|
||||||
collection: mockSubmissionCollectionId,
|
|
||||||
definition: 'traditional',
|
|
||||||
selfUrl: mockSubmissionSelfUrl,
|
|
||||||
activeSection: null,
|
|
||||||
sections: {
|
|
||||||
extraction: {
|
|
||||||
config: '',
|
|
||||||
mandatory: true,
|
|
||||||
sectionType: 'utils',
|
|
||||||
visibility: {
|
|
||||||
main: 'HIDDEN',
|
|
||||||
other: 'HIDDEN'
|
|
||||||
},
|
|
||||||
collapsed: false,
|
|
||||||
enabled: true,
|
|
||||||
data: {},
|
|
||||||
errors: [],
|
|
||||||
isLoading: false,
|
|
||||||
isValid: false
|
|
||||||
} as any,
|
|
||||||
collection: {
|
|
||||||
config: '',
|
|
||||||
mandatory: true,
|
|
||||||
sectionType: 'collection',
|
|
||||||
visibility: {
|
|
||||||
main: 'HIDDEN',
|
|
||||||
other: 'HIDDEN'
|
|
||||||
},
|
|
||||||
collapsed: false,
|
|
||||||
enabled: true,
|
|
||||||
data: {},
|
|
||||||
errors: [],
|
|
||||||
isLoading: false,
|
|
||||||
isValid: false
|
|
||||||
} as any,
|
|
||||||
traditionalpageone: {
|
|
||||||
header: 'submit.progressbar.describe.stepone',
|
|
||||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone',
|
|
||||||
mandatory: true,
|
|
||||||
sectionType: 'submission-form',
|
|
||||||
collapsed: false,
|
|
||||||
enabled: true,
|
|
||||||
data: {},
|
|
||||||
errors: [],
|
|
||||||
formId: '2_traditionalpageone',
|
|
||||||
isLoading: false,
|
|
||||||
isValid: false
|
|
||||||
} as any,
|
|
||||||
traditionalpagetwo: {
|
|
||||||
header: 'submit.progressbar.describe.steptwo',
|
|
||||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpagetwo',
|
|
||||||
mandatory: false,
|
|
||||||
sectionType: 'submission-form',
|
|
||||||
collapsed: false,
|
|
||||||
enabled: false,
|
|
||||||
data: {},
|
|
||||||
errors: [],
|
|
||||||
isLoading: false,
|
|
||||||
isValid: false
|
|
||||||
} as any,
|
|
||||||
license: {
|
|
||||||
header: 'submit.progressbar.license',
|
|
||||||
config: '',
|
|
||||||
mandatory: true,
|
|
||||||
sectionType: 'license',
|
|
||||||
visibility: {
|
|
||||||
main: null,
|
|
||||||
other: 'READONLY'
|
|
||||||
},
|
|
||||||
collapsed: false,
|
|
||||||
enabled: true,
|
|
||||||
data: {},
|
|
||||||
errors: [],
|
|
||||||
isLoading: false,
|
|
||||||
isValid: false
|
|
||||||
} as any
|
|
||||||
},
|
|
||||||
isLoading: false,
|
|
||||||
savePending: false,
|
|
||||||
depositPending: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export const mockSectionsState = Object.assign({}, {
|
export const mockSectionsState = Object.assign({}, {
|
||||||
extraction: {
|
extraction: {
|
||||||
config: '',
|
config: '',
|
||||||
|
@@ -1,16 +1,29 @@
|
|||||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, HostListener, Input, Output, ViewEncapsulation, } from '@angular/core';
|
import {
|
||||||
|
ChangeDetectionStrategy,
|
||||||
|
ChangeDetectorRef,
|
||||||
|
Component,
|
||||||
|
EventEmitter,
|
||||||
|
HostListener,
|
||||||
|
Input,
|
||||||
|
Output,
|
||||||
|
ViewEncapsulation,
|
||||||
|
} from '@angular/core';
|
||||||
|
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
import { FileUploader } from 'ng2-file-upload';
|
import { FileUploader } from 'ng2-file-upload';
|
||||||
import { uniqueId } from 'lodash';
|
import { uniqueId } from 'lodash';
|
||||||
import { ScrollToService } from '@nicky-lenaers/ngx-scroll-to';
|
import { ScrollToConfigOptions, ScrollToService } from '@nicky-lenaers/ngx-scroll-to';
|
||||||
|
|
||||||
import { UploaderOptions } from './uploader-options.model';
|
import { UploaderOptions } from './uploader-options.model';
|
||||||
import { hasValue, isNotEmpty, isUndefined } from '../empty.util';
|
import { hasValue, isNotEmpty, isUndefined } from '../empty.util';
|
||||||
import { UploaderService } from './uploader.service';
|
import { UploaderService } from './uploader.service';
|
||||||
import { UploaderProperties } from './uploader-properties.model';
|
import { UploaderProperties } from './uploader-properties.model';
|
||||||
import { HttpXsrfTokenExtractor } from '@angular/common/http';
|
import { HttpXsrfTokenExtractor } from '@angular/common/http';
|
||||||
import { XSRF_COOKIE, XSRF_REQUEST_HEADER, XSRF_RESPONSE_HEADER } from '../../core/xsrf/xsrf.interceptor';
|
import {
|
||||||
|
XSRF_REQUEST_HEADER,
|
||||||
|
XSRF_RESPONSE_HEADER,
|
||||||
|
XSRF_COOKIE
|
||||||
|
} from '../../core/xsrf/xsrf.interceptor';
|
||||||
import { CookieService } from '../../core/services/cookie.service';
|
import { CookieService } from '../../core/services/cookie.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -133,6 +146,12 @@ export class UploaderComponent {
|
|||||||
this.uploader.options.headers = [{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() }];
|
this.uploader.options.headers = [{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() }];
|
||||||
this.onBeforeUpload();
|
this.onBeforeUpload();
|
||||||
this.isOverDocumentDropZone = observableOf(false);
|
this.isOverDocumentDropZone = observableOf(false);
|
||||||
|
|
||||||
|
// Move page target to the uploader
|
||||||
|
const config: ScrollToConfigOptions = {
|
||||||
|
target: this.uploaderId
|
||||||
|
};
|
||||||
|
this.scrollToService.scrollTo(config);
|
||||||
};
|
};
|
||||||
if (hasValue(this.uploadProperties)) {
|
if (hasValue(this.uploadProperties)) {
|
||||||
this.uploader.onBuildItemForm = (item, form) => {
|
this.uploader.onBuildItemForm = (item, form) => {
|
||||||
|
@@ -1,36 +1,35 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div *ngIf="!(isLoading() | async)" class="submission-form-header mb-3 d-flex flex-wrap position-sticky">
|
<div *ngIf="!(isLoading() | async)">
|
||||||
<div *ngIf="(uploadEnabled$ | async)" class="w-100">
|
<ds-submission-upload-files [submissionId]="submissionId"
|
||||||
<ds-submission-upload-files [submissionId]="submissionId"
|
[collectionId]="collectionId"
|
||||||
[collectionId]="collectionId"
|
[sectionId]="'upload'"
|
||||||
[sectionId]="'upload'"
|
[uploadFilesOptions]="uploadFilesOptions"></ds-submission-upload-files>
|
||||||
[uploadFilesOptions]="uploadFilesOptions"></ds-submission-upload-files>
|
<div class="clearfix"></div>
|
||||||
<div class="clearfix"></div>
|
</div>
|
||||||
</div>
|
<div *ngIf="!(isLoading() | async)" class="submission-form-header mb-3 d-flex flex-wrap position-sticky">
|
||||||
|
<div class="submission-form-header-item mb-3 mb-sm-0 flex-sm-grow-1 flex-md-grow-0">
|
||||||
|
<ds-submission-form-collection [currentCollectionId]="collectionId"
|
||||||
|
[currentDefinition]="definitionId"
|
||||||
|
[submissionId]="submissionId"
|
||||||
|
(collectionChange)="onCollectionChange($event)">
|
||||||
|
</ds-submission-form-collection>
|
||||||
|
</div>
|
||||||
|
<div class="submission-form-header-item text-right">
|
||||||
|
<ds-submission-form-section-add [collectionId]="collectionId"
|
||||||
|
[submissionId]="submissionId">
|
||||||
|
</ds-submission-form-section-add>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="submission-form-header-item mb-3 mb-sm-0 flex-sm-grow-1 flex-md-grow-0">
|
<div class="submission-form-content">
|
||||||
<ds-submission-form-collection [currentCollectionId]="collectionId"
|
<ds-loading *ngIf="(isLoading() | async)" message="Loading..."></ds-loading>
|
||||||
[currentDefinition]="definitionId"
|
<ng-container *ngFor="let object of (submissionSections | async)">
|
||||||
[submissionId]="submissionId"
|
<ds-submission-section-container [collectionId]="collectionId"
|
||||||
(collectionChange)="onCollectionChange($event)">
|
[submissionId]="submissionId"
|
||||||
</ds-submission-form-collection>
|
[sectionData]="object"></ds-submission-section-container>
|
||||||
</div>
|
</ng-container>
|
||||||
<div class="submission-form-header-item text-right">
|
</div>
|
||||||
<ds-submission-form-section-add [collectionId]="collectionId"
|
<div *ngIf="!(isLoading() | async)" class="submission-form-footer mt-3 mb-3 position-sticky">
|
||||||
[submissionId]="submissionId">
|
<ds-submission-form-footer [submissionId]="submissionId"></ds-submission-form-footer>
|
||||||
</ds-submission-form-section-add>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="submission-form-content">
|
|
||||||
<ds-loading *ngIf="(isLoading() | async)" message="Loading..."></ds-loading>
|
|
||||||
<ng-container *ngFor="let object of (submissionSections | async)">
|
|
||||||
<ds-submission-section-container [collectionId]="collectionId"
|
|
||||||
[submissionId]="submissionId"
|
|
||||||
[sectionData]="object"></ds-submission-section-container>
|
|
||||||
</ng-container>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="!(isLoading() | async)" class="submission-form-footer mt-3 mb-3 position-sticky">
|
|
||||||
<ds-submission-form-footer [submissionId]="submissionId"></ds-submission-form-footer>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
@@ -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,7 +55,6 @@ 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: { isSectionTypeAvailable: () => observableOf(true) } },
|
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
SubmissionFormComponent
|
SubmissionFormComponent
|
||||||
],
|
],
|
||||||
@@ -116,7 +115,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();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -141,7 +140,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,
|
||||||
@@ -202,7 +201,7 @@ describe('SubmissionFormComponent Component', () => {
|
|||||||
submissionDefinition: {
|
submissionDefinition: {
|
||||||
name: 'traditional'
|
name: 'traditional'
|
||||||
}
|
}
|
||||||
} as any);
|
} as any);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
scheduler.flush();
|
scheduler.flush();
|
||||||
|
@@ -15,8 +15,6 @@ import { SubmissionObjectEntry } from '../objects/submission-objects.reducer';
|
|||||||
import { SectionDataObject } from '../sections/models/section-data.model';
|
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 { SectionsService } from '../sections/sections.service';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component represents the submission form.
|
* This component represents the submission form.
|
||||||
@@ -71,11 +69,6 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
public loading: Observable<boolean> = observableOf(true);
|
public loading: Observable<boolean> = observableOf(true);
|
||||||
|
|
||||||
/**
|
|
||||||
* Emits true when the submission config has bitstream uploading enabled in submission
|
|
||||||
*/
|
|
||||||
public uploadEnabled$: Observable<boolean>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Observable of the list of submission's sections
|
* Observable of the list of submission's sections
|
||||||
* @type {Observable<WorkspaceitemSectionsObject>}
|
* @type {Observable<WorkspaceitemSectionsObject>}
|
||||||
@@ -107,14 +100,12 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +129,6 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
|
|||||||
return observableOf([]);
|
return observableOf([]);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
this.uploadEnabled$ = this.sectionsService.isSectionTypeAvailable(this.submissionId, SectionsType.Upload);
|
|
||||||
|
|
||||||
// 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(
|
||||||
|
@@ -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 { cold, getTestScheduler } from 'jasmine-marbles';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
@@ -17,8 +17,7 @@ import { SectionsService } from './sections.service';
|
|||||||
import {
|
import {
|
||||||
mockSectionsData,
|
mockSectionsData,
|
||||||
mockSectionsErrors,
|
mockSectionsErrors,
|
||||||
mockSubmissionState,
|
mockSubmissionState
|
||||||
mockSubmissionStateWithoutUpload
|
|
||||||
} from '../../shared/mocks/submission.mock';
|
} from '../../shared/mocks/submission.mock';
|
||||||
import {
|
import {
|
||||||
DisableSectionAction,
|
DisableSectionAction,
|
||||||
@@ -28,7 +27,11 @@ import {
|
|||||||
SectionStatusChangeAction,
|
SectionStatusChangeAction,
|
||||||
UpdateSectionDataAction
|
UpdateSectionDataAction
|
||||||
} from '../objects/submission-objects.actions';
|
} 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 parseSectionErrors from '../utils/parseSectionErrors';
|
||||||
import { SubmissionScopeType } from '../../core/submission/submission-scope-type';
|
import { SubmissionScopeType } from '../../core/submission/submission-scope-type';
|
||||||
import { SubmissionSectionError } from '../objects/submission-objects.reducer';
|
import { SubmissionSectionError } from '../objects/submission-objects.reducer';
|
||||||
@@ -49,7 +52,6 @@ describe('SectionsService test suite', () => {
|
|||||||
const sectionErrors: any = parseSectionErrors(mockSectionsErrors);
|
const sectionErrors: any = parseSectionErrors(mockSectionsErrors);
|
||||||
const sectionData: any = mockSectionsData;
|
const sectionData: any = mockSectionsData;
|
||||||
const submissionState: any = Object.assign({}, mockSubmissionState[submissionId]);
|
const submissionState: any = Object.assign({}, mockSubmissionState[submissionId]);
|
||||||
const submissionStateWithoutUpload: any = Object.assign({}, mockSubmissionStateWithoutUpload[submissionId]);
|
|
||||||
const sectionState: any = Object.assign({}, mockSubmissionState['826'].sections[sectionId]);
|
const sectionState: any = Object.assign({}, mockSubmissionState['826'].sections[sectionId]);
|
||||||
|
|
||||||
const store: any = jasmine.createSpyObj('store', {
|
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', () => {
|
describe('addSection', () => {
|
||||||
it('should dispatch a new EnableSectionAction a move target to new section', () => {
|
it('should dispatch a new EnableSectionAction a move target to new section', () => {
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@ import { distinctUntilChanged, filter, map, take } from 'rxjs/operators';
|
|||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { ScrollToConfigOptions, ScrollToService } from '@nicky-lenaers/ngx-scroll-to';
|
import { ScrollToConfigOptions, ScrollToService } from '@nicky-lenaers/ngx-scroll-to';
|
||||||
import { findKey, isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
|
|
||||||
import { SubmissionState } from '../submission.reducers';
|
import { SubmissionState } from '../submission.reducers';
|
||||||
import { hasValue, isEmpty, isNotEmpty, isNotUndefined } from '../../shared/empty.util';
|
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
|
* @param submissionId
|
||||||
* The submission id
|
* The submission id
|
||||||
* @param sectionId
|
* @param sectionId
|
||||||
* The section id
|
* The section id
|
||||||
* @return Observable<boolean>
|
* @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> {
|
public isSectionAvailable(submissionId: string, sectionId: string): Observable<boolean> {
|
||||||
return this.store.select(submissionObjectFromIdSelector(submissionId)).pipe(
|
return this.store.select(submissionObjectFromIdSelector(submissionId)).pipe(
|
||||||
@@ -309,25 +309,6 @@ export class SectionsService {
|
|||||||
distinctUntilChanged());
|
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
|
* Dispatch a new [EnableSectionAction] to add a new section and move page target to it
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user