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

Set indeterminated items

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