Commit 86fc145c authored by Felipe Artur's avatar Felipe Artur

Order issues by priority

parent ff7fe2d1
module Milestoneish module Milestoneish
def closed_items_count(user) def closed_items_count(user)
memoize_per_user(user, :closed_items_count) do memoize_per_user(user, :closed_items_count) do
(count_issues_by_state(user)['closed'] || 0) + merge_requests.closed_and_merged.size (count_issues_by_state(user)['closed'].count || 0) + merge_requests.closed_and_merged.size
end end
end end
...@@ -12,7 +12,7 @@ module Milestoneish ...@@ -12,7 +12,7 @@ module Milestoneish
end end
def total_issues_count(user) def total_issues_count(user)
count_issues_by_state(user).values.sum issues_visible_to_user(user).length
end end
def complete?(user) def complete?(user)
...@@ -39,8 +39,8 @@ module Milestoneish ...@@ -39,8 +39,8 @@ module Milestoneish
def issues_visible_to_user(user) def issues_visible_to_user(user)
memoize_per_user(user, :issues_visible_to_user) do memoize_per_user(user, :issues_visible_to_user) do
IssuesFinder.new(user, issues_finder_params) IssuesFinder.new(user, issues_finder_params.merge({ sort: 'priority'}))
.execute.includes(:assignees).where(milestone_id: milestoneish_ids) .execute.preload(:assignees).where(milestone_id: milestoneish_ids)
end end
end end
...@@ -66,7 +66,9 @@ module Milestoneish ...@@ -66,7 +66,9 @@ module Milestoneish
def count_issues_by_state(user) def count_issues_by_state(user)
memoize_per_user(user, :count_issues_by_state) do memoize_per_user(user, :count_issues_by_state) do
issues_visible_to_user(user).reorder(nil).group(:state).count # Need to group and count using ruby array to not break
# label ordering
issues_visible_to_user(user).to_a.group_by(&:state)
end end
end end
......
...@@ -44,7 +44,7 @@ class Issue < ActiveRecord::Base ...@@ -44,7 +44,7 @@ class Issue < ActiveRecord::Base
scope :created_after, -> (datetime) { where("created_at >= ?", datetime) } scope :created_after, -> (datetime) { where("created_at >= ?", datetime) }
scope :include_associations, -> { includes(:labels, project: :namespace) } scope :preload_associations, -> { preload(:labels, project: :namespace) }
after_save :expire_etag_cache after_save :expire_etag_cache
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
= title = title
- if show_counter - if show_counter
.counter .counter
= number_with_delimiter(issuables.size) = number_with_delimiter(issuables.length)
- class_prefix = dom_class(issuables).pluralize - class_prefix = dom_class(issuables).pluralize
%ul{ class: "well-list milestone-#{class_prefix}-list", id: "#{class_prefix}-list-#{id}" } %ul{ class: "well-list milestone-#{class_prefix}-list", id: "#{class_prefix}-list-#{id}" }
= render partial: 'shared/milestones/issuable', = render partial: 'shared/milestones/issuable',
collection: issuables.recent, collection: issuables,
as: :issuable, as: :issuable,
locals: { show_project_name: show_project_name, show_full_project_name: show_full_project_name } locals: { show_project_name: show_project_name, show_full_project_name: show_full_project_name }
...@@ -68,10 +68,10 @@ ...@@ -68,10 +68,10 @@
.sidebar-collapsed-icon .sidebar-collapsed-icon
%strong %strong
= icon('hashtag', 'aria-hidden': 'true') = icon('hashtag', 'aria-hidden': 'true')
%span= milestone.issues_visible_to_user(current_user).count %span= milestone.issues_visible_to_user(current_user).length
.title.hide-collapsed .title.hide-collapsed
Issues Issues
%span.badge= milestone.issues_visible_to_user(current_user).count %span.badge= milestone.issues_visible_to_user(current_user).length
- if project && can?(current_user, :create_issue, project) - if project && can?(current_user, :create_issue, project)
= link_to new_namespace_project_issue_path(project.namespace, project, issue: { milestone_id: milestone.id }), class: "pull-right", title: "New Issue" do = link_to new_namespace_project_issue_path(project.namespace, project, issue: { milestone_id: milestone.id }), class: "pull-right", title: "New Issue" do
New issue New issue
...@@ -79,11 +79,11 @@ ...@@ -79,11 +79,11 @@
%span.milestone-stat %span.milestone-stat
= link_to milestones_browse_issuables_path(milestone, type: :issues) do = link_to milestones_browse_issuables_path(milestone, type: :issues) do
Open: Open:
= milestone.issues_visible_to_user(current_user).opened.count = milestone.issues_visible_to_user(current_user).opened.length
%span.milestone-stat %span.milestone-stat
= link_to milestones_browse_issuables_path(milestone, type: :issues, state: 'closed') do = link_to milestones_browse_issuables_path(milestone, type: :issues, state: 'closed') do
Closed: Closed:
= milestone.issues_visible_to_user(current_user).closed.count = milestone.issues_visible_to_user(current_user).closed.length
.block.merge-requests .block.merge-requests
.sidebar-collapsed-icon .sidebar-collapsed-icon
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
.tab-content.milestone-content .tab-content.milestone-content
- if milestone.is_a?(GlobalMilestone) || can?(current_user, :read_issue, @project) - if milestone.is_a?(GlobalMilestone) || can?(current_user, :read_issue, @project)
.tab-pane.active#tab-issues{ data: { sort_endpoint: (sort_issues_namespace_project_milestone_path(@project.namespace, @project, @milestone) if @project && current_user) } } .tab-pane.active#tab-issues{ data: { sort_endpoint: (sort_issues_namespace_project_milestone_path(@project.namespace, @project, @milestone) if @project && current_user) } }
= render 'shared/milestones/issues_tab', issues: milestone.issues_visible_to_user(current_user).include_associations, show_project_name: show_project_name, show_full_project_name: show_full_project_name = render 'shared/milestones/issues_tab', issues: milestone.issues_visible_to_user(current_user).preload_associations, show_project_name: show_project_name, show_full_project_name: show_full_project_name
.tab-pane#tab-merge-requests{ data: { sort_endpoint: (sort_merge_requests_namespace_project_milestone_path(@project.namespace, @project, @milestone) if @project && current_user) } } .tab-pane#tab-merge-requests{ data: { sort_endpoint: (sort_merge_requests_namespace_project_milestone_path(@project.namespace, @project, @milestone) if @project && current_user) } }
-# loaded async -# loaded async
= render "shared/milestones/tab_loading" = render "shared/milestones/tab_loading"
......
--- ---
title: Remove Drag and drop and sorting from milestone view title: Remove issues/merge requests drag n drop and sorting from milestone view
merge_request: merge_request:
author: author:
...@@ -117,7 +117,7 @@ module API ...@@ -117,7 +117,7 @@ module API
finder_params = { finder_params = {
project_id: user_project.id, project_id: user_project.id,
milestone_title: milestone.title, milestone_title: milestone.title,
sort: 'created_desc' sort: 'label_priority'
} }
issues = IssuesFinder.new(current_user, finder_params).execute issues = IssuesFinder.new(current_user, finder_params).execute
...@@ -140,7 +140,7 @@ module API ...@@ -140,7 +140,7 @@ module API
finder_params = { finder_params = {
project_id: user_project.id, project_id: user_project.id,
milestone_title: milestone.title, milestone_title: milestone.title,
sort: 'created_desc' sort: 'label_priority'
} }
merge_requests = MergeRequestsFinder.new(current_user, finder_params).execute merge_requests = MergeRequestsFinder.new(current_user, finder_params).execute
......
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