forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsection-container.component.ts
More file actions
117 lines (105 loc) · 2.75 KB
/
section-container.component.ts
File metadata and controls
117 lines (105 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import {
AsyncPipe,
NgClass,
NgComponentOutlet,
} from '@angular/common';
import {
Component,
Injector,
Input,
OnInit,
ViewChild,
} from '@angular/core';
import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';
import { AlertComponent } from '../../../shared/alert/alert.component';
import { AlertType } from '../../../shared/alert/alert-type';
import { SectionDataObject } from '../models/section-data.model';
import { SectionsDirective } from '../sections.directive';
import { rendersSectionType } from '../sections-decorator';
/**
* This component represents a section that contains the submission license form.
*/
@Component({
selector: 'ds-base-submission-section-container',
templateUrl: './section-container.component.html',
styleUrls: ['./section-container.component.scss'],
imports: [
AlertComponent,
NgbAccordionModule,
NgComponentOutlet,
TranslateModule,
NgClass,
AsyncPipe,
SectionsDirective,
],
standalone: true,
})
export class SubmissionSectionContainerComponent implements OnInit {
/**
* The collection id this submission belonging to
* @type {string}
*/
@Input() collectionId: string;
/**
* The section data
* @type {SectionDataObject}
*/
@Input() sectionData: SectionDataObject;
/**
* The submission id
* @type {string}
*/
@Input() submissionId: string;
/**
* The AlertType enumeration
* @type {AlertType}
*/
public AlertTypeEnum = AlertType;
/**
* Injector to inject a section component with the @Input parameters
* @type {Injector}
*/
public objectInjector: Injector;
/**
* The SectionsDirective reference
*/
@ViewChild('sectionRef') sectionRef: SectionsDirective;
/**
* Initialize instance variables
*
* @param {Injector} injector
*/
constructor(private injector: Injector) {
}
/**
* Initialize all instance variables
*/
ngOnInit() {
this.objectInjector = Injector.create({
providers: [
{ provide: 'collectionIdProvider', useFactory: () => (this.collectionId), deps: [] },
{ provide: 'sectionDataProvider', useFactory: () => (this.sectionData), deps: [] },
{ provide: 'submissionIdProvider', useFactory: () => (this.submissionId), deps: [] },
],
parent: this.injector,
});
}
/**
* Remove section from submission form
*
* @param event
* the event emitted
*/
public removeSection(event) {
event.preventDefault();
event.stopPropagation();
this.sectionRef.removeSection(this.submissionId, this.sectionData.id);
}
/**
* Find the correct component based on the section's type
*/
getSectionContent() {
return rendersSectionType(this.sectionData.sectionType);
}
}