diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2016-04-20 19:18:32 +0000 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2016-04-20 19:18:32 +0000 |
commit | 692c35e6f499598d0c6f91eb83ca8837ca93e07f (patch) | |
tree | c8af3c1ea77c3845957e34f238950a379339cd01 /app/helpers | |
parent | 9a60887199ef1087285ea6997f2eb117f87d0a03 (diff) | |
parent | 490f77318b8d54be30558c3ef8914335ed83549b (diff) | |
download | gitlab-ce-692c35e6f499598d0c6f91eb83ca8837ca93e07f.tar.gz |
Merge branch 'multi-filter-labels' into 'master'
Mutliple label filter
Fixes #989
See merge request !3438
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_helper.rb | 9 | ||||
-rw-r--r-- | app/helpers/issuables_helper.rb | 19 |
2 files changed, 27 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 16e5b8ac223..3e0074da394 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -254,11 +254,11 @@ module ApplicationHelper def page_filter_path(options = {}) without = options.delete(:without) + add_label = options.delete(:label) exist_opts = { state: params[:state], scope: params[:scope], - label_name: params[:label_name], milestone_title: params[:milestone_title], assignee_id: params[:assignee_id], author_id: params[:author_id], @@ -275,6 +275,13 @@ module ApplicationHelper path = request.path path << "?#{options.to_param}" + if add_label + if params[:label_name].present? and params[:label_name].respond_to?('any?') + params[:label_name].each do |label| + path << "&label_name[]=#{label}" + end + end + end path end diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 49b6b79ce35..39474217286 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -16,6 +16,25 @@ module IssuablesHelper base_issuable_scope(issuable).where('iid > ?', issuable.iid).last end + def multi_label_name(current_labels, default_label) + # current_labels may be a string from before + if current_labels.is_a?(Array) + if current_labels.count > 1 + "#{current_labels[0]} +#{current_labels.count - 1} more" + else + current_labels[0] + end + elsif current_labels.is_a?(String) + if current_labels.nil? || current_labels.empty? + default_label + else + current_labels + end + else + default_label + end + end + def issuable_json_path(issuable) project = issuable.project |