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 ...@@ -126,8 +126,10 @@ class GitLabDropdown
@selectFirstRow() @selectFirstRow()
# Event listeners # Event listeners
@dropdown.on "shown.bs.dropdown", @opened @dropdown.on "shown.bs.dropdown", @opened
@dropdown.on "hidden.bs.dropdown", @hidden @dropdown.on "hidden.bs.dropdown", @hidden
@dropdown.on "click", ".dropdown-menu", @shouldPropagate
if @dropdown.find(".dropdown-toggle-page").length if @dropdown.find(".dropdown-toggle-page").length
@dropdown.find(".dropdown-toggle-page, .dropdown-menu-back").on "click", (e) => @dropdown.find(".dropdown-toggle-page, .dropdown-menu-back").on "click", (e) =>
...@@ -177,6 +179,10 @@ class GitLabDropdown ...@@ -177,6 +179,10 @@ class GitLabDropdown
@appendMenu(full_html) @appendMenu(full_html)
shouldPropagate: (e) =>
if @options.multiSelect
e.stopPropagation()
opened: => opened: =>
contentHtml = $('.dropdown-content', @dropdown).html() contentHtml = $('.dropdown-content', @dropdown).html()
if @remote && contentHtml is "" if @remote && contentHtml is ""
......
...@@ -13,6 +13,7 @@ class @LabelsSelect ...@@ -13,6 +13,7 @@ class @LabelsSelect
showNo = $dropdown.data('show-no') showNo = $dropdown.data('show-no')
showAny = $dropdown.data('show-any') showAny = $dropdown.data('show-any')
defaultLabel = $dropdown.data('default-label') defaultLabel = $dropdown.data('default-label')
abilityName = $dropdown.data('ability-name')
$selectbox = $dropdown.closest('.selectbox') $selectbox = $dropdown.closest('.selectbox')
$block = $selectbox.closest('.block') $block = $selectbox.closest('.block')
$value = $block.find('.value') $value = $block.find('.value')
...@@ -195,16 +196,17 @@ class @LabelsSelect ...@@ -195,16 +196,17 @@ class @LabelsSelect
.map(-> .map(->
@value @value
).get() ).get()
# need inline-block here instead of show, console.log 'selected', selected
# which will default to the element's style in this case inline. data = {}
selected = if selected.length then selected else [''] data[abilityName] = {}
data[abilityName].label_ids = selected
if not selected.length
data[abilityName].label_ids = ['']
$loading.fadeIn() $loading.fadeIn()
$.ajax( $.ajax(
type: 'PUT' type: 'PUT'
url: issueURL url: issueURL
data: data: data
issue:
assignee_id: selected
).done (data) -> ).done (data) ->
$loading.fadeOut() $loading.fadeOut()
$selectbox.hide() $selectbox.hide()
......
...@@ -11,6 +11,7 @@ class @MilestoneSelect ...@@ -11,6 +11,7 @@ class @MilestoneSelect
useId = $dropdown.data('use-id') useId = $dropdown.data('use-id')
defaultLabel = $dropdown.data('default-label') defaultLabel = $dropdown.data('default-label')
issuableId = $dropdown.data('issuable-id') issuableId = $dropdown.data('issuable-id')
abilityName = $dropdown.data('ability-name')
$selectbox = $dropdown.closest('.selectbox') $selectbox = $dropdown.closest('.selectbox')
$block = $selectbox.closest('.block') $block = $selectbox.closest('.block')
$value = $block.find('.value') $value = $block.find('.value')
...@@ -70,14 +71,15 @@ class @MilestoneSelect ...@@ -70,14 +71,15 @@ class @MilestoneSelect
.closest('.selectbox') .closest('.selectbox')
.find('input[type="hidden"]') .find('input[type="hidden"]')
.val() .val()
data = {}
data[abilityName] = {}
data[abilityName].milestone_id = selected
$loading $loading
.fadeIn() .fadeIn()
$.ajax( $.ajax(
type: 'PUT' type: 'PUT'
url: issueUpdateURL url: issueUpdateURL
data: data: data
issue:
milestone_id: selected
).done (data) -> ).done (data) ->
$loading.fadeOut() $loading.fadeOut()
$selectbox.hide() $selectbox.hide()
......
...@@ -15,6 +15,7 @@ class @UsersSelect ...@@ -15,6 +15,7 @@ class @UsersSelect
issueURL = $dropdown.data('issueUpdate') issueURL = $dropdown.data('issueUpdate')
$selectbox = $dropdown.closest('.selectbox') $selectbox = $dropdown.closest('.selectbox')
$block = $selectbox.closest('.block') $block = $selectbox.closest('.block')
abilityName = $dropdown.data('ability-name')
$value = $block.find('.value') $value = $block.find('.value')
$loading = $block.find('.block-loading').fadeOut() $loading = $block.find('.block-loading').fadeOut()
...@@ -86,14 +87,16 @@ class @UsersSelect ...@@ -86,14 +87,16 @@ class @UsersSelect
selected = $dropdown selected = $dropdown
.closest('.selectbox') .closest('.selectbox')
.find("input[name='#{$dropdown.data('field-name')}']").val() .find("input[name='#{$dropdown.data('field-name')}']").val()
data = {}
data[abilityName] = {}
data[abilityName].assignee_id = selected
console.log 'data',data
$loading $loading
.fadeIn() .fadeIn()
$.ajax( $.ajax(
type: 'PUT' type: 'PUT'
url: issueURL url: issueURL
data: data: data
issue:
assignee_id: selected
).done (data) -> ).done (data) ->
$loading.fadeOut() $loading.fadeOut()
$selectbox.hide() $selectbox.hide()
......
...@@ -154,10 +154,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -154,10 +154,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request.target_project, @merge_request]) @merge_request.target_project, @merge_request])
end end
format.json do format.json do
render json: { render json: @merge_request.to_json(include: [:milestone, :labels, :assignee])
saved: @merge_request.valid?,
assignee_avatar_url: @merge_request.assignee.try(:avatar_url)
}
end end
end end
else else
......
%aside.right-sidebar{ class: sidebar_gutter_collapsed_class } %aside.right-sidebar{ class: sidebar_gutter_collapsed_class }
.issuable-sidebar .issuable-sidebar
.block.issuable-sidebar-header .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 %span.issuable-count.hide-collapsed.pull-left
= issuable.iid = issuable.iid
of of
...@@ -43,8 +47,8 @@ ...@@ -43,8 +47,8 @@
.light None .light None
.selectbox.hide-collapsed .selectbox.hide-collapsed
= f.hidden_field 'assignee_id', value: issuable.assignee.id, id: nil = 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) } }) = 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 .block.milestone
.sidebar-collapsed-icon .sidebar-collapsed-icon
...@@ -67,8 +71,8 @@ ...@@ -67,8 +71,8 @@
.light None .light None
.selectbox.hide-collapsed .selectbox.hide-collapsed
= f.hidden_field 'milestone_id', value: issuable.milestone.id, id: nil = 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 }}) = 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? - if issuable.project.labels.any?
.block.labels .block.labels
...@@ -89,9 +93,9 @@ ...@@ -89,9 +93,9 @@
.light None .light None
.selectbox.hide-collapsed .selectbox.hide-collapsed
- issuable.labels.each do |label| - 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 .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 %span.dropdown-toggle-text
Label Label
= icon('chevron-down') = 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