Commit 696de46a authored by Fatih Acet's avatar Fatih Acet

IssueNotesRefactor: Implement note delete.

parent 96ede7f7
......@@ -58,10 +58,10 @@ export default {
<div class="timeline-entry-inner">
<div class="timeline-icon">
<user-avatar-link
:link-href="author.path"
:img-src="author.avatar_url"
:img-alt="author.name"
:img-size="40" />
:linkHref="author.path"
:imgSrc="author.avatar_url"
:imgAlt="author.name"
:imgSize="40" />
</div>
<div class="timeline-content">
<div class="discussion">
......
......@@ -39,15 +39,20 @@ export default {
this.isEditing = true;
},
deleteHandler() {
this.isDeleting = true;
this.$store
.dispatch('deleteNote', this.note)
.then(() => {
this.isDeleting = false;
})
.catch(() => {
this.isDeleting = false;
});
const msg = 'Are you sure you want to delete this list?';
const isConfirmed = confirm(msg); // eslint-disable-line
if (isConfirmed) {
this.isDeleting = true;
this.$store
.dispatch('deleteNote', this.note)
.then(() => {
this.isDeleting = false;
})
.catch(() => {
this.isDeleting = false;
});
}
},
formUpdateHandler() {
// console.log('update requested', data);
......@@ -66,10 +71,10 @@ export default {
<div class="timeline-entry-inner">
<div class="timeline-icon">
<user-avatar-link
:link-href="author.path"
:img-src="author.avatar_url"
:img-alt="author.name"
:img-size="40" />
:linkHref="author.path"
:imgSrc="author.avatar_url"
:imgAlt="author.name"
:imgSize="40" />
</div>
<div class="timeline-content">
<div class="note-header">
......
......@@ -97,6 +97,7 @@ export default {
</li>
<li>
<a
v-if="canEdit"
@click.prevent="deleteHandler"
class="js-note-delete"
href="#">
......
......@@ -8,6 +8,6 @@ export default {
return Vue.http.get(endpoint);
},
deleteNote(endpoint) {
return Vue.http.get(endpoint);
return Vue.http.delete(endpoint);
},
};
......@@ -53,10 +53,8 @@ const actions = {
});
},
deleteNote(context, note) {
// FIXME: Implement request, remove fake delete timer...
return service
.deleteNote(`${document.location.href}.json`)
.then(res => res.json)
.deleteNote(note.path)
.then(() => {
context.commit('deleteNote', note);
})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment