Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
95649362
Commit
95649362
authored
Jan 09, 2015
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create the admin email select box which queries through both projects and groups.
parent
1297d5bf
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
2 deletions
+59
-2
app/assets/javascripts/admin_email_select.js.coffee
app/assets/javascripts/admin_email_select.js.coffee
+46
-0
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+2
-0
app/helpers/admin_email_helper.rb
app/helpers/admin_email_helper.rb
+1
-1
app/helpers/selects_helper.rb
app/helpers/selects_helper.rb
+9
-0
app/views/admin/emails/show.html.haml
app/views/admin/emails/show.html.haml
+1
-1
No files found.
app/assets/javascripts/admin_email_select.js.coffee
0 → 100644
View file @
95649362
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
}
"
app/assets/javascripts/dispatcher.js.coffee
View file @
95649362
...
@@ -81,6 +81,8 @@ class Dispatcher
...
@@ -81,6 +81,8 @@ class Dispatcher
new
User
()
new
User
()
when
'projects:group_links:index'
when
'projects:group_links:index'
new
GroupsSelect
()
new
GroupsSelect
()
when
'admin:emails:show'
new
AdminEmailSelect
()
switch
path
.
first
()
switch
path
.
first
()
when
'admin'
when
'admin'
...
...
app/helpers/admin_email_helper.rb
View file @
95649362
app/helpers/selects_helper.rb
View file @
95649362
...
@@ -35,4 +35,13 @@ module SelectsHelper
...
@@ -35,4 +35,13 @@ module SelectsHelper
hidden_field_tag
(
id
,
value
,
class:
css_class
)
hidden_field_tag
(
id
,
value
,
class:
css_class
)
end
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
end
app/views/admin/emails/show.html.haml
View file @
95649362
...
@@ -17,6 +17,6 @@
...
@@ -17,6 +17,6 @@
.form-group
.form-group
%label
.control-label
{
for: :recipients
}
Recipient group
%label
.control-label
{
for: :recipients
}
Recipient group
.col-sm-10
.col-sm-10
=
select_tag
:recipients
,
admin_email_grouped_recipient_options
,
class: :select2
,
required:
true
=
admin_email_select_tag
(
:recipients
)
.form-actions
.form-actions
=
submit_tag
'Send message'
,
class:
'btn btn-create'
=
submit_tag
'Send message'
,
class:
'btn btn-create'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment