From d95d56f0b9b2a321e18bb0f92b008f58e37b20a7 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 4 Jun 2014 18:07:15 +0300 Subject: [PATCH 1/6] Add current_user_id to gon vars Signed-off-by: Dmitriy Zaporozhets --- app/controllers/application_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2730e9942ec..aa532de7aa4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 From ad60701e9e097a046f65048bd4e707da512daa07 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 4 Jun 2014 18:10:53 +0300 Subject: [PATCH 2/6] Add only open/reopen scopes to issues Signed-off-by: Dmitriy Zaporozhets --- app/models/concerns/issuable.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 713eab5ad7d..9a227fcef59 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -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, From 47937802a2c29f6ec4a1bd15bb06e8e2866fdb7f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 4 Jun 2014 18:51:01 +0300 Subject: [PATCH 3/6] Add js milestone class. Activate drag-drop for issues on milestone page Signed-off-by: Dmitriy Zaporozhets --- app/assets/javascripts/dispatcher.js.coffee | 2 ++ app/assets/javascripts/milestone.js.coffee | 40 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 app/assets/javascripts/milestone.js.coffee diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index b61d9875e03..6518c380bdc 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -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' diff --git a/app/assets/javascripts/milestone.js.coffee b/app/assets/javascripts/milestone.js.coffee new file mode 100644 index 00000000000..bbbaa288b89 --- /dev/null +++ b/app/assets/javascripts/milestone.js.coffee @@ -0,0 +1,40 @@ +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, #issues-list-reopened").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" + when 'reopened' + "issue[state_event]=reopen" + + Milestone.updateIssue(ui.item, issue_url, data) + + ).disableSelection() + +@Milestone = Milestone From f1ec62f465711c136d9ffc84b328f7c55e68fa9c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 4 Jun 2014 18:52:35 +0300 Subject: [PATCH 4/6] Add reopened tab to milestone issues. Add ids and data to milestone issues to enable dragging Signed-off-by: Dmitriy Zaporozhets --- app/assets/stylesheets/main/mixins.scss | 2 +- .../stylesheets/sections/milestone.scss | 3 +++ app/controllers/projects/issues_controller.rb | 5 ++++ .../projects/milestones/_issue.html.haml | 9 +++++++ .../projects/milestones/_issues.html.haml | 11 +++----- app/views/projects/milestones/show.html.haml | 25 +++++++++++-------- 6 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 app/assets/stylesheets/sections/milestone.scss create mode 100644 app/views/projects/milestones/_issue.html.haml diff --git a/app/assets/stylesheets/main/mixins.scss b/app/assets/stylesheets/main/mixins.scss index 289490712b6..cf6d5ba9336 100644 --- a/app/assets/stylesheets/main/mixins.scss +++ b/app/assets/stylesheets/main/mixins.scss @@ -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; diff --git a/app/assets/stylesheets/sections/milestone.scss b/app/assets/stylesheets/sections/milestone.scss new file mode 100644 index 00000000000..d20391e38fd --- /dev/null +++ b/app/assets/stylesheets/sections/milestone.scss @@ -0,0 +1,3 @@ +.issues-sortable-list .str-truncated { + max-width: 70%; +} diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 6eec2094f86..6c6fc7e0779 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -87,6 +87,11 @@ class Projects::IssuesController < Projects::ApplicationController render :edit end end + format.json do + render json: { + saved: @issue.valid?, + } + end end end diff --git a/app/views/projects/milestones/_issue.html.haml b/app/views/projects/milestones/_issue.html.haml new file mode 100644 index 00000000000..5fba8cd5364 --- /dev/null +++ b/app/views/projects/milestones/_issue.html.haml @@ -0,0 +1,9 @@ +%li{ '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" + diff --git a/app/views/projects/milestones/_issues.html.haml b/app/views/projects/milestones/_issues.html.haml index 83eb327975b..9dbcab19a2a 100644 --- a/app/views/projects/milestones/_issues.html.haml +++ b/app/views/projects/milestones/_issues.html.haml @@ -1,11 +1,6 @@ .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 diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml index d355f258827..594b6a0c72f 100644 --- a/app/views/projects/milestones/show.html.haml +++ b/app/views/projects/milestones/show.html.haml @@ -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 @@ -74,12 +75,14 @@ .tab-content .tab-pane.active#tab-issues .row - .col-md-4 - = render('issues', title: 'Unstarted Issues (open and unassigned)', issues: @issues.opened.unassigned) - .col-md-4 - = render('issues', title: 'Ongoing Issues (open and assigned)', issues: @issues.opened.assigned) - .col-md-4 - = render('issues', title: 'Completed Issues (closed)', issues: @issues.closed) + .col-md-3 + = render('issues', title: 'Unstarted Issues (open and unassigned)', issues: @issues.only_opened.unassigned, id: 'unassigned') + .col-md-3 + = render('issues', title: 'Ongoing Issues (open and assigned)', issues: @issues.only_opened.assigned, id: 'ongoing') + .col-md-3 + = render('issues', title: 'Completed Issues (closed)', issues: @issues.closed, id: 'closed') + .col-md-3 + = render('issues', title: 'Reopened Issues (reopened)', issues: @issues.only_reopened, id: 'reopened') .tab-pane#tab-merge-requests .row From eeef2c7350502bb1f77a723ff4677901d2a68926 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 4 Jun 2014 20:39:43 +0300 Subject: [PATCH 5/6] Fix tests Signed-off-by: Dmitriy Zaporozhets --- app/views/projects/milestones/_issue.html.haml | 2 +- features/steps/project/milestones.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/projects/milestones/_issue.html.haml b/app/views/projects/milestones/_issue.html.haml index 5fba8cd5364..fe93164a704 100644 --- a/app/views/projects/milestones/_issue.html.haml +++ b/app/views/projects/milestones/_issue.html.haml @@ -1,4 +1,4 @@ -%li{ 'data-iid' => issue.iid, 'data-url' => project_issue_path(@project, issue) } +%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} diff --git a/features/steps/project/milestones.rb b/features/steps/project/milestones.rb index 9ce18fbaabd..5562b523d1b 100644 --- a/features/steps/project/milestones.rb +++ b/features/steps/project/milestones.rb @@ -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 From 9654b098c6478e7c17bc8c848f9284daa26ead76 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 5 Jun 2014 09:29:24 +0300 Subject: [PATCH 6/6] Milestone drag-n-drop with 3 columns Signed-off-by: Dmitriy Zaporozhets --- app/assets/javascripts/milestone.js.coffee | 7 ++++--- app/views/projects/milestones/show.html.haml | 12 +++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/milestone.js.coffee b/app/assets/javascripts/milestone.js.coffee index bbbaa288b89..d2857948cd7 100644 --- a/app/assets/javascripts/milestone.js.coffee +++ b/app/assets/javascripts/milestone.js.coffee @@ -15,7 +15,7 @@ class Milestone @bindSorting() bindSorting: -> - $("#issues-list-unassigned, #issues-list-ongoing, #issues-list-closed, #issues-list-reopened").sortable( + $("#issues-list-unassigned, #issues-list-ongoing, #issues-list-closed").sortable( connectWith: ".issues-sortable-list", dropOnEmpty: true, receive: (event, ui) -> @@ -30,8 +30,9 @@ class Milestone "issue[assignee_id]=" when 'closed' "issue[state_event]=close" - when 'reopened' - "issue[state_event]=reopen" + + if $(ui.sender).data('state') == "closed" + data += "&issue[state_event]=reopen" Milestone.updateIssue(ui.item, issue_url, data) diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml index 594b6a0c72f..67b45fc30ba 100644 --- a/app/views/projects/milestones/show.html.haml +++ b/app/views/projects/milestones/show.html.haml @@ -75,14 +75,12 @@ .tab-content .tab-pane.active#tab-issues .row - .col-md-3 - = render('issues', title: 'Unstarted Issues (open and unassigned)', issues: @issues.only_opened.unassigned, id: 'unassigned') - .col-md-3 - = render('issues', title: 'Ongoing Issues (open and assigned)', issues: @issues.only_opened.assigned, id: 'ongoing') - .col-md-3 + .col-md-4 + = 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, id: 'ongoing') + .col-md-4 = render('issues', title: 'Completed Issues (closed)', issues: @issues.closed, id: 'closed') - .col-md-3 - = render('issues', title: 'Reopened Issues (reopened)', issues: @issues.only_reopened, id: 'reopened') .tab-pane#tab-merge-requests .row