Skip to content
Snippets Groups Projects
Commit e8d84110 authored by Jacob Schatz's avatar Jacob Schatz
Browse files

Adds new dropdown ajax to user selection

parent 74c7a537
No related branches found
No related tags found
1 merge request!3175Updates sidebar to use new dropdowns for issues and merge requests
Loading
Loading
@@ -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()
Loading
Loading
Loading
Loading
@@ -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) =>
Loading
Loading
@@ -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'
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -114,7 +114,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
end
format.json do
render json: @issue.to_json(include: [:milestone, :labels])
render json: @issue.to_json(include: [:milestone, :labels, :assignee])
end
end
end
Loading
Loading
Loading
Loading
@@ -28,6 +28,7 @@
= icon('user')
.title.hide-collapsed
Assignee
=icon('spinner spin', class: 'block-loading')
- if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
= link_to 'Edit', '#', class: 'edit-link pull-right'
.value.bold.hide-collapsed
Loading
Loading
@@ -42,7 +43,8 @@
.light None
 
.selectbox.hide-collapsed
= dropdown_tag("Select assignee", options: { toggle_class: "js-user-search js-author-search", title: "Filter by user", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable dropdown-menu-author", placeholder: "Search users", data: { first_user: (current_user.username if current_user), current_user: true, project_id: (@project.id if @project), selected: params[:author_id], field_name: "author_id" } })
= f.hidden_field 'assignee_id', value: issuable.assignee.id, id: nil
= dropdown_tag("Select assignee", options: { toggle_class: "js-user-search js-author-search", title: "Filter by user", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable dropdown-menu-author", placeholder: "Search users", data: { first_user: (current_user.username if current_user), current_user: true, project_id: (@project.id if @project), field_name: "issue[assignee_id]", issue_update: namespace_project_issue_path(@project.namespace, @project, issuable.id, :json) } })
 
.block.milestone
.sidebar-collapsed-icon
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment