Commit 16ba5eb4 authored by Jacob Schatz's avatar Jacob Schatz

Updates sidebar milestone to use new dropdowns

parent 63c8a05b
...@@ -5,6 +5,27 @@ ...@@ -5,6 +5,27 @@
group_projects_path: "/api/:version/groups/:id/projects.json" group_projects_path: "/api/:version/groups/:id/projects.json"
projects_path: "/api/:version/projects.json" projects_path: "/api/:version/projects.json"
labels_path: "/api/:version/projects/:id/labels" 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) -> group: (group_id, callback) ->
url = Api.buildUrl(Api.group_path) url = Api.buildUrl(Api.group_path)
......
...@@ -143,10 +143,11 @@ class GitLabDropdown ...@@ -143,10 +143,11 @@ class GitLabDropdown
selector = ".dropdown-page-one .dropdown-content a" selector = ".dropdown-page-one .dropdown-content a"
@dropdown.on "click", selector, (e) -> @dropdown.on "click", selector, (e) ->
e.preventDefault()
self.rowClicked $(@) self.rowClicked $(@)
if self.options.clicked if self.options.clicked
self.options.clicked() self.options.clicked.call(@,e)
toggleLoading: -> toggleLoading: ->
$('.dropdown-menu', @dropdown).toggleClass LOADING_CLASS $('.dropdown-menu', @dropdown).toggleClass LOADING_CLASS
......
class @MilestoneSelect class @MilestoneSelect
constructor: -> constructor: (@opts) ->
opts = @opts
$('.js-milestone-select').each (i, dropdown) -> $('.js-milestone-select').each (i, dropdown) ->
$dropdown = $(dropdown) $dropdown = $(dropdown)
projectId = $dropdown.data('project-id') projectId = $dropdown.data('project-id')
...@@ -9,6 +10,7 @@ class @MilestoneSelect ...@@ -9,6 +10,7 @@ class @MilestoneSelect
showAny = $dropdown.data('show-any') showAny = $dropdown.data('show-any')
useId = $dropdown.data('use-id') useId = $dropdown.data('use-id')
defaultLabel = $dropdown.data('default-label') defaultLabel = $dropdown.data('default-label')
issuableId = $dropdown.data('issuable-id')
$dropdown.glDropdown( $dropdown.glDropdown(
data: (term, callback) -> data: (term, callback) ->
...@@ -53,13 +55,14 @@ class @MilestoneSelect ...@@ -53,13 +55,14 @@ class @MilestoneSelect
milestone.id milestone.id
isSelected: (milestone) -> isSelected: (milestone) ->
milestone.title is selectedMilestone 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) clicked: (e) ->
Issues.filterResults $dropdown.closest('form') if $(dropdown).hasClass "js-filter-submit" && opts.submitForm
else if $dropdown.hasClass 'js-filter-submit' $(dropdown).parents('form').submit()
$dropdown.closest('form').submit() else
milestoneVal = $(@)
.closest('.selectbox')
.find('input[type="hidden"]')
.val()
Api.issues.update(projectId, issuableId, milestone_id: milestoneVal, (data) => console.log 'data', data)
) )
...@@ -58,6 +58,7 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -58,6 +58,7 @@ class Projects::IssuesController < Projects::ApplicationController
end end
def edit def edit
puts params
respond_with(@issue) respond_with(@issue)
end end
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
.merge-request{'data-url' => merge_request_path(@merge_request)} .merge-request{'data-url' => merge_request_path(@merge_request)}
= render "projects/merge_requests/show/mr_title" = render "projects/merge_requests/show/mr_title"
.merge-request-details.issuable-details .merge-request-details.issuable-details{data: {id: @merge_request.project.id}}
= render "projects/merge_requests/show/mr_box" = render "projects/merge_requests/show/mr_box"
.append-bottom-default.mr-source-target.prepend-top-default .append-bottom-default.mr-source-target.prepend-top-default
- if @merge_request.open? - if @merge_request.open?
......
...@@ -55,7 +55,9 @@ ...@@ -55,7 +55,9 @@
:javascript :javascript
new UsersSelect(); new UsersSelect();
new LabelsSelect(); new LabelsSelect();
new MilestoneSelect(); new MilestoneSelect({
submitForm: true
});
new IssueStatusSelect(); new IssueStatusSelect();
$('form.filter-form').on('submit', function (event) { $('form.filter-form').on('submit', function (event) {
event.preventDefault(); event.preventDefault();
......
...@@ -62,10 +62,9 @@ ...@@ -62,10 +62,9 @@
= issuable.milestone.title = issuable.milestone.title
- else - else
.light None .light None
.selectbox.hide-collapsed .selectbox.hide-collapsed
= f.select(:milestone_id, milestone_options(issuable), { include_blank: true }, { class: 'select2 select2-compact js-select2 js-milestone', data: { placeholder: 'Select milestone' }}) = dropdown_tag("Milestone", options: { title: "Assign milestone", toggle_class: 'js-milestone-select', filter: true, dropdown_class: "dropdown-menu-selectable", placeholder: "Search milestones", data: { show_no: true, field_name: "milestone_id", project_id: @project.id, issuable_id: issuable.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :js), use_id: true }})
= hidden_field_tag :issuable_context
= f.submit class: 'btn hide'
- if issuable.project.labels.any? - if issuable.project.labels.any?
.block.labels .block.labels
...@@ -117,4 +116,5 @@ ...@@ -117,4 +116,5 @@
:javascript :javascript
new Subscription('.subscription'); new Subscription('.subscription');
new MilestoneSelect();
new IssuableContext(); new IssuableContext();
...@@ -36,7 +36,7 @@ Rails.application.configure do ...@@ -36,7 +36,7 @@ Rails.application.configure do
# For having correct urls in mails # For having correct urls in mails
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
# Open sent mails in browser # Open sent mails in browser
config.action_mailer.delivery_method = :letter_opener config.action_mailer.delivery_method = :test
# Don't make a mess when bootstrapping a development environment # Don't make a mess when bootstrapping a development environment
config.action_mailer.perform_deliveries = (ENV['BOOTSTRAP'] != '1') config.action_mailer.perform_deliveries = (ENV['BOOTSTRAP'] != '1')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment