Deleting a namespace now uses the modal

This commit is contained in:
kolaente 2018-09-12 08:23:52 +02:00
parent c8a305f930
commit cb6eb2d1ca
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -29,7 +29,7 @@
</button> </button>
</div> </div>
<div class="column is-1"> <div class="column is-1">
<button @click="deleteNamespace()" class="button is-danger is-fullwidth" :class="{ 'is-loading': loading}"> <button @click="showDeleteModal = true" class="button is-danger is-fullwidth" :class="{ 'is-loading': loading}">
<span class="icon is-small"> <span class="icon is-small">
<icon icon="trash-alt"/> <icon icon="trash-alt"/>
</span> </span>
@ -38,6 +38,15 @@
</div> </div>
</div> </div>
</div> </div>
<modal
v-if="showDeleteModal"
@close="showDeleteModal = false"
v-on:submit="deleteNamespace()">
<span slot="header">Delete the namespace</span>
<p slot="text">Are you sure you want to delete this namespace and all of its contents?
<br/>This includes lists & tasks and <b>CANNOT BE UNDONE!</b></p>
</modal>
</div> </div>
</template> </template>
@ -54,6 +63,7 @@
namespace: {title: '', description:''}, namespace: {title: '', description:''},
error: '', error: '',
loading: false, loading: false,
showDeleteModal: false,
} }
}, },
beforeMount() { beforeMount() {
@ -101,11 +111,6 @@
}) })
}, },
deleteNamespace() { 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')}}) HTTP.delete(`namespaces/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(() => { .then(() => {
this.handleSuccess({message: 'The namespace was successfully deleted.'}) this.handleSuccess({message: 'The namespace was successfully deleted.'})