diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-08-26 16:30:03 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-08-26 16:30:03 +0300 |
commit | 17af835387c996f82b46f3bade67d513b4e40cc5 (patch) | |
tree | a98fc3a53601ce398df32a723947d27daff9e3ff | |
parent | 4675ff46e8b1d354d86cdf80ac3bd4f60814dbe3 (diff) | |
download | gitlab-ce-17af835387c996f82b46f3bade67d513b4e40cc5.tar.gz |
Add event filter for group and project show pages
-rw-r--r-- | app/assets/javascripts/activities.js.coffee | 31 | ||||
-rw-r--r-- | app/assets/javascripts/dashboard.js.coffee | 27 | ||||
-rw-r--r-- | app/assets/javascripts/dispatcher.js.coffee | 3 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/dashboard_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/groups_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 5 | ||||
-rw-r--r-- | app/helpers/events_helper.rb | 2 | ||||
-rw-r--r-- | app/views/dashboard/_activities.html.haml | 7 | ||||
-rw-r--r-- | app/views/groups/show.html.haml | 1 | ||||
-rw-r--r-- | app/views/projects/show.html.haml | 1 | ||||
-rw-r--r-- | app/views/shared/_event_filter.html.haml | 5 |
12 files changed, 54 insertions, 42 deletions
diff --git a/app/assets/javascripts/activities.js.coffee b/app/assets/javascripts/activities.js.coffee new file mode 100644 index 00000000000..fdefbfb92bd --- /dev/null +++ b/app/assets/javascripts/activities.js.coffee @@ -0,0 +1,31 @@ +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 diff --git a/app/assets/javascripts/dashboard.js.coffee b/app/assets/javascripts/dashboard.js.coffee index 4871936d5b2..d2bd9e7362b 100644 --- a/app/assets/javascripts/dashboard.js.coffee +++ b/app/assets/javascripts/dashboard.js.coffee @@ -1,13 +1,7 @@ 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" diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index b0b947dd476..c8ddbed5097 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -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' diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 724122d4b93..b93bf0f98eb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index f6620b25818..23da2c274dc 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -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 diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 60fc3f6b551..3378675692a 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -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| diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9b4fe5a9b5b..23b54ec44a8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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 diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 3db010966c5..3c637404c4f 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -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 diff --git a/app/views/dashboard/_activities.html.haml b/app/views/dashboard/_activities.html.haml index 2b7d23c225d..89117726317 100644 --- a/app/views/dashboard/_activities.html.haml +++ b/app/views/dashboard/_activities.html.haml @@ -1,10 +1,5 @@ = 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 diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 8afc4ab4a12..e613ed3eaa3 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -6,6 +6,7 @@ %span.cgray You will only see events from projects in this group %hr + = render 'shared/event_filter' - if @events.any? .content_list - else diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 8a3427f3980..06ca5169dff 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -3,6 +3,7 @@ .row .span9 = render "events/event_last_push", event: @last_push + = render 'shared/event_filter' .content_list .loading.hide .span3 diff --git a/app/views/shared/_event_filter.html.haml b/app/views/shared/_event_filter.html.haml new file mode 100644 index 00000000000..ee0b57fbe5a --- /dev/null +++ b/app/views/shared/_event_filter.html.haml @@ -0,0 +1,5 @@ +.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' |