summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-03-08 12:32:04 +0000
committerPhil Hughes <me@iamphill.com>2016-03-10 13:54:54 +0000
commitdd35de1ad8e6ff8436552666d3f9f9bec0a309d9 (patch)
tree0897b2b6db4e92afb0626aa32e2e085803196e13 /app/assets/javascripts
parent730af552682febb3f7ce010bbc0a30b3bff5014c (diff)
downloadgitlab-ce-dd35de1ad8e6ff8436552666d3f9f9bec0a309d9.tar.gz
Uses a publicly facing URL so that it allows labels & milestones to be visible when not logged in
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/api.js.coffee26
-rw-r--r--app/assets/javascripts/gl_dropdown.js.coffee1
-rw-r--r--app/assets/javascripts/labels_select.js.coffee21
-rw-r--r--app/assets/javascripts/milestone_select.js.coffee26
4 files changed, 37 insertions, 37 deletions
diff --git a/app/assets/javascripts/api.js.coffee b/app/assets/javascripts/api.js.coffee
index 36c6a76e09c..2ddf8612db3 100644
--- a/app/assets/javascripts/api.js.coffee
+++ b/app/assets/javascripts/api.js.coffee
@@ -5,7 +5,6 @@
group_projects_path: "/api/:version/groups/:id/projects.json"
projects_path: "/api/:version/projects.json"
labels_path: "/api/:version/projects/:id/labels"
- milestones_path: "/api/:version/projects/:id/milestones"
group: (group_id, callback) ->
url = Api.buildUrl(Api.group_path)
@@ -63,18 +62,6 @@
).done (projects) ->
callback(projects)
- projectLabels: (project_id, callback) ->
- url = Api.buildUrl(Api.labels_path)
- url = url.replace(':id', project_id)
-
- $.ajax(
- url: url
- data:
- private_token: gon.api_token
- dataType: "json"
- ).done (labels) ->
- callback(labels)
-
newLabel: (project_id, data, callback) ->
url = Api.buildUrl(Api.labels_path)
url = url.replace(':id', project_id)
@@ -88,19 +75,6 @@
).done (label) ->
callback(label)
-
- milestones: (project_id, callback) ->
- url = Api.buildUrl(Api.milestones_path)
- url = url.replace(':id', project_id)
-
- $.ajax(
- url: url
- data:
- private_token: gon.api_token
- dataType: "json"
- ).done (milestones) ->
- callback(milestones)
-
# Return group projects list. Filtered by query
groupProjects: (group_id, query, callback) ->
url = Api.buildUrl(Api.group_projects_path)
diff --git a/app/assets/javascripts/gl_dropdown.js.coffee b/app/assets/javascripts/gl_dropdown.js.coffee
index c65b3e31450..a714ba3d675 100644
--- a/app/assets/javascripts/gl_dropdown.js.coffee
+++ b/app/assets/javascripts/gl_dropdown.js.coffee
@@ -220,7 +220,6 @@ class GitLabDropdown
if @renderedData
selectedObject = @renderedData[selectedIndex]
value = if @options.id then @options.id(selectedObject, el) else selectedObject.id
- console.log value
if @options.multiSelect
fieldName = "#{fieldName}[]"
diff --git a/app/assets/javascripts/labels_select.js.coffee b/app/assets/javascripts/labels_select.js.coffee
index 0b4e2ad7aa6..14ee529ba35 100644
--- a/app/assets/javascripts/labels_select.js.coffee
+++ b/app/assets/javascripts/labels_select.js.coffee
@@ -2,6 +2,7 @@ class @LabelsSelect
constructor: ->
$('.js-label-select').each (i, dropdown) ->
projectId = $(dropdown).data('project-id')
+ labelUrl = $(dropdown).data("labels")
selectedLabel = $(dropdown).data('selected')
newLabelField = $('#new_label_name')
newColorField = $('#new_label_color')
@@ -32,13 +33,25 @@ class @LabelsSelect
$(dropdown).glDropdown(
data: (term, callback) ->
- Api.projectLabels 8, callback
+ # We have to fetch the JS version of the labels list because there is no
+ # public facing JSON url for labels
+ $.ajax(
+ url: labelUrl
+ ).done (data) ->
+ html = $(data)
+ data = []
+ html.find('.label-row a').each ->
+ data.push(
+ title: $(@).text().trim()
+ )
+
+ callback data
renderRow: (label) ->
- selected = if label.name is selectedLabel then "is-active" else ""
+ selected = if label.title is selectedLabel then "is-active" else ""
"<li>
<a href='#' class='#{selected}'>
- #{label.name}
+ #{label.title}
</a>
</li>"
filterable: true
@@ -47,7 +60,7 @@ class @LabelsSelect
selectable: true
fieldName: $(dropdown).data('field-name')
id: (label) ->
- label.name
+ label.title
clicked: ->
if $(dropdown).hasClass "js-filter-submit"
$(dropdown).parents('form').submit()
diff --git a/app/assets/javascripts/milestone_select.js.coffee b/app/assets/javascripts/milestone_select.js.coffee
index 9c45800af6e..92b42bfe864 100644
--- a/app/assets/javascripts/milestone_select.js.coffee
+++ b/app/assets/javascripts/milestone_select.js.coffee
@@ -2,18 +2,29 @@ class @MilestoneSelect
constructor: ->
$('.js-milestone-select').each (i, dropdown) ->
projectId = $(dropdown).data('project-id')
+ milestonesUrl = $(dropdown).data('milestones')
selectedMilestone = $(dropdown).data('selected')
showNo = $(dropdown).data('show-no')
showAny = $(dropdown).data('show-any')
+ useId = $(dropdown).data('use-id')
$(dropdown).glDropdown(
data: (term, callback) ->
- Api.milestones projectId, (data) ->
- data = $.map data, (milestone) ->
- return milestone if milestone.state isnt "closed"
+ $.ajax(
+ url: milestonesUrl
+ ).done (data) ->
+ html = $(data)
+ data = []
+ html.find('.milestone strong a').each ->
+ link = $(@).attr("href").split("/")
+ data.push(
+ id: link[link.length - 1]
+ title: $(@).text().trim()
+ )
if showNo
data.unshift(
+ id: "0"
title: 'No milestone'
)
@@ -34,10 +45,13 @@ class @MilestoneSelect
text: (milestone) ->
milestone.title
id: (milestone) ->
- if milestone.title isnt "Any milestone"
- milestone.title
+ if !useId
+ if milestone.title isnt "Any milestone"
+ milestone.title
+ else
+ ""
else
- ""
+ milestone.id
isSelected: (milestone) ->
milestone.title is selectedMilestone
clicked: ->