Commit de9e559d authored by Clement Ho's avatar Clement Ho Committed by Phil Hughes

Fix unassigned checkmark

parent 1930c19c
...@@ -45,6 +45,12 @@ gl.issueBoards.BoardSidebar = Vue.extend({ ...@@ -45,6 +45,12 @@ gl.issueBoards.BoardSidebar = Vue.extend({
detail: { detail: {
handler () { handler () {
if (this.issue.id !== this.detail.issue.id) { if (this.issue.id !== this.detail.issue.id) {
$('.block.assignee')
.find('input:not(.js-vue)[name="issue[assignee_ids][]"]')
.each((i, el) => {
$(el).remove();
});
$('.js-issue-board-sidebar', this.$el).each((i, el) => { $('.js-issue-board-sidebar', this.$el).each((i, el) => {
$(el).data('glDropdown').clearMenu(); $(el).data('glDropdown').clearMenu();
}); });
......
...@@ -50,7 +50,11 @@ function UsersSelect(currentUser, els) { ...@@ -50,7 +50,11 @@ function UsersSelect(currentUser, els) {
$collapsedSidebar = $block.find('.sidebar-collapsed-user'); $collapsedSidebar = $block.find('.sidebar-collapsed-user');
$loading = $block.find('.block-loading').fadeOut(); $loading = $block.find('.block-loading').fadeOut();
selectedIdDefault = (defaultNullUser && showNullUser) ? 0 : null; selectedIdDefault = (defaultNullUser && showNullUser) ? 0 : null;
selectedId = $dropdown.data('selected') || selectedIdDefault; selectedId = $dropdown.data('selected');
if (selectedId === undefined) {
selectedId = selectedIdDefault;
}
const assignYourself = function () { const assignYourself = function () {
const unassignedSelected = $dropdown.closest('.selectbox') const unassignedSelected = $dropdown.closest('.selectbox')
...@@ -423,8 +427,9 @@ function UsersSelect(currentUser, els) { ...@@ -423,8 +427,9 @@ function UsersSelect(currentUser, els) {
}, },
opened: function(e) { opened: function(e) {
const $el = $(e.currentTarget); const $el = $(e.currentTarget);
if ($dropdown.hasClass('js-issue-board-sidebar')) { const selected = getSelected();
selectedId = parseInt($dropdown[0].dataset.selected, 10) || selectedIdDefault; if ($dropdown.hasClass('js-issue-board-sidebar') && selected.length === 0) {
this.addInput($dropdown.data('field-name'), 0, {});
} }
$el.find('.is-active').removeClass('is-active'); $el.find('.is-active').removeClass('is-active');
...@@ -432,8 +437,10 @@ function UsersSelect(currentUser, els) { ...@@ -432,8 +437,10 @@ function UsersSelect(currentUser, els) {
$el.find(`li[data-user-id="${id}"] .dropdown-menu-user-link`).addClass('is-active'); $el.find(`li[data-user-id="${id}"] .dropdown-menu-user-link`).addClass('is-active');
} }
if ($selectbox[0]) { if (selected.length > 0) {
getSelected().forEach(selectedId => highlightSelected(selectedId)); getSelected().forEach(selectedId => highlightSelected(selectedId));
} else if ($dropdown.hasClass('js-issue-board-sidebar')) {
highlightSelected(0);
} else { } else {
highlightSelected(selectedId); highlightSelected(selectedId);
} }
...@@ -444,15 +451,19 @@ function UsersSelect(currentUser, els) { ...@@ -444,15 +451,19 @@ function UsersSelect(currentUser, els) {
username = user.username ? "@" + user.username : ""; username = user.username ? "@" + user.username : "";
avatar = user.avatar_url ? user.avatar_url : false; avatar = user.avatar_url ? user.avatar_url : false;
let selected = user.id === parseInt(selectedId, 10); let selected = false;
if (this.multiSelect) { if (this.multiSelect) {
selected = getSelected().find(u => user.id === u);
const fieldName = this.fieldName; const fieldName = this.fieldName;
const field = $dropdown.closest('.selectbox').find("input[name='" + fieldName + "'][value='" + user.id + "']"); const field = $dropdown.closest('.selectbox').find("input[name='" + fieldName + "'][value='" + user.id + "']");
if (field.length) { if (field.length) {
selected = true; selected = true;
} }
} else {
selected = user.id === selectedId;
} }
img = ""; img = "";
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
- if can?(current_user, :admin_issue, @project) - if can?(current_user, :admin_issue, @project)
.selectbox.hide-collapsed .selectbox.hide-collapsed
%input{ type: "hidden", %input.js-vue{ type: "hidden",
name: "issue[assignee_ids][]", name: "issue[assignee_ids][]",
":value" => "assignee.id", ":value" => "assignee.id",
"v-if" => "issue.assignees", "v-if" => "issue.assignees",
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
.dropdown .dropdown
%button.dropdown-menu-toggle.js-user-search.js-author-search.js-multiselect.js-save-user-data.js-issue-board-sidebar{ type: "button", ref: "assigneeDropdown", data: { toggle: "dropdown", field_name: "issue[assignee_ids][]", first_user: (current_user.username if current_user), current_user: "true", project_id: @project.id, null_user: "true", multi_select: "true", 'max-select' => 1, dropdown: { header: 'Assignee' } }, %button.dropdown-menu-toggle.js-user-search.js-author-search.js-multiselect.js-save-user-data.js-issue-board-sidebar{ type: "button", ref: "assigneeDropdown", data: { toggle: "dropdown", field_name: "issue[assignee_ids][]", first_user: (current_user.username if current_user), current_user: "true", project_id: @project.id, null_user: "true", multi_select: "true", 'max-select' => 1, dropdown: { header: 'Assignee' } },
":data-issuable-id" => "issue.id", ":data-issuable-id" => "issue.id",
":data-selected" => "assigneeId",
":data-issue-update" => "'#{namespace_project_issues_path(@project.namespace, @project)}/' + issue.id + '.json'" } ":data-issue-update" => "'#{namespace_project_issues_path(@project.namespace, @project)}/' + issue.id + '.json'" }
Select assignee Select assignee
= icon("chevron-down") = icon("chevron-down")
......
...@@ -26,9 +26,20 @@ RSpec.describe 'Dashboard Issues', feature: true do ...@@ -26,9 +26,20 @@ RSpec.describe 'Dashboard Issues', feature: true do
expect(page).not_to have_content(other_issue.title) expect(page).not_to have_content(other_issue.title)
end end
it 'shows checkmark when unassigned is selected for assignee', js: true do
find('.js-assignee-search').click
find('li', text: 'Unassigned').click
find('.js-assignee-search').click
expect(find('li[data-user-id="0"] a.is-active')).to be_visible
end
it 'shows issues when current user is author', js: true do it 'shows issues when current user is author', js: true do
find('#assignee_id', visible: false).set('') find('#assignee_id', visible: false).set('')
find('.js-author-search', match: :first).click find('.js-author-search', match: :first).click
expect(find('li[data-user-id="null"] a.is-active')).to be_visible
find('.dropdown-menu-author li a', match: :first, text: current_user.to_reference).click find('.dropdown-menu-author li a', match: :first, text: current_user.to_reference).click
find('.js-author-search', match: :first).click find('.js-author-search', match: :first).click
......
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