Skip to content

Commit

Permalink
Added an onchange for the subject manager
Browse files Browse the repository at this point in the history
  • Loading branch information
bp-cos committed Apr 18, 2024
1 parent 02c7206 commit 3821c75
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/preprints/-components/submit/metadata/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
@provider={{@manager.provider}}
@metadataChangeset={{this.metadataFormChangeset}}
@doesAutosave={{true}}
@onchange={{this.validate}}
id={{subjectsFieldId}}
as |subjectsManager|
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class PreprintStateMachine extends Component<StateMachineArgs>{
provider = this.args.provider;
@tracked preprint: PreprintModel;
displayAuthorAssertions = true;
@tracked statusFlowIndex = 5;
@tracked statusFlowIndex = 1;

constructor(owner: unknown, args: StateMachineArgs) {
super(owner, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default class SubjectManagerComponent extends Component {

// optional
metadataChangeset?: BufferedChangeset;
onchange?: () => void;

// private
@service intl!: Intl;
Expand Down Expand Up @@ -136,6 +137,11 @@ export default class SubjectManagerComponent extends Component {
if (this.metadataChangeset) {
this.metadataChangeset.validate('subjects');
}

if (this.onchange) {
this.onchange();
}

} catch (e) {
const errorMessage = this.intl.t('registries.registration_metadata.save_subjects_error');
captureException(e, { errorMessage });
Expand Down

0 comments on commit 3821c75

Please sign in to comment.