From 51031a68f76b23b8936bf674d9bc65491b207ebe Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Date: Wed, 30 Mar 2016 09:17:03 -0500 Subject: [PATCH 1/3] Make entire todo row clickable --- app/assets/javascripts/todos.js.coffee | 5 +++++ app/assets/stylesheets/pages/todos.scss | 6 ++++++ app/views/dashboard/todos/_todo.html.haml | 2 +- features/dashboard/todos.feature | 5 +++++ features/steps/dashboard/todos.rb | 8 ++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/todos.js.coffee b/app/assets/javascripts/todos.js.coffee index b6b4bd90e6..b815ac4124 100644 --- a/app/assets/javascripts/todos.js.coffee +++ b/app/assets/javascripts/todos.js.coffee @@ -10,6 +10,7 @@ class @Todos initBtnListeners: -> $('.done-todo').on('click', @doneClicked) $('.js-todos-mark-all').on('click', @allDoneClicked) + $('.todo').on('click', @goToTodoUrl) doneClicked: (e) => e.preventDefault() @@ -54,3 +55,7 @@ class @Todos updateBadges: (data) -> $('.todos-pending .badge, .todos-pending-count').text data.count $('.todos-done .badge').text data.done_count + + goToTodoUrl: (e) -> + $this = $(e.currentTarget) + window.location.href = $this.data('url') diff --git a/app/assets/stylesheets/pages/todos.scss b/app/assets/stylesheets/pages/todos.scss index f983e9829e..e909e15f74 100644 --- a/app/assets/stylesheets/pages/todos.scss +++ b/app/assets/stylesheets/pages/todos.scss @@ -13,6 +13,12 @@ } } +.todo { + &:hover { + cursor: pointer; + } +} + .todo-item { .todo-title { @include str-truncated(calc(100% - 174px)); diff --git a/app/views/dashboard/todos/_todo.html.haml b/app/views/dashboard/todos/_todo.html.haml index e3a4d64df0..25d2b64e38 100644 --- a/app/views/dashboard/todos/_todo.html.haml +++ b/app/views/dashboard/todos/_todo.html.haml @@ -1,4 +1,4 @@ -%li{class: "todo todo-#{todo.done? ? 'done' : 'pending'}", id: dom_id(todo) } +%li{class: "todo todo-#{todo.done? ? 'done' : 'pending'}", id: dom_id(todo), data:{url: todo_target_path(todo)} } .todo-item.todo-block = image_tag avatar_icon(todo.author_email, 40), class: 'avatar s40', alt:'' diff --git a/features/dashboard/todos.feature b/features/dashboard/todos.feature index 1e7b1b50d6..8677b45081 100644 --- a/features/dashboard/todos.feature +++ b/features/dashboard/todos.feature @@ -36,3 +36,8 @@ Feature: Dashboard Todos Scenario: I filter by action Given I filter by "Mentioned" Then I should not see todos related to "Assignments" in the list + + @javascript + Scenario: I click on a todo row + Given I click on the todo + Then I should be directed to the corresponding page diff --git a/features/steps/dashboard/todos.rb b/features/steps/dashboard/todos.rb index 963e4f2136..5c30d8e0c7 100644 --- a/features/steps/dashboard/todos.rb +++ b/features/steps/dashboard/todos.rb @@ -88,6 +88,14 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps should_not_see_todo "John Doe assigned you issue ##{issue.iid}" end + step 'I click on the todo' do + execute_script("$('.todo:nth-child(1)').click()") + end + + step 'I should be directed to the corresponding page' do + page.should have_css('.identifier', text: 'Merge Request !1') + end + def should_see_todo(position, title, body, pending = true) page.within(".todo:nth-child(#{position})") do expect(page).to have_content title From 0591a7820beaa8e710e9239e7a455eba529797c6 Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Date: Wed, 30 Mar 2016 11:34:33 -0500 Subject: [PATCH 2/3] Change window.location to use turbolinks --- app/assets/javascripts/todos.js.coffee | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/todos.js.coffee b/app/assets/javascripts/todos.js.coffee index b815ac4124..064fac4fbd 100644 --- a/app/assets/javascripts/todos.js.coffee +++ b/app/assets/javascripts/todos.js.coffee @@ -56,6 +56,5 @@ class @Todos $('.todos-pending .badge, .todos-pending-count').text data.count $('.todos-done .badge').text data.done_count - goToTodoUrl: (e) -> - $this = $(e.currentTarget) - window.location.href = $this.data('url') + goToTodoUrl: -> + Turbolinks.visit($(this).data('url')) From f79687ea9763a7c7f5ade988ed76b0128de9098e Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Date: Wed, 30 Mar 2016 12:28:36 -0500 Subject: [PATCH 3/3] Clear .todo listener --- app/assets/javascripts/todos.js.coffee | 1 + features/steps/dashboard/todos.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/todos.js.coffee b/app/assets/javascripts/todos.js.coffee index 064fac4fbd..ec2df6c5b7 100644 --- a/app/assets/javascripts/todos.js.coffee +++ b/app/assets/javascripts/todos.js.coffee @@ -6,6 +6,7 @@ class @Todos clearListeners: -> $('.done-todo').off('click') $('.js-todos-mark-all').off('click') + $('.todo').off('click') initBtnListeners: -> $('.done-todo').on('click', @doneClicked) diff --git a/features/steps/dashboard/todos.rb b/features/steps/dashboard/todos.rb index 5c30d8e0c7..30b21b93ac 100644 --- a/features/steps/dashboard/todos.rb +++ b/features/steps/dashboard/todos.rb @@ -89,7 +89,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps end step 'I click on the todo' do - execute_script("$('.todo:nth-child(1)').click()") + find('.todo:nth-child(1)').click end step 'I should be directed to the corresponding page' do