diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-04-29 23:47:31 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-05-06 19:58:27 +0300 |
commit | a3d55db91053955a36c6a48c9ad596752a3aba40 (patch) | |
tree | 9669df0e2d0ba30623dbbca8af39712c75af9686 | |
parent | 18baf550e1ecfd0a8cd356490c3cae4e4566fb8f (diff) |
Update task list behavior for Issues
-rw-r--r-- | app/assets/javascripts/issue.js.coffee | 27 | ||||
-rw-r--r-- | app/views/projects/issues/_issue_context.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/issues/show.html.haml | 4 |
3 files changed, 27 insertions, 6 deletions
diff --git a/app/assets/javascripts/issue.js.coffee b/app/assets/javascripts/issue.js.coffee index 4e2e6550eb2..63d38594d28 100644 --- a/app/assets/javascripts/issue.js.coffee +++ b/app/assets/javascripts/issue.js.coffee @@ -6,11 +6,11 @@ class @Issue $(".context .inline-update").on "change", "#issue_assignee_id", -> $(this).submit() - if $("a.btn-close").length - $("li.task-list-item input:checkbox").prop("disabled", false) + # Prevent duplicate event bindings + @disableTaskList() - $('.task-list-item input:checkbox').off('change') - $('.task-list-item input:checkbox').change('issue', updateTaskState) + if $("a.btn-close").length + @initTaskList() $('.issue-details').waitForImages -> $('.issuable-affix').affix offset: @@ -22,3 +22,22 @@ class @Issue $(@).width($(@).outerWidth()) .on 'affixed-top.bs.affix affixed-bottom.bs.affix', -> $(@).width('') + + initTaskList: -> + $('.issue-details .js-task-list-container').taskList('enable') + $(document).on 'tasklist:changed', '.issue-details .js-task-list-container', @updateTaskList + + disableTaskList: -> + $('.issue-details .js-task-list-container').taskList('disable') + $(document).off 'tasklist:changed', '.issue-details .js-task-list-container' + + # TODO (rspeicher): Make the issue description inline-editable like a note so + # that we can re-use its form here + updateTaskList: -> + patchData = {} + patchData['issue'] = {'description': $('.js-task-list-field', this).val()} + + $.ajax + type: 'PATCH' + url: $('form.js-issue-update').attr('action') + data: patchData diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml index 7cadb9983fa..323f5c84a85 100644 --- a/app/views/projects/issues/_issue_context.html.haml +++ b/app/views/projects/issues/_issue_context.html.haml @@ -1,4 +1,4 @@ -= form_for [@project.namespace.becomes(Namespace), @project, @issue], remote: true, html: {class: 'edit-issue inline-update'} do |f| += form_for [@project.namespace.becomes(Namespace), @project, @issue], remote: true, html: {class: 'edit-issue inline-update js-issue-update'} do |f| %div.prepend-top-20 .issuable-context-title %label diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index 81478dfe568..2d248c15f4f 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -31,10 +31,12 @@ = gfm escape_once(@issue.title) %div - if @issue.description.present? - .description + .description.js-task-list-container .wiki = preserve do = markdown(@issue.description, parse_tasks: true) + %textarea.hidden.js-task-list-field + = @issue.description %hr .issue-discussion |