diff options
author | Tucker Chapman <tucker.r.chapman@gmail.com> | 2019-04-05 18:50:21 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-04-05 18:50:21 +0300 |
commit | cca4a5fd37b18590767f1ff8d2e2240f06060c0d (patch) | |
tree | 64bb5d7c17ad98bc7bd1e662b1b0019416281305 | |
parent | e4a371582cf044dc3027f48cb923c8c7309a7b6d (diff) |
Add checkbox to choose to create new list when creating new label
-rw-r--r-- | app/assets/javascripts/boards/components/new_list_dropdown.js | 6 | ||||
-rw-r--r-- | app/assets/javascripts/create_label.js | 9 | ||||
-rw-r--r-- | app/assets/javascripts/gl_dropdown.js | 5 | ||||
-rw-r--r-- | app/views/shared/boards/components/sidebar/_labels.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/issuable/_board_create_list_dropdown.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/issuable/_label_page_create.html.haml | 8 | ||||
-rw-r--r-- | changelogs/unreleased/create-label-and-list-checkbox.yml | 5 | ||||
-rw-r--r-- | locale/gitlab.pot | 3 | ||||
-rw-r--r-- | spec/features/boards/boards_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/boards/sidebar_spec.rb | 18 |
10 files changed, 51 insertions, 9 deletions
diff --git a/app/assets/javascripts/boards/components/new_list_dropdown.js b/app/assets/javascripts/boards/components/new_list_dropdown.js index 10577da9305..a5ed695af35 100644 --- a/app/assets/javascripts/boards/components/new_list_dropdown.js +++ b/app/assets/javascripts/boards/components/new_list_dropdown.js @@ -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, diff --git a/app/assets/javascripts/create_label.js b/app/assets/javascripts/create_label.js index 28ca7d97314..eac0e37bcaa 100644 --- a/app/assets/javascripts/create_label.js +++ b/app/assets/javascripts/create_label.js @@ -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]); } }, ); diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js index 27d8669b256..1c6b18c0e03 100644 --- a/app/assets/javascripts/gl_dropdown.js +++ b/app/assets/javascripts/gl_dropdown.js @@ -561,10 +561,9 @@ GitLabDropdown = (function() { !$target.data('isLink') ) { e.stopPropagation(); - return false; - } else { - return true; } + + return true; } }; diff --git a/app/views/shared/boards/components/sidebar/_labels.html.haml b/app/views/shared/boards/components/sidebar/_labels.html.haml index c6eade3bbbc..47cc912a9a1 100644 --- a/app/views/shared/boards/components/sidebar/_labels.html.haml +++ b/app/views/shared/boards/components/sidebar/_labels.html.haml @@ -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 } diff --git a/app/views/shared/issuable/_board_create_list_dropdown.html.haml b/app/views/shared/issuable/_board_create_list_dropdown.html.haml index fd413bd68c8..416b4a34651 100644 --- a/app/views/shared/issuable/_board_create_list_dropdown.html.haml +++ b/app/views/shared/issuable/_board_create_list_dropdown.html.haml @@ -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 diff --git a/app/views/shared/issuable/_label_page_create.html.haml b/app/views/shared/issuable/_label_page_create.html.haml index 55edaa7eda4..d173e3c0192 100644 --- a/app/views/shared/issuable/_label_page_create.html.haml +++ b/app/views/shared/issuable/_label_page_create.html.haml @@ -1,4 +1,7 @@ - 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') diff --git a/changelogs/unreleased/create-label-and-list-checkbox.yml b/changelogs/unreleased/create-label-and-list-checkbox.yml new file mode 100644 index 00000000000..330372df1be --- /dev/null +++ b/changelogs/unreleased/create-label-and-list-checkbox.yml @@ -0,0 +1,5 @@ +--- +title: 'Added "Add List" checkbox to create label dropdown to make creation of list optional' +merge_request: 25716 +author: Tucker Chapman +type: fixed diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 6d5abda257c..826103e16f4 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -453,6 +453,9 @@ msgstr "" msgid "Add license" msgstr "" +msgid "Add list" +msgstr "" + msgid "Add new application" msgstr "" diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb index ea69ec0319b..4c6175f5590 100644 --- a/spec/features/boards/boards_spec.rb +++ b/spec/features/boards/boards_spec.rb @@ -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 diff --git a/spec/features/boards/sidebar_spec.rb b/spec/features/boards/sidebar_spec.rb index ee38e756f9e..dfdb8d589eb 100644 --- a/spec/features/boards/sidebar_spec.rb +++ b/spec/features/boards/sidebar_spec.rb @@ -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 |