2014-02-13 09:08:26 -05:00
|
|
|
module SelectsHelper
|
|
|
|
def users_select_tag(id, opts = {})
|
|
|
|
css_class = "ajax-users-select "
|
|
|
|
css_class << "multiselect " if opts[:multiple]
|
|
|
|
css_class << (opts[:class] || '')
|
|
|
|
value = opts[:selected] || ''
|
2015-03-26 22:13:49 -04:00
|
|
|
placeholder = opts[:placeholder] || 'Search for a user'
|
2014-02-13 09:08:26 -05:00
|
|
|
|
2015-03-26 22:13:49 -04:00
|
|
|
null_user = opts[:null_user] || false
|
|
|
|
any_user = opts[:any_user] || false
|
2015-04-10 09:25:32 -04:00
|
|
|
email_user = opts[:email_user] || false
|
2015-03-31 02:53:42 -04:00
|
|
|
first_user = opts[:first_user] && current_user ? current_user.username : false
|
2015-08-21 00:33:00 -04:00
|
|
|
current_user = opts[:current_user] || false
|
2015-05-19 23:46:48 -04:00
|
|
|
project = opts[:project] || @project
|
2014-02-13 09:08:26 -05:00
|
|
|
|
2015-03-26 22:13:49 -04:00
|
|
|
html = {
|
|
|
|
class: css_class,
|
|
|
|
'data-placeholder' => placeholder,
|
|
|
|
'data-null-user' => null_user,
|
|
|
|
'data-any-user' => any_user,
|
2015-04-10 09:25:32 -04:00
|
|
|
'data-email-user' => email_user,
|
2015-08-21 00:33:00 -04:00
|
|
|
'data-first-user' => first_user,
|
|
|
|
'data-current-user' => current_user
|
2015-03-26 22:13:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
unless opts[:scope] == :all
|
2015-05-19 23:46:48 -04:00
|
|
|
if project
|
|
|
|
html['data-project-id'] = project.id
|
2015-03-26 22:13:49 -04:00
|
|
|
elsif @group
|
|
|
|
html['data-group-id'] = @group.id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
hidden_field_tag(id, value, html)
|
2014-02-13 09:08:26 -05:00
|
|
|
end
|
2014-12-30 04:32:24 -05:00
|
|
|
|
|
|
|
def groups_select_tag(id, opts = {})
|
|
|
|
css_class = "ajax-groups-select "
|
|
|
|
css_class << "multiselect " if opts[:multiple]
|
|
|
|
css_class << (opts[:class] || '')
|
|
|
|
value = opts[:selected] || ''
|
|
|
|
|
|
|
|
hidden_field_tag(id, value, class: css_class)
|
|
|
|
end
|
2014-02-13 09:08:26 -05:00
|
|
|
end
|