BigW Consortium Gitlab

Move CommentTypeToggle use from gl_form to notes

parent 5e3fa025
......@@ -3,8 +3,6 @@
/* global DropzoneInput */
/* global autosize */
import CommentTypeToggle from './comment_type_toggle';
window.gl = window.gl || {};
function GLForm(form) {
......@@ -43,20 +41,6 @@ GLForm.prototype.setupForm = function() {
this.form.find('.js-note-discard').hide();
this.form.show();
if (this.isAutosizeable) this.setupAutosize();
this.initCommentTypeToggle();
};
GLForm.prototype.initCommentTypeToggle = function () {
this.commentTypeToggle = new CommentTypeToggle(
this.form[0].querySelector('.js-comment-type-dropdown .dropdown-toggle'),
this.form[0].querySelector('.js-comment-type-dropdown .dropdown-menu'),
document.getElementById('note_type'),
this.form[0].querySelector('.js-comment-type-dropdown .js-comment-submit-button'),
document.querySelector('.js-note-target-close'),
);
this.commentTypeToggle.initDroplab();
};
GLForm.prototype.setupAutosize = function () {
......
......@@ -5,6 +5,7 @@
/* global mrRefreshWidgetUrl */
import Cookies from 'js-cookie';
import CommentTypeToggle from './comment_type_toggle';
require('./autosave');
window.autosize = require('vendor/autosize');
......@@ -137,6 +138,18 @@ require('./task_list');
$(document).off("click", '.system-note-commit-list-toggler');
};
Notes.prototype.initCommentTypeToggle = function (form) {
this.commentTypeToggle = new CommentTypeToggle(
form[0].querySelector('.js-comment-type-dropdown .dropdown-toggle'),
form[0].querySelector('.js-comment-type-dropdown .dropdown-menu'),
document.getElementById('note_type'),
form[0].querySelector('.js-comment-type-dropdown .js-comment-submit-button'),
document.querySelector('.js-note-target-close'),
);
this.commentTypeToggle.initDroplab();
};
Notes.prototype.keydownNoteText = function(e) {
var $textarea, discussionNoteForm, editNote, myLastNote, myLastNoteEditBtn, newText, originalText;
if (gl.utils.isMetaKey(e)) {
......@@ -455,7 +468,9 @@ require('./task_list');
form.find("#note_type").val('');
form.find("#in_reply_to_discussion_id").remove();
form.find('.js-comment-resolve-button').closest('comment-and-resolve-btn').remove();
return this.parentTimeline = form.parents('.timeline');
this.parentTimeline = form.parents('.timeline');
this.initCommentTypeToggle(form);
};
/*
......
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