Event filters stores at cookies.
This commit is contained in:
parent
b255c3c44b
commit
97d17cf835
6 changed files with 56 additions and 11 deletions
27
app/assets/javascripts/dashboard.js
Normal file
27
app/assets/javascripts/dashboard.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
* 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
|
end
|
||||||
|
|
||||||
def event_filter
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,9 +22,6 @@ module EventsHelper
|
||||||
|
|
||||||
def event_filter_link key, tooltip
|
def event_filter_link key, tooltip
|
||||||
key = key.to_s
|
key = key.to_s
|
||||||
|
|
||||||
filter = @event_filter.options key
|
|
||||||
|
|
||||||
inactive = if @event_filter.active? key
|
inactive = if @event_filter.active? key
|
||||||
nil
|
nil
|
||||||
else
|
else
|
||||||
|
@ -32,7 +29,7 @@ module EventsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
content_tag :div, class: "filter_icon #{inactive}" do
|
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"
|
image_tag "event_filter_#{key}.png"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
= javascript_include_tag 'dashboard'
|
||||||
- if @has_authorized_projects
|
- if @has_authorized_projects
|
||||||
.projects
|
.projects
|
||||||
.activities.span8
|
.activities.span8
|
||||||
|
|
|
@ -12,20 +12,39 @@ Feature: Event filters
|
||||||
And I should see new member event
|
And I should see new member event
|
||||||
And I should see merge request event
|
And I should see merge request event
|
||||||
|
|
||||||
|
@javascript
|
||||||
Scenario: I should see only pushed events
|
Scenario: I should see only pushed events
|
||||||
When I click "push" event filter
|
When I click "push" event filter
|
||||||
Then I should see push event
|
Then I should see push event
|
||||||
And I should not see new member event
|
And I should not see new member event
|
||||||
And I should not see merge request event
|
And I should not see merge request event
|
||||||
|
|
||||||
|
@javascript
|
||||||
Scenario: I should see only joined events
|
Scenario: I should see only joined events
|
||||||
When I click "team" event filter
|
When I click "team" event filter
|
||||||
Then I should see new member event
|
Then I should see new member event
|
||||||
And I should not see push event
|
And I should not see push event
|
||||||
And I should not see merge request event
|
And I should not see merge request event
|
||||||
|
|
||||||
|
@javascript
|
||||||
Scenario: I should see only merged events
|
Scenario: I should see only merged events
|
||||||
When I click "merge" event filter
|
When I click "merge" event filter
|
||||||
Then I should see merge request event
|
Then I should see merge request event
|
||||||
And I should not see push event
|
And I should not see push event
|
||||||
And I should not see new member 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
|
include SharedProject
|
||||||
|
|
||||||
Then 'I should see push event' do
|
Then 'I should see push event' do
|
||||||
page.has_selector?('span.pushed').should be_true
|
page.should have_selector('span.pushed')
|
||||||
end
|
end
|
||||||
|
|
||||||
Then 'I should not see push event' do
|
Then 'I should not see push event' do
|
||||||
page.has_selector?('span.pushed').should be_false
|
page.should_not have_selector('span.pushed')
|
||||||
end
|
end
|
||||||
|
|
||||||
Then 'I should see new member event' do
|
Then 'I should see new member event' do
|
||||||
page.has_selector?('span.joined').should be_true
|
page.should have_selector('span.joined')
|
||||||
end
|
end
|
||||||
|
|
||||||
And 'I should not see new member event' do
|
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
|
end
|
||||||
|
|
||||||
Then 'I should see merge request event' do
|
Then 'I should see merge request event' do
|
||||||
page.has_selector?('span.merged').should be_true
|
page.should have_selector('span.merged')
|
||||||
end
|
end
|
||||||
|
|
||||||
And 'I should not see merge request event' do
|
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
|
end
|
||||||
|
|
||||||
And 'this project has push event' do
|
And 'this project has push event' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue