提交 696de46a 编写于 作者: F Fatih Acet

IssueNotesRefactor: Implement note delete.

上级 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,15 +39,20 @@ export default { ...@@ -39,15 +39,20 @@ export default {
this.isEditing = true; this.isEditing = true;
}, },
deleteHandler() { deleteHandler() {
this.isDeleting = true; const msg = 'Are you sure you want to delete this list?';
this.$store const isConfirmed = confirm(msg); // eslint-disable-line
.dispatch('deleteNote', this.note)
.then(() => { if (isConfirmed) {
this.isDeleting = false; this.isDeleting = true;
}) this.$store
.catch(() => { .dispatch('deleteNote', this.note)
this.isDeleting = false; .then(() => {
}); this.isDeleting = false;
})
.catch(() => {
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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册