Skip to content

Commit

Permalink
[Instrument] ControlpanelDeleteInstrumentData error (#8681)
Browse files Browse the repository at this point in the history
Fix clear instrument button regression introduced by #7018 and reported in PR #8673 

Fixes #7065, Fixes #8580
  • Loading branch information
laemtl authored May 11, 2023
1 parent 5d929ad commit 06d27dc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
31 changes: 21 additions & 10 deletions modules/instruments/jsx/ControlpanelDeleteInstrumentData.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,25 @@ class ControlpanelDeleteInstrumentData extends Component {
confirmButtonText: 'Yes, delete the data',
}).then((result) => {
if (result.value) {
this.refs.ClearInstrument.dispatchEvent(
new Event('submit')
);
const formData = new FormData();
formData.append('ClearInstrument', 1);
fetch(
window.location.href,
{
method: 'POST',
body: formData,
}
).then((response) => {
if (!response.ok) {
console.error(
response.status + ': ' + response.statusText
);
return;
}
window.location.reload();
}).catch((error) => {
console.error(error);
});
}
});
}
Expand All @@ -43,19 +59,14 @@ class ControlpanelDeleteInstrumentData extends Component {
* @return {JSX} - React markup for the component
*/
render() {
return <form ref="ClearInstrument" method="post">
return (
<input
className="button"
type="button"
value="Delete instrument data"
onClick={this.confirmDeletion}
/>
<input
type="hidden"
name="ClearInstrument"
value="1"
/>
</form>;
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class NDB_BVL_InstrumentStatus_ControlPanel extends NDB_BVL_InstrumentStatus
$this->subtest ?? ''
);
$instrument->clearInstrument();
return false;
return true;
} else {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ const lorisModules = {
imaging_qc: ['imagingQCIndex'],
server_processes_manager: ['server_processes_managerIndex'],
statistics: ['WidgetIndex'],
instruments: ['CandidateInstrumentList'],
instruments: ['CandidateInstrumentList', 'ControlpanelDeleteInstrumentData'],
candidate_profile: ['CandidateInfo'],
api_docs: ['swagger-ui_custom'],
};
Expand Down

0 comments on commit 06d27dc

Please # to comment.