diff options
author | Jacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home> | 2016-03-11 08:28:10 +0300 |
---|---|---|
committer | Jacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home> | 2016-03-25 15:03:16 +0300 |
commit | 16ba5eb4d89f903d89fbad33086013a2f69717dd (patch) | |
tree | fbd5d4e681f74b3b38e40e8cfc36cfd215654fcd /app/assets | |
parent | 63c8a05bf7f18ac4093ece1f08b4b5fd8dba5fac (diff) |
Updates sidebar milestone to use new dropdowns
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/api.js.coffee | 21 | ||||
-rw-r--r-- | app/assets/javascripts/gl_dropdown.js.coffee | 3 | ||||
-rw-r--r-- | app/assets/javascripts/milestone_select.js.coffee | 21 |
3 files changed, 35 insertions, 10 deletions
diff --git a/app/assets/javascripts/api.js.coffee b/app/assets/javascripts/api.js.coffee index f3ed9a66715..b259c6556ae 100644 --- a/app/assets/javascripts/api.js.coffee +++ b/app/assets/javascripts/api.js.coffee @@ -5,6 +5,27 @@ group_projects_path: "/api/:version/groups/:id/projects.json" projects_path: "/api/:version/projects.json" labels_path: "/api/:version/projects/:id/labels" + issues_paths: + update : "/api/:version/projects/:id/issues/:issue_id" + merge_request_path: "/api/:version/issues/:id.json" + + issues: + update: (project_id, issue_id, data, callback) -> + url = Api.buildUrl(Api.issues_paths.update) + url = url + .replace(":id", project_id) + .replace(":issue_id", issue_id) + if not data? + data = {} + data.private_token = gon.api_token + $.ajax( + url: url + type: "PUT" + data: data + dataType: "json" + ).done (issue) -> + if callback? + callback(issue) group: (group_id, callback) -> url = Api.buildUrl(Api.group_path) diff --git a/app/assets/javascripts/gl_dropdown.js.coffee b/app/assets/javascripts/gl_dropdown.js.coffee index 4b78bcde774..6cd39f5f0b9 100644 --- a/app/assets/javascripts/gl_dropdown.js.coffee +++ b/app/assets/javascripts/gl_dropdown.js.coffee @@ -143,10 +143,11 @@ class GitLabDropdown selector = ".dropdown-page-one .dropdown-content a" @dropdown.on "click", selector, (e) -> + e.preventDefault() self.rowClicked $(@) if self.options.clicked - self.options.clicked() + self.options.clicked.call(@,e) toggleLoading: -> $('.dropdown-menu', @dropdown).toggleClass LOADING_CLASS diff --git a/app/assets/javascripts/milestone_select.js.coffee b/app/assets/javascripts/milestone_select.js.coffee index e17a1adb648..18647e25c55 100644 --- a/app/assets/javascripts/milestone_select.js.coffee +++ b/app/assets/javascripts/milestone_select.js.coffee @@ -1,5 +1,6 @@ class @MilestoneSelect - constructor: -> + constructor: (@opts) -> + opts = @opts $('.js-milestone-select').each (i, dropdown) -> $dropdown = $(dropdown) projectId = $dropdown.data('project-id') @@ -9,6 +10,7 @@ class @MilestoneSelect showAny = $dropdown.data('show-any') useId = $dropdown.data('use-id') defaultLabel = $dropdown.data('default-label') + issuableId = $dropdown.data('issuable-id') $dropdown.glDropdown( data: (term, callback) -> @@ -53,13 +55,14 @@ class @MilestoneSelect milestone.id isSelected: (milestone) -> milestone.title is selectedMilestone - clicked: -> - page = $('body').data 'page' - isIssueIndex = page is 'projects:issues:index' - isMRIndex = page is page is 'projects:merge_requests:index' - if $dropdown.hasClass('js-filter-submit') and (isIssueIndex or isMRIndex) - Issues.filterResults $dropdown.closest('form') - else if $dropdown.hasClass 'js-filter-submit' - $dropdown.closest('form').submit() + clicked: (e) -> + if $(dropdown).hasClass "js-filter-submit" && opts.submitForm + $(dropdown).parents('form').submit() + else + milestoneVal = $(@) + .closest('.selectbox') + .find('input[type="hidden"]') + .val() + Api.issues.update(projectId, issuableId, milestone_id: milestoneVal, (data) => console.log 'data', data) ) |