Commit 4ca8a175 authored by Marin Jankovski's avatar Marin Jankovski

Filter group milestones.

parent 0723bf1a
...@@ -6,6 +6,16 @@ class Groups::MilestonesController < ApplicationController ...@@ -6,6 +6,16 @@ class Groups::MilestonesController < ApplicationController
project_ids = @group.projects project_ids = @group.projects
project_milestones = Milestone.where(project_id: project_ids) project_milestones = Milestone.where(project_id: project_ids)
@group_milestones = Milestones::GroupService.new(project_milestones).execute @group_milestones = Milestones::GroupService.new(project_milestones).execute
@group_milestones = case params[:status]
when 'all'; @group_milestones
when 'closed'; status('closed')
else status('active')
end end
end
private
def status(state)
@group_milestones.map{ |milestone| next if milestone.state != state; milestone }.compact
end
end end
...@@ -35,8 +35,7 @@ module GroupsHelper ...@@ -35,8 +35,7 @@ module GroupsHelper
def group_filter_path(entity, options={}) def group_filter_path(entity, options={})
exist_opts = { exist_opts = {
state: params[:state], status: params[:status]
scope: params[:scope]
} }
options = exist_opts.merge(options) options = exist_opts.merge(options)
......
...@@ -38,4 +38,13 @@ class GroupMilestone ...@@ -38,4 +38,13 @@ class GroupMilestone
rescue ZeroDivisionError rescue ZeroDivisionError
100 100
end end
def state
state = milestones.map{ |milestone| milestone.state }
if state.all?{ |milestone_state| milestone_state == 'active' }
'active'
else
'closed'
end
end
end end
= form_tag group_filter_path(entity), method: 'get' do = form_tag group_filter_path(entity), method: 'get' do
%fieldset %fieldset
%ul.nav.nav-pills.nav-stacked %ul.nav.nav-pills.nav-stacked
%li{class: ("active" if !params[:status])} %li{class: ("active" if (params[:status] == 'active' || !params[:status]))}
= link_to group_filter_path(entity, status: nil) do = link_to group_filter_path(entity, status: 'active') do
Active Active
%li{class: ("active" if params[:status] == 'closed')} %li{class: ("active" if params[:status] == 'closed')}
= link_to group_filter_path(entity, status: 'closed') do = link_to group_filter_path(entity, status: 'closed') do
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
.fixed.sidebar-expand-button.hidden-lg.hidden-md .fixed.sidebar-expand-button.hidden-lg.hidden-md
%i.icon-list.icon-2x %i.icon-list.icon-2x
.col-md-3.responsive-side .col-md-3.responsive-side
= render 'groups/filter', entity: 'milestones' = render 'groups/filter', entity: 'milestone'
.col-md-9 .col-md-9
.panel.panel-default .panel.panel-default
%ul.well-list %ul.well-list
...@@ -22,14 +22,12 @@ ...@@ -22,14 +22,12 @@
.nothing-here-block No milestones to show .nothing-here-block No milestones to show
- else - else
- @group_milestones.each do |milestone| - @group_milestones.each do |milestone|
%li{class: "milestone milestone-open", id: 1 } %li{class: "milestone milestone-#{milestone.state == 'closed' ? 'closed' : 'open'}", id: dom_id(milestone.milestones.first) }
- unless milestone.state == 'closed'
.pull-right .pull-right
= link_to 'Close Milestone', root_path, method: :put, remote: true, class: "btn btn-small btn-remove" = link_to 'Close Milestone', root_path, method: :put, remote: true, class: "btn btn-small btn-remove"
%h4 %h4
= link_to_gfm truncate(milestone.title, length: 100), root_path = link_to_gfm truncate(milestone.title, length: 100), root_path
- if false
%span.muted Empty
- else
%div %div
%div %div
= link_to root_path do = link_to root_path 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