Commit 4d0c5bba authored by Lin Jen-Shin's avatar Lin Jen-Shin

Unify app/views/shared/issuable/_search_bar.html.haml

This is a bit tricky, so here we tried to port some codes to CE
if it doesn't hurt. If we tried to keep the behaviour completely
the same, the code would be pretty complicated without a good reason.

This also tries to reduce the changes by not moving a block into a
partial, which would force indentation and a lot of changes.
parent 8078f779
...@@ -28,4 +28,8 @@ class Board < ActiveRecord::Base ...@@ -28,4 +28,8 @@ class Board < ActiveRecord::Base
def closed_list def closed_list
lists.merge(List.closed).take lists.merge(List.closed).take
end end
def scoped?
false
end
end end
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
- board = local_assigns.fetch(:board, nil) - board = local_assigns.fetch(:board, nil)
- block_css_class = type != :boards_modal ? 'row-content-block second-block' : '' - block_css_class = type != :boards_modal ? 'row-content-block second-block' : ''
- full_path = @project.present? ? @project.full_path : @group.full_path - full_path = @project.present? ? @project.full_path : @group.full_path
- user_can_admin_list = can?(current_user, :admin_list, board.parent)
.issues-filters .issues-filters
.issues-details-filters.filtered-search-block{ class: block_css_class, "v-pre" => type == :boards_modal } .issues-details-filters.filtered-search-block{ class: block_css_class, "v-pre" => type == :boards_modal }
- if type == :boards && board - if type == :boards && board
#js-multiple-boards-switcher.inline.boards-switcher{ "v-cloak" => true } #js-multiple-boards-switcher.inline.boards-switcher{ "v-cloak" => true }
= render "shared/boards/switcher", board: board = render_if_exists "shared/boards/switcher", board: board
= form_tag page_filter_path(without: [:assignee_id, :author_id, :milestone_title, :label_name, :search]), method: :get, class: 'filter-form js-filter-form' do = form_tag page_filter_path(without: [:assignee_id, :author_id, :milestone_title, :label_name, :search]), method: :get, class: 'filter-form js-filter-form' do
- if params[:search].present? - if params[:search].present?
= hidden_field_tag :search, params[:search] = hidden_field_tag :search, params[:search]
...@@ -104,31 +105,17 @@ ...@@ -104,31 +105,17 @@
%span.js-data-value.prepend-left-10 %span.js-data-value.prepend-left-10
{{name}} {{name}}
- if type == :issues || type == :boards || type == :boards_modal = render_if_exists 'shared/issuable/filter_weight', type: type
#js-dropdown-weight.filtered-search-input-dropdown-menu.dropdown-menu
%ul{ 'data-dropdown' => true }
%li.filter-dropdown-item{ 'data-value' => 'None' }
%button.btn.btn-link
None
%li.filter-dropdown-item{ 'data-value' => 'Any' }
%button.btn.btn-link
Any
%li.divider.droplab-item-ignore
%ul.filter-dropdown{ data: { dropdown: true, dynamic: true } }
%li.filter-dropdown-item{ data: { value: '{{id}}' } }
%button.btn.btn-link {{title}}
%button.clear-search.hidden{ type: 'button' } %button.clear-search.hidden{ type: 'button' }
= icon('times') = icon('times')
.filter-dropdown-container .filter-dropdown-container
- if type == :boards - if type == :boards
- user_can_admin_list = can?(current_user, :admin_list, board.parent)
.js-board-config{ data: { can_admin_list: user_can_admin_list, has_scope: board.scoped? } } .js-board-config{ data: { can_admin_list: user_can_admin_list, has_scope: board.scoped? } }
- if user_can_admin_list - if user_can_admin_list
= render_if_exists 'shared/issuable/board_create_list_dropdown', board: board = render 'shared/issuable/board_create_list_dropdown', board: board
- if @project - if @project
#js-add-issues-btn.prepend-left-10{ data: { can_admin_list: can?(current_user, :admin_list, @project) } } #js-add-issues-btn.prepend-left-10{ data: { can_admin_list: can?(current_user, :admin_list, @project) } }
#js-toggle-focus-btn.prepend-left-10 #js-toggle-focus-btn
- elsif type != :boards_modal - elsif type != :boards_modal
= render 'shared/sort_dropdown' = render 'shared/sort_dropdown'
module EE module EE
module Board module Board
extend ActiveSupport::Concern extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
# Empty state for milestones and weights. # Empty state for milestones and weights.
EMPTY_SCOPE_STATE = [nil, -1].freeze EMPTY_SCOPE_STATE = [nil, -1].freeze
...@@ -21,6 +22,16 @@ module EE ...@@ -21,6 +22,16 @@ module EE
validates :name, presence: true validates :name, presence: true
end end
override :scoped?
def scoped?
return super unless parent.feature_available?(:scoped_issue_board)
EMPTY_SCOPE_STATE.exclude?(milestone_id) ||
EMPTY_SCOPE_STATE.exclude?(weight) ||
labels.any? ||
assignee.present?
end
def milestone def milestone
return nil unless parent.feature_available?(:scoped_issue_board) return nil unless parent.feature_available?(:scoped_issue_board)
...@@ -34,15 +45,6 @@ module EE ...@@ -34,15 +45,6 @@ module EE
end end
end end
def scoped?
return false unless parent.feature_available?(:scoped_issue_board)
EMPTY_SCOPE_STATE.exclude?(milestone_id) ||
EMPTY_SCOPE_STATE.exclude?(weight) ||
labels.any? ||
assignee.present?
end
def as_json(options = {}) def as_json(options = {})
milestone_attrs = options.fetch(:include, {}) milestone_attrs = options.fetch(:include, {})
.extract!(:milestone) .extract!(:milestone)
......
- type = local_assigns.fetch(:type)
- return unless type == :issues || type == :boards || type == :boards_modal
#js-dropdown-weight.filtered-search-input-dropdown-menu.dropdown-menu
%ul{ 'data-dropdown' => true }
%li.filter-dropdown-item{ 'data-value' => 'None' }
%button.btn.btn-link
None
%li.filter-dropdown-item{ 'data-value' => 'Any' }
%button.btn.btn-link
Any
%li.divider.droplab-item-ignore
%ul.filter-dropdown{ data: { dropdown: true, dynamic: true } }
%li.filter-dropdown-item{ data: { value: '{{id}}' } }
%button.btn.btn-link {{title}}
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