diff options
author | Phil Hughes <me@iamphill.com> | 2016-06-07 09:44:01 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-06-14 08:36:07 +0100 |
commit | f67b06ada016915211e84a7d12a063aa25e422f3 (patch) | |
tree | 25b94f817c9971c5e347530cce1732f34ffd80f7 /app/assets/javascripts/right_sidebar.js.coffee | |
parent | f34af6b83cc2663bb8a076f4df9c82047e5511ab (diff) | |
download | gitlab-ce-f67b06ada016915211e84a7d12a063aa25e422f3.tar.gz |
Manually create todo for issuable
Added a button into the sidebar for issues & merge requests to allow users to manually create todo items
Closes #15045
Diffstat (limited to 'app/assets/javascripts/right_sidebar.js.coffee')
-rw-r--r-- | app/assets/javascripts/right_sidebar.js.coffee | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/app/assets/javascripts/right_sidebar.js.coffee b/app/assets/javascripts/right_sidebar.js.coffee index c9cb0f4bb32..3ee943fe78c 100644 --- a/app/assets/javascripts/right_sidebar.js.coffee +++ b/app/assets/javascripts/right_sidebar.js.coffee @@ -43,6 +43,45 @@ class @Sidebar $('.right-sidebar') .hasClass('right-sidebar-collapsed'), { path: '/' }) + $(document) + .off 'click', '.js-issuable-todo' + .on 'click', '.js-issuable-todo', @toggleTodo + + toggleTodo: (e) -> + $this = $(@) + $btnText = $this.find('span') + data = { + todo_id: $this.attr('data-id') + } + + $.ajax( + url: $this.data('url') + type: 'POST' + dataType: 'json' + data: data + beforeSend: -> + $this.disable() + $('.js-issuable-todo-loading').removeClass 'hidden' + ).done (data) -> + $todoPendingCount = $('.todos-pending-count') + $todoPendingCount.text data.count + + $this.enable() + $('.js-issuable-todo-loading').addClass 'hidden' + + if data.count is 0 + $this.removeAttr 'data-id' + $btnText.text $this.data('todo-text') + + $todoPendingCount + .addClass 'hidden' + else + $btnText.text $this.data('mark-text') + $todoPendingCount + .removeClass 'hidden' + + if data.todo? + $this.attr 'data-id', data.todo.id sidebarDropdownLoading: (e) -> $sidebarCollapsedIcon = $(@).closest('.block').find('.sidebar-collapsed-icon') @@ -117,5 +156,3 @@ class @Sidebar getBlock: (name) -> @sidebar.find(".block.#{name}") - - |