Skip to content

Commit acb9b24

Browse files
authored
Merge pull request DSpace#2202 from mwoodiupui/themeable-section-upload-file
Themeable `SubmissionSectionUploadFileComponent`
2 parents 37a323e + 10899aa commit acb9b24

9 files changed

Lines changed: 132 additions & 8 deletions

src/app/submission/sections/upload/file/section-upload-file.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ describe('SubmissionSectionUploadFileComponent test suite', () => {
175175
it('should init file data properly', () => {
176176
uploadService.getFileData.and.returnValue(observableOf(fileData));
177177

178-
comp.ngOnChanges();
178+
comp.ngOnChanges({});
179179

180180
expect(comp.fileData).toEqual(fileData);
181181
});

src/app/submission/sections/upload/file/section-upload-file.component.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { ChangeDetectorRef, Component, Input, OnChanges, OnInit, ViewChild } from '@angular/core';
1+
import {
2+
ChangeDetectorRef,
3+
Component,
4+
Input,
5+
OnChanges,
6+
OnDestroy,
7+
OnInit,
8+
SimpleChanges,
9+
ViewChild
10+
} from '@angular/core';
211

312
import { BehaviorSubject, Subscription } from 'rxjs';
413
import { filter } from 'rxjs/operators';
@@ -27,7 +36,7 @@ import { NgbModalOptions } from '@ng-bootstrap/ng-bootstrap/modal/modal-config';
2736
styleUrls: ['./section-upload-file.component.scss'],
2837
templateUrl: './section-upload-file.component.html',
2938
})
30-
export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit {
39+
export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit, OnDestroy {
3140

3241
/**
3342
* The list of available access condition
@@ -168,13 +177,13 @@ export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit {
168177
/**
169178
* Retrieve bitstream's metadata
170179
*/
171-
ngOnChanges() {
180+
ngOnChanges(changes: SimpleChanges): void {
172181
if (this.availableAccessConditionOptions) {
173182
// Retrieve file state
174183
this.subscriptions.push(
175184
this.uploadService
176-
.getFileData(this.submissionId, this.sectionId, this.fileId).pipe(
177-
filter((bitstream) => isNotUndefined(bitstream)))
185+
.getFileData(this.submissionId, this.sectionId, this.fileId)
186+
.pipe(filter((bitstream) => isNotUndefined(bitstream)))
178187
.subscribe((bitstream) => {
179188
this.fileData = bitstream;
180189
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import { Component, Input } from '@angular/core';
2+
import { SubmissionFormsModel } from 'src/app/core/config/models/config-submission-forms.model';
3+
import { ThemedComponent } from 'src/app/shared/theme-support/themed.component';
4+
import { SubmissionSectionUploadFileComponent } from './section-upload-file.component';
5+
6+
@Component({
7+
selector: 'ds-themed-submission-upload-section-file',
8+
styleUrls: [],
9+
templateUrl: '../../../../shared/theme-support/themed.component.html'
10+
})
11+
export class ThemedSubmissionSectionUploadFileComponent
12+
extends ThemedComponent<SubmissionSectionUploadFileComponent> {
13+
14+
/**
15+
* The list of available access condition
16+
* @type {Array}
17+
*/
18+
@Input() availableAccessConditionOptions: any[];
19+
20+
/**
21+
* The submission id
22+
* @type {string}
23+
*/
24+
@Input() collectionId: string;
25+
26+
/**
27+
* Define if collection access conditions policy type :
28+
* POLICY_DEFAULT_NO_LIST : is not possible to define additional access group/s for the single file
29+
* POLICY_DEFAULT_WITH_LIST : is possible to define additional access group/s for the single file
30+
* @type {number}
31+
*/
32+
@Input() collectionPolicyType: number;
33+
34+
/**
35+
* The configuration for the bitstream's metadata form
36+
* @type {SubmissionFormsModel}
37+
*/
38+
@Input() configMetadataForm: SubmissionFormsModel;
39+
40+
/**
41+
* The bitstream id
42+
* @type {string}
43+
*/
44+
@Input() fileId: string;
45+
46+
/**
47+
* The bitstream array key
48+
* @type {string}
49+
*/
50+
@Input() fileIndex: string;
51+
52+
/**
53+
* The bitstream id
54+
* @type {string}
55+
*/
56+
@Input() fileName: string;
57+
58+
/**
59+
* The section id
60+
* @type {string}
61+
*/
62+
@Input() sectionId: string;
63+
64+
/**
65+
* The submission id
66+
* @type {string}
67+
*/
68+
@Input() submissionId: string;
69+
70+
protected inAndOutputNames: (keyof SubmissionSectionUploadFileComponent & keyof this)[] = [
71+
'availableAccessConditionOptions',
72+
'collectionId',
73+
'collectionPolicyType',
74+
'configMetadataForm',
75+
'fileId',
76+
'fileIndex',
77+
'fileName',
78+
'sectionId',
79+
'submissionId'
80+
];
81+
82+
protected getComponentName(): string {
83+
return 'SubmissionSectionUploadFileComponent';
84+
}
85+
86+
protected importThemedComponent(themeName: string): Promise<any> {
87+
return import(`../../../../../themes/${themeName}/app/submission/sections/upload/file/section-upload-file.component`);
88+
}
89+
90+
protected importUnthemedComponent(): Promise<any> {
91+
return import(`./section-upload-file.component`);
92+
}
93+
}

src/app/submission/sections/upload/section-upload.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h3 class="text-center"><span class="text-muted">{{'submission.sections.upload.n
2828
</div>
2929

3030
<ng-container *ngFor="let fileEntry of fileList">
31-
<ds-submission-upload-section-file
31+
<ds-themed-submission-upload-section-file
3232
[availableAccessConditionOptions]="availableAccessConditionOptions"
3333
[collectionId]="collectionId"
3434
[collectionPolicyType]="collectionPolicyType"
@@ -37,7 +37,7 @@ <h3 class="text-center"><span class="text-muted">{{'submission.sections.upload.n
3737
[fileIndex]="fileList.indexOf(fileEntry)"
3838
[fileName]="fileNames[fileList.indexOf(fileEntry)]"
3939
[sectionId]="sectionData.id"
40-
[submissionId]="submissionId"></ds-submission-upload-section-file>
40+
[submissionId]="submissionId"></ds-themed-submission-upload-section-file>
4141
<div class="row">
4242
<div class="col-md-12">
4343
<hr/>

src/app/submission/submission.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { ResearchEntitiesModule } from '../entity-groups/research-entities/resea
4949
import { ThemedSubmissionEditComponent } from './edit/themed-submission-edit.component';
5050
import { ThemedSubmissionSubmitComponent } from './submit/themed-submission-submit.component';
5151
import { ThemedSubmissionImportExternalComponent } from './import-external/themed-submission-import-external.component';
52+
import { ThemedSubmissionSectionUploadFileComponent } from './sections/upload/file/themed-section-upload-file.component';
5253
import { FormModule } from '../shared/form/form.module';
5354
import { NgbAccordionModule, NgbCollapseModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
5455
import { SubmissionSectionAccessesComponent } from './sections/accesses/section-accesses.component';
@@ -104,6 +105,7 @@ const DECLARATIONS = [
104105
PublisherPolicyComponent,
105106
PublicationInformationComponent,
106107
MetadataInformationComponent,
108+
ThemedSubmissionSectionUploadFileComponent,
107109
];
108110

109111
@NgModule({

src/themes/custom/app/submission/sections/upload/file/section-upload-file.component.html

Whitespace-only changes.

src/themes/custom/app/submission/sections/upload/file/section-upload-file.component.scss

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Component } from '@angular/core';
2+
import {
3+
SubmissionSectionUploadFileComponent as BaseComponent
4+
} from 'src/app/submission/sections/upload/file/section-upload-file.component';
5+
6+
/**
7+
* This component represents a single bitstream contained in the submission
8+
*/
9+
@Component({
10+
selector: 'ds-submission-upload-section-file',
11+
// styleUrls: ['./section-upload-file.component.scss'],
12+
styleUrls: ['../../../../../../../app/submission/sections/upload/file/section-upload-file.component.scss'],
13+
// templateUrl: './section-upload-file.component.html'
14+
templateUrl: '../../../../../../../app/submission/sections/upload/file/section-upload-file.component.html'
15+
})
16+
export class SubmissionSectionUploadFileComponent
17+
extends BaseComponent {
18+
}

src/themes/custom/lazy-theme.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ import {
141141
import { NgxGalleryModule } from '@kolkov/ngx-gallery';
142142
import { WorkspaceItemsDeletePageComponent } from './app/workspace-items-delete-page/workspace-items-delete/workspace-items-delete.component';
143143
import { ThumbnailComponent } from './app/thumbnail/thumbnail.component';
144+
import { SubmissionSectionUploadFileComponent } from './app/submission/sections/upload/file/section-upload-file.component';
144145
import { ItemStatusComponent } from './app/item-page/edit-item-page/item-status/item-status.component';
145146
import { EditBitstreamPageComponent } from './app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component';
146147
import { FormModule } from '../../app/shared/form/form.module';
@@ -220,6 +221,7 @@ const DECLARATIONS = [
220221
MediaViewerVideoComponent,
221222
WorkspaceItemsDeletePageComponent,
222223
ThumbnailComponent,
224+
SubmissionSectionUploadFileComponent,
223225
ItemStatusComponent,
224226
EditBitstreamPageComponent,
225227
];

0 commit comments

Comments
 (0)