11import { attr , belongsTo , hasMany , AsyncBelongsTo , AsyncHasMany } from '@ember-data/model' ;
22import { computed } from '@ember/object' ;
33import { alias } from '@ember/object/computed' ;
4+ import AbstractNodeModel from 'ember-osf-web/models/abstract-node' ;
45import CitationModel from 'ember-osf-web/models/citation' ;
56import PreprintRequestModel from 'ember-osf-web/models/preprint-request' ;
67import { ReviewsState } from 'ember-osf-web/models/provider' ;
@@ -11,51 +12,63 @@ import FileModel from './file';
1112import IdentifierModel from './identifier' ;
1213import LicenseModel from './license' ;
1314import NodeModel from './node' ;
14- import OsfModel , { Permission } from './osf-model' ;
15+ import { Permission } from './osf-model' ;
1516import PreprintProviderModel from './preprint-provider' ;
1617import SubjectModel from './subject' ;
1718
1819export enum PreprintDataLinksEnum {
1920 AVAILABLE = 'available' ,
20- YES = 'yes' ,
2121 NO = 'no' ,
2222 NOT_APPLICABLE = 'not_applicable' ,
2323}
2424
2525export enum PreprintPreregLinksEnum {
2626 AVAILABLE = 'available' ,
27- YES = 'yes' ,
2827 NO = 'no' ,
2928 NOT_APPLICABLE = 'not_applicable' ,
3029}
3130
32- export default class PreprintModel extends OsfModel {
31+ export enum PreprintPreregLinkInfoEnum {
32+ PREREG_EMPTY = '' ,
33+ PREREG_DESIGNS = 'prereg_designs' ,
34+ PREREG_ANALYSIS = 'prereg_analysis' ,
35+ PREREG_BOTH = 'prereg_both' ,
36+ }
37+
38+ export interface PreprintLicenseRecordModel {
39+ copyright_holders : string [ ] ;
40+ year : string ;
41+ }
42+
43+ export default class PreprintModel extends AbstractNodeModel {
3344 @attr ( 'fixstring' ) title ! : string ;
3445 @attr ( 'date' ) dateCreated ! : Date ;
3546 @attr ( 'date' ) datePublished ! : Date ;
3647 @attr ( 'date' ) dateWithdrawn ! : Date ;
3748 @attr ( 'date' ) originalPublicationDate ! : Date | null ;
49+ @attr ( 'fixstring' ) customPublicationCitation ! : string | null ;
3850 @attr ( 'date' ) dateModified ! : Date ;
3951 @attr ( 'fixstring' ) doi ! : string | null ;
4052 @attr ( 'boolean' ) public ! : boolean ;
4153 @attr ( 'boolean' ) isPublished ! : boolean ;
4254 @attr ( 'boolean' ) isPreprintOrphan ! : boolean ;
43- @attr ( 'object' ) licenseRecord ! : any ;
55+ @attr ( 'object' ) licenseRecord ! : PreprintLicenseRecordModel ;
4456 @attr ( 'string' ) reviewsState ! : ReviewsState ;
4557 @attr ( 'string' ) description ! : string ;
4658 @attr ( 'date' ) dateLastTransitioned ! : Date ;
4759 @attr ( 'date' ) preprintDoiCreated ! : Date ;
4860 @attr ( 'array' ) currentUserPermissions ! : Permission [ ] ;
4961 @attr ( 'fixstringarray' ) tags ! : string [ ] ;
50- @attr ( 'fixstring' ) withdrawalJustification ! : string ;
62+ @attr ( 'fixstring' ) withdrawalJustification ! : string ;
5163 @attr ( 'boolean' ) hasCoi ! : boolean ;
5264 @attr ( 'string' ) hasDataLinks ! : PreprintDataLinksEnum ;
5365 @attr ( 'string' ) hasPreregLinks ! : PreprintPreregLinksEnum ;
54- @attr ( 'string' ) conflictOfInterestStatement ! : string ;
66+ @attr ( 'string' ) conflictOfInterestStatement ! : string | null ;
5567 @attr ( 'array' ) dataLinks ! : string [ ] ;
5668 @attr ( 'array' ) preregLinks ! : string [ ] ;
57- @attr ( 'string' ) whyNoData ! : string ;
58- @attr ( 'string' ) whyNoPrereg ! : string ;
69+ @attr ( 'string' ) whyNoData ! : string | null ;
70+ @attr ( 'string' ) whyNoPrereg ! : string | null ;
71+ @attr ( 'string' ) preregLinkInfo ! : PreprintPreregLinkInfoEnum ;
5972
6073 @belongsTo ( 'node' , { inverse : 'preprints' } )
6174 node ! : AsyncBelongsTo < NodeModel > & NodeModel ;
@@ -72,9 +85,6 @@ export default class PreprintModel extends OsfModel {
7285 @hasMany ( 'review-action' )
7386 reviewActions ! : AsyncHasMany < ReviewActionModel > ;
7487
75- @hasMany ( 'files' , { inverse : 'target' } )
76- files ! : AsyncHasMany < FileModel > & FileModel ;
77-
7888 @hasMany ( 'contributors' , { inverse : 'preprint' } )
7989 contributors ! : AsyncHasMany < ContributorModel > & ContributorModel ;
8090
@@ -103,7 +113,7 @@ export default class PreprintModel extends OsfModel {
103113 @computed ( 'license' , 'licenseRecord' )
104114 get licenseText ( ) : string {
105115 const text = this . license . get ( 'text' ) || '' ;
106- const { year = '' , copyright_holders = [ ] } = this . licenseRecord ; // eslint-disable-line camelcase
116+ const { year = '' , copyright_holders = [ ] } = this . licenseRecord ;
107117
108118 return text
109119 . replace ( / ( { { year} } ) / g, year )
0 commit comments