-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathadditional-info.component.ts
More file actions
68 lines (57 loc) · 2.14 KB
/
Copy pathadditional-info.component.ts
File metadata and controls
68 lines (57 loc) · 2.14 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
import { createDispatchMap, select } from '@ngxs/store';
import { TranslatePipe } from '@ngx-translate/core';
import { Accordion, AccordionContent, AccordionHeader, AccordionPanel } from 'primeng/accordion';
import { Card } from 'primeng/card';
import { Skeleton } from 'primeng/skeleton';
import { Tag } from 'primeng/tag';
import { DatePipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, computed, effect } from '@angular/core';
import { CitationSectionComponent } from '@osf/features/preprints/components/preprint-details/citation-section/citation-section.component';
import { PreprintSelectors } from '@osf/features/preprints/store/preprint';
import { ResourceType } from '@shared/enums';
import { InterpolatePipe } from '@shared/pipes';
import { FetchSelectedSubjects, SubjectsSelectors } from '@shared/stores';
@Component({
selector: 'osf-preprint-additional-info',
imports: [
Card,
TranslatePipe,
Tag,
Skeleton,
DatePipe,
Accordion,
AccordionPanel,
AccordionHeader,
AccordionContent,
InterpolatePipe,
CitationSectionComponent,
],
templateUrl: './additional-info.component.html',
styleUrl: './additional-info.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AdditionalInfoComponent {
private actions = createDispatchMap({
fetchSubjects: FetchSelectedSubjects,
});
preprint = select(PreprintSelectors.getPreprint);
isPreprintLoading = select(PreprintSelectors.isPreprintLoading);
subjects = select(SubjectsSelectors.getSelectedSubjects);
areSelectedSubjectsLoading = select(SubjectsSelectors.areSelectedSubjectsLoading);
license = computed(() => {
const preprint = this.preprint();
if (!preprint) return null;
return preprint.embeddedLicense;
});
licenseOptionsRecord = computed(() => {
return (this.preprint()?.licenseOptions ?? {}) as Record<string, string>;
});
skeletonData = Array.from({ length: 5 }, () => null);
constructor() {
effect(() => {
const preprint = this.preprint();
if (!preprint) return;
this.actions.fetchSubjects(this.preprint()!.id, ResourceType.Preprint);
});
}
}