Commit 67798492bc5409b5a596fa28022e1e6cdf5985e4

Authored by Dmitriy Zaporozhets
1 parent f0f88390

Add placeholder support for project_users_select_tag

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/assets/javascripts/project_users_select.js.coffee
... ... @@ -20,8 +20,9 @@ $ -&gt;
20 20  
21 21 $('.ajax-project-users-select').each (i, select) ->
22 22 project_id = $('body').data('project-id')
  23 +
23 24 $(select).select2
24   - placeholder: "Search for a user"
  25 + placeholder: $(select).data('placeholder') || "Search for a user"
25 26 multiple: $(select).hasClass('multiselect')
26 27 minimumInputLength: 0
27 28 query: (query) ->
... ...
app/helpers/selects_helper.rb
... ... @@ -13,7 +13,8 @@ module SelectsHelper
13 13 css_class << "multiselect " if opts[:multiple]
14 14 css_class << (opts[:class] || '')
15 15 value = opts[:selected] || ''
  16 + placeholder = opts[:placeholder] || 'Select user'
16 17  
17   - hidden_field_tag(id, value, class: css_class)
  18 + hidden_field_tag(id, value, class: css_class, 'data-placeholder' => placeholder)
18 19 end
19 20 end
... ...
app/views/projects/issues/_issues.html.haml
... ... @@ -6,7 +6,7 @@
6 6 = form_tag bulk_update_project_issues_path(@project), method: :post do
7 7 %span Update selected issues with &nbsp;
8 8 = select_tag('update[status]', options_for_select(['open', 'closed']), prompt: "Status")
9   - = project_users_select_tag('update[assignee_id]')
  9 + = project_users_select_tag('update[assignee_id]', placeholder: 'Assignee')
10 10 = select_tag('update[milestone_id]', bulk_update_milestone_options, prompt: "Milestone")
11 11 = hidden_field_tag 'update[issues_ids]', []
12 12 = hidden_field_tag :status, params[:status]
... ...