diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb index cb5fed0bc3e2a3edabf45191c455adc5892bdea9..5e810942d1cce627139f2c08ea3366c15584a399 100644 --- a/app/controllers/groups/milestones_controller.rb +++ b/app/controllers/groups/milestones_controller.rb @@ -6,6 +6,16 @@ class Groups::MilestonesController < ApplicationController project_ids = @group.projects project_milestones = Milestone.where(project_id: project_ids) @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 + private + + def status(state) + @group_milestones.map{ |milestone| next if milestone.state != state; milestone }.compact + end end diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 0762a6925b3b44df96445620e175052ae4169797..0dc53dedeb7bab58f27ac275c0579cb2e3e9cdaa 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -35,8 +35,7 @@ module GroupsHelper def group_filter_path(entity, options={}) exist_opts = { - state: params[:state], - scope: params[:scope] + status: params[:status] } options = exist_opts.merge(options) diff --git a/app/models/group_milestone.rb b/app/models/group_milestone.rb index c2fb3a5edee77f027b709b416ac4385a437e5461..132c0eb2497ea0001c2befd6f5f9582cd9f86d6e 100644 --- a/app/models/group_milestone.rb +++ b/app/models/group_milestone.rb @@ -38,4 +38,13 @@ class GroupMilestone rescue ZeroDivisionError 100 end + + def state + state = milestones.map{ |milestone| milestone.state } + if state.all?{ |milestone_state| milestone_state == 'active' } + 'active' + else + 'closed' + end + end end diff --git a/app/views/groups/_filter.html.haml b/app/views/groups/_filter.html.haml index 2e97ea40afe4cb1c9eaa715b2ca98631bb23d90a..393be3f1d12e192916d8b8d81c114d92b447a6e9 100644 --- a/app/views/groups/_filter.html.haml +++ b/app/views/groups/_filter.html.haml @@ -1,8 +1,8 @@ = form_tag group_filter_path(entity), method: 'get' do %fieldset %ul.nav.nav-pills.nav-stacked - %li{class: ("active" if !params[:status])} - = link_to group_filter_path(entity, status: nil) do + %li{class: ("active" if (params[:status] == 'active' || !params[:status]))} + = link_to group_filter_path(entity, status: 'active') do Active %li{class: ("active" if params[:status] == 'closed')} = link_to group_filter_path(entity, status: 'closed') do diff --git a/app/views/groups/milestones/index.html.haml b/app/views/groups/milestones/index.html.haml index 97cc88db522983463e732077dd1b83e66f81c05b..9ce8bf32aea3770100059e67e839b7cc214b81f5 100644 --- a/app/views/groups/milestones/index.html.haml +++ b/app/views/groups/milestones/index.html.haml @@ -13,7 +13,7 @@ .fixed.sidebar-expand-button.hidden-lg.hidden-md %i.icon-list.icon-2x .col-md-3.responsive-side - = render 'groups/filter', entity: 'milestones' + = render 'groups/filter', entity: 'milestone' .col-md-9 .panel.panel-default %ul.well-list @@ -22,27 +22,25 @@ .nothing-here-block No milestones to show - else - @group_milestones.each do |milestone| - %li{class: "milestone milestone-open", id: 1 } - .pull-right - = link_to 'Close Milestone', root_path, method: :put, remote: true, class: "btn btn-small btn-remove" + %li{class: "milestone milestone-#{milestone.state == 'closed' ? 'closed' : 'open'}", id: dom_id(milestone.milestones.first) } + - unless milestone.state == 'closed' + .pull-right + = link_to 'Close Milestone', root_path, method: :put, remote: true, class: "btn btn-small btn-remove" %h4 = link_to_gfm truncate(milestone.title, length: 100), root_path - - if false - %span.muted Empty - - else + %div %div - %div - = link_to root_path do - = pluralize milestone.issue_count, 'Issue' - - = link_to root_path do - = pluralize milestone.merge_requests_count, 'Merge Request' - - %span.light #{milestone.percent_complete}% complete - .progress.progress-info - .progress-bar{style: "width: #{milestone.percent_complete}%;"} - %div - %br - - milestone.project_names.each do |name| - %span.label.label-default - = name + = link_to root_path do + = pluralize milestone.issue_count, 'Issue' + + = link_to root_path do + = pluralize milestone.merge_requests_count, 'Merge Request' + + %span.light #{milestone.percent_complete}% complete + .progress.progress-info + .progress-bar{style: "width: #{milestone.percent_complete}%;"} + %div + %br + - milestone.project_names.each do |name| + %span.label.label-default + = name