Skip to content

Commit

Permalink
Fix Delete instrument data btn not working
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Apr 26, 2023
1 parent 8a0ceda commit 33fa615
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
29 changes: 19 additions & 10 deletions modules/instruments/jsx/ControlpanelDeleteInstrumentData.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,23 @@ 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 +57,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

0 comments on commit 33fa615

Please sign in to comment.