Skip to content

Commit

Permalink
Use loading state to avoid double click
Browse files Browse the repository at this point in the history
  • Loading branch information
John Holt authored and John Holt committed Sep 6, 2023
1 parent 7b2f50f commit 5b68d64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion client/src/js/app/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ const store = new Vuex.Store({
oidcId: state => state.auth.oidcId,
apiUrl: state => state.apiUrl,
appUrl: state => state.appUrl,
getAppOptions: state => state.appOptions
getAppOptions: state => state.appOptions,
isLoading: state => state.isLoading,
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,16 @@ export default {
// Save the sample to the server via backbone model
// Location should be the sample LOCATION
async onSaveSample(location) {
try {
if (this.$store.getters.isLoading) { // avoid double click
return
}
try {
this.$store.commit('loading', true)
const result = await this.$refs.containerForm.validate()
if (result) {
const samplesRef = this.$refs.samples
samplesRef.$refs[`sample-row-${location}`][0].closeSampleEditing()
await this.saveSample(location)
const samplesRef = this.$refs.samples
samplesRef.$refs[`sample-row-${location}`][0].closeSampleEditing()
this.$refs.containerForm.reset()
}
else {
Expand Down

0 comments on commit 5b68d64

Please sign in to comment.