Commit ef59be4d authored by Valery Sizov's avatar Valery Sizov

Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ee into ce-upstream

parents c8765c31 90cb7c64
class @WeightSelect
constructor: ->
$('.js-weight-select').each (i, dropdown) ->
$(dropdown).glDropdown(
$dropdown = $(dropdown)
updateUrl = $dropdown.data('issueUpdate')
$selectbox = $dropdown.closest('.selectbox')
$block = $selectbox.closest('.block')
$sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon span')
$value = $block.find('.value')
abilityName = $dropdown.data('ability-name')
$loading = $block.find('.block-loading').fadeOut()
updateWeight = (selected) ->
data = {}
data[abilityName] = {}
data[abilityName].weight = selected
$loading
.fadeIn()
$dropdown.trigger('loading.gl.dropdown')
$.ajax(
type: 'PUT'
dataType: 'json'
url: updateUrl
data: data
).done (data) ->
$dropdown.trigger('loaded.gl.dropdown')
$loading.fadeOut()
$selectbox.hide()
$value.html(data.weight)
$sidebarCollapsedValue.html(data.weight)
$dropdown.glDropdown(
selectable: true
fieldName: $(dropdown).data("field-name")
fieldName: $dropdown.data("field-name")
hidden: (e) ->
$selectbox.hide()
# display:block overrides the hide-collapse rule
$value.removeAttr('style')
id: (obj, el) ->
$(el).data "id"
clicked: ->
clicked: (selected) ->
if $(dropdown).is ".js-filter-submit"
$(dropdown).parents('form').submit()
else
selected = $dropdown
.closest('.selectbox')
.find("input[name='#{$dropdown.data('field-name')}']").val()
updateWeight(selected)
)
......@@ -129,19 +129,23 @@
- else
No
.title.hide-collapsed
%label Weight
Weight
= icon('spinner spin', class: 'block-loading')
- if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
.pull-right
= link_to 'Edit', '#', class: 'edit-link'
.value.hide-collapsed
= link_to 'Edit', '#', class: 'edit-link pull-right'
.value.bold.hide-collapsed
- if issuable.weight
= icon('balance-scale')
= issuable.weight
- else
.light None
.selectbox.hide-collapsed
= f.select :weight, issues_weight_options(issuable.weight, edit: true), { include_blank: true },
{ class: 'select2 js-select2', data: { placeholder: "Select weight" }}
= dropdown_tag("Weight", options: { title: "Change weight", toggle_class: 'js-weight-select', dropdown_class: "dropdown-menu-selectable",
placeholder: "Search weight", data: { field_name: "weight", issue_update: "#{issuable_json_path(issuable)}", ability_name: "#{issuable.to_ability_name}" } }) do
%ul
- Issue.weight_options.select{|weight| weight != "Everything" && weight != "Any Weight"}.each do |weight|
%li
%a{href: "#", data: { id: weight }, class: ("is-active" if params[:weight] == weight.to_s)}
= weight
= render "shared/issuable/participants", participants: issuable.participants(current_user)
- if current_user
......@@ -174,6 +178,7 @@
:javascript
new MilestoneSelect('{"namespace":"#{@project.namespace.path}","path":"#{@project.path}"}');
new LabelsSelect();
new WeightSelect();
new IssuableContext('#{current_user.to_json(only: [:username, :id, :name])}');
new Subscription('.subscription')
new Sidebar();
......@@ -238,6 +238,27 @@ describe 'Issues', feature: true do
end
end
describe 'update weight from issue#show', js: true do
let!(:issue) { create(:issue, project: project) }
before do
visit namespace_project_issue_path(project.namespace, project, issue)
end
it 'should allow user to update to a weight' do
page.within('.weight') do
expect(page).to have_content "None"
click_link 'Edit'
find('.dropdown-content a', text: '1').click
page.within('.value') do
expect(page).to have_content "1"
end
end
end
end
describe 'update milestone from issue#show' do
let!(:issue) { create(:issue, project: project, author: @user) }
let!(:milestone) { create(:milestone, project: project) }
......
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