summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-03-17 12:54:02 +0000
committerPhil Hughes <me@iamphill.com>2016-03-17 12:54:02 +0000
commit421215e3385860af42530895c22021c0704275e2 (patch)
tree1da835043cf34e61729a6660829cf8a513e052c6
parent8f8720209f1f325042cbe3f134797c85cc0c64c4 (diff)
downloadgitlab-ce-421215e3385860af42530895c22021c0704275e2.tar.gz
Removed the flash success message
Removes the group if empty
-rw-r--r--app/assets/javascripts/todos.js.coffee52
-rw-r--r--app/assets/stylesheets/framework/buttons.scss10
-rw-r--r--app/assets/stylesheets/framework/flash.scss6
-rw-r--r--app/controllers/dashboard/todos_controller.rb4
-rw-r--r--app/views/dashboard/todos/_todo.html.haml4
5 files changed, 35 insertions, 41 deletions
diff --git a/app/assets/javascripts/todos.js.coffee b/app/assets/javascripts/todos.js.coffee
index 811652c8d8b..951b786b1fd 100644
--- a/app/assets/javascripts/todos.js.coffee
+++ b/app/assets/javascripts/todos.js.coffee
@@ -1,47 +1,35 @@
class @Todos
- _this = null;
constructor: (@name) ->
- _this = @
+ @clearListeners()
@initBtnListeners()
-
+
+ clearListeners: ->
+ $('.done-todo').off('click')
+
initBtnListeners: ->
$('.done-todo').on('click', @doneClicked)
-
- doneClicked: (e) ->
- $this = $(this)
- doneURL = $this.attr('href')
+
+ doneClicked: (e) =>
e.preventDefault()
e.stopImmediatePropagation()
- $spinner = $('<i></i>').addClass('fa fa-spinner fa-spin')
- $this.addClass("disabled")
- $this.append($spinner)
+
+ $this = $(e.currentTarget)
+ $this.disable()
+
$.ajax
type: 'POST'
- url: doneURL
+ url: $this.attr('href')
dataType: 'json'
data: '_method': 'delete'
- error: (data, textStatus, jqXHR) ->
- new Flash('Unable to update your todos.', 'alert')
- _this.clearDone($this.closest('li'))
- return
-
- success: (data, textStatus, jqXHR) ->
- _this.clearDone($this.closest('li'))
- return
+ success: (data) =>
+ @clearDone $this.closest('li'), data
- clearDone: ($row) ->
+ clearDone: ($row, data) ->
$ul = $row.closest('ul')
$row.remove()
+
+ $('.todos-pending .badge, .todos-pending-count').text data.count
+ $('.todos-done .badge').text data.done_count
+
if not $ul.find('li').length
- Turbolinks.visit(location.href)
- else
- $pendingBadge = $('.todos-pending .badge')
- $pendingBadge.text parseInt($pendingBadge.text()) - 1
-
- $doneBadge = $('.todos-done .badge')
- $doneBadge.text parseInt($doneBadge.text()) + 1
-
- $mainTodosPendingBadge = $('.todos-pending-count')
- $mainTodosPendingBadge.text parseInt($mainTodosPendingBadge.text()) - 1
- return
- \ No newline at end of file
+ $ul.parents('.panel').remove()
diff --git a/app/assets/stylesheets/framework/buttons.scss b/app/assets/stylesheets/framework/buttons.scss
index fa115a4bf56..657c5f033c7 100644
--- a/app/assets/stylesheets/framework/buttons.scss
+++ b/app/assets/stylesheets/framework/buttons.scss
@@ -208,3 +208,13 @@
background-color: #e4e7ed !important;
}
}
+
+.btn-loading {
+ &:not(.disabled) .fa {
+ display: none;
+ }
+
+ .fa {
+ margin-right: 5px;
+ }
+}
diff --git a/app/assets/stylesheets/framework/flash.scss b/app/assets/stylesheets/framework/flash.scss
index 244d0e2f0c8..1bfd0213995 100644
--- a/app/assets/stylesheets/framework/flash.scss
+++ b/app/assets/stylesheets/framework/flash.scss
@@ -5,12 +5,6 @@
width: 100%;
z-index: 100;
- .flash-success {
- @extend .alert;
- @extend .alert-success;
- margin: 0;
- }
-
.flash-notice {
@extend .alert;
@extend .alert-info;
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb
index 54f718d0110..10120dfdf3b 100644
--- a/app/controllers/dashboard/todos_controller.rb
+++ b/app/controllers/dashboard/todos_controller.rb
@@ -1,5 +1,5 @@
class Dashboard::TodosController < Dashboard::ApplicationController
- before_action :find_todos, only: [:index, :destroy_all]
+ before_action :find_todos, only: [:index, :destroy, :destroy_all]
def index
@todos = @todos.page(params[:page]).per(PER_PAGE)
@@ -14,7 +14,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
format.html { redirect_to dashboard_todos_path, notice: todo_notice }
format.js { render nothing: true }
format.json do
- render json: { status: 'OK', notice: todo_notice }
+ render json: { count: @todos.size, done_count: current_user.todos.done.count }
end
end
end
diff --git a/app/views/dashboard/todos/_todo.html.haml b/app/views/dashboard/todos/_todo.html.haml
index b7deb9da543..42f3cf4de02 100644
--- a/app/views/dashboard/todos/_todo.html.haml
+++ b/app/views/dashboard/todos/_todo.html.haml
@@ -16,7 +16,9 @@
- if todo.pending?
.todo-actions.pull-right
- = link_to 'Done', [:dashboard, todo], method: :delete, class: 'btn done-todo'
+ = link_to [:dashboard, todo], method: :delete, class: 'btn btn-loading done-todo' do
+ = icon('spinner spin')
+ Done
.todo-body
.todo-note