Commit 22aef628 authored by Jacob Schatz's avatar Jacob Schatz

New dropdowns work on merge requests too!

parent e8d84110
......@@ -126,8 +126,10 @@ class GitLabDropdown
@selectFirstRow()
# Event listeners
@dropdown.on "shown.bs.dropdown", @opened
@dropdown.on "hidden.bs.dropdown", @hidden
@dropdown.on "click", ".dropdown-menu", @shouldPropagate
if @dropdown.find(".dropdown-toggle-page").length
@dropdown.find(".dropdown-toggle-page, .dropdown-menu-back").on "click", (e) =>
......@@ -177,6 +179,10 @@ class GitLabDropdown
@appendMenu(full_html)
shouldPropagate: (e) =>
if @options.multiSelect
e.stopPropagation()
opened: =>
contentHtml = $('.dropdown-content', @dropdown).html()
if @remote && contentHtml is ""
......
......@@ -13,6 +13,7 @@ class @LabelsSelect
showNo = $dropdown.data('show-no')
showAny = $dropdown.data('show-any')
defaultLabel = $dropdown.data('default-label')
abilityName = $dropdown.data('ability-name')
$selectbox = $dropdown.closest('.selectbox')
$block = $selectbox.closest('.block')
$value = $block.find('.value')
......@@ -195,16 +196,17 @@ class @LabelsSelect
.map(->
@value
).get()
# 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 ['']
console.log 'selected', selected
data = {}
data[abilityName] = {}
data[abilityName].label_ids = selected
if not selected.length
data[abilityName].label_ids = ['']
$loading.fadeIn()
$.ajax(
type: 'PUT'
url: issueURL
data:
issue:
assignee_id: selected
data: data
).done (data) ->
$loading.fadeOut()
$selectbox.hide()
......
......@@ -11,6 +11,7 @@ class @MilestoneSelect
useId = $dropdown.data('use-id')
defaultLabel = $dropdown.data('default-label')
issuableId = $dropdown.data('issuable-id')
abilityName = $dropdown.data('ability-name')
$selectbox = $dropdown.closest('.selectbox')
$block = $selectbox.closest('.block')
$value = $block.find('.value')
......@@ -70,14 +71,15 @@ class @MilestoneSelect
.closest('.selectbox')
.find('input[type="hidden"]')
.val()
data = {}
data[abilityName] = {}
data[abilityName].milestone_id = selected
$loading
.fadeIn()
$.ajax(
type: 'PUT'
url: issueUpdateURL
data:
issue:
milestone_id: selected
data: data
).done (data) ->
$loading.fadeOut()
$selectbox.hide()
......
......@@ -15,6 +15,7 @@ class @UsersSelect
issueURL = $dropdown.data('issueUpdate')
$selectbox = $dropdown.closest('.selectbox')
$block = $selectbox.closest('.block')
abilityName = $dropdown.data('ability-name')
$value = $block.find('.value')
$loading = $block.find('.block-loading').fadeOut()
......@@ -86,14 +87,16 @@ class @UsersSelect
selected = $dropdown
.closest('.selectbox')
.find("input[name='#{$dropdown.data('field-name')}']").val()
data = {}
data[abilityName] = {}
data[abilityName].assignee_id = selected
console.log 'data',data
$loading
.fadeIn()
$.ajax(
type: 'PUT'
url: issueURL
data:
issue:
assignee_id: selected
data: data
).done (data) ->
$loading.fadeOut()
$selectbox.hide()
......
......@@ -154,10 +154,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request.target_project, @merge_request])
end
format.json do
render json: {
saved: @merge_request.valid?,
assignee_avatar_url: @merge_request.assignee.try(:avatar_url)
}
render json: @merge_request.to_json(include: [:milestone, :labels, :assignee])
end
end
else
......
%aside.right-sidebar{ class: sidebar_gutter_collapsed_class }
.issuable-sidebar
.block.issuable-sidebar-header
- if issuable.to_ability_name == 'merge_request'
- issuable_url = namespace_project_merge_request_path(@project.namespace, @project, issuable.id, :json)
- else
- issuable_url = namespace_project_issue_path(@project.namespace, @project, issuable.id, :json)
%span.issuable-count.hide-collapsed.pull-left
= issuable.iid
of
......@@ -43,8 +47,8 @@
.light None
.selectbox.hide-collapsed
= 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) } })
= 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: "#{issuable.to_ability_name}[assignee_id]", issue_update: issuable_url, ability_name: issuable.to_ability_name } })
.block.milestone
.sidebar-collapsed-icon
......@@ -67,8 +71,8 @@
.light None
.selectbox.hide-collapsed
= f.hidden_field 'milestone_id', value: issuable.milestone.id, id: nil
= dropdown_tag("Milestone", options: { title: "Assign milestone", toggle_class: 'js-milestone-select', filter: true, dropdown_class: "dropdown-menu-selectable", placeholder: "Search milestones", data: { show_no: true, field_name: "issue[milestone_id]", project_id: @project.id, issuable_id: issuable.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :json), issue_update: namespace_project_issue_path(@project.namespace, @project, issuable.id, :json), use_id: true }})
= f.hidden_field 'milestone_id', value: issuable.milestone_id, id: nil
= dropdown_tag('Milestone', options: { title: 'Assign milestone', toggle_class: 'js-milestone-select', filter: true, dropdown_class: 'dropdown-menu-selectable', placeholder: 'Search milestones', data: { show_no: true, field_name: "#{issuable.to_ability_name}[milestone_id]", project_id: @project.id, issuable_id: issuable.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :json), ability_name: issuable.to_ability_name, issue_update: issuable_url, use_id: true }})
- if issuable.project.labels.any?
.block.labels
......@@ -89,9 +93,9 @@
.light None
.selectbox.hide-collapsed
- issuable.labels.each do |label|
= hidden_field_tag 'issue[label_names][]', label.id, id: nil
= hidden_field_tag "{issuable.to_ability_name}[label_names][]", label.id, id: nil
.dropdown
%button.dropdown-menu-toggle.js-label-select.js-multiselect{type: "button", data: {toggle: "dropdown", field_name: "issue[label_names][]", show_no: "true", show_any: "true", selected: issuable.label_names.join(","), project_id: (@project.id if @project), issue_update: namespace_project_issue_path(@project.namespace, @project, issuable.id, :json), labels: (namespace_project_labels_path(@project.namespace, @project, :json) if @project)}}
%button.dropdown-menu-toggle.js-label-select.js-multiselect{type: "button", data: {toggle: "dropdown", field_name: "{issuable.to_ability_name}[label_names][]", ability_name: issuable.to_ability_name, show_no: "true", show_any: "true", selected: issuable.label_names.join(","), project_id: (@project.id if @project), issue_update: issuable_url, labels: (namespace_project_labels_path(@project.namespace, @project, :json) if @project)}}
%span.dropdown-toggle-text
Label
= icon('chevron-down')
......
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