Commit 17af8353 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add event filter for group and project show pages

parent 4675ff46
class Activities
constructor: ->
Pager.init 20, true
$(".event_filter_link").bind "click", (event) =>
event.preventDefault()
@toggleFilter($(event.currentTarget))
@reloadActivities()
reloadActivities: ->
$(".content_list").html ''
Pager.init 20, true
toggleFilter: (sender) ->
sender.parent().toggleClass "inactive"
event_filters = $.cookie("event_filter")
filter = sender.attr("id").split("_")[0]
if event_filters
event_filters = event_filters.split(",")
else
event_filters = new Array()
index = event_filters.indexOf(filter)
if index is -1
event_filters.push filter
else
event_filters.splice index, 1
$.cookie "event_filter", event_filters.join(","), { path: '/' }
@Activities = Activities
class Dashboard
constructor: ->
Pager.init 20, true
@initSidebarTab()
$(".event_filter_link").bind "click", (event) =>
event.preventDefault()
@toggleFilter($(event.currentTarget))
@reloadActivities()
$(".dash-filter").keyup ->
terms = $(this).val()
uiBox = $(this).parents('.ui-box').first()
......@@ -24,27 +18,6 @@ class Dashboard
reloadActivities: ->
$(".content_list").html ''
Pager.init 20, true
toggleFilter: (sender) ->
sender.parent().toggleClass "inactive"
event_filters = $.cookie("event_filter")
filter = sender.attr("id").split("_")[0]
if event_filters
event_filters = event_filters.split(",")
else
event_filters = new Array()
index = event_filters.indexOf(filter)
if index is -1
event_filters.push filter
else
event_filters.splice index, 1
$.cookie "event_filter", event_filters.join(","), { path: '/' }
initSidebarTab: ->
key = "dashboard_sidebar_filter"
......
......@@ -20,10 +20,11 @@ class Dispatcher
Issues.init()
when 'dashboard:show'
new Dashboard()
new Activities()
when 'projects:commit:show'
new Commit()
when 'groups:show', 'projects:show'
Pager.init(20, true)
new Activities()
when 'projects:new', 'projects:edit'
new Project()
when 'projects:walls:show'
......
......@@ -155,4 +155,9 @@ class ApplicationController < ActionController::Base
redirect_to new_profile_password_path and return
end
end
def event_filter
filters = cookies['event_filter'].split(',') if cookies['event_filter'].present?
@event_filter ||= EventFilter.new(filters)
end
end
......@@ -66,9 +66,4 @@ class DashboardController < ApplicationController
def load_projects
@projects = current_user.authorized_projects.sorted_by_activity
end
def event_filter
filters = cookies['event_filter'].split(',') if cookies['event_filter'].present?
@event_filter ||= EventFilter.new(filters)
end
end
......@@ -31,7 +31,9 @@ class GroupsController < ApplicationController
end
def show
@events = Event.in_projects(project_ids).limit(20).offset(params[:offset] || 0)
@events = Event.in_projects(project_ids)
@events = event_filter.apply_filter(@events)
@events = @events.limit(20).offset(params[:offset] || 0)
@last_push = current_user.recent_push
respond_to do |format|
......
......@@ -55,7 +55,10 @@ class ProjectsController < Projects::ApplicationController
def show
limit = (params[:limit] || 20).to_i
@events = @project.events.recent.limit(limit).offset(params[:offset] || 0)
@events = @project.events.recent
@events = event_filter.apply_filter(@events)
@events = @events.limit(limit).offset(params[:offset] || 0)
# Ensure project default branch is set if it possible
# Normally it defined on push or during creation
......
......@@ -28,7 +28,7 @@ module EventsHelper
end
content_tag :div, class: "filter_icon #{inactive}" do
link_to dashboard_path, class: 'has_tooltip event_filter_link', id: "#{key}_event_filter", 'data-original-title' => tooltip do
link_to request.path, class: 'has_tooltip event_filter_link', id: "#{key}_event_filter", 'data-original-title' => tooltip do
content_tag :i, nil, class: icon_for_event[key]
end
end
......
= render "events/event_last_push", event: @last_push
.event_filter
= event_filter_link EventFilter.push, 'Push events'
= event_filter_link EventFilter.merged, 'Merge events'
= event_filter_link EventFilter.comments, 'Comments'
= event_filter_link EventFilter.team, 'Team'
= render 'shared/event_filter'
- if @events.any?
.content_list
......
......@@ -6,6 +6,7 @@
&nbsp;
%span.cgray You will only see events from projects in this group
%hr
= render 'shared/event_filter'
- if @events.any?
.content_list
- else
......
......@@ -3,6 +3,7 @@
.row
.span9
= render "events/event_last_push", event: @last_push
= render 'shared/event_filter'
.content_list
.loading.hide
.span3
......
.event_filter
= event_filter_link EventFilter.push, 'Push events'
= event_filter_link EventFilter.merged, 'Merge events'
= event_filter_link EventFilter.comments, 'Comments'
= event_filter_link EventFilter.team, 'Team'
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