Commit 22b8b9a7 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Address feedback

parent 228a6845
...@@ -491,7 +491,9 @@ class GitLabDropdown ...@@ -491,7 +491,9 @@ class GitLabDropdown
addInput: (fieldName, value)-> addInput: (fieldName, value)->
# Create hidden input for form # Create hidden input for form
$input = $("<input type='hidden' name='#{fieldName}' value='#{value}' />") $input = $('<input>').attr('type', 'hidden')
.attr('name', fieldName)
.val(value)
if @options.inputId? if @options.inputId?
$input.attr('id', @options.inputId) $input.attr('id', @options.inputId)
......
...@@ -13,7 +13,7 @@ class @IssuableBulkActions ...@@ -13,7 +13,7 @@ class @IssuableBulkActions
@container.find selector @container.find selector
bindEvents: -> bindEvents: ->
@form.on 'submit', @onFormSubmit.bind(@) @form.off('submit').on('submit', @onFormSubmit.bind(@))
onFormSubmit: (e) -> onFormSubmit: (e) ->
e.preventDefault() e.preventDefault()
......
...@@ -199,6 +199,9 @@ class @LabelsSelect ...@@ -199,6 +199,9 @@ class @LabelsSelect
callback data callback data
renderRow: (label, instance) -> renderRow: (label, instance) ->
$li = $('<li>')
$a = $('<a href="#">')
selectedClass = [] selectedClass = []
removesAll = label.id is 0 or not label.id? removesAll = label.id is 0 or not label.id?
...@@ -238,21 +241,15 @@ class @LabelsSelect ...@@ -238,21 +241,15 @@ class @LabelsSelect
colorEl = '' colorEl = ''
# We need to identify which items are actually labels # We need to identify which items are actually labels
labelIdHtml = labelClass = ''
if label.id if label.id
# Add label id only for labels selectedClass.push('label-item')
labelIdHtml = "data-label-id='#{label.id}'" $a.attr('data-label-id', label.id)
# Add class only for labels $a.addClass(selectedClass.join(' '))
labelClass = 'label-item' .html("#{colorEl} #{_.escape(label.title)}")
"<li> # Return generated html
<a href='#' #{labelIdHtml} class='#{labelClass} #{selectedClass.join(' ')}'> $li.html($a).prop('outerHTML')
#{colorEl}
#{_.escape(label.title)}
</a>
</li>"
persistWhenHide: $dropdown.data('persistWhenHide') persistWhenHide: $dropdown.data('persistWhenHide')
search: search:
fields: ['title'] fields: ['title']
......
...@@ -96,10 +96,4 @@ module IssuablesHelper ...@@ -96,10 +96,4 @@ module IssuablesHelper
issuable.open? ? :opened : :closed issuable.open? ? :opened : :closed
end end
end end
def label_ids(issuable)
return nil if !issuable.labels.any?
issuable.labels.pluck :id
end
end end
%li{ id: dom_id(issue), class: issue_css_classes(issue), url: issue_path(issue), data: { labels: label_ids(issue), id: issue.id } } %li{ id: dom_id(issue), class: issue_css_classes(issue), url: issue_path(issue), data: { labels: issue.label_ids, id: issue.id } }
- if controller.controller_name == 'issues' && can?(current_user, :admin_issue, @project) - if controller.controller_name == 'issues' && can?(current_user, :admin_issue, @project)
.issue-check .issue-check
= check_box_tag dom_id(issue,"selected"), nil, false, 'data-id' => issue.id, class: "selected_issue" = check_box_tag dom_id(issue,"selected"), nil, false, 'data-id' => issue.id, class: "selected_issue"
......
%li{id: dom_id(label), :"data-id" => label.id} %li{id: dom_id(label), data: { id: label.id } } }
= render "shared/label_row", label: label = render "shared/label_row", label: label
.pull-info-right .pull-info-right
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
= dropdown_tag("Milestone", options: { title: "Assign milestone", toggle_class: 'js-milestone-select js-extra-options js-filter-submit js-filter-bulk-update', filter: true, dropdown_class: "dropdown-menu-selectable dropdown-menu-milestone", placeholder: "Search milestones", data: { show_no: true, field_name: "update[milestone_id]", project_id: @project.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :json), use_id: true } }) = dropdown_tag("Milestone", options: { title: "Assign milestone", toggle_class: 'js-milestone-select js-extra-options js-filter-submit js-filter-bulk-update', filter: true, dropdown_class: "dropdown-menu-selectable dropdown-menu-milestone", placeholder: "Search milestones", data: { show_no: true, field_name: "update[milestone_id]", project_id: @project.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :json), use_id: true } })
.filter-item.inline.labels-filter .filter-item.inline.labels-filter
= render "shared/issuable/label_dropdown", classes: ' js-filter-bulk-update js-multiselect ', show_create: false, show_footer: false, extra_options: false, filter_submit: false, show_footer: false, data_options: { persist_when_hide: "true", field_name: "update[label_ids][]", show_no: false, show_any: false, use_id: true } = render "shared/issuable/label_dropdown", classes: ['js-filter-bulk-update', 'js-multiselect'], show_create: false, show_footer: false, extra_options: false, filter_submit: false, show_footer: false, data_options: { persist_when_hide: "true", field_name: "update[label_ids][]", show_no: false, show_any: false, use_id: true }
= hidden_field_tag 'update[issues_ids]', [] = hidden_field_tag 'update[issues_ids]', []
= hidden_field_tag :state_event, params[:state_event] = hidden_field_tag :state_event, params[:state_event]
......
...@@ -3,23 +3,23 @@ ...@@ -3,23 +3,23 @@
- filter_submit = local_assigns.fetch(:filter_submit, true) - filter_submit = local_assigns.fetch(:filter_submit, true)
- show_footer = local_assigns.fetch(:show_footer, true) - show_footer = local_assigns.fetch(:show_footer, true)
- data_options = local_assigns.fetch(:data_options, {}) - data_options = local_assigns.fetch(:data_options, {})
- classes = local_assigns.fetch(:classes, '') - classes = local_assigns.fetch(:classes, [])
- dropdown_data = {toggle: 'dropdown', field_name: 'label_name[]', show_no: "true", show_any: "true", selected: params[:label_name], project_id: @project.try(:id), labels: labels_filter_path, default_label: "Label"} - dropdown_data = {toggle: 'dropdown', field_name: 'label_name[]', show_no: "true", show_any: "true", selected: params[:label_name], project_id: @project.try(:id), labels: labels_filter_path, default_label: "Label"}
- dropdown_data.merge!(data_options) - dropdown_data.merge!(data_options)
- classes << ' js-extra-options ' if extra_options - classes << 'js-extra-options' if extra_options
- classes << ' js-filter-submit ' if filter_submit - classes << 'js-filter-submit' if filter_submit
- if params[:label_name].present? - if params[:label_name].present?
- if params[:label_name].respond_to?('any?') - if params[:label_name].respond_to?('any?')
- params[:label_name].each do |label| - params[:label_name].each do |label|
= hidden_field_tag "label_name[]", label, id: nil = hidden_field_tag "label_name[]", label, id: nil
.dropdown .dropdown
%button.dropdown-menu-toggle.js-label-select.js-multiselect{class: classes, type: "button", data: dropdown_data} %button.dropdown-menu-toggle.js-label-select.js-multiselect{class: classes.join(' '), type: "button", data: dropdown_data}
%span.dropdown-toggle-text %span.dropdown-toggle-text
= h(multi_label_name(params[:label_name], "Label")) = h(multi_label_name(params[:label_name], "Label"))
= icon('chevron-down') = icon('chevron-down')
.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", locals: { title: "Filter by label", show_footer: show_footer } = render partial: "shared/issuable/label_page_default", locals: { title: "Filter by label", show_footer: show_footer, show_create: show_create }
- if can? current_user, :admin_label, @project and @project and show_create - if show_create and @project and can?(current_user, :admin_label, @project)
= render partial: "shared/issuable/label_page_create" = render partial: "shared/issuable/label_page_create"
= dropdown_loading = dropdown_loading
- title = local_assigns.fetch(:title, 'Assign labels') - title = local_assigns.fetch(:title, 'Assign labels')
- show_create = local_assigns.fetch(:show_create, true)
- show_footer = local_assigns.fetch(:show_footer, true) - show_footer = local_assigns.fetch(:show_footer, true)
- filter_placeholder = local_assigns.fetch(:filter_placeholder, 'Search labels') - filter_placeholder = local_assigns.fetch(:filter_placeholder, 'Search labels')
.dropdown-page-one .dropdown-page-one
...@@ -8,14 +9,14 @@ ...@@ -8,14 +9,14 @@
- if @project and show_footer - if @project and show_footer
= dropdown_footer do = dropdown_footer do
%ul.dropdown-footer-list %ul.dropdown-footer-list
- if can? current_user, :admin_label, @project - if can?(current_user, :admin_label, @project)
%li %li
%a.dropdown-toggle-page{href: "#"} %a.dropdown-toggle-page{href: "#"}
Create new Create new
%li %li
= link_to namespace_project_labels_path(@project.namespace, @project), :"data-is-link" => true do = link_to namespace_project_labels_path(@project.namespace, @project), :"data-is-link" => true do
- if can? current_user, :admin_label, @project - if show_create && @project && can?(current_user, :admin_label, @project)
Manage labels Manage labels
- else - else
View labels View labels
= dropdown_loading = dropdown_loading
\ No newline at end of file
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