Skip to content

Commit

Permalink
Merge pull request #65 from ConductionNL/feature/REGISTERS-54/modal-r…
Browse files Browse the repository at this point in the history
…emove-timeout

added a timeout clear to all modals where necessary
  • Loading branch information
RalkeyOfficial authored Nov 12, 2024
2 parents d81f038 + c02166d commit 48c570f
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/modals/object/DeleteObject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ export default {
success: null,
loading: false,
error: false,
closeModalTimeout: null,
}
},
methods: {
closeDialog() {
navigationStore.setDialog(false)
clearTimeout(this.closeModalTimeout)
this.success = null
this.loading = false
this.error = false
Expand All @@ -84,7 +86,7 @@ export default {
}).then(({ response }) => {
this.success = response.ok
this.error = false
response.ok && setTimeout(this.closeDialog, 2000)
response.ok && (this.closeModalTimeout = setTimeout(this.closeDialog, 2000))
}).catch((error) => {
this.success = false
this.error = error.message || 'An error occurred while deleting the object'
Expand Down
4 changes: 3 additions & 1 deletion src/modals/object/EditObject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export default {
loading: false,
error: false,
hasUpdated: false,
closeModalTimeout: null,
}
},
mounted() {
Expand Down Expand Up @@ -220,6 +221,7 @@ export default {
},
closeModal() {
navigationStore.setModal(false)
clearTimeout(this.closeModalTimeout)
this.success = null
this.loading = false
this.error = false
Expand All @@ -241,7 +243,7 @@ export default {
}).then(({ response }) => {
this.success = response.ok
this.error = false
response.ok && setTimeout(this.closeModal, 2000)
response.ok && (this.closeModalTimeout = setTimeout(this.closeModal, 2000))
}).catch((error) => {
this.success = false
this.error = error.message || 'An error occurred while saving the object'
Expand Down
4 changes: 3 additions & 1 deletion src/modals/register/DeleteRegister.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ export default {
success: false,
loading: false,
error: false,
closeModalTimeout: null,
}
},
methods: {
closeDialog() {
navigationStore.setDialog(false)
clearTimeout(this.closeModalTimeout)
this.success = false
this.loading = false
this.error = false
Expand All @@ -84,7 +86,7 @@ export default {
}).then(({ response }) => {
this.success = response.ok
this.error = false
response.ok && setTimeout(this.closeDialog, 2000)
response.ok && (this.closeModalTimeout = setTimeout(this.closeDialog, 2000))
}).catch((error) => {
this.success = false
this.error = error.message || 'Er is een fout opgetreden bij het verwijderen van het register'
Expand Down
4 changes: 3 additions & 1 deletion src/modals/register/EditRegister.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default {
loading: false,
error: false,
hasUpdated: false,
closeModalTimeout: null,
}
},
mounted() {
Expand Down Expand Up @@ -193,6 +194,7 @@ export default {
},
closeModal() {
navigationStore.setModal(false)
clearTimeout(this.closeModalTimeout)
this.success = null
this.loading = false
this.error = false
Expand All @@ -217,7 +219,7 @@ export default {
}).then(({ response }) => {
this.success = response.ok
this.error = false
response.ok && setTimeout(this.closeModal, 2000)
response.ok && (this.closeModalTimeout = setTimeout(this.closeModal, 2000))
}).catch((error) => {
this.success = false
this.error = error.message || 'An error occurred while saving the register'
Expand Down
8 changes: 5 additions & 3 deletions src/modals/register/UploadRegister.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,26 @@ export default {
return {
register: {
json: '{}',
url: ''
url: '',
},
success: false,
loading: false,
error: false,
hasUpdated: false,
closeModalTimeout: null,
}
},
methods: {
closeModal() {
navigationStore.setModal(false)
clearTimeout(this.closeModalTimeout)
this.success = null
this.loading = false
this.error = false
this.hasUpdated = false
this.register = {
json: '{}',
url: ''
url: '',
}
},
async uploadRegister() {
Expand All @@ -104,7 +106,7 @@ export default {
registerStore.uploadRegister(this.register).then(({ response }) => {
this.success = response.ok
this.error = false
response.ok && setTimeout(this.closeModal, 2000)
response.ok && (this.closeModalTimeout = setTimeout(this.closeModal, 2000))
}).catch((error) => {
this.success = false
this.error = error.message || 'An error occurred while uploading the register'
Expand Down
4 changes: 3 additions & 1 deletion src/modals/schema/DeleteSchema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ export default {
success: false,
loading: false,
error: false,
closeModalTimeout: null,
}
},
methods: {
closeDialog() {
navigationStore.setDialog(false)
clearTimeout(this.closeModalTimeout)
this.success = false
this.loading = false
this.error = false
Expand All @@ -84,7 +86,7 @@ export default {
}).then(({ response }) => {
this.success = response.ok
this.error = false
response.ok && setTimeout(this.closeDialog, 2000)
response.ok && (this.closeModalTimeout = setTimeout(this.closeDialog, 2000))
}).catch((error) => {
this.success = false
this.error = error.message || 'An error occurred while deleting the schema'
Expand Down
17 changes: 10 additions & 7 deletions src/modals/schema/DeleteSchemaProperty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { navigationStore, schemaStore } from '../../store/store.js'
</p>

<template #actions>
<NcButton :disabled="loading" icon="" @click="navigationStore.setModal(null)">
<NcButton :disabled="loading" icon="" @click="closeModal">
<template #icon>
<Cancel :size="20" />
</template>
Expand Down Expand Up @@ -68,9 +68,17 @@ export default {
loading: false,
success: null,
error: false,
closeModalTimeout: null,
}
},
methods: {
closeModal() {
navigationStore.setModal(null)
schemaStore.setSchemaPropertyKey(null)
clearTimeout(this.closeModalTimeout)
this.success = null
this.error = false
},
DeleteProperty() {
this.loading = true
Expand All @@ -88,12 +96,7 @@ export default {
this.success = response.ok
// Wait for the user to read the feedback then close the modal
const self = this
setTimeout(function() {
self.success = null
navigationStore.setModal(null)
schemaStore.setSchemaPropertyKey(null)
}, 2000)
this.closeModalTimeout = setTimeout(this.closeModal, 2000)
})
.catch((err) => {
this.error = err
Expand Down
4 changes: 3 additions & 1 deletion src/modals/schema/EditSchema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default {
loading: false,
error: false,
hasUpdated: false,
closeModalTimeout: null,
}
},
mounted() {
Expand All @@ -127,6 +128,7 @@ export default {
},
closeModal() {
navigationStore.setModal(false)
clearTimeout(this.closeModalTimeout)
this.success = null
this.loading = false
this.error = false
Expand Down Expand Up @@ -170,7 +172,7 @@ export default {
} else {
this.success = response.ok
this.error = false
response.ok && setTimeout(this.closeModal, 2000)
response.ok && (this.closeModalTimeout = setTimeout(this.closeModal, 2000))
}
}).catch((error) => {
Expand Down
4 changes: 3 additions & 1 deletion src/modals/schema/EditSchemaProperty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ export default {
success: null,
error: false,
hasUpdated: false,
closeModalTimeout: null,
}
},
computed: {
Expand Down Expand Up @@ -388,6 +389,7 @@ export default {
closeModal() {
navigationStore.setModal(false)
schemaStore.setSchemaPropertyKey(null)
clearTimeout(this.closeModalTimeout)
this.success = null
this.hasUpdated = false
this.properties = {
Expand Down Expand Up @@ -444,7 +446,7 @@ export default {
.then(({ response }) => {
this.success = response.ok
setTimeout(this.closeModal, 2000)
this.closeModalTimeout = setTimeout(this.closeModal, 2000)
}).catch((err) => {
this.success = false
this.error = err
Expand Down
4 changes: 3 additions & 1 deletion src/modals/schema/UploadSchema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ export default {
loading: false,
error: false,
hasUpdated: false,
closeModalTimeout: null,
}
},
methods: {
closeModal() {
navigationStore.setModal(false)
clearTimeout(this.closeModalTimeout)
this.success = null
this.loading = false
this.error = false
Expand All @@ -124,7 +126,7 @@ export default {
schemaStore.uploadSchema(newSchema).then(({ response }) => {
this.success = response.ok
this.error = false
response.ok && setTimeout(this.closeModal, 2000)
response.ok && (this.closeModalTimeout = setTimeout(this.closeModal, 2000))
}).catch((error) => {
this.success = false
this.error = error.message || 'An error occurred while uploading the schema'
Expand Down
4 changes: 3 additions & 1 deletion src/modals/source/DeleteSource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ export default {
success: false,
loading: false,
error: false,
closeModalTimeout: null,
}
},
methods: {
closeDialog() {
navigationStore.setDialog(false)
clearTimeout(this.closeModalTimeout)
this.success = false
this.loading = false
this.error = false
Expand All @@ -84,7 +86,7 @@ export default {
}).then(({ response }) => {
this.success = response.ok
this.error = false
response.ok && setTimeout(this.closeDialog, 2000)
response.ok && (this.closeModalTimeout = setTimeout(this.closeDialog, 2000))
}).catch((error) => {
this.success = false
this.error = error.message || 'An error occurred while deleting the source'
Expand Down
4 changes: 3 additions & 1 deletion src/modals/source/EditSource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default {
loading: false,
error: false,
hasUpdated: false,
closeModalTimeout: null,
}
},
mounted() {
Expand All @@ -125,6 +126,7 @@ export default {
},
closeModal() {
navigationStore.setModal(false)
clearTimeout(this.closeModalTimeout)
this.success = null
this.loading = false
this.error = false
Expand All @@ -147,7 +149,7 @@ export default {
}).then(({ response }) => {
this.success = response.ok
this.error = false
response.ok && setTimeout(this.closeModal, 2000)
response.ok && (this.closeModalTimeout = setTimeout(this.closeModal, 2000))
}).catch((error) => {
this.success = false
this.error = error.message || 'An error occurred while saving the source'
Expand Down

0 comments on commit 48c570f

Please sign in to comment.