Commit cca4a5fd authored by Tucker Chapman's avatar Tucker Chapman Committed by Phil Hughes

Add checkbox to choose to create new list when creating new label

parent e4a37158
......@@ -8,7 +8,11 @@ import boardsStore from '../stores/boards_store';
$(document)
.off('created.label')
.on('created.label', (e, label) => {
.on('created.label', (e, label, addNewList) => {
if (!addNewList) {
return;
}
boardsStore.new({
title: label.title,
position: boardsStore.state.lists.length - 2,
......
......@@ -14,6 +14,7 @@ export default class CreateLabelDropdown {
this.$newLabelField = $('#new_label_name', this.$el);
this.$newColorField = $('#new_label_color', this.$el);
this.$colorPreview = $('.js-dropdown-label-color-preview', this.$el);
this.$addList = $('.js-add-list', this.$el);
this.$newLabelError = $('.js-label-error', this.$el);
this.$newLabelCreateButton = $('.js-new-label-btn', this.$el);
this.$colorSuggestions = $('.suggest-colors-dropdown a', this.$el);
......@@ -21,6 +22,8 @@ export default class CreateLabelDropdown {
this.$newLabelError.hide();
this.$newLabelCreateButton.disable();
this.addListDefault = this.$addList.is(':checked');
this.cleanBinding();
this.addBinding();
}
......@@ -83,6 +86,8 @@ export default class CreateLabelDropdown {
this.$newColorField.val('').trigger('change');
this.$addList.prop('checked', this.addListDefault);
this.$colorPreview
.css('background-color', '')
.parent()
......@@ -116,9 +121,9 @@ export default class CreateLabelDropdown {
this.$newLabelError.html(errors).show();
} else {
const addNewList = this.$addList.is(':checked');
this.$dropdownBack.trigger('click');
$(document).trigger('created.label', label);
$(document).trigger('created.label', [label, addNewList]);
}
},
);
......
......@@ -561,10 +561,9 @@ GitLabDropdown = (function() {
!$target.data('isLink')
) {
e.stopPropagation();
return false;
} else {
return true;
}
return true;
}
};
......
......@@ -28,4 +28,4 @@
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
= render partial: "shared/issuable/label_page_default"
- if can?(current_user, :admin_label, current_board_parent)
= render partial: "shared/issuable/label_page_create"
= render partial: "shared/issuable/label_page_create", locals: { show_add_list: true }
......@@ -4,5 +4,5 @@
.dropdown-menu.dropdown-extended-height.dropdown-menu-paging.dropdown-menu-right.dropdown-menu-issues-board-new.dropdown-menu-selectable.js-tab-container-labels
= render partial: "shared/issuable/label_page_default", locals: { show_footer: true, show_create: true, show_boards_content: true, title: "Add list" }
- if can?(current_user, :admin_label, board.parent)
= render partial: "shared/issuable/label_page_create"
= render partial: "shared/issuable/label_page_create", locals: { show_add_list: true, add_list: true, add_list_class: 'd-none' }
= dropdown_loading
- show_close = local_assigns.fetch(:show_close, true)
- show_add_list = local_assigns.fetch(:show_add_list, false)
- add_list = local_assigns.fetch(:add_list, false)
- add_list_class = local_assigns.fetch(:add_list_class, '')
- subject = @project || @group
.dropdown-page-two.dropdown-new-label
= dropdown_title(create_label_title(subject), options: { back: true, close: show_close })
......@@ -12,6 +15,11 @@
.dropdown-label-color-input
.dropdown-label-color-preview.js-dropdown-label-color-preview
%input#new_label_color.default-dropdown-input{ type: "text", placeholder: _('Assign custom color like #FF0000') }
- if show_add_list
.dropdown-label-input{ class: add_list_class }
%label
%input.js-add-list{ type: "checkbox", name: "add_list", checked: add_list }
%span= _('Add list')
.clearfix
%button.btn.btn-primary.float-left.js-new-label-btn{ type: "button" }
= _('Create')
......
---
title: 'Added "Add List" checkbox to create label dropdown to make creation of list optional'
merge_request: 25716
author: Tucker Chapman
type: fixed
......@@ -453,6 +453,9 @@ msgstr ""
msgid "Add license"
msgstr ""
msgid "Add list"
msgstr ""
msgid "Add new application"
msgstr ""
......
......@@ -345,7 +345,7 @@ describe 'Issue Boards', :js do
click_link 'Create project label'
fill_in('new_label_name', with: 'Testing New Label')
fill_in('new_label_name', with: 'Testing New Label - with list')
first('.suggest-colors a').click
......
......@@ -343,6 +343,24 @@ describe 'Issue Boards', :js do
expect(page).to have_link 'test label'
end
expect(page).to have_selector('.board', count: 3)
end
it 'creates project label and list' do
click_card(card)
page.within('.labels') do
click_link 'Edit'
click_link 'Create project label'
fill_in 'new_label_name', with: 'test label'
first('.suggest-colors-dropdown a').click
first('.js-add-list').click
click_button 'Create'
wait_for_requests
expect(page).to have_link 'test label'
end
expect(page).to have_selector('.board', count: 4)
end
end
......
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