2018-03-17 18:26:18 +05:30
|
|
|
<script>
|
2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
|
|
|
import noteEditedText from './note_edited_text.vue';
|
|
|
|
import noteAwardsList from './note_awards_list.vue';
|
|
|
|
import noteAttachment from './note_attachment.vue';
|
|
|
|
import noteForm from './note_form.vue';
|
|
|
|
import TaskList from '../../task_list';
|
|
|
|
import autosave from '../mixins/autosave';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
noteEditedText,
|
|
|
|
noteAwardsList,
|
|
|
|
noteAttachment,
|
|
|
|
noteForm,
|
|
|
|
},
|
|
|
|
mixins: [autosave],
|
|
|
|
props: {
|
|
|
|
note: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
canEdit: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
isEditing: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
noteBody() {
|
|
|
|
return this.note.note;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.renderGFM();
|
|
|
|
this.initTaskList();
|
|
|
|
|
|
|
|
if (this.isEditing) {
|
|
|
|
this.initAutoSave(this.note.noteable_type);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
updated() {
|
|
|
|
this.initTaskList();
|
|
|
|
this.renderGFM();
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
if (this.isEditing) {
|
|
|
|
if (!this.autosave) {
|
2018-03-27 19:54:05 +05:30
|
|
|
this.initAutoSave(this.note.noteable_type);
|
2018-05-09 12:01:36 +05:30
|
|
|
} else {
|
|
|
|
this.setAutoSave();
|
2018-03-17 18:26:18 +05:30
|
|
|
}
|
2018-05-09 12:01:36 +05:30
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
renderGFM() {
|
|
|
|
$(this.$refs['note-body']).renderGFM();
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
initTaskList() {
|
|
|
|
if (this.canEdit) {
|
|
|
|
this.taskList = new TaskList({
|
|
|
|
dataType: 'note',
|
|
|
|
fieldName: 'note',
|
|
|
|
selector: '.notes',
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
}
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
handleFormUpdate(note, parentElement, callback) {
|
|
|
|
this.$emit('handleFormUpdate', note, parentElement, callback);
|
|
|
|
},
|
|
|
|
formCancelHandler(shouldConfirm, isDirty) {
|
|
|
|
this.$emit('cancelFormEdition', shouldConfirm, isDirty);
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
};
|
2018-03-17 18:26:18 +05:30
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
:class="{ 'js-task-list-container': canEdit }"
|
|
|
|
ref="note-body"
|
|
|
|
class="note-body">
|
|
|
|
<div
|
|
|
|
v-html="note.note_html"
|
|
|
|
class="note-text md"></div>
|
|
|
|
<note-form
|
|
|
|
v-if="isEditing"
|
|
|
|
ref="noteForm"
|
|
|
|
@handleFormUpdate="handleFormUpdate"
|
|
|
|
@cancelFormEdition="formCancelHandler"
|
|
|
|
:is-editing="isEditing"
|
|
|
|
:note-body="noteBody"
|
|
|
|
:note-id="note.id"
|
|
|
|
/>
|
|
|
|
<textarea
|
|
|
|
v-if="canEdit"
|
|
|
|
v-model="note.note"
|
|
|
|
:data-update-url="note.path"
|
|
|
|
class="hidden js-task-list-field"></textarea>
|
|
|
|
<note-edited-text
|
|
|
|
v-if="note.last_edited_at"
|
|
|
|
:edited-at="note.last_edited_at"
|
|
|
|
:edited-by="note.last_edited_by"
|
|
|
|
action-text="Edited"
|
|
|
|
/>
|
|
|
|
<note-awards-list
|
|
|
|
v-if="note.award_emoji.length"
|
|
|
|
:note-id="note.id"
|
|
|
|
:note-author-id="note.author.id"
|
|
|
|
:awards="note.award_emoji"
|
|
|
|
:toggle-award-path="note.toggle_award_path"
|
2018-05-09 12:01:36 +05:30
|
|
|
:can-award-emoji="note.current_user.can_award_emoji"
|
2018-03-17 18:26:18 +05:30
|
|
|
/>
|
|
|
|
<note-attachment
|
|
|
|
v-if="note.attachment"
|
|
|
|
:attachment="note.attachment"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|