Commit bb367689 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'milestone-issues-dragging' into 'master'

Milestone issues dragging

This is part of #1207.
I will submit this feature with small but finished merge requests.
parents 248a3e56 9654b098
......@@ -21,6 +21,8 @@ class Dispatcher
Issues.init()
when 'projects:issues:show'
new Issue()
when 'projects:milestones:show'
new Milestone()
when 'projects:issues:new', 'projects:merge_requests:new'
GitLab.GfmAutoComplete.setup()
when 'dashboard:show'
......
class Milestone
@updateIssue: (li, issue_url, data) ->
$.ajax
type: "PUT"
url: issue_url
data: data
success: (data) ->
if data.saved == true
$(li).effect 'highlight'
else
new Flash("Issue update failed", 'alert')
dataType: "json"
constructor: ->
@bindSorting()
bindSorting: ->
$("#issues-list-unassigned, #issues-list-ongoing, #issues-list-closed").sortable(
connectWith: ".issues-sortable-list",
dropOnEmpty: true,
receive: (event, ui) ->
new_state = $(this).data('state')
issue_id = ui.item.data('iid')
issue_url = ui.item.data('url')
data = switch new_state
when 'ongoing'
"issue[assignee_id]=" + gon.current_user_id
when 'unassigned'
"issue[assignee_id]="
when 'closed'
"issue[state_event]=close"
if $(ui.sender).data('state') == "closed"
data += "&issue[state_event]=reopen"
Milestone.updateIssue(ui.item, issue_url, data)
).disableSelection()
@Milestone = Milestone
......@@ -124,7 +124,7 @@
margin-bottom: 10px;
}
@mixin str-truncated($max_width: "82%") {
@mixin str-truncated($max_width: 82%) {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
......
.issues-sortable-list .str-truncated {
max-width: 70%;
}
......@@ -174,10 +174,14 @@ class ApplicationController < ActionController::Base
def add_gon_variables
gon.default_issues_tracker = Project.issues_tracker.default_value
gon.api_version = API::API.version
gon.api_token = current_user.private_token if current_user
gon.gravatar_url = request.ssl? || Gitlab.config.gitlab.https ? Gitlab.config.gravatar.ssl_url : Gitlab.config.gravatar.plain_url
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
gon.gravatar_enabled = Gitlab.config.gravatar.enabled
if current_user
gon.current_user_id = current_user.id
gon.api_token = current_user.private_token
end
end
def check_password_expiration
......
......@@ -87,6 +87,11 @@ class Projects::IssuesController < Projects::ApplicationController
render :edit
end
end
format.json do
render json: {
saved: @issue.valid?,
}
end
end
end
......
......@@ -24,6 +24,8 @@ module Issuable
scope :unassigned, -> { where("assignee_id IS NULL") }
scope :of_projects, ->(ids) { where(project_id: ids) }
scope :opened, -> { with_state(:opened, :reopened) }
scope :only_opened, -> { with_state(:opened) }
scope :only_reopened, -> { with_state(:reopened) }
scope :closed, -> { with_state(:closed) }
delegate :name,
......
%li{ class: 'issue-row', 'data-iid' => issue.iid, 'data-url' => project_issue_path(@project, issue) }
%span.str-truncated
= link_to [@project, issue] do
%span.cgray ##{issue.iid}
= link_to_gfm issue.title, [@project, issue]
- if issue.assignee
.pull-right
= image_tag avatar_icon(issue.assignee.email, 16), class: "avatar s16"
.panel.panel-default
.panel-heading= title
%ul.well-list
%ul{ class: "well-list issues-sortable-list", id: "issues-list-#{id}", "data-state" => id }
- issues.each do |issue|
%li
= link_to [@project, issue] do
%span.label{class: issue.closed? ? 'label-danger' : 'label-info'} ##{issue.iid}
= link_to_gfm truncate(issue.title, length: 40), [@project, issue]
- if issue.assignee
.pull-right
= image_tag avatar_icon(issue.assignee.email, 16), class: "avatar s16"
= render 'issue', issue: issue
%li.light Drag and drop available
......@@ -35,6 +35,12 @@
%h4.title
= gfm escape_once(@milestone.title)
- if @milestone.description.present?
.description
.wiki
= preserve do
= markdown @milestone.description
.context
%p
Progress:
......@@ -45,11 +51,6 @@
.progress.progress-info
.progress-bar{style: "width: #{@milestone.percent_complete}%;"}
- if @milestone.description.present?
.description
.wiki
= preserve do
= markdown @milestone.description
%ul.nav.nav-tabs
%li.active
......@@ -75,11 +76,11 @@
.tab-pane.active#tab-issues
.row
.col-md-4
= render('issues', title: 'Unstarted Issues (open and unassigned)', issues: @issues.opened.unassigned)
= render('issues', title: 'Unstarted Issues (open and unassigned)', issues: @issues.opened.unassigned, id: 'unassigned')
.col-md-4
= render('issues', title: 'Ongoing Issues (open and assigned)', issues: @issues.opened.assigned)
= render('issues', title: 'Ongoing Issues (open and assigned)', issues: @issues.opened.assigned, id: 'ongoing')
.col-md-4
= render('issues', title: 'Completed Issues (closed)', issues: @issues.closed)
= render('issues', title: 'Completed Issues (closed)', issues: @issues.closed, id: 'closed')
.tab-pane#tab-merge-requests
.row
......
......@@ -54,6 +54,6 @@ class ProjectMilestones < Spinach::FeatureSteps
end
Then "I should see 3 issues" do
page.should have_selector('#tab-issues li', count: 4)
page.should have_selector('#tab-issues li.issue-row', count: 4)
end
end
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