diff options
Diffstat (limited to 'app/assets/javascripts/notes/components/note_body.vue')
-rw-r--r-- | app/assets/javascripts/notes/components/note_body.vue | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/app/assets/javascripts/notes/components/note_body.vue b/app/assets/javascripts/notes/components/note_body.vue index 358f49deb35..42b78929f8a 100644 --- a/app/assets/javascripts/notes/components/note_body.vue +++ b/app/assets/javascripts/notes/components/note_body.vue @@ -1,8 +1,7 @@ <script> -import { mapActions } from 'vuex'; +import { mapActions, mapGetters, mapState } from 'vuex'; import $ from 'jquery'; import '~/behaviors/markdown/render_gfm'; -import getDiscussion from 'ee_else_ce/notes/mixins/get_discussion'; import noteEditedText from './note_edited_text.vue'; import noteAwardsList from './note_awards_list.vue'; import noteAttachment from './note_attachment.vue'; @@ -18,7 +17,7 @@ export default { noteForm, Suggestions, }, - mixins: [autosave, getDiscussion], + mixins: [autosave], props: { note: { type: Object, @@ -45,6 +44,15 @@ export default { }, }, computed: { + ...mapGetters(['getDiscussion']), + discussion() { + if (!this.note.isDraft) return {}; + + return this.getDiscussion(this.note.discussion_id); + }, + ...mapState({ + batchSuggestionsInfo: state => state.notes.batchSuggestionsInfo, + }), noteBody() { return this.note.note; }, @@ -74,7 +82,12 @@ export default { } }, methods: { - ...mapActions(['submitSuggestion']), + ...mapActions([ + 'submitSuggestion', + 'submitSuggestionBatch', + 'addSuggestionInfoToBatch', + 'removeSuggestionInfoFromBatch', + ]), renderGFM() { $(this.$refs['note-body']).renderGFM(); }, @@ -91,6 +104,17 @@ export default { callback, ); }, + applySuggestionBatch({ flashContainer }) { + return this.submitSuggestionBatch({ flashContainer }); + }, + addSuggestionToBatch(suggestionId) { + const { discussion_id: discussionId, id: noteId } = this.note; + + this.addSuggestionInfoToBatch({ suggestionId, discussionId, noteId }); + }, + removeSuggestionFromBatch(suggestionId) { + this.removeSuggestionInfoFromBatch(suggestionId); + }, }, }; </script> @@ -100,10 +124,14 @@ export default { <suggestions v-if="hasSuggestion && !isEditing" :suggestions="note.suggestions" + :batch-suggestions-info="batchSuggestionsInfo" :note-html="note.note_html" :line-type="lineType" :help-page-path="helpPagePath" @apply="applySuggestion" + @applyBatch="applySuggestionBatch" + @addToBatch="addSuggestionToBatch" + @removeFromBatch="removeSuggestionFromBatch" /> <div v-else class="note-text md" v-html="note.note_html"></div> <note-form |