Commit 2a18425e authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

phil review changes

parent 75ac2699
...@@ -2,37 +2,37 @@ import DropLab from '@gitlab-org/droplab'; ...@@ -2,37 +2,37 @@ import DropLab from '@gitlab-org/droplab';
import InputSetter from '@gitlab-org/droplab/dist/plugins/InputSetter'; import InputSetter from '@gitlab-org/droplab/dist/plugins/InputSetter';
class CommentTypeToggle { class CommentTypeToggle {
constructor(trigger, list, input, button, secondaryButton) { constructor(dropdownTrigger, dropdownList, noteTypeInput, submitButton, closeButton) {
this.trigger = trigger; this.dropdownTrigger = dropdownTrigger;
this.list = list; this.dropdownList = dropdownList;
this.input = input; this.noteTypeInput = noteTypeInput;
this.button = button; this.submitButton = submitButton;
this.secondaryButton = secondaryButton; this.closeButton = closeButton;
} }
initDroplab() { initDroplab() {
this.droplab = new DropLab(); this.droplab = new DropLab();
const inputSetterConfig = [{ const inputSetterConfig = [{
input: this.input, input: this.noteTypeInput,
valueAttribute: 'data-value', valueAttribute: 'data-value',
}, },
{ {
input: this.button, input: this.submitButton,
valueAttribute: 'data-button-text', valueAttribute: 'data-button-text',
}]; }];
if (this.secondaryButton) { if (this.closeButton) {
inputSetterConfig.push({ inputSetterConfig.push({
input: this.secondaryButton, input: this.closeButton,
valueAttribute: 'data-secondary-button-text', valueAttribute: 'data-secondary-button-text',
}, { }, {
input: this.secondaryButton, input: this.closeButton,
valueAttribute: 'data-secondary-button-text', valueAttribute: 'data-secondary-button-text',
inputAttribute: 'data-alternative-text', inputAttribute: 'data-alternative-text',
}); });
} }
this.droplab.init(this.trigger, this.list, [InputSetter], { this.droplab.init(this.dropdownTrigger, this.dropdownList, [InputSetter], {
InputSetter: inputSetterConfig InputSetter: inputSetterConfig
}); });
} }
......
...@@ -29,10 +29,7 @@ GLForm.prototype.setupForm = function() { ...@@ -29,10 +29,7 @@ GLForm.prototype.setupForm = function() {
this.form.find('.div-dropzone').remove(); this.form.find('.div-dropzone').remove();
this.form.addClass('gfm-form'); this.form.addClass('gfm-form');
// remove notify commit author checkbox for non-commit notes // remove notify commit author checkbox for non-commit notes
gl.utils.disableButtonIfEmptyField(this.form.find('.js-note-text'), this.form.find('.js-comment-button')); gl.utils.disableButtonIfEmptyField(this.form.find('.js-note-text'), this.form.find('.js-comment-button, .js-note-new-discussion'));
const newDiscussionToggle = this.form.find('.js-note-new-discussion');
if (newDiscussionToggle) gl.utils.disableButtonIfEmptyField(this.form.find('.js-note-text'), newDiscussionToggle);
gl.GfmAutoComplete.setup(this.form.find('.js-gfm-input')); gl.GfmAutoComplete.setup(this.form.find('.js-gfm-input'));
new DropzoneInput(this.form); new DropzoneInput(this.form);
......
...@@ -279,7 +279,7 @@ $(function () { ...@@ -279,7 +279,7 @@ $(function () {
// Disable form buttons while a form is submitting // Disable form buttons while a form is submitting
$body.on('ajax:complete, ajax:beforeSend, submit', 'form', function (e) { $body.on('ajax:complete, ajax:beforeSend, submit', 'form', function (e) {
var buttons; var buttons;
buttons = $('[type="submit"]', this); buttons = $('[type="submit"], .js-disable-on-submit', this);
switch (e.type) { switch (e.type) {
case 'ajax:beforeSend': case 'ajax:beforeSend':
case 'submit': case 'submit':
......
...@@ -111,18 +111,10 @@ require('./task_list'); ...@@ -111,18 +111,10 @@ require('./task_list');
$(document).on("visibilitychange", this.visibilityChange); $(document).on("visibilitychange", this.visibilityChange);
// when issue status changes, we need to refresh data // when issue status changes, we need to refresh data
$(document).on("issuable:change", this.refresh); $(document).on("issuable:change", this.refresh);
$(document).on('submit', '.js-main-target-form', this.disableDropdown)
// when a key is clicked on the notes // when a key is clicked on the notes
return $(document).on("keydown", ".js-note-text", this.keydownNoteText); return $(document).on("keydown", ".js-note-text", this.keydownNoteText);
}; };
Notes.prototype.disableDropdown = function(e) {
const $form = $(e.target);
$form.find('.js-note-new-discussion').disable();
};
Notes.prototype.cleanBinding = function() { Notes.prototype.cleanBinding = function() {
$(document).off("ajax:success", ".js-main-target-form"); $(document).off("ajax:success", ".js-main-target-form");
$(document).off("ajax:success", ".js-discussion-note-form"); $(document).off("ajax:success", ".js-discussion-note-form");
...@@ -149,9 +141,9 @@ require('./task_list'); ...@@ -149,9 +141,9 @@ require('./task_list');
this.commentTypeToggle = new CommentTypeToggle( this.commentTypeToggle = new CommentTypeToggle(
form.querySelector('.js-comment-type-dropdown .dropdown-toggle'), form.querySelector('.js-comment-type-dropdown .dropdown-toggle'),
form.querySelector('.js-comment-type-dropdown .dropdown-menu'), form.querySelector('.js-comment-type-dropdown .dropdown-menu'),
document.querySelector('.js-main-target-form #note_type'), form.querySelector('#note_type'),
form.querySelector('.js-comment-type-dropdown .js-comment-submit-button'), form.querySelector('.js-comment-type-dropdown .js-comment-submit-button'),
document.querySelector('.js-main-target-form .js-note-target-close'), form.querySelector('.js-note-target-close'),
); );
this.commentTypeToggle.initDroplab(); this.commentTypeToggle.initDroplab();
......
...@@ -312,6 +312,8 @@ ...@@ -312,6 +312,8 @@
} }
.comment-type-dropdown { .comment-type-dropdown {
background: red;
.dropdown-toggle .fa { .dropdown-toggle .fa {
color: $white-light; color: $white-light;
padding-right: 2px; padding-right: 2px;
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
.pull-left.btn-group.append-right-10.comment-type-dropdown.js-comment-type-dropdown .pull-left.btn-group.append-right-10.comment-type-dropdown.js-comment-type-dropdown
%input.btn.btn-nr.btn-create.comment-btn.js-comment-button.js-comment-submit-button{ type: 'submit', value: 'Comment' } %input.btn.btn-nr.btn-create.comment-btn.js-comment-button.js-comment-submit-button{ type: 'submit', value: 'Comment' }
- if @note.can_be_discussion_note? - if @note.can_be_discussion_note?
= button_tag type: 'button', class: 'btn btn-nr dropdown-toggle comment-btn js-note-new-discussion', data: { 'dropdown-trigger' => '#resolvable-comment-menu' } do = button_tag type: 'button', class: 'btn btn-nr dropdown-toggle comment-btn js-note-new-discussion js-disable-on-submit', data: { 'dropdown-trigger' => '#resolvable-comment-menu' }, 'aria-label' => 'Open comment type dropdown' do
= icon('caret-down') = icon('caret-down')
%ul#resolvable-comment-menu.dropdown-menu{ data: { dropdown: true } } %ul#resolvable-comment-menu.dropdown-menu{ data: { dropdown: true } }
%li#comment{ data: { value: '', 'button-text' => 'Comment', 'secondary-button-text' => 'Comment & close merge request' }, class: 'droplab-item-selected' } %li#comment.droplab-item-selected{ data: { value: '', 'button-text' => 'Comment', 'secondary-button-text' => "Comment & close #{noteable_type.titleize.downcase}" } }
= icon('check') = icon('check')
.description .description
%strong Comment %strong Comment
......
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