1- import { attr , belongsTo , hasMany , SyncHasMany , AsyncBelongsTo , AsyncHasMany } from '@ember-data/model' ;
1+ import { attr , belongsTo , hasMany , AsyncBelongsTo , AsyncHasMany } from '@ember-data/model' ;
22import { computed } from '@ember/object' ;
33import { 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' ;
48
59import ContributorModel from './contributor' ;
610import FileModel from './file' ;
711import LicenseModel from './license' ;
812import NodeModel from './node' ;
9- import OsfModel from './osf-model' ;
13+ import OsfModel , { Permission } from './osf-model' ;
1014import PreprintProviderModel from './preprint-provider' ;
11- import ReviewActionModel from './review-action' ;
1215import SubjectModel from './subject' ;
1316
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+
1431export default class PreprintModel extends OsfModel {
1532 @attr ( 'fixstring' ) title ! : string ;
1633 @attr ( 'date' ) dateCreated ! : Date ;
1734 @attr ( 'date' ) datePublished ! : Date ;
35+ @attr ( 'date' ) dateWithdrawn ! : Date ;
1836 @attr ( 'date' ) originalPublicationDate ! : Date | null ;
1937 @attr ( 'date' ) dateModified ! : Date ;
2038 @attr ( 'fixstring' ) doi ! : string | null ;
39+ @attr ( 'boolean' ) public ! : boolean ;
2140 @attr ( 'boolean' ) isPublished ! : boolean ;
2241 @attr ( 'boolean' ) isPreprintOrphan ! : boolean ;
2342 @attr ( 'object' ) licenseRecord ! : any ;
24- @attr ( 'string' ) reviewsState ! : string ;
43+ @attr ( 'string' ) reviewsState ! : ReviewsState ;
44+ @attr ( 'string' ) description ! : string ;
2545 @attr ( 'date' ) dateLastTransitioned ! : Date ;
2646 @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 ;
2758
2859 @belongsTo ( 'node' , { inverse : 'preprints' } )
2960 node ! : AsyncBelongsTo < NodeModel > & NodeModel ;
@@ -37,18 +68,34 @@ export default class PreprintModel extends OsfModel {
3768 @belongsTo ( 'preprint-provider' , { inverse : 'preprints' } )
3869 provider ! : AsyncBelongsTo < PreprintProviderModel > & PreprintProviderModel ;
3970
40- @hasMany ( 'review-action' , { inverse : 'target' } )
71+ @hasMany ( 'review-action' )
4172 reviewActions ! : AsyncHasMany < ReviewActionModel > ;
4273
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 ;
4579
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 > ;
4891
4992 @alias ( 'links.doi' ) articleDoiUrl ! : string | null ;
5093 @alias ( 'links.preprint_doi' ) preprintDoiUrl ! : string ;
5194
95+ get isWithdrawn ( ) : boolean {
96+ return this . dateWithdrawn !== null ;
97+ }
98+
5299 @computed ( 'license' , 'licenseRecord' )
53100 get licenseText ( ) : string {
54101 const text = this . license . get ( 'text' ) || '' ;
0 commit comments