Skip to content
Snippets Groups Projects
Unverified Commit 47e67f3c authored by Arinde Eniola's avatar Arinde Eniola Committed by Connor Shea
Browse files

add check to append the issue url to the newly created note

parent a32010bc
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -88,12 +88,13 @@
$.ajax(
url: url
type: "POST"
context: @
data: data
dataType: "json"
).done (issue) ->
callback(issue)
callback.call(@, issue)
.error (message) ->
callback(message.responseJSON)
callback.call(@, message.responseJSON)
 
# Return group projects list. Filtered by query
groupProjects: (group_id, query, callback) ->
Loading
Loading
Loading
Loading
@@ -3,16 +3,16 @@ class @CreateIssueFromComment
constructor: ->
@hideOrShowCheckbox()
 
$('.diffs').on 'click', '.create-issue-from-note', (e) =>
$('#diffs').on 'click', '.create-issue-from-note', (e) =>
$eventTarget = $(event.target)
if $eventTarget.is('[type="checkbox"]:checked')
$form = $eventTarget.closest('.js-discussion-note-form')
@addFormatToTextArea $form
@setUpListenerForFormSubmit $form
@setUpListenerForNoteCreation()
else if not $eventTarget.is('[type="checkbox"]:checked')
@setBackToDefault($eventTarget)
 
hideOrShowCheckbox: ->
$('.merge-request').on 'createIssueFromComment:show', () ->
$(this).find('.create-issue-from-note').removeClass('hidden')
Loading
Loading
@@ -40,17 +40,28 @@ class @CreateIssueFromComment
return false
 
# check if the the title is present since it is required
textValueArr = textAreaValue.split('---')
if $.trim(textValueArr[0])
@createIssue textValueArr, $(form).closest('.tab-content').data('project-id')
@textValueArr = textAreaValue.split('---')
@projectId = $(form).closest('.tab-content').data('project-id')
if $.trim(@textValueArr[0])
@setUpListenerForNoteCreation()
else
return false
 
setUpListenerForNoteCreation: ->
$('#diffs')
.off 'note:created'
.on 'note:created', (e, note) =>
@note = note
@createIssue @textValueArr, @projectId
createIssue: (textArr, projectId) ->
# Create new label with API
Api.newIssue projectId, {
# Create new Issue with API
newIssue = Api.newIssue.bind(@)
newIssue projectId, {
title: textArr[0]
description: textArr[1] if textArr[1]
}, (issue) ->
if issue
console.log 'crap'
description: textArr[1]
}, (issue) =>
if issue and issue.title
$noteText = $('.js-task-list-container').find('note-text')
projectUrl = $('.shortcuts-issues').attr('href')
$noteText.append("<p><a href='#{projectUrl}/#{issue.iid}'></a></p>")
Loading
Loading
@@ -49,6 +49,7 @@ class Dispatcher
new ZenMode()
new GLForm($('.release-form'))
when 'projects:merge_requests:show'
new CreateIssueFromComment()
new Diff()
shortcut_handler = new ShortcutsIssuable(true)
new ZenMode()
Loading
Loading
Loading
Loading
@@ -225,6 +225,7 @@ class @Notes
 
# Add note to 'Changes' page discussions
discussionContainer.append note_html
$('#diffs').trigger('note:created', note)
 
# Init discussion on 'Discussion' page if it is merge request page
if $('body').attr('data-page').indexOf('projects:merge_request') is 0
Loading
Loading
@@ -234,6 +235,7 @@ class @Notes
else
# append new note to all matching discussions
discussionContainer.append note_html
$('#diffs').trigger('note:created', note)
 
gl.utils.localTimeAgo($('.js-timeago', note_html), false)
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment