Updates sidebar milestone to use new dropdowns
This commit is contained in:
parent
63c8a05bf7
commit
16ba5eb4d8
8 changed files with 44 additions and 16 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
)
|
||||
|
|
|
@ -58,6 +58,7 @@ class Projects::IssuesController < Projects::ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
puts params
|
||||
respond_with(@issue)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
.merge-request{'data-url' => merge_request_path(@merge_request)}
|
||||
= 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"
|
||||
.append-bottom-default.mr-source-target.prepend-top-default
|
||||
- if @merge_request.open?
|
||||
|
|
|
@ -55,7 +55,9 @@
|
|||
:javascript
|
||||
new UsersSelect();
|
||||
new LabelsSelect();
|
||||
new MilestoneSelect();
|
||||
new MilestoneSelect({
|
||||
submitForm: true
|
||||
});
|
||||
new IssueStatusSelect();
|
||||
$('form.filter-form').on('submit', function (event) {
|
||||
event.preventDefault();
|
||||
|
|
|
@ -62,10 +62,9 @@
|
|||
= issuable.milestone.title
|
||||
- else
|
||||
.light None
|
||||
|
||||
.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' }})
|
||||
= hidden_field_tag :issuable_context
|
||||
= f.submit class: 'btn hide'
|
||||
= 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 }})
|
||||
|
||||
- if issuable.project.labels.any?
|
||||
.block.labels
|
||||
|
@ -117,4 +116,5 @@
|
|||
|
||||
:javascript
|
||||
new Subscription('.subscription');
|
||||
new MilestoneSelect();
|
||||
new IssuableContext();
|
||||
|
|
|
@ -36,7 +36,7 @@ Rails.application.configure do
|
|||
# For having correct urls in mails
|
||||
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
||||
# 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
|
||||
config.action_mailer.perform_deliveries = (ENV['BOOTSTRAP'] != '1')
|
||||
|
||||
|
|
Loading…
Reference in a new issue