Commit d28fa2ce authored by Rémy Coutable's avatar Rémy Coutable

Display "iid of max_iid" in Issuables' sidebar

parent 54613b6a
...@@ -8,20 +8,16 @@ module IssuablesHelper ...@@ -8,20 +8,16 @@ module IssuablesHelper
"right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}" "right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}"
end end
def issuable_index(issuable)
base_issuable_scope(issuable).where('id < ?', issuable.id).size + 1
end
def issuables_count(issuable) def issuables_count(issuable)
base_issuable_scope(issuable).size base_issuable_scope(issuable).maximum(:iid)
end end
def next_issuable_for(issuable) def next_issuable_for(issuable)
base_issuable_scope(issuable).where('id > ?', issuable.id).last base_issuable_scope(issuable).where('iid > ?', issuable.iid).last
end end
def prev_issuable_for(issuable) def prev_issuable_for(issuable)
base_issuable_scope(issuable).where('id < ?', issuable.id).first base_issuable_scope(issuable).where('iid < ?', issuable.iid).first
end end
private private
...@@ -31,7 +27,7 @@ module IssuablesHelper ...@@ -31,7 +27,7 @@ module IssuablesHelper
end end
def base_issuable_scope(issuable) def base_issuable_scope(issuable)
issuable.project.send(issuable.to_scope_name).send(issuable_state_scope(issuable)) issuable.project.send(issuable.class.table_name).send(issuable_state_scope(issuable))
end end
def issuable_state_scope(issuable) def issuable_state_scope(issuable)
......
...@@ -168,16 +168,6 @@ module Issuable ...@@ -168,16 +168,6 @@ module Issuable
self.class.to_s.underscore self.class.to_s.underscore
end end
# Convert this Issuable class name to a format usable for scoping
#
# Examples:
#
# issuable.class # => MergeRequest
# issuable.to_scope_name # => "merge_requests"
def to_scope_name
self.class.to_s.tableize
end
# Returns a Hash of attributes to be used for Twitter card metadata # Returns a Hash of attributes to be used for Twitter card metadata
def card_attributes def card_attributes
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.issuable-sidebar .issuable-sidebar
.block .block
%span.issuable-count.pull-left %span.issuable-count.pull-left
= issuable_index(issuable) = issuable.iid
of of
= issuables_count(issuable) = issuables_count(issuable)
%span.pull-right %span.pull-right
......
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