mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-24 20:16:08 +10:00
Create the admin email select box which queries through both projects and groups.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
class @AdminEmailSelect
|
||||
constructor: ->
|
||||
$('.ajax-admin-email-select').each (i, select) =>
|
||||
skip_ldap = $(select).hasClass('skip_ldap')
|
||||
|
||||
$(select).select2
|
||||
placeholder: "Select group or project"
|
||||
multiple: $(select).hasClass('multiselect')
|
||||
minimumInputLength: 0
|
||||
query: (query) ->
|
||||
group_result = Api.groups query.term, skip_ldap, (groups) ->
|
||||
groups
|
||||
|
||||
project_result = Api.projects query.term, (projects) ->
|
||||
projects
|
||||
|
||||
$.when(project_result, group_result).done (projects, groups) ->
|
||||
data = $.merge(groups[0], projects[0])
|
||||
query.callback({ results: data})
|
||||
|
||||
formatResult: (args...) =>
|
||||
@formatResult(args...)
|
||||
formatSelection: (args...) =>
|
||||
@formatSelection(args...)
|
||||
dropdownCssClass: "ajax-admin-email-dropdown"
|
||||
escapeMarkup: (m) -> # we do not want to escape markup since we are displaying html in results
|
||||
m
|
||||
|
||||
formatResult: (object) ->
|
||||
if object.path_with_namespace
|
||||
"<div class='project-result'>
|
||||
<div class='project-name'>#{object.name}</div>
|
||||
<div class='project-path'>#{object.path_with_namespace}</div>
|
||||
</div>"
|
||||
else
|
||||
"<div class='group-result'>
|
||||
<div class='group-name'>#{object.name}</div>
|
||||
<div class='group-path'>#{object.path}</div>
|
||||
</div>"
|
||||
|
||||
formatSelection: (object) ->
|
||||
if object.path_with_namespace
|
||||
"Project: #{object.name}"
|
||||
else
|
||||
"Group: #{object.name}"
|
||||
|
||||
@@ -81,6 +81,8 @@ class Dispatcher
|
||||
new User()
|
||||
when 'projects:group_links:index'
|
||||
new GroupsSelect()
|
||||
when 'admin:emails:show'
|
||||
new AdminEmailSelect()
|
||||
|
||||
switch path.first()
|
||||
when 'admin'
|
||||
|
||||
@@ -16,4 +16,4 @@ module AdminEmailHelper
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,4 +35,13 @@ module SelectsHelper
|
||||
|
||||
hidden_field_tag(id, value, class: css_class)
|
||||
end
|
||||
|
||||
def admin_email_select_tag(id, opts = {})
|
||||
css_class = "ajax-admin-email-select "
|
||||
css_class << "multiselect " if opts[:multiple]
|
||||
css_class << (opts[:class] || '')
|
||||
value = opts[:selected] || ''
|
||||
|
||||
hidden_field_tag(id, value, class: css_class)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,6 +17,6 @@
|
||||
.form-group
|
||||
%label.control-label{for: :recipients} Recipient group
|
||||
.col-sm-10
|
||||
= select_tag :recipients, admin_email_grouped_recipient_options, class: :select2, required: true
|
||||
= admin_email_select_tag(:recipients)
|
||||
.form-actions
|
||||
= submit_tag 'Send message', class: 'btn btn-create'
|
||||
|
||||
@@ -18,4 +18,4 @@ class AdminEmailsWorker
|
||||
Project.find($1).team.users.subscribed_for_admin_email
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user