Commit 4ab6bfce authored by Alfredo Sumaran's avatar Alfredo Sumaran

Set indeterminated items

parent 243e5132
......@@ -11,6 +11,8 @@ class GitLabDropdownFilter
$inputContainer = @input.parent()
$clearButton = $inputContainer.find('.js-dropdown-input-clear')
@indeterminatedIds = []
# Clear click
$clearButton.on 'click', (e) =>
e.preventDefault()
......@@ -298,6 +300,13 @@ class GitLabDropdown
opened: =>
@addArrowKeyEvent()
if @options.setIndeterminatedIds
@options.setIndeterminatedIds.call(@)
# Makes indeterminated items effective
if @fullData and @dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update')
@parseData @fullData
contentHtml = $('.dropdown-content', @dropdown).html()
if @remote && contentHtml is ""
@remote.execute()
......@@ -309,6 +318,9 @@ class GitLabDropdown
hidden: (e) =>
@removeArrayKeyEvent()
return if @dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update')
if @options.filterable
@dropdown
.find(".dropdown-input-field")
......@@ -358,7 +370,7 @@ class GitLabDropdown
if @options.renderRow
# Call the render function
html = @options.renderRow(data)
html = @options.renderRow.call(@options, data, @)
else
if not selected
value = if @options.id then @options.id(data) else data.id
......
class @LabelsSelect
constructor: ->
_this = @
$('.js-label-select').each (i, dropdown) ->
$dropdown = $(dropdown)
projectId = $dropdown.data('project-id')
......@@ -196,15 +198,25 @@ class @LabelsSelect
callback data
renderRow: (label) ->
renderRow: (label, instance) ->
selectedClass = []
removesAll = label.id is 0 or not label.id?
selectedClass = []
if $dropdown.hasClass('js-filter-bulk-update')
indeterminated = instance.indeterminatedIds
if indeterminated.indexOf(label.id) isnt -1
selectedClass.push 'indeterminated'
if $form.find("input[type='hidden']\
[name='#{$dropdown.data('fieldName')}']\
[value='#{this.id(label)}']").length
selectedClass.push 'is-active'
index = selectedClass.indexOf('indeterminated')
if index isnt -1
selectedClass.splice(index, 1)
if $dropdown.hasClass('js-multiselect') and removesAll
selectedClass.push 'dropdown-clear-active'
......@@ -264,6 +276,8 @@ class @LabelsSelect
label.id
hidden: ->
return if $dropdown.hasClass('js-filter-bulk-update')
page = $('body').data 'page'
isIssueIndex = page is 'projects:issues:index'
isMRIndex = page is 'projects:merge_requests:index'
......@@ -301,4 +315,18 @@ class @LabelsSelect
return
else
saveLabelData()
setIndeterminatedIds: ->
if @dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update')
console.log 'options.setIndeterminatedIds'
@indeterminatedIds = _this.getIndeterminatedIds()
)
getIndeterminatedIds: ->
label_ids = []
$('.selected_issue:checked').each (i, el) ->
issue_id = $(el).data('id')
label_ids.push $("#issue_#{issue_id}").data('labels')
_.flatten(label_ids)
......@@ -232,9 +232,8 @@
a {
padding-left: 25px;
&.is-active {
&.indeterminated, &.is-active{
&::before {
content: "\f00c";
position: absolute;
left: 5px;
top: 50%;
......@@ -246,6 +245,14 @@
-moz-osx-font-smoothing: grayscale;
}
}
&.indeterminated::before {
content: "\f068";
}
&.is-active::before {
content: "\f00c";
}
}
}
......
......@@ -97,4 +97,9 @@ module IssuablesHelper
end
end
def label_ids(issuable)
return nil if !issuable.labels.any?
issuable.labels.pluck :id
end
end
%li{ id: dom_id(issue), class: issue_css_classes(issue), url: issue_path(issue) }
%li{ id: dom_id(issue), class: issue_css_classes(issue), url: issue_path(issue), :'data-labels' => label_ids(issue) }
- if controller.controller_name == 'issues' && can?(current_user, :admin_issue, @project)
.issue-check
= check_box_tag dom_id(issue,"selected"), nil, false, 'data-id' => issue.id, class: "selected_issue"
......
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