File tree Expand file tree Collapse file tree 3 files changed +17
-14
lines changed
preprints/-components/submit/preprint-state-machine Expand file tree Collapse file tree 3 files changed +17
-14
lines changed Original file line number Diff line number Diff line change 11import { hasMany , AsyncHasMany , attr } from '@ember-data/model' ;
2-
2+ import { PromiseManyArray } from '@ember-data/store/-private' ;
33import BaseFileItem from 'ember-osf-web/models/base-file-item' ;
44import DraftRegistrationModel from 'ember-osf-web/models/draft-registration' ;
55import FileProviderModel from 'ember-osf-web/models/file-provider' ;
6-
6+ import ReviewActionModel from 'ember-osf-web/models/review-action' ;
77import { Permission } from './osf-model' ;
88
99export default class AbstractNodeModel extends BaseFileItem {
@@ -15,6 +15,9 @@ export default class AbstractNodeModel extends BaseFileItem {
1515
1616 @attr ( 'array' ) currentUserPermissions ! : Permission [ ] ;
1717
18+ @hasMany ( 'review-action' , { inverse : 'target' } )
19+ reviewActions ! : PromiseManyArray < ReviewActionModel > ;
20+
1821}
1922
2023declare module 'ember-data/types/registries/model' {
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ export default class ReviewActionModel extends Action {
6363 @attr ( 'string' ) fromState ! : RegistrationReviewStates ;
6464 @attr ( 'string' ) toState ! : RegistrationReviewStates ;
6565
66- @belongsTo ( 'registration ' , { inverse : 'reviewActions' , polymorphic : true } )
66+ @belongsTo ( 'abstract-node ' , { inverse : 'reviewActions' , polymorphic : true } )
6767 target ! : ( AsyncBelongsTo < RegistrationModel > & RegistrationModel
6868 ) | ( AsyncBelongsTo < PreprintModel > & PreprintModel ) ;
6969
Original file line number Diff line number Diff line change @@ -201,19 +201,19 @@ export default class PreprintStateMachine extends Component<StateMachineArgs>{
201201 @waitFor
202202 public async onSubmit ( ) : Promise < void > {
203203 this . args . resetPageDirty ( ) ;
204- if ( ! this . isEditFlow ) {
205- if ( this . provider . reviewsWorkflow ) {
206- const reviewAction = this . store . createRecord ( 'review-action' , {
207- actionTrigger : 'submit' ,
208- target : this . preprint ,
209- } ) ;
210- await reviewAction . save ( ) ;
211- } else {
212- this . preprint . isPublished = true ;
213- await this . preprint . save ( ) ;
214- }
204+ if ( this . provider . reviewsWorkflow ) {
205+ const reviewAction = this . store . createRecord ( 'review-action' , {
206+ actionTrigger : 'submit' ,
207+ target : this . preprint ,
208+ } ) ;
209+ await reviewAction . save ( ) ;
210+ } else {
211+ this . preprint . isPublished = true ;
212+ await this . preprint . save ( ) ;
215213 }
216214
215+ await this . preprint . reload ( ) ;
216+
217217 await this . router . transitionTo ( 'preprints.detail' , this . provider . id , this . preprint . id ) ;
218218 }
219219
You can’t perform that action at this time.
0 commit comments