diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-04-30 00:00:30 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-05-06 19:58:27 +0300 |
commit | ce29e5cd8f09212afd3274326917c364272a6e39 (patch) | |
tree | d1ebc66e36295916867d58ede3648df89950fda6 | |
parent | 922497560eb7d619a6064d7b1d44c831ccd64ea9 (diff) |
Update task list behavior for Merge Requests
-rw-r--r-- | app/assets/javascripts/merge_request.js.coffee | 27 | ||||
-rw-r--r-- | app/views/projects/merge_requests/show/_context.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/merge_requests/show/_mr_box.html.haml | 4 |
3 files changed, 27 insertions, 6 deletions
diff --git a/app/assets/javascripts/merge_request.js.coffee b/app/assets/javascripts/merge_request.js.coffee index ae5d088d593..c8affba5b29 100644 --- a/app/assets/javascripts/merge_request.js.coffee +++ b/app/assets/javascripts/merge_request.js.coffee @@ -17,8 +17,11 @@ class @MergeRequest disableButtonIfEmptyField '#commit_message', '.accept_merge_request' + # Prevent duplicate event bindings + @disableTaskList() + if $("a.btn-close").length - $("li.task-list-item input:checkbox").prop("disabled", false) + @initTaskList() $('.merge-request-details').waitForImages -> $('.issuable-affix').affix offset: @@ -77,9 +80,6 @@ class @MergeRequest this.$('.remove_source_branch_in_progress').hide() this.$('.remove_source_branch_widget.failed').show() - $('.task-list-item input:checkbox').off('change') - $('.task-list-item input:checkbox').change('merge_request', updateTaskState) - activateTab: (action) -> this.$('.merge-request-tabs li').removeClass 'active' this.$('.tab-content').hide() @@ -156,3 +156,22 @@ class @MergeRequest else setTimeout(merge_request.mergeInProgress, 3000) dataType: 'json' + + initTaskList: -> + $('.merge-request-details .js-task-list-container').taskList('enable') + $(document).on 'tasklist:changed', '.merge-request-details .js-task-list-container', @updateTaskList + + disableTaskList: -> + $('.merge-request-details .js-task-list-container').taskList('disable') + $(document).off 'tasklist:changed', '.merge-request-details .js-task-list-container' + + # TODO (rspeicher): Make the merge request description inline-editable like a + # note so that we can re-use its form here + updateTaskList: -> + patchData = {} + patchData['merge_request'] = {'description': $('.js-task-list-field', this).val()} + + $.ajax + type: 'PATCH' + url: $('form.js-merge-request-update').attr('action') + data: patchData diff --git a/app/views/projects/merge_requests/show/_context.html.haml b/app/views/projects/merge_requests/show/_context.html.haml index eb80391ebcd..7b9ad15a84a 100644 --- a/app/views/projects/merge_requests/show/_context.html.haml +++ b/app/views/projects/merge_requests/show/_context.html.haml @@ -1,4 +1,4 @@ -= form_for [@project.namespace.becomes(Namespace), @project, @merge_request], remote: true, html: {class: 'edit-merge_request inline-update'} do |f| += form_for [@project.namespace.becomes(Namespace), @project, @merge_request], remote: true, html: {class: 'edit-merge_request inline-update js-merge-request-update'} do |f| %div.prepend-top-20 .issuable-context-title %label diff --git a/app/views/projects/merge_requests/show/_mr_box.html.haml b/app/views/projects/merge_requests/show/_mr_box.html.haml index ada9ae58b8f..80cfeb1c88c 100644 --- a/app/views/projects/merge_requests/show/_mr_box.html.haml +++ b/app/views/projects/merge_requests/show/_mr_box.html.haml @@ -3,7 +3,9 @@ %div - if @merge_request.description.present? - .description + .description.js-task-list-container .wiki = preserve do = markdown(@merge_request.description, parse_tasks: true) + %textarea.hidden.js-task-list-field + = @merge_request.description |