summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-06-07 09:44:01 +0100
committerPhil Hughes <me@iamphill.com>2016-06-14 08:36:07 +0100
commitf67b06ada016915211e84a7d12a063aa25e422f3 (patch)
tree25b94f817c9971c5e347530cce1732f34ffd80f7 /app/assets
parentf34af6b83cc2663bb8a076f4df9c82047e5511ab (diff)
downloadgitlab-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')
-rw-r--r--app/assets/javascripts/right_sidebar.js.coffee41
-rw-r--r--app/assets/stylesheets/pages/issuable.scss12
2 files changed, 45 insertions, 8 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}")
-
-
diff --git a/app/assets/stylesheets/pages/issuable.scss b/app/assets/stylesheets/pages/issuable.scss
index ea453ce356a..acbb7e7f713 100644
--- a/app/assets/stylesheets/pages/issuable.scss
+++ b/app/assets/stylesheets/pages/issuable.scss
@@ -34,6 +34,10 @@
color: inherit;
}
+ .issuable-header-text {
+ margin-top: 7px;
+ }
+
.block {
@include clearfix;
padding: $gl-padding 0;
@@ -60,10 +64,6 @@
margin-top: 0;
}
- .issuable-count {
- margin-top: 7px;
- }
-
.gutter-toggle {
margin-left: 20px;
padding-left: 10px;
@@ -250,7 +250,7 @@
}
}
- .issuable-pager {
+ .issuable-header-btn {
background: $gray-normal;
border: 1px solid $border-gray-normal;
&:hover {
@@ -263,7 +263,7 @@
}
}
- a:not(.issuable-pager) {
+ a:not(.issuable-header-btn) {
&:hover {
color: $md-link-color;
text-decoration: none;