Commit 97d17cf8 authored by Alex Denisov's avatar Alex Denisov

Event filters stores at cookies.

parent b255c3c4
/**
* Init dashboard page
*
*/
function dashboardPage(){
$(".event_filter_link").bind('click',(function(){
enableFilter(this.id);
}));
}
function enableFilter(sender_id){
var event_filters = $.cookie('event_filter');
var filter = sender_id.split('_')[0];
if (!event_filters) {
event_filters = new Array();
} else {
event_filters = event_filters.split(',');
}
var index = event_filters.indexOf(filter);
if (index == -1) {
event_filters.push(filter);
} else {
event_filters.splice(index, 1);
}
$.cookie('event_filter', event_filters.join(','));
};
......@@ -60,6 +60,7 @@ class DashboardController < ApplicationController
end
def event_filter
@event_filter ||= EventFilter.new(params[:event_filter])
filters = cookies['event_filter'].split(',') if cookies['event_filter']
@event_filter ||= EventFilter.new(filters)
end
end
......@@ -22,9 +22,6 @@ module EventsHelper
def event_filter_link key, tooltip
key = key.to_s
filter = @event_filter.options key
inactive = if @event_filter.active? key
nil
else
......@@ -32,7 +29,7 @@ module EventsHelper
end
content_tag :div, class: "filter_icon #{inactive}" do
link_to dashboard_path(event_filter: filter), class: 'has_tooltip', id: "#{key}_event_filter", 'data-original-title' => tooltip do
link_to dashboard_path, class: 'has_tooltip event_filter_link', id: "#{key}_event_filter", 'data-original-title' => tooltip do
image_tag "event_filter_#{key}.png"
end
end
......
= javascript_include_tag 'dashboard'
- if @has_authorized_projects
.projects
.activities.span8
......
......@@ -12,20 +12,39 @@ Feature: Event filters
And I should see new member event
And I should see merge request event
@javascript
Scenario: I should see only pushed events
When I click "push" event filter
Then I should see push event
And I should not see new member event
And I should not see merge request event
@javascript
Scenario: I should see only joined events
When I click "team" event filter
Then I should see new member event
And I should not see push event
And I should not see merge request event
@javascript
Scenario: I should see only merged events
When I click "merge" event filter
Then I should see merge request event
And I should not see push event
And I should not see new member event
@javascript
Scenario: I should see only selected events while page reloaded
When I click "push" event filter
And I visit dashboard page
Then I should see push event
And I should not see new member event
When I click "team" event filter
And I visit dashboard page
Then I should see push event
And I should see new member event
And I should not see merge request event
When I click "push" event
Then I should not see push event
And I should see new member event
And I should not see merge request event
......@@ -4,27 +4,27 @@ class EventFilters < Spinach::FeatureSteps
include SharedProject
Then 'I should see push event' do
page.has_selector?('span.pushed').should be_true
page.should have_selector('span.pushed')
end
Then 'I should not see push event' do
page.has_selector?('span.pushed').should be_false
page.should_not have_selector('span.pushed')
end
Then 'I should see new member event' do
page.has_selector?('span.joined').should be_true
page.should have_selector('span.joined')
end
And 'I should not see new member event' do
page.has_selector?('span.joined').should be_false
page.should_not have_selector('span.joined')
end
Then 'I should see merge request event' do
page.has_selector?('span.merged').should be_true
page.should have_selector('span.merged')
end
And 'I should not see merge request event' do
page.has_selector?('span.merged').should be_false
page.should_not have_selector('span.merged')
end
And 'this project has push event' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment