Commit 27ee0fc5 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Helper for ajax group selectbox

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 2660e83c
@Api = @Api =
groups_path: "/api/:version/groups.json"
group_path: "/api/:version/groups/:id.json"
users_path: "/api/:version/users.json" users_path: "/api/:version/users.json"
user_path: "/api/:version/users/:id.json" user_path: "/api/:version/users/:id.json"
notes_path: "/api/:version/projects/:id/notes.json" notes_path: "/api/:version/projects/:id/notes.json"
...@@ -51,6 +53,33 @@ ...@@ -51,6 +53,33 @@
).done (users) -> ).done (users) ->
callback(users) callback(users)
group: (group_id, callback) ->
url = Api.buildUrl(Api.group_path)
url = url.replace(':id', group_id)
$.ajax(
url: url
data:
private_token: gon.api_token
dataType: "json"
).done (group) ->
callback(group)
# Return groups list. Filtered by query
# Only active groups retrieved
groups: (query, skip_ldap, callback) ->
url = Api.buildUrl(Api.groups_path)
$.ajax(
url: url
data:
private_token: gon.api_token
search: query
per_page: 20
dataType: "json"
).done (groups) ->
callback(groups)
# Return project users list. Filtered by query # Return project users list. Filtered by query
# Only active users retrieved # Only active users retrieved
projectUsers: (project_id, query, callback) -> projectUsers: (project_id, query, callback) ->
......
...@@ -116,6 +116,18 @@ select { ...@@ -116,6 +116,18 @@ select {
} }
} }
.group-result {
.group-image {
float: left;
}
.group-name {
font-weight: bold;
}
.group-path {
color: #999;
}
}
.user-result { .user-result {
.user-image { .user-image {
float: left; float: left;
......
...@@ -17,4 +17,13 @@ module SelectsHelper ...@@ -17,4 +17,13 @@ module SelectsHelper
project_id = opts[:project_id] || @project.id project_id = opts[:project_id] || @project.id
hidden_field_tag(id, value, class: css_class, 'data-placeholder' => placeholder, 'data-project-id' => project_id) hidden_field_tag(id, value, class: css_class, 'data-placeholder' => placeholder, 'data-project-id' => project_id)
end end
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
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment