From 391777173512eae74d7861fac2448bf9c379bcf8 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 15 Sep 2016 12:18:54 +0200 Subject: [PATCH] SONAR-7790 Improve issue comment modal UI --- .../main/js/components/issue/issue-view.js | 29 +++++++++------- .../issue/templates/DeleteComment.hbs | 6 ++++ .../issue/views/DeleteCommentView.js | 34 +++++++++++++++++++ 3 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 server/sonar-web/src/main/js/components/issue/templates/DeleteComment.hbs create mode 100644 server/sonar-web/src/main/js/components/issue/views/DeleteCommentView.js diff --git a/server/sonar-web/src/main/js/components/issue/issue-view.js b/server/sonar-web/src/main/js/components/issue/issue-view.js index b3ea2c3637c..8b0d7493d8a 100644 --- a/server/sonar-web/src/main/js/components/issue/issue-view.js +++ b/server/sonar-web/src/main/js/components/issue/issue-view.js @@ -26,6 +26,7 @@ import ChangeLogView from './views/changelog-view'; import TransitionsFormView from './views/transitions-form-view'; import AssignFormView from './views/assign-form-view'; import CommentFormView from './views/comment-form-view'; +import DeleteCommentView from './views/DeleteCommentView'; import SetSeverityFormView from './views/set-severity-form-view'; import SetTypeFormView from './views/set-type-form-view'; import TagsFormView from './views/tags-form-view'; @@ -144,18 +145,22 @@ export default Marionette.ItemView.extend({ }, deleteComment (e) { - const that = this; - const commentKey = $(e.target).closest('[data-comment-key]').data('comment-key'); - const confirmMsg = $(e.target).data('confirm-msg'); - if (confirm(confirmMsg)) { - this.disableControls(); - return $.ajax({ - type: 'POST', - url: window.baseUrl + '/api/issues/delete_comment?key=' + commentKey - }).done(function () { - that.updateAfterAction(true); - }); - } + e.stopPropagation(); + $('body').click(); + const commentEl = $(e.currentTarget).closest('.issue-comment'); + const commentKey = commentEl.data('comment-key'); + this.popup = new DeleteCommentView({ + triggerEl: $(e.currentTarget), + bottomRight: true, + onDelete: () => { + this.disableControls(); + $.ajax({ + type: 'POST', + url: window.baseUrl + '/api/issues/delete_comment?key=' + commentKey + }).done(() => this.updateAfterAction(true)); + } + }); + this.popup.render(); }, transition (e) { diff --git a/server/sonar-web/src/main/js/components/issue/templates/DeleteComment.hbs b/server/sonar-web/src/main/js/components/issue/templates/DeleteComment.hbs new file mode 100644 index 00000000000..939bf523509 --- /dev/null +++ b/server/sonar-web/src/main/js/components/issue/templates/DeleteComment.hbs @@ -0,0 +1,6 @@ +
+
{{t 'issue.comment.delete_confirm_message'}}
+ +
+ +
diff --git a/server/sonar-web/src/main/js/components/issue/views/DeleteCommentView.js b/server/sonar-web/src/main/js/components/issue/views/DeleteCommentView.js new file mode 100644 index 00000000000..e5aaaaa36fa --- /dev/null +++ b/server/sonar-web/src/main/js/components/issue/views/DeleteCommentView.js @@ -0,0 +1,34 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import PopupView from '../../common/popup'; +import Template from '../templates/DeleteComment.hbs'; + +export default PopupView.extend({ + template: Template, + + events: { + 'click button': 'handleSubmit' + }, + + handleSubmit (e) { + e.preventDefault(); + this.options.onDelete(); + } +}); -- 2.39.5