Enhancements

This commit is contained in:
Alfredo Sumaran 2016-05-13 00:56:37 -05:00
parent 2ee779f17d
commit 5ea0165175
4 changed files with 26 additions and 24 deletions

View file

@ -1,5 +1,5 @@
class @Flash
constructor: (message, type)->
constructor: (message, type = 'alert')->
@flash = $(".flash-container")
@flash.html("")

View file

@ -460,10 +460,10 @@ class GitLabDropdown
el.addClass ACTIVE_CLASS
el.removeClass INDETERMINATE_CLASS
if !value?
if not value?
field.remove()
if !field.length and fieldName
if not field.length and fieldName
@addInput(fieldName, value)
return selectedObject
@ -491,14 +491,12 @@ class GitLabDropdown
addInput: (fieldName, value)->
# Create hidden input for form
input = "<input type='hidden' name='#{fieldName}' value='#{value}' />"
if @options.inputId?
input = $(input)
.attr('id', @options.inputId)
@dropdown.before input
$input = $("<input type='hidden' name='#{fieldName}' value='#{value}' />")
removeInputs: ->
@dropdown.parent().find('input[type="hidden"]').remove()
if @options.inputId?
$input.attr('id', @options.inputId)
@dropdown.before $input
selectRowAtIndex: (e, index) ->
selector = ".dropdown-content li:not(.divider,.dropdown-header,.separator):eq(#{index}) a"

View file

@ -32,10 +32,9 @@ class @IssuableBulkActions
location.reload()
xhr.fail ->
console.error 'fail'
new Flash("Issue update failed")
xhr.always ->
_this.onFormSubmitAlways()
xhr.always @onFormSubmitAlways.bind(@)
onFormSubmitAlways: ->
@form.find('[type="submit"]').enable()
@ -49,7 +48,7 @@ class @IssuableBulkActions
@getSelectedIssues().map ->
_labels = $(@).data('labels')
if _labels
_labels.map (labelId)->
_labels.map (labelId) ->
labels.push(labelId) if labels.indexOf(labelId) is -1
labels
@ -85,10 +84,10 @@ class @IssuableBulkActions
add_label_ids : []
remove_label_ids : []
for id in @getLabelsToApply()
@getLabelsToApply().map (id) ->
formData.update.add_label_ids.push id
for id in @getLabelsToRemove()
@getLabelsToRemove().map (id) ->
formData.update.remove_label_ids.push id
formData
@ -97,7 +96,7 @@ class @IssuableBulkActions
labelIds = []
$labels = @form.find('.labels-filter input[name="update[label_ids][]"]')
for label in $labels
$labels.each (k, label) ->
labelIds.push $(label).val() if label
labelIds

View file

@ -27,7 +27,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
before do
check 'check_all_issues'
open_labels_dropdown ['bug']
click_button 'Update issues'
update_issues
end
it do
@ -40,7 +40,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
before do
check "selected_issue_#{issue1.id}"
open_labels_dropdown ['bug']
click_button 'Update issues'
update_issues
end
it do
@ -55,7 +55,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
before do
check 'check_all_issues'
open_labels_dropdown ['bug', 'feature']
click_button 'Update issues'
update_issues
end
it do
@ -70,7 +70,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
before do
check "selected_issue_#{issue1.id}"
open_labels_dropdown ['bug', 'feature']
click_button 'Update issues'
update_issues
end
it do
@ -95,7 +95,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
check 'check_all_issues'
unmark_labels_in_dropdown ['bug', 'feature']
click_button 'Update issues'
update_issues
end
it do
@ -115,7 +115,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
check_issue issue1
unmark_labels_in_dropdown ['bug']
click_button 'Update issues'
update_issues
end
it do
@ -136,7 +136,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
check_issue issue1
check_issue issue2
unmark_labels_in_dropdown ['bug']
click_button 'Update issues'
update_issues
end
it do
@ -188,4 +188,9 @@ feature 'Issues > Labels bulk assignment', feature: true do
check "selected_issue_#{issue.id}"
end
end
def update_issues
click_button 'Update issues'
wait_for_ajax
end
end