diff options
author | Phil Hughes <me@iamphill.com> | 2016-08-18 11:38:12 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-08-19 15:27:18 +0100 |
commit | 87284321ffc23fde2be175cb9ba01a5aa37071a6 (patch) | |
tree | 53d16861b5d6c118d2fbbf2054a175cb747a59fe /app/helpers | |
parent | 696740844b58cc24cd983a1b87acc9f7a6acaad7 (diff) | |
download | gitlab-ce-87284321ffc23fde2be175cb9ba01a5aa37071a6.tar.gz |
Addressed feedback
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/issuables_helper.rb | 16 |
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 |