diff options
author | Jacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home> | 2016-03-16 16:52:07 -0400 |
---|---|---|
committer | Jacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home> | 2016-03-25 08:07:57 -0400 |
commit | e8d84110165d1358d90ebafb72ec91a441624527 (patch) | |
tree | 08a9cbe1edfd2c8357906cddc4a56fa35f887e04 /app/assets | |
parent | 74c7a537eda71ba8b08f56edacee56e09d5c1004 (diff) | |
download | gitlab-ce-e8d84110165d1358d90ebafb72ec91a441624527.tar.gz |
Adds new dropdown ajax to user selection
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/labels_select.js.coffee | 5 | ||||
-rw-r--r-- | app/assets/javascripts/users_select.js.coffee | 38 |
2 files changed, 39 insertions, 4 deletions
diff --git a/app/assets/javascripts/labels_select.js.coffee b/app/assets/javascripts/labels_select.js.coffee index c05daca4afb..464e6cb456a 100644 --- a/app/assets/javascripts/labels_select.js.coffee +++ b/app/assets/javascripts/labels_select.js.coffee @@ -198,14 +198,13 @@ class @LabelsSelect # need inline-block here instead of show, # which will default to the element's style in this case inline. selected = if selected.length then selected else [''] - $loading - .fadeIn() + $loading.fadeIn() $.ajax( type: 'PUT' url: issueURL data: issue: - label_ids: selected + assignee_id: selected ).done (data) -> $loading.fadeOut() $selectbox.hide() diff --git a/app/assets/javascripts/users_select.js.coffee b/app/assets/javascripts/users_select.js.coffee index fe4a54e07e1..2bfe6b72432 100644 --- a/app/assets/javascripts/users_select.js.coffee +++ b/app/assets/javascripts/users_select.js.coffee @@ -12,6 +12,11 @@ class @UsersSelect firstUser = $dropdown.data('first-user') selectedId = $dropdown.data('selected') defaultLabel = $dropdown.data('default-label') + issueURL = $dropdown.data('issueUpdate') + $selectbox = $dropdown.closest('.selectbox') + $block = $selectbox.closest('.block') + $value = $block.find('.value') + $loading = $block.find('.block-loading').fadeOut() $dropdown.glDropdown( data: (term, callback) => @@ -57,11 +62,17 @@ class @UsersSelect fields: ['name', 'username'] selectable: true fieldName: $dropdown.data('field-name') + toggleLabel: (selected) -> if selected && 'id' of selected selected.name else defaultLabel + + hidden: -> + $selectbox.hide() + $value.show() + clicked: -> page = $('body').data 'page' isIssueIndex = page is 'projects:issues:index' @@ -72,7 +83,32 @@ class @UsersSelect else if $dropdown.hasClass 'js-filter-submit' $dropdown.closest('form').submit() else - console.log 'else' + selected = $dropdown + .closest('.selectbox') + .find("input[name='#{$dropdown.data('field-name')}']").val() + $loading + .fadeIn() + $.ajax( + type: 'PUT' + url: issueURL + data: + issue: + assignee_id: selected + ).done (data) -> + $loading.fadeOut() + $selectbox.hide() + href = $value + .show() + .find('.author') + .text(data.assignee.name) + .end() + .find('a') + .attr('href') + splitHref = href.split('/') + splitHref[splitHref.length - 1] = data.assignee.username + $value + .find('a') + .attr('href',splitHref.join('/')) renderRow: (user) -> username = if user.username then "@#{user.username}" else "" avatar = if user.avatar_url then user.avatar_url else false |