Commit a4515778 authored by Fatih Acet's avatar Fatih Acet

IssueNotesRefactor: Fix ToDo list editability.

parent 77f6f0b8
...@@ -147,6 +147,7 @@ export default { ...@@ -147,6 +147,7 @@ export default {
</div> </div>
<issue-note-body <issue-note-body
:note="note" :note="note"
:canEdit="note.current_user.can_edit"
:isEditing="isEditing" :isEditing="isEditing"
:formUpdateHandler="formUpdateHandler" :formUpdateHandler="formUpdateHandler"
:formCancelHandler="formCancelHandler" :formCancelHandler="formCancelHandler"
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import IssueNoteEditedText from './issue_note_edited_text.vue'; import IssueNoteEditedText from './issue_note_edited_text.vue';
import IssueNoteAwardsList from './issue_note_awards_list.vue'; import IssueNoteAwardsList from './issue_note_awards_list.vue';
import IssueNoteForm from './issue_note_form.vue'; import IssueNoteForm from './issue_note_form.vue';
import TaskList from '../../task_list';
export default { export default {
props: { props: {
...@@ -9,6 +10,10 @@ export default { ...@@ -9,6 +10,10 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
canEdit: {
type: Boolean,
required: true,
},
isEditing: { isEditing: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -32,6 +37,15 @@ export default { ...@@ -32,6 +37,15 @@ export default {
renderGFM() { renderGFM() {
$(this.$refs['note-body']).renderGFM(); $(this.$refs['note-body']).renderGFM();
}, },
initTaskList() {
if (this.canEdit) {
new TaskList({
dataType: 'note',
fieldName: 'note',
selector: '.notes'
});
}
},
handleFormUpdate() { handleFormUpdate() {
this.formUpdateHandler({ this.formUpdateHandler({
note: this.$refs.noteForm.note, note: this.$refs.noteForm.note,
...@@ -40,12 +54,17 @@ export default { ...@@ -40,12 +54,17 @@ export default {
}, },
mounted() { mounted() {
this.renderGFM(); this.renderGFM();
this.initTaskList();
},
updated() {
this.initTaskList();
}, },
}; };
</script> </script>
<template> <template>
<div <div
:class="{ 'js-task-list-container': canEdit }"
ref="note-body" ref="note-body"
class="note-body"> class="note-body">
<div <div
...@@ -57,6 +76,11 @@ export default { ...@@ -57,6 +76,11 @@ export default {
:updateHandler="handleFormUpdate" :updateHandler="handleFormUpdate"
:cancelHandler="formCancelHandler" :cancelHandler="formCancelHandler"
:noteBody="note.note" /> :noteBody="note.note" />
<textarea
v-if="canEdit"
v-model="note.note"
:data-update-url="note.path"
class="hidden js-task-list-field"></textarea>
<issue-note-edited-text <issue-note-edited-text
v-if="note.last_edited_by" v-if="note.last_edited_by"
:editedAt="note.last_edited_at" :editedAt="note.last_edited_at"
......
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