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
"right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}"
end
def issuable_index(issuable)
base_issuable_scope(issuable).where('id < ?', issuable.id).size + 1
end
def issuables_count(issuable)
base_issuable_scope(issuable).size
base_issuable_scope(issuable).maximum(:iid)
end
def next_issuable_for(issuable)
base_issuable_scope(issuable).where('id > ?', issuable.id).last
base_issuable_scope(issuable).where('iid > ?', issuable.iid).last
end
def prev_issuable_for(issuable)
base_issuable_scope(issuable).where('id < ?', issuable.id).first
base_issuable_scope(issuable).where('iid < ?', issuable.iid).first
end
private
......@@ -31,7 +27,7 @@ module IssuablesHelper
end
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
def issuable_state_scope(issuable)
......
......@@ -168,16 +168,6 @@ module Issuable
self.class.to_s.underscore
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
def card_attributes
{
......
......@@ -2,7 +2,7 @@
.issuable-sidebar
.block
%span.issuable-count.pull-left
= issuable_index(issuable)
= issuable.iid
of
= issuables_count(issuable)
%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