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

IssueNotesRefactor: Implement note delete.

parent 96ede7f7
...@@ -58,10 +58,10 @@ export default { ...@@ -58,10 +58,10 @@ export default {
<div class="timeline-entry-inner"> <div class="timeline-entry-inner">
<div class="timeline-icon"> <div class="timeline-icon">
<user-avatar-link <user-avatar-link
:link-href="author.path" :linkHref="author.path"
:img-src="author.avatar_url" :imgSrc="author.avatar_url"
:img-alt="author.name" :imgAlt="author.name"
:img-size="40" /> :imgSize="40" />
</div> </div>
<div class="timeline-content"> <div class="timeline-content">
<div class="discussion"> <div class="discussion">
......
...@@ -39,6 +39,10 @@ export default { ...@@ -39,6 +39,10 @@ export default {
this.isEditing = true; this.isEditing = true;
}, },
deleteHandler() { deleteHandler() {
const msg = 'Are you sure you want to delete this list?';
const isConfirmed = confirm(msg); // eslint-disable-line
if (isConfirmed) {
this.isDeleting = true; this.isDeleting = true;
this.$store this.$store
.dispatch('deleteNote', this.note) .dispatch('deleteNote', this.note)
...@@ -48,6 +52,7 @@ export default { ...@@ -48,6 +52,7 @@ export default {
.catch(() => { .catch(() => {
this.isDeleting = false; this.isDeleting = false;
}); });
}
}, },
formUpdateHandler() { formUpdateHandler() {
// console.log('update requested', data); // console.log('update requested', data);
...@@ -66,10 +71,10 @@ export default { ...@@ -66,10 +71,10 @@ export default {
<div class="timeline-entry-inner"> <div class="timeline-entry-inner">
<div class="timeline-icon"> <div class="timeline-icon">
<user-avatar-link <user-avatar-link
:link-href="author.path" :linkHref="author.path"
:img-src="author.avatar_url" :imgSrc="author.avatar_url"
:img-alt="author.name" :imgAlt="author.name"
:img-size="40" /> :imgSize="40" />
</div> </div>
<div class="timeline-content"> <div class="timeline-content">
<div class="note-header"> <div class="note-header">
......
...@@ -97,6 +97,7 @@ export default { ...@@ -97,6 +97,7 @@ export default {
</li> </li>
<li> <li>
<a <a
v-if="canEdit"
@click.prevent="deleteHandler" @click.prevent="deleteHandler"
class="js-note-delete" class="js-note-delete"
href="#"> href="#">
......
...@@ -8,6 +8,6 @@ export default { ...@@ -8,6 +8,6 @@ export default {
return Vue.http.get(endpoint); return Vue.http.get(endpoint);
}, },
deleteNote(endpoint) { deleteNote(endpoint) {
return Vue.http.get(endpoint); return Vue.http.delete(endpoint);
}, },
}; };
...@@ -53,10 +53,8 @@ const actions = { ...@@ -53,10 +53,8 @@ const actions = {
}); });
}, },
deleteNote(context, note) { deleteNote(context, note) {
// FIXME: Implement request, remove fake delete timer...
return service return service
.deleteNote(`${document.location.href}.json`) .deleteNote(note.path)
.then(res => res.json)
.then(() => { .then(() => {
context.commit('deleteNote', note); 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