From 5200686bd980751d73738fdecd8232b682a7fcdc Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Thu, 6 Apr 2017 01:31:44 -0500 Subject: Disable submit button and dropdown when submitt comment form --- app/assets/javascripts/notes.js | 7 +++++++ app/views/projects/notes/_comment_type_button.html.haml | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 83c33cbe885..ee62ca2fbfb 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -112,10 +112,17 @@ require('./task_list'); // when issue status changes, we need to refresh data $(document).on("issuable:change", this.refresh); + $(document).on('submit', '.js-main-target-form', this.disableDropdown) + // when a key is clicked on the notes 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() { $(document).off("ajax:success", ".js-main-target-form"); $(document).off("ajax:success", ".js-discussion-note-form"); diff --git a/app/views/projects/notes/_comment_type_button.html.haml b/app/views/projects/notes/_comment_type_button.html.haml index 078b606eda8..2a851d57fd6 100644 --- a/app/views/projects/notes/_comment_type_button.html.haml +++ b/app/views/projects/notes/_comment_type_button.html.haml @@ -1,8 +1,7 @@ - noteable_type = @note.noteable_type .pull-left.btn-group.append-right-10.comment-type-dropdown.js-comment-type-dropdown - %button.btn.btn-nr.btn-create.comment-btn.js-comment-button.js-comment-submit-button - 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? = button_tag type: 'button', class: 'btn btn-nr dropdown-toggle comment-btn js-note-new-discussion', data: { 'dropdown-trigger' => '#resolvable-comment-menu' } do = icon('caret-down') -- cgit v1.2.1