summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/milestone_select.js.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/milestone_select.js.coffee')
-rw-r--r--app/assets/javascripts/milestone_select.js.coffee26
1 files changed, 17 insertions, 9 deletions
diff --git a/app/assets/javascripts/milestone_select.js.coffee b/app/assets/javascripts/milestone_select.js.coffee
index 52fa5740c49..b6983b93cc7 100644
--- a/app/assets/javascripts/milestone_select.js.coffee
+++ b/app/assets/javascripts/milestone_select.js.coffee
@@ -1,5 +1,8 @@
class @MilestoneSelect
- constructor: () ->
+ constructor: (currentProject) ->
+ if currentProject?
+ _this = @
+ @currentProject = JSON.parse(currentProject)
$('.js-milestone-select').each (i, dropdown) ->
$dropdown = $(dropdown)
projectId = $dropdown.data('project-id')
@@ -17,6 +20,13 @@ class @MilestoneSelect
$value = $block.find('.value')
$loading = $block.find('.block-loading').fadeOut()
+ if issueUpdateURL
+ milestoneLinkTemplate = _.template(
+ '<a href="/<%= namespace %>/<%= path %>/milestones/<%= iid %>"><%= title %></a>'
+ )
+
+ milestoneLinkNoneTemplate = '<div class="light">None</div>'
+
$dropdown.glDropdown(
data: (term, callback) ->
$.ajax(
@@ -85,12 +95,10 @@ class @MilestoneSelect
$milestoneLink = $value
.show()
.find('a')
- href = $milestoneLink
- .text(data.milestone.title)
- .attr('href')
-
- splitHref = href.split('/')
- splitHref[splitHref.length - 1] = data.milestone.iid
- $milestoneLink
- .attr('href',splitHref.join('/'))
+ if data.milestone?
+ data.milestone.namespace = _this.currentProject.namespace
+ data.milestone.path = _this.currentProject.path
+ $value.html(milestoneLinkTemplate(data.milestone))
+ else
+ $value.html(milestoneLinkNoneTemplate)
) \ No newline at end of file