1
- import { attr , belongsTo , hasMany , SyncHasMany , AsyncBelongsTo , AsyncHasMany } from '@ember-data/model' ;
1
+ import { attr , belongsTo , hasMany , AsyncBelongsTo , AsyncHasMany } from '@ember-data/model' ;
2
2
import { computed } from '@ember/object' ;
3
3
import { alias } from '@ember/object/computed' ;
4
+ import CitationModel from 'ember-osf-web/models/citation' ;
5
+ import PreprintRequestModel from 'ember-osf-web/models/preprint-request' ;
6
+ import { ReviewsState } from 'ember-osf-web/models/provider' ;
7
+ import ReviewActionModel from 'ember-osf-web/models/review-action' ;
4
8
5
9
import ContributorModel from './contributor' ;
6
10
import FileModel from './file' ;
7
11
import LicenseModel from './license' ;
8
12
import NodeModel from './node' ;
9
- import OsfModel from './osf-model' ;
13
+ import OsfModel , { Permission } from './osf-model' ;
10
14
import PreprintProviderModel from './preprint-provider' ;
11
- import ReviewActionModel from './review-action' ;
12
15
import SubjectModel from './subject' ;
13
16
17
+ export enum PreprintDataLinksEnum {
18
+ AVAILABLE = 'available' ,
19
+ YES = 'yes' ,
20
+ NO = 'no' ,
21
+ NOT_APPLICABLE = 'not_applicable' ,
22
+ }
23
+
24
+ export enum PreprintPreregLinksEnum {
25
+ AVAILABLE = 'available' ,
26
+ YES = 'yes' ,
27
+ NO = 'no' ,
28
+ NOT_APPLICABLE = 'not_applicable' ,
29
+ }
30
+
14
31
export default class PreprintModel extends OsfModel {
15
32
@attr ( 'fixstring' ) title ! : string ;
16
33
@attr ( 'date' ) dateCreated ! : Date ;
17
34
@attr ( 'date' ) datePublished ! : Date ;
35
+ @attr ( 'date' ) dateWithdrawn ! : Date ;
18
36
@attr ( 'date' ) originalPublicationDate ! : Date | null ;
19
37
@attr ( 'date' ) dateModified ! : Date ;
20
38
@attr ( 'fixstring' ) doi ! : string | null ;
39
+ @attr ( 'boolean' ) public ! : boolean ;
21
40
@attr ( 'boolean' ) isPublished ! : boolean ;
22
41
@attr ( 'boolean' ) isPreprintOrphan ! : boolean ;
23
42
@attr ( 'object' ) licenseRecord ! : any ;
24
- @attr ( 'string' ) reviewsState ! : string ;
43
+ @attr ( 'string' ) reviewsState ! : ReviewsState ;
44
+ @attr ( 'string' ) description ! : string ;
25
45
@attr ( 'date' ) dateLastTransitioned ! : Date ;
26
46
@attr ( 'date' ) preprintDoiCreated ! : Date ;
47
+ @attr ( 'array' ) currentUserPermissions ! : Permission [ ] ;
48
+ @attr ( 'fixstringarray' ) tags ! : string [ ] ;
49
+ @attr ( 'fixstring' ) withdrawalJustification ! : string ;
50
+ @attr ( 'boolean' ) hasCoi ! : boolean ;
51
+ @attr ( 'string' ) hasDataLinks ! : PreprintDataLinksEnum ;
52
+ @attr ( 'string' ) hasPreregLinks ! : PreprintPreregLinksEnum ;
53
+ @attr ( 'string' ) conflictOfInterestStatement ! : string ;
54
+ @attr ( 'array' ) dataLinks ! : string [ ] ;
55
+ @attr ( 'array' ) preregLinks ! : string [ ] ;
56
+ @attr ( 'string' ) whyNoData ! : string ;
57
+ @attr ( 'string' ) whyNoPrereg ! : string ;
27
58
28
59
@belongsTo ( 'node' , { inverse : 'preprints' } )
29
60
node ! : AsyncBelongsTo < NodeModel > & NodeModel ;
@@ -37,18 +68,34 @@ export default class PreprintModel extends OsfModel {
37
68
@belongsTo ( 'preprint-provider' , { inverse : 'preprints' } )
38
69
provider ! : AsyncBelongsTo < PreprintProviderModel > & PreprintProviderModel ;
39
70
40
- @hasMany ( 'review-action' , { inverse : 'target' } )
71
+ @hasMany ( 'review-action' )
41
72
reviewActions ! : AsyncHasMany < ReviewActionModel > ;
42
73
43
- @hasMany ( 'contributor' )
44
- contributors ! : AsyncHasMany < ContributorModel > ;
74
+ @hasMany ( 'files' , { inverse : 'target' } )
75
+ files ! : AsyncHasMany < FileModel > & FileModel ;
76
+
77
+ @hasMany ( 'contributors' , { inverse : 'preprint' } )
78
+ contributors ! : AsyncHasMany < ContributorModel > & ContributorModel ;
45
79
46
- @hasMany ( 'subject' , { inverse : null , async : false } )
47
- subjects ! : SyncHasMany < SubjectModel > ;
80
+ @hasMany ( 'contributor' , { inverse : null } )
81
+ bibliographicContributors ! : AsyncHasMany < ContributorModel > ;
82
+
83
+ @belongsTo ( 'citation' , { inverse : null } )
84
+ citation ! : AsyncBelongsTo < CitationModel > ;
85
+
86
+ @hasMany ( 'subject' , { inverse : null } )
87
+ subjects ! : AsyncHasMany < SubjectModel > ;
88
+
89
+ @hasMany ( 'preprint-request' , { inverse : 'target' } )
90
+ requests ! : AsyncHasMany < PreprintRequestModel > ;
48
91
49
92
@alias ( 'links.doi' ) articleDoiUrl ! : string | null ;
50
93
@alias ( 'links.preprint_doi' ) preprintDoiUrl ! : string ;
51
94
95
+ get isWithdrawn ( ) : boolean {
96
+ return this . dateWithdrawn !== null ;
97
+ }
98
+
52
99
@computed ( 'license' , 'licenseRecord' )
53
100
get licenseText ( ) : string {
54
101
const text = this . license . get ( 'text' ) || '' ;
0 commit comments