Skip to content
Snippets Groups Projects
Commit 17af8353 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Add event filter for group and project show pages

parent 4675ff46
No related branches found
No related tags found
No related merge requests found
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 class Dashboard
constructor: -> constructor: ->
Pager.init 20, true
@initSidebarTab() @initSidebarTab()
   
$(".event_filter_link").bind "click", (event) =>
event.preventDefault()
@toggleFilter($(event.currentTarget))
@reloadActivities()
$(".dash-filter").keyup -> $(".dash-filter").keyup ->
terms = $(this).val() terms = $(this).val()
uiBox = $(this).parents('.ui-box').first() uiBox = $(this).parents('.ui-box').first()
Loading
@@ -24,27 +18,6 @@ class Dashboard
Loading
@@ -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: -> initSidebarTab: ->
key = "dashboard_sidebar_filter" key = "dashboard_sidebar_filter"
   
Loading
Loading
Loading
@@ -20,10 +20,11 @@ class Dispatcher
Loading
@@ -20,10 +20,11 @@ class Dispatcher
Issues.init() Issues.init()
when 'dashboard:show' when 'dashboard:show'
new Dashboard() new Dashboard()
new Activities()
when 'projects:commit:show' when 'projects:commit:show'
new Commit() new Commit()
when 'groups:show', 'projects:show' when 'groups:show', 'projects:show'
Pager.init(20, true) new Activities()
when 'projects:new', 'projects:edit' when 'projects:new', 'projects:edit'
new Project() new Project()
when 'projects:walls:show' when 'projects:walls:show'
Loading
Loading
Loading
@@ -155,4 +155,9 @@ class ApplicationController < ActionController::Base
Loading
@@ -155,4 +155,9 @@ class ApplicationController < ActionController::Base
redirect_to new_profile_password_path and return redirect_to new_profile_password_path and return
end end
end end
def event_filter
filters = cookies['event_filter'].split(',') if cookies['event_filter'].present?
@event_filter ||= EventFilter.new(filters)
end
end end
Loading
@@ -66,9 +66,4 @@ class DashboardController < ApplicationController
Loading
@@ -66,9 +66,4 @@ class DashboardController < ApplicationController
def load_projects def load_projects
@projects = current_user.authorized_projects.sorted_by_activity @projects = current_user.authorized_projects.sorted_by_activity
end end
def event_filter
filters = cookies['event_filter'].split(',') if cookies['event_filter'].present?
@event_filter ||= EventFilter.new(filters)
end
end end
Loading
@@ -31,7 +31,9 @@ class GroupsController < ApplicationController
Loading
@@ -31,7 +31,9 @@ class GroupsController < ApplicationController
end end
   
def show 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 @last_push = current_user.recent_push
   
respond_to do |format| respond_to do |format|
Loading
Loading
Loading
@@ -55,7 +55,10 @@ class ProjectsController < Projects::ApplicationController
Loading
@@ -55,7 +55,10 @@ class ProjectsController < Projects::ApplicationController
   
def show def show
limit = (params[:limit] || 20).to_i 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 # Ensure project default branch is set if it possible
# Normally it defined on push or during creation # Normally it defined on push or during creation
Loading
Loading
Loading
@@ -28,7 +28,7 @@ module EventsHelper
Loading
@@ -28,7 +28,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, 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] content_tag :i, nil, class: icon_for_event[key]
end end
end end
Loading
Loading
= render "events/event_last_push", event: @last_push = render "events/event_last_push", event: @last_push
= render 'shared/event_filter'
.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'
   
- if @events.any? - if @events.any?
.content_list .content_list
Loading
Loading
Loading
@@ -6,6 +6,7 @@
Loading
@@ -6,6 +6,7 @@
&nbsp; &nbsp;
%span.cgray You will only see events from projects in this group %span.cgray You will only see events from projects in this group
%hr %hr
= render 'shared/event_filter'
- if @events.any? - if @events.any?
.content_list .content_list
- else - else
Loading
Loading
Loading
@@ -3,6 +3,7 @@
Loading
@@ -3,6 +3,7 @@
.row .row
.span9 .span9
= render "events/event_last_push", event: @last_push = render "events/event_last_push", event: @last_push
= render 'shared/event_filter'
.content_list .content_list
.loading.hide .loading.hide
.span3 .span3
Loading
Loading
.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'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment