BigW Consortium Gitlab

Commit 25b9d8e5 by Phil Hughes Committed by Timothy Andrew

Merge branch '32861-fix-milestone-drag-and-drop-assignees' into 'master'

Fix milestone page assignees when dropped in ongoing list Closes #32861 See merge request !12076
parent ed967111
......@@ -65,14 +65,18 @@
};
Milestone.successCallback = function(data, element) {
var img_tag;
if (data.assignee) {
img_tag = $('<img/>');
img_tag.attr('src', data.assignee.avatar_url);
img_tag.addClass('avatar s16');
$(element).find('.assignee-icon img').replaceWith(img_tag);
} else {
$(element).find('.assignee-icon').empty();
const $avatarContainer = $(element).find('.assignee-icon');
$avatarContainer.empty();
if (data.assignees && data.assignees.length > 0) {
const $avatars = data.assignees.map((assignee) => {
const img_tag = $('<img/>');
img_tag.attr('src', assignee.avatar_url);
img_tag.addClass('avatar s16');
return img_tag;
});
$avatarContainer.append($avatars);
}
};
......@@ -161,9 +165,9 @@
data = (function() {
switch (newState) {
case 'ongoing':
return opts.fieldName + '[assignee_id]=' + gon.current_user_id;
return `${opts.fieldName}[assignee_ids][]=${gon.current_user_id}`;
case 'unassigned':
return opts.fieldName + '[assignee_id]=';
return `${opts.fieldName}[assignee_ids][]=0`;
case 'closed':
return opts.fieldName + '[state_event]=close';
}
......
......@@ -37,6 +37,14 @@ describe 'Milestone draggable', feature: true, js: true do
expect(issue_target).to have_selector('.issuable-row')
end
it 'assigns issue when it has been dragged to ongoing list' do
login_as(:admin)
create_and_drag_issue
expect(@issue.reload.assignees).not_to be_empty
expect(page).to have_selector("#sortable_issue_#{@issue.iid} .assignee-icon img", count: 1)
end
end
context 'merge requests' do
......@@ -72,7 +80,7 @@ describe 'Milestone draggable', feature: true, js: true do
end
def create_and_drag_issue(params = {})
create(:issue, params.merge(title: 'Foo', project: project, milestone: milestone))
@issue = create(:issue, params.merge(title: 'Foo', project: project, milestone: milestone))
visit namespace_project_milestone_path(project.namespace, project, milestone)
scroll_into_view('.milestone-content')
......
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