mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-11 20:13:07 +00:00
[CST-12043] feature: add primary bitstream switch
This commit is contained in:
@@ -4,7 +4,8 @@ import {
|
||||
BehaviorSubject,
|
||||
combineLatest as observableCombineLatest,
|
||||
Observable,
|
||||
Subscription
|
||||
Subscription,
|
||||
combineLatest
|
||||
} from 'rxjs';
|
||||
import { distinctUntilChanged, filter, map, mergeMap, switchMap, tap } from 'rxjs/operators';
|
||||
|
||||
@@ -31,6 +32,7 @@ import { AccessConditionOption } from '../../../core/config/models/config-access
|
||||
import { followLink } from '../../../shared/utils/follow-link-config.model';
|
||||
import { getFirstSucceededRemoteData } from '../../../core/shared/operators';
|
||||
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
||||
import { WorkspaceitemSectionUploadObject } from 'src/app/core/submission/models/workspaceitem-section-upload.model';
|
||||
|
||||
export const POLICY_DEFAULT_NO_LIST = 1; // Banner1
|
||||
export const POLICY_DEFAULT_WITH_LIST = 2; // Banner2
|
||||
@@ -58,10 +60,10 @@ export class SubmissionSectionUploadComponent extends SectionModelComponent {
|
||||
public AlertTypeEnum = AlertType;
|
||||
|
||||
/**
|
||||
* The array containing the keys of file list array
|
||||
* The uuid of primary bitstream file
|
||||
* @type {Array}
|
||||
*/
|
||||
public fileIndexes: string[] = [];
|
||||
public primaryBitstreamUUID: string | null = null;
|
||||
|
||||
/**
|
||||
* The file list
|
||||
@@ -194,27 +196,18 @@ export class SubmissionSectionUploadComponent extends SectionModelComponent {
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}),
|
||||
|
||||
|
||||
// retrieve submission's bitstreams from state
|
||||
observableCombineLatest(this.configMetadataForm$,
|
||||
this.bitstreamService.getUploadedFileList(this.submissionId, this.sectionData.id)).pipe(
|
||||
filter(([configMetadataForm, fileList]: [SubmissionFormsModel, any[]]) => {
|
||||
return isNotEmpty(configMetadataForm) && isNotUndefined(fileList);
|
||||
combineLatest([this.configMetadataForm$,
|
||||
this.bitstreamService.getUploadedFilesData(this.submissionId, this.sectionData.id)]).pipe(
|
||||
filter(([configMetadataForm, { files }]: [SubmissionFormsModel, WorkspaceitemSectionUploadObject]) => {
|
||||
return isNotEmpty(configMetadataForm) && isNotEmpty(files);
|
||||
}),
|
||||
distinctUntilChanged())
|
||||
.subscribe(([configMetadataForm, fileList]: [SubmissionFormsModel, any[]]) => {
|
||||
this.fileList = [];
|
||||
this.fileIndexes = [];
|
||||
this.fileNames = [];
|
||||
this.changeDetectorRef.detectChanges();
|
||||
if (isNotUndefined(fileList) && fileList.length > 0) {
|
||||
fileList.forEach((file) => {
|
||||
this.fileList.push(file);
|
||||
this.fileIndexes.push(file.uuid);
|
||||
this.fileNames.push(this.getFileName(configMetadataForm, file));
|
||||
});
|
||||
}
|
||||
|
||||
this.changeDetectorRef.detectChanges();
|
||||
.subscribe(([configMetadataForm, { primary, files }]: [SubmissionFormsModel, WorkspaceitemSectionUploadObject]) => {
|
||||
this.primaryBitstreamUUID = primary;
|
||||
this.fileList = files;
|
||||
this.fileNames = Array.from(files, file => this.getFileName(configMetadataForm, file));
|
||||
}
|
||||
)
|
||||
);
|
||||
|
Reference in New Issue
Block a user