BigW Consortium Gitlab

issue.js.coffee 903 Bytes
Newer Older
1
#= require jquery.waitforimages
2
#= require task_list
3

4
class @Issue
5
  constructor: ->
6 7
    # Prevent duplicate event bindings
    @disableTaskList()
8

9 10
    if $("a.btn-close").length
      @initTaskList()
11

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  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'
28
      url: $('form.js-issuable-update').attr('action')
29
      data: patchData