Commit 89654431 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Group#ldap_cn selectbox with ajax autocomplete via api

parent 0f69c2f8
...@@ -2,13 +2,14 @@ ...@@ -2,13 +2,14 @@
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"
ldap_groups_path: "/api/:version/ldap/groups.json"
# Get 20 (depends on api) recent notes # Get 20 (depends on api) recent notes
# and sort the ascending from oldest to newest # and sort the ascending from oldest to newest
notes: (project_id, callback) -> notes: (project_id, callback) ->
url = Api.buildUrl(Api.notes_path) url = Api.buildUrl(Api.notes_path)
url = url.replace(':id', project_id) url = url.replace(':id', project_id)
$.ajax( $.ajax(
url: url, url: url,
data: data:
...@@ -37,7 +38,7 @@ ...@@ -37,7 +38,7 @@
# Only active users retrieved # Only active users retrieved
users: (query, callback) -> users: (query, callback) ->
url = Api.buildUrl(Api.users_path) url = Api.buildUrl(Api.users_path)
$.ajax( $.ajax(
url: url url: url
data: data:
...@@ -52,3 +53,18 @@ ...@@ -52,3 +53,18 @@
buildUrl: (url) -> buildUrl: (url) ->
url = gon.relative_url_root + url if gon.relative_url_root? url = gon.relative_url_root + url if gon.relative_url_root?
return url.replace(':version', gon.api_version) return url.replace(':version', gon.api_version)
# Return LDAP groups list. Filtered by query
ldap_groups: (query, callback) ->
url = Api.buildUrl(Api.ldap_groups_path)
$.ajax(
url: url
data:
private_token: gon.api_token
search: query
per_page: 20
active: true
dataType: "json"
).done (groups) ->
callback(groups)
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
= f.label :ldap_cn do = f.label :ldap_cn do
LDAP Group cn LDAP Group cn
.controls .controls
= f.text_field :ldap_cn, placeholder: "Ex. QA group", class: "xxlarge left" = f.hidden_field :ldap_cn, placeholder: "Ex. QA group", class: "xxlarge ajax-ldap-groups-select"
.control-group .control-group
= f.label :ldap_access do = f.label :ldap_access do
......
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