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 @@ |
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 | 60 | end |
61 | 61 | |
62 | 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 | 65 | end |
65 | 66 | end | ... | ... |
app/helpers/events_helper.rb
... | ... | @@ -22,9 +22,6 @@ module EventsHelper |
22 | 22 | |
23 | 23 | def event_filter_link key, tooltip |
24 | 24 | key = key.to_s |
25 | - | |
26 | - filter = @event_filter.options key | |
27 | - | |
28 | 25 | inactive = if @event_filter.active? key |
29 | 26 | nil |
30 | 27 | else |
... | ... | @@ -32,7 +29,7 @@ module EventsHelper |
32 | 29 | end |
33 | 30 | |
34 | 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 | 33 | image_tag "event_filter_#{key}.png" |
37 | 34 | end |
38 | 35 | end | ... | ... |
app/views/dashboard/index.html.haml
features/dashboard/event_filters.feature
... | ... | @@ -12,20 +12,39 @@ Feature: Event filters |
12 | 12 | And I should see new member event |
13 | 13 | And I should see merge request event |
14 | 14 | |
15 | + @javascript | |
15 | 16 | Scenario: I should see only pushed events |
16 | 17 | When I click "push" event filter |
17 | 18 | Then I should see push event |
18 | 19 | And I should not see new member event |
19 | 20 | And I should not see merge request event |
20 | 21 | |
22 | + @javascript | |
21 | 23 | Scenario: I should see only joined events |
22 | 24 | When I click "team" event filter |
23 | 25 | Then I should see new member event |
24 | 26 | And I should not see push event |
25 | 27 | And I should not see merge request event |
26 | 28 | |
29 | + @javascript | |
27 | 30 | Scenario: I should see only merged events |
28 | 31 | When I click "merge" event filter |
29 | 32 | Then I should see merge request event |
30 | 33 | And I should not see push event |
31 | 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 | 4 | include SharedProject |
5 | 5 | |
6 | 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 | 8 | end |
9 | 9 | |
10 | 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 | 12 | end |
13 | 13 | |
14 | 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 | 16 | end |
17 | 17 | |
18 | 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 | 20 | end |
21 | 21 | |
22 | 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 | 24 | end |
25 | 25 | |
26 | 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 | 28 | end |
29 | 29 | |
30 | 30 | And 'this project has push event' do | ... | ... |