summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-08-18 11:38:12 +0100
committerPhil Hughes <me@iamphill.com>2016-08-19 15:27:18 +0100
commit87284321ffc23fde2be175cb9ba01a5aa37071a6 (patch)
tree53d16861b5d6c118d2fbbf2054a175cb747a59fe /app/helpers
parent696740844b58cc24cd983a1b87acc9f7a6acaad7 (diff)
downloadgitlab-ce-87284321ffc23fde2be175cb9ba01a5aa37071a6.tar.gz
Addressed feedback
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/issuables_helper.rb16
1 files changed, 6 insertions, 10 deletions
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index b95a3e95001..c3f4c1b148d 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -72,18 +72,14 @@ module IssuablesHelper
end
end
- def issuable_labels_tooltip(labels)
- max_labels = 5
- label_size = labels.size
- label_names = labels.each_with_index.map do |label, i|
- label.name unless i >= max_labels
- end
+ def issuable_labels_tooltip(labels, limit: 5)
+ first = labels[0...limit]
+ last = labels[(limit-1)...-1]
- if label_size > max_labels
- label_names << "and #{label_size - max_labels} more"
- end
+ label_names = first.collect(&:name)
+ label_names << "and #{last.size} more" unless last.empty?
- label_names.compact.join(', ')
+ label_names.join(', ')
end
private