mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-23 03:26:07 +10:00
Ability to move issue to another project Tasks: - [x] Create scaffold of service that will move issue to another project. - [x] Close old issue, add system note about moving issue to a new project. - [x] Create a new issue, add system note about issue being moved from old project. - [x] Check if issue can be moved to another project before executing service - [x] Check permissions when moving an issue (`:admin_issue` ability) - [x] Display select box for a new project when editing an issue - [x] Show only projects that issue can be moved into in that select box - [x] Add project select handler, helper and some permission filters to it - [x] Preserve as much information as possible, including author - [x] Prepare mechanisms that unfolds local references in issue description - [x] Rewrite issue description with references unfolding and add some specs for it - [x] Rewrite all system notes and comments attached to issue that is being moved - [x] Update `Label` so that is was able to create cross reference labels (separate MR) - [x] Add notifications about moving issue to another project - [x] Display confirmation alert/message when issue move has been requested - [x] Make it possible to undo selecting project where issue will be moved to - [x] Add column to issue, that will indicate if it has been moved to another project - [x] Do not allow to move issue that has been already moved - [x] Write top-to-bottom feature spec in RSpec instead of Spinach UI:   Closes #3024 See merge request !2831
83 lines
2.0 KiB
CoffeeScript
83 lines
2.0 KiB
CoffeeScript
class @IssuableForm
|
|
issueMoveConfirmMsg: 'Are you sure you want to move this issue to another project?'
|
|
wipRegex: /^\s*(\[WIP\]\s*|WIP:\s*|WIP\s+)+\s*/i
|
|
|
|
constructor: (@form) ->
|
|
GitLab.GfmAutoComplete.setup()
|
|
new UsersSelect()
|
|
new ZenMode()
|
|
|
|
@titleField = @form.find("input[name*='[title]']")
|
|
@descriptionField = @form.find("textarea[name*='[description]']")
|
|
@issueMoveField = @form.find("#move_to_project_id")
|
|
|
|
return unless @titleField.length && @descriptionField.length
|
|
|
|
@initAutosave()
|
|
|
|
@form.on "submit", @handleSubmit
|
|
@form.on "click", ".btn-cancel", @resetAutosave
|
|
|
|
@initWip()
|
|
|
|
initAutosave: ->
|
|
new Autosave @titleField, [
|
|
document.location.pathname,
|
|
document.location.search,
|
|
"title"
|
|
]
|
|
|
|
new Autosave @descriptionField, [
|
|
document.location.pathname,
|
|
document.location.search,
|
|
"description"
|
|
]
|
|
|
|
handleSubmit: =>
|
|
if (parseInt(@issueMoveField?.val()) ? 0) > 0
|
|
return false unless confirm(@issueMoveConfirmMsg)
|
|
|
|
@resetAutosave()
|
|
|
|
resetAutosave: =>
|
|
@titleField.data("autosave").reset()
|
|
@descriptionField.data("autosave").reset()
|
|
|
|
initWip: ->
|
|
@$wipExplanation = @form.find(".js-wip-explanation")
|
|
@$noWipExplanation = @form.find(".js-no-wip-explanation")
|
|
return unless @$wipExplanation.length and @$noWipExplanation.length
|
|
|
|
@form.on "click", ".js-toggle-wip", @toggleWip
|
|
|
|
@titleField.on "keyup blur", @renderWipExplanation
|
|
|
|
@renderWipExplanation()
|
|
|
|
workInProgress: ->
|
|
@wipRegex.test @titleField.val()
|
|
|
|
renderWipExplanation: =>
|
|
if @workInProgress()
|
|
@$wipExplanation.show()
|
|
@$noWipExplanation.hide()
|
|
else
|
|
@$wipExplanation.hide()
|
|
@$noWipExplanation.show()
|
|
|
|
toggleWip: (event) =>
|
|
event.preventDefault()
|
|
|
|
if @workInProgress()
|
|
@removeWip()
|
|
else
|
|
@addWip()
|
|
|
|
@renderWipExplanation()
|
|
|
|
removeWip: ->
|
|
@titleField.val @titleField.val().replace(@wipRegex, "")
|
|
|
|
addWip: ->
|
|
@titleField.val "WIP: #{@titleField.val()}"
|