Added method to delete a namespace

This commit is contained in:
kolaente 2018-09-11 20:16:08 +02:00
parent 300fe9dfa6
commit 42b3f8fb25
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 35 additions and 7 deletions

View file

@ -20,13 +20,22 @@
<textarea :class="{ 'disabled': loading}" :disabled="loading" class="textarea" placeholder="The namespaces description goes here..." id="namespacedescription" v-model="namespace.description"></textarea> <textarea :class="{ 'disabled': loading}" :disabled="loading" class="textarea" placeholder="The namespaces description goes here..." id="namespacedescription" v-model="namespace.description"></textarea>
</div> </div>
</div> </div>
</form>
<div class="columns bigbuttons">
<button type="submit" class="button is-success is-fullwidth" :class="{ 'is-loading': loading}"> <div class="column">
<button @click="submit()" class="button is-success is-fullwidth" :class="{ 'is-loading': loading}">
Save Save
</button> </button>
</div>
</form> <div class="column is-1">
<button @click="deleteNamespace()" class="button is-danger is-fullwidth" :class="{ 'is-loading': loading}">
<span class="icon is-small">
<icon icon="trash-alt"/>
</span>
</button>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -91,6 +100,21 @@
this.handleError(e) this.handleError(e)
}) })
}, },
deleteNamespace() {
// TODO: add better looking modal to ask the user if he is sure
if (!confirm('Are you sure you want to delete this namespace and all of its contents? This includes lists & tasks and CANNOT BE UNDONE!')) {
return
}
HTTP.delete(`namespaces/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(() => {
this.handleSuccess({message: 'The namespace was successfully deleted.'})
router.push({name: 'home'})
})
.catch(e => {
this.handleError(e)
})
},
handleError(e) { handleError(e) {
this.loading = false this.loading = false
message.error(e, this) message.error(e, this)
@ -104,5 +128,7 @@
</script> </script>
<style scoped> <style scoped>
.bigbuttons{
margin-top: 0.5rem;
}
</style> </style>

View file

@ -20,6 +20,7 @@ import { faTasks } from '@fortawesome/free-solid-svg-icons'
import { faCog } from '@fortawesome/free-solid-svg-icons' import { faCog } from '@fortawesome/free-solid-svg-icons'
import { faAngleRight } from '@fortawesome/free-solid-svg-icons' import { faAngleRight } from '@fortawesome/free-solid-svg-icons'
import { faLayerGroup } from '@fortawesome/free-solid-svg-icons' import { faLayerGroup } from '@fortawesome/free-solid-svg-icons'
import { faTrashAlt } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(faSignOutAlt) library.add(faSignOutAlt)
@ -29,6 +30,7 @@ library.add(faTasks)
library.add(faCog) library.add(faCog)
library.add(faAngleRight) library.add(faAngleRight)
library.add(faLayerGroup) library.add(faLayerGroup)
library.add(faTrashAlt)
Vue.component('icon', FontAwesomeIcon) Vue.component('icon', FontAwesomeIcon)