Adds new dropdown ajax to user selection
This commit is contained in:
parent
74c7a537ed
commit
e8d8411016
|
@ -198,14 +198,13 @@ class @LabelsSelect
|
||||||
# need inline-block here instead of show,
|
# need inline-block here instead of show,
|
||||||
# which will default to the element's style in this case inline.
|
# which will default to the element's style in this case inline.
|
||||||
selected = if selected.length then selected else ['']
|
selected = if selected.length then selected else ['']
|
||||||
$loading
|
$loading.fadeIn()
|
||||||
.fadeIn()
|
|
||||||
$.ajax(
|
$.ajax(
|
||||||
type: 'PUT'
|
type: 'PUT'
|
||||||
url: issueURL
|
url: issueURL
|
||||||
data:
|
data:
|
||||||
issue:
|
issue:
|
||||||
label_ids: selected
|
assignee_id: selected
|
||||||
).done (data) ->
|
).done (data) ->
|
||||||
$loading.fadeOut()
|
$loading.fadeOut()
|
||||||
$selectbox.hide()
|
$selectbox.hide()
|
||||||
|
|
|
@ -12,6 +12,11 @@ class @UsersSelect
|
||||||
firstUser = $dropdown.data('first-user')
|
firstUser = $dropdown.data('first-user')
|
||||||
selectedId = $dropdown.data('selected')
|
selectedId = $dropdown.data('selected')
|
||||||
defaultLabel = $dropdown.data('default-label')
|
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(
|
$dropdown.glDropdown(
|
||||||
data: (term, callback) =>
|
data: (term, callback) =>
|
||||||
|
@ -57,11 +62,17 @@ class @UsersSelect
|
||||||
fields: ['name', 'username']
|
fields: ['name', 'username']
|
||||||
selectable: true
|
selectable: true
|
||||||
fieldName: $dropdown.data('field-name')
|
fieldName: $dropdown.data('field-name')
|
||||||
|
|
||||||
toggleLabel: (selected) ->
|
toggleLabel: (selected) ->
|
||||||
if selected && 'id' of selected
|
if selected && 'id' of selected
|
||||||
selected.name
|
selected.name
|
||||||
else
|
else
|
||||||
defaultLabel
|
defaultLabel
|
||||||
|
|
||||||
|
hidden: ->
|
||||||
|
$selectbox.hide()
|
||||||
|
$value.show()
|
||||||
|
|
||||||
clicked: ->
|
clicked: ->
|
||||||
page = $('body').data 'page'
|
page = $('body').data 'page'
|
||||||
isIssueIndex = page is 'projects:issues:index'
|
isIssueIndex = page is 'projects:issues:index'
|
||||||
|
@ -72,7 +83,32 @@ class @UsersSelect
|
||||||
else if $dropdown.hasClass 'js-filter-submit'
|
else if $dropdown.hasClass 'js-filter-submit'
|
||||||
$dropdown.closest('form').submit()
|
$dropdown.closest('form').submit()
|
||||||
else
|
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) ->
|
renderRow: (user) ->
|
||||||
username = if user.username then "@#{user.username}" else ""
|
username = if user.username then "@#{user.username}" else ""
|
||||||
avatar = if user.avatar_url then user.avatar_url else false
|
avatar = if user.avatar_url then user.avatar_url else false
|
||||||
|
|
|
@ -114,7 +114,7 @@ class Projects::IssuesController < Projects::ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
format.json do
|
format.json do
|
||||||
render json: @issue.to_json(include: [:milestone, :labels])
|
render json: @issue.to_json(include: [:milestone, :labels, :assignee])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
= icon('user')
|
= icon('user')
|
||||||
.title.hide-collapsed
|
.title.hide-collapsed
|
||||||
Assignee
|
Assignee
|
||||||
|
=icon('spinner spin', class: 'block-loading')
|
||||||
- if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
|
- if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
|
||||||
= link_to 'Edit', '#', class: 'edit-link pull-right'
|
= link_to 'Edit', '#', class: 'edit-link pull-right'
|
||||||
.value.bold.hide-collapsed
|
.value.bold.hide-collapsed
|
||||||
|
@ -42,7 +43,8 @@
|
||||||
.light None
|
.light None
|
||||||
|
|
||||||
.selectbox.hide-collapsed
|
.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
|
.block.milestone
|
||||||
.sidebar-collapsed-icon
|
.sidebar-collapsed-icon
|
||||||
|
|
Loading…
Reference in New Issue