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'; ...@@ -8,7 +8,11 @@ import boardsStore from '../stores/boards_store';
$(document) $(document)
.off('created.label') .off('created.label')
.on('created.label', (e, label) => { .on('created.label', (e, label, addNewList) => {
if (!addNewList) {
return;
}
boardsStore.new({ boardsStore.new({
title: label.title, title: label.title,
position: boardsStore.state.lists.length - 2, position: boardsStore.state.lists.length - 2,
......
...@@ -14,6 +14,7 @@ export default class CreateLabelDropdown { ...@@ -14,6 +14,7 @@ export default class CreateLabelDropdown {
this.$newLabelField = $('#new_label_name', this.$el); this.$newLabelField = $('#new_label_name', this.$el);
this.$newColorField = $('#new_label_color', this.$el); this.$newColorField = $('#new_label_color', this.$el);
this.$colorPreview = $('.js-dropdown-label-color-preview', 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.$newLabelError = $('.js-label-error', this.$el);
this.$newLabelCreateButton = $('.js-new-label-btn', this.$el); this.$newLabelCreateButton = $('.js-new-label-btn', this.$el);
this.$colorSuggestions = $('.suggest-colors-dropdown a', this.$el); this.$colorSuggestions = $('.suggest-colors-dropdown a', this.$el);
...@@ -21,6 +22,8 @@ export default class CreateLabelDropdown { ...@@ -21,6 +22,8 @@ export default class CreateLabelDropdown {
this.$newLabelError.hide(); this.$newLabelError.hide();
this.$newLabelCreateButton.disable(); this.$newLabelCreateButton.disable();
this.addListDefault = this.$addList.is(':checked');
this.cleanBinding(); this.cleanBinding();
this.addBinding(); this.addBinding();
} }
...@@ -83,6 +86,8 @@ export default class CreateLabelDropdown { ...@@ -83,6 +86,8 @@ export default class CreateLabelDropdown {
this.$newColorField.val('').trigger('change'); this.$newColorField.val('').trigger('change');
this.$addList.prop('checked', this.addListDefault);
this.$colorPreview this.$colorPreview
.css('background-color', '') .css('background-color', '')
.parent() .parent()
...@@ -116,9 +121,9 @@ export default class CreateLabelDropdown { ...@@ -116,9 +121,9 @@ export default class CreateLabelDropdown {
this.$newLabelError.html(errors).show(); this.$newLabelError.html(errors).show();
} else { } else {
const addNewList = this.$addList.is(':checked');
this.$dropdownBack.trigger('click'); this.$dropdownBack.trigger('click');
$(document).trigger('created.label', [label, addNewList]);
$(document).trigger('created.label', label);
} }
}, },
); );
......
...@@ -561,10 +561,9 @@ GitLabDropdown = (function() { ...@@ -561,10 +561,9 @@ GitLabDropdown = (function() {
!$target.data('isLink') !$target.data('isLink')
) { ) {
e.stopPropagation(); e.stopPropagation();
return false;
} else {
return true;
} }
return true;
} }
}; };
......
...@@ -28,4 +28,4 @@ ...@@ -28,4 +28,4 @@
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable .dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
= render partial: "shared/issuable/label_page_default" = render partial: "shared/issuable/label_page_default"
- if can?(current_user, :admin_label, current_board_parent) - 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 @@ ...@@ -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 .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" } = 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) - 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 = dropdown_loading
- show_close = local_assigns.fetch(:show_close, true) - 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 - subject = @project || @group
.dropdown-page-two.dropdown-new-label .dropdown-page-two.dropdown-new-label
= dropdown_title(create_label_title(subject), options: { back: true, close: show_close }) = dropdown_title(create_label_title(subject), options: { back: true, close: show_close })
...@@ -12,6 +15,11 @@ ...@@ -12,6 +15,11 @@
.dropdown-label-color-input .dropdown-label-color-input
.dropdown-label-color-preview.js-dropdown-label-color-preview .dropdown-label-color-preview.js-dropdown-label-color-preview
%input#new_label_color.default-dropdown-input{ type: "text", placeholder: _('Assign custom color like #FF0000') } %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 .clearfix
%button.btn.btn-primary.float-left.js-new-label-btn{ type: "button" } %button.btn.btn-primary.float-left.js-new-label-btn{ type: "button" }
= _('Create') = _('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 "" ...@@ -453,6 +453,9 @@ msgstr ""
msgid "Add license" msgid "Add license"
msgstr "" msgstr ""
msgid "Add list"
msgstr ""
msgid "Add new application" msgid "Add new application"
msgstr "" msgstr ""
......
...@@ -345,7 +345,7 @@ describe 'Issue Boards', :js do ...@@ -345,7 +345,7 @@ describe 'Issue Boards', :js do
click_link 'Create project label' 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 first('.suggest-colors a').click
......
...@@ -343,6 +343,24 @@ describe 'Issue Boards', :js do ...@@ -343,6 +343,24 @@ describe 'Issue Boards', :js do
expect(page).to have_link 'test label' expect(page).to have_link 'test label'
end 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
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