mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-11 13:46:11 +10:00
Fix unwanted label unassignment ## What does this MR do? - When updating the milestone - [x] Do not remove labels when assigning a milestone - [x] Do not remove labels when unassigning a milestone - [x] Do not remove labels when assigning a milestone and adding another label - When toggling selected issues labels should be kept - [x] Select an issue with an assigned label -> pick another label from dropdown-> unselect the issue -> select the issue again -> submit the form: Existing label should not be removed. ## Are there points in the code the reviewer needs to double check? Labels should not be added or removed to issues when doing bulk actions unless we explicitly select a label from the dropdown ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [ ] API support added - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !4863
97 lines
3.1 KiB
CoffeeScript
97 lines
3.1 KiB
CoffeeScript
issuable_created = false
|
|
@Issuable =
|
|
init: ->
|
|
unless issuable_created
|
|
issuable_created = true
|
|
Issuable.initTemplates()
|
|
Issuable.initSearch()
|
|
Issuable.initChecks()
|
|
Issuable.initLabelFilterRemove()
|
|
|
|
initTemplates: ->
|
|
Issuable.labelRow = _.template(
|
|
'<% _.each(labels, function(label){ %>
|
|
<span class="label-row btn-group" role="group" aria-label="<%= _.escape(label.title) %>" style="color: <%= label.text_color %>;">
|
|
<a href="#" class="btn btn-transparent has-tooltip" style="background-color: <%= label.color %>;" title="<%= _.escape(label.description) %>" data-container="body">
|
|
<%= _.escape(label.title) %>
|
|
</a>
|
|
<button type="button" class="btn btn-transparent label-remove js-label-filter-remove" style="background-color: <%= label.color %>;" data-label="<%= _.escape(label.title) %>">
|
|
<i class="fa fa-times"></i>
|
|
</button>
|
|
</span>
|
|
<% }); %>'
|
|
)
|
|
|
|
initSearch: ->
|
|
@timer = null
|
|
$('#issue_search')
|
|
.off 'keyup'
|
|
.on 'keyup', ->
|
|
clearTimeout(@timer)
|
|
@timer = setTimeout( ->
|
|
$search = $('#issue_search')
|
|
$form = $('.js-filter-form')
|
|
$input = $("input[name='#{$search.attr('name')}']", $form)
|
|
|
|
if $input.length is 0
|
|
$form.append "<input type='hidden' name='#{$search.attr('name')}' value='#{_.escape($search.val())}'/>"
|
|
else
|
|
$input.val $search.val()
|
|
|
|
Issuable.filterResults $form
|
|
, 500)
|
|
|
|
initLabelFilterRemove: ->
|
|
$(document)
|
|
.off 'click', '.js-label-filter-remove'
|
|
.on 'click', '.js-label-filter-remove', (e) ->
|
|
$button = $(@)
|
|
|
|
# Remove the label input box
|
|
$('input[name="label_name[]"]')
|
|
.filter -> @value is $button.data('label')
|
|
.remove()
|
|
|
|
# Submit the form to get new data
|
|
Issuable.filterResults $('.filter-form')
|
|
$('.js-label-select').trigger('update.label')
|
|
|
|
filterResults: (form) =>
|
|
formData = form.serialize()
|
|
|
|
$('.issues-holder, .merge-requests-holder').css('opacity', '0.5')
|
|
formAction = form.attr('action')
|
|
issuesUrl = formAction
|
|
issuesUrl += ("#{if formAction.indexOf('?') < 0 then '?' else '&'}")
|
|
issuesUrl += formData
|
|
|
|
Turbolinks.visit(issuesUrl);
|
|
|
|
initChecks: ->
|
|
@issuableBulkActions = $('.bulk-update').data('bulkActions')
|
|
|
|
$('.check_all_issues').off('click').on('click', ->
|
|
$('.selected_issue').prop('checked', @checked)
|
|
Issuable.checkChanged()
|
|
)
|
|
|
|
$('.selected_issue').off('change').on('change', Issuable.checkChanged.bind(@))
|
|
|
|
|
|
checkChanged: ->
|
|
checked_issues = $('.selected_issue:checked')
|
|
if checked_issues.length > 0
|
|
ids = $.map checked_issues, (value) ->
|
|
$(value).data('id')
|
|
|
|
$('#update_issues_ids').val ids
|
|
$('.issues-other-filters').hide()
|
|
$('.issues_bulk_update').show()
|
|
else
|
|
$('#update_issues_ids').val []
|
|
$('.issues_bulk_update').hide()
|
|
$('.issues-other-filters').show()
|
|
@issuableBulkActions.willUpdateLabels = false
|
|
|
|
return true
|