Commit 97d17cf835ebe5121330a3775ae58bcab792851e
1 parent
b255c3c4
Exists in
master
and in
4 other branches
Event filters stores at cookies.
Showing
6 changed files
with
56 additions
and
11 deletions
Show diff stats
@@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
1 | +/** | ||
2 | + * Init dashboard page | ||
3 | + * | ||
4 | + */ | ||
5 | +function dashboardPage(){ | ||
6 | + $(".event_filter_link").bind('click',(function(){ | ||
7 | + enableFilter(this.id); | ||
8 | + })); | ||
9 | +} | ||
10 | + | ||
11 | +function enableFilter(sender_id){ | ||
12 | + var event_filters = $.cookie('event_filter'); | ||
13 | + var filter = sender_id.split('_')[0]; | ||
14 | + if (!event_filters) { | ||
15 | + event_filters = new Array(); | ||
16 | + } else { | ||
17 | + event_filters = event_filters.split(','); | ||
18 | + } | ||
19 | + var index = event_filters.indexOf(filter); | ||
20 | + if (index == -1) { | ||
21 | + event_filters.push(filter); | ||
22 | + } else { | ||
23 | + event_filters.splice(index, 1); | ||
24 | + } | ||
25 | + $.cookie('event_filter', event_filters.join(',')); | ||
26 | +}; | ||
27 | + |
app/controllers/dashboard_controller.rb
@@ -60,6 +60,7 @@ class DashboardController < ApplicationController | @@ -60,6 +60,7 @@ class DashboardController < ApplicationController | ||
60 | end | 60 | end |
61 | 61 | ||
62 | def event_filter | 62 | def event_filter |
63 | - @event_filter ||= EventFilter.new(params[:event_filter]) | 63 | + filters = cookies['event_filter'].split(',') if cookies['event_filter'] |
64 | + @event_filter ||= EventFilter.new(filters) | ||
64 | end | 65 | end |
65 | end | 66 | end |
app/helpers/events_helper.rb
@@ -22,9 +22,6 @@ module EventsHelper | @@ -22,9 +22,6 @@ module EventsHelper | ||
22 | 22 | ||
23 | def event_filter_link key, tooltip | 23 | def event_filter_link key, tooltip |
24 | key = key.to_s | 24 | key = key.to_s |
25 | - | ||
26 | - filter = @event_filter.options key | ||
27 | - | ||
28 | inactive = if @event_filter.active? key | 25 | inactive = if @event_filter.active? key |
29 | nil | 26 | nil |
30 | else | 27 | else |
@@ -32,7 +29,7 @@ module EventsHelper | @@ -32,7 +29,7 @@ module EventsHelper | ||
32 | end | 29 | end |
33 | 30 | ||
34 | content_tag :div, class: "filter_icon #{inactive}" do | 31 | content_tag :div, class: "filter_icon #{inactive}" do |
35 | - link_to dashboard_path(event_filter: filter), class: 'has_tooltip', id: "#{key}_event_filter", 'data-original-title' => tooltip do | 32 | + link_to dashboard_path, class: 'has_tooltip event_filter_link', id: "#{key}_event_filter", 'data-original-title' => tooltip do |
36 | image_tag "event_filter_#{key}.png" | 33 | image_tag "event_filter_#{key}.png" |
37 | end | 34 | end |
38 | end | 35 | end |
app/views/dashboard/index.html.haml
features/dashboard/event_filters.feature
@@ -12,20 +12,39 @@ Feature: Event filters | @@ -12,20 +12,39 @@ Feature: Event filters | ||
12 | And I should see new member event | 12 | And I should see new member event |
13 | And I should see merge request event | 13 | And I should see merge request event |
14 | 14 | ||
15 | + @javascript | ||
15 | Scenario: I should see only pushed events | 16 | Scenario: I should see only pushed events |
16 | When I click "push" event filter | 17 | When I click "push" event filter |
17 | Then I should see push event | 18 | Then I should see push event |
18 | And I should not see new member event | 19 | And I should not see new member event |
19 | And I should not see merge request event | 20 | And I should not see merge request event |
20 | 21 | ||
22 | + @javascript | ||
21 | Scenario: I should see only joined events | 23 | Scenario: I should see only joined events |
22 | When I click "team" event filter | 24 | When I click "team" event filter |
23 | Then I should see new member event | 25 | Then I should see new member event |
24 | And I should not see push event | 26 | And I should not see push event |
25 | And I should not see merge request event | 27 | And I should not see merge request event |
26 | 28 | ||
29 | + @javascript | ||
27 | Scenario: I should see only merged events | 30 | Scenario: I should see only merged events |
28 | When I click "merge" event filter | 31 | When I click "merge" event filter |
29 | Then I should see merge request event | 32 | Then I should see merge request event |
30 | And I should not see push event | 33 | And I should not see push event |
31 | And I should not see new member event | 34 | And I should not see new member event |
35 | + | ||
36 | + @javascript | ||
37 | + Scenario: I should see only selected events while page reloaded | ||
38 | + When I click "push" event filter | ||
39 | + And I visit dashboard page | ||
40 | + Then I should see push event | ||
41 | + And I should not see new member event | ||
42 | + When I click "team" event filter | ||
43 | + And I visit dashboard page | ||
44 | + Then I should see push event | ||
45 | + And I should see new member event | ||
46 | + And I should not see merge request event | ||
47 | + When I click "push" event | ||
48 | + Then I should not see push event | ||
49 | + And I should see new member event | ||
50 | + And I should not see merge request event |
features/steps/dashboard/dashboard_event_filters.rb
@@ -4,27 +4,27 @@ class EventFilters < Spinach::FeatureSteps | @@ -4,27 +4,27 @@ class EventFilters < Spinach::FeatureSteps | ||
4 | include SharedProject | 4 | include SharedProject |
5 | 5 | ||
6 | Then 'I should see push event' do | 6 | Then 'I should see push event' do |
7 | - page.has_selector?('span.pushed').should be_true | 7 | + page.should have_selector('span.pushed') |
8 | end | 8 | end |
9 | 9 | ||
10 | Then 'I should not see push event' do | 10 | Then 'I should not see push event' do |
11 | - page.has_selector?('span.pushed').should be_false | 11 | + page.should_not have_selector('span.pushed') |
12 | end | 12 | end |
13 | 13 | ||
14 | Then 'I should see new member event' do | 14 | Then 'I should see new member event' do |
15 | - page.has_selector?('span.joined').should be_true | 15 | + page.should have_selector('span.joined') |
16 | end | 16 | end |
17 | 17 | ||
18 | And 'I should not see new member event' do | 18 | And 'I should not see new member event' do |
19 | - page.has_selector?('span.joined').should be_false | 19 | + page.should_not have_selector('span.joined') |
20 | end | 20 | end |
21 | 21 | ||
22 | Then 'I should see merge request event' do | 22 | Then 'I should see merge request event' do |
23 | - page.has_selector?('span.merged').should be_true | 23 | + page.should have_selector('span.merged') |
24 | end | 24 | end |
25 | 25 | ||
26 | And 'I should not see merge request event' do | 26 | And 'I should not see merge request event' do |
27 | - page.has_selector?('span.merged').should be_false | 27 | + page.should_not have_selector('span.merged') |
28 | end | 28 | end |
29 | 29 | ||
30 | And 'this project has push event' do | 30 | And 'this project has push event' do |