mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
verify whether file uploads are mandatory => observe changes to both filelist and required status
This commit is contained in:
@@ -532,6 +532,8 @@
|
|||||||
|
|
||||||
"error.validation.pattern": "This input is restricted by the current pattern: {{ pattern }}.",
|
"error.validation.pattern": "This input is restricted by the current pattern: {{ pattern }}.",
|
||||||
|
|
||||||
|
"error.validation.filerequired": "The file upload is mandatory",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"footer.copyright": "copyright © 2002-{{ year }}",
|
"footer.copyright": "copyright © 2002-{{ year }}",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { ChangeDetectorRef, Component, Inject } from '@angular/core';
|
import { ChangeDetectorRef, Component, Inject } from '@angular/core';
|
||||||
|
|
||||||
import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs';
|
import { BehaviorSubject, combineLatest as observableCombineLatest, Observable, Subscription} from 'rxjs';
|
||||||
import { distinctUntilChanged, filter, find, flatMap, map, reduce, take, tap } from 'rxjs/operators';
|
import { distinctUntilChanged, filter, find, flatMap, map, reduce, take, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { SectionModelComponent } from '../models/section.model';
|
import { SectionModelComponent } from '../models/section.model';
|
||||||
@@ -108,7 +108,7 @@ export class SubmissionSectionUploadComponent extends SectionModelComponent {
|
|||||||
* Is the upload required
|
* Is the upload required
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
public required: boolean;
|
public required$ = new BehaviorSubject<boolean>(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array to track all subscriptions and unsubscribe them onDestroy
|
* Array to track all subscriptions and unsubscribe them onDestroy
|
||||||
@@ -178,7 +178,7 @@ export class SubmissionSectionUploadComponent extends SectionModelComponent {
|
|||||||
}),
|
}),
|
||||||
flatMap(() => config$),
|
flatMap(() => config$),
|
||||||
flatMap((config: SubmissionUploadsModel) => {
|
flatMap((config: SubmissionUploadsModel) => {
|
||||||
this.required = config.required;
|
this.required$.next(config.required);
|
||||||
this.availableAccessConditionOptions = isNotEmpty(config.accessConditionOptions) ? config.accessConditionOptions : [];
|
this.availableAccessConditionOptions = isNotEmpty(config.accessConditionOptions) ? config.accessConditionOptions : [];
|
||||||
|
|
||||||
this.collectionPolicyType = this.availableAccessConditionOptions.length > 0
|
this.collectionPolicyType = this.availableAccessConditionOptions.length > 0
|
||||||
@@ -282,9 +282,11 @@ export class SubmissionSectionUploadComponent extends SectionModelComponent {
|
|||||||
protected getSectionStatus(): Observable<boolean> {
|
protected getSectionStatus(): Observable<boolean> {
|
||||||
// if not mandatory, always true
|
// if not mandatory, always true
|
||||||
// if mandatory, at least one file is required
|
// if mandatory, at least one file is required
|
||||||
return this.bitstreamService.getUploadedFileList(this.submissionId, this.sectionData.id).pipe(
|
return observableCombineLatest(this.required$,
|
||||||
map((fileList: any[]) =>
|
this.bitstreamService.getUploadedFileList(this.submissionId, this.sectionData.id),
|
||||||
(!this.required || (isNotUndefined(fileList) && fileList.length > 0))));
|
(required,fileList: any[]) => {
|
||||||
|
return (!required || (isNotUndefined(fileList) && fileList.length > 0));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user