summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-14 08:34:05 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-14 08:34:05 +0300
commit190e483fb4b5edb6d8dfa71b67dc52da402ddab9 (patch)
treeaa769f7be3c6a827c5c663028bd6202ed43b0740 /app
parentb01f8b63c2c13f8d6b9111771fb4f1422214d91c (diff)
downloadgitlab-ce-190e483fb4b5edb6d8dfa71b67dc52da402ddab9.tar.gz
Rework of milestones
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/common.scss11
-rw-r--r--app/controllers/milestones_controller.rb7
-rw-r--r--app/models/milestone.rb19
-rw-r--r--app/models/snippet.rb2
-rw-r--r--app/views/issues/_show.html.haml2
-rw-r--r--app/views/milestones/_milestone.html.haml6
-rw-r--r--app/views/milestones/index.html.haml5
-rw-r--r--app/views/milestones/show.html.haml54
8 files changed, 72 insertions, 34 deletions
diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss
index a9777f56ee2..d38aa1738a3 100644
--- a/app/assets/stylesheets/common.scss
+++ b/app/assets/stylesheets/common.scss
@@ -531,9 +531,14 @@ pre {
}
}
-.milestone .progress {
- margin-bottom: 0;
- margin-top: 4px;
+.milestone {
+ &.milestone-closed {
+ background: #eee;
+ }
+ .progress {
+ margin-bottom: 0;
+ margin-top: 4px;
+ }
}
.float-link {
diff --git a/app/controllers/milestones_controller.rb b/app/controllers/milestones_controller.rb
index fadfee2dc06..276317d1c2d 100644
--- a/app/controllers/milestones_controller.rb
+++ b/app/controllers/milestones_controller.rb
@@ -12,11 +12,12 @@ class MilestonesController < ProjectResourceController
def index
@milestones = case params[:f]
- when 'all'; @project.milestones
- else @project.milestones.active
+ when 'all'; @project.milestones.order("closed, due_date DESC")
+ when 'closed'; @project.milestones.closed.order("due_date DESC")
+ else @project.milestones.active.order("due_date ASC")
end
- @milestones = @milestones.includes(:project).order("due_date")
+ @milestones = @milestones.includes(:project)
@milestones = @milestones.page(params[:page]).per(20)
end
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index a50831a2241..e700cc2f2f7 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -19,12 +19,19 @@ class Milestone < ActiveRecord::Base
has_many :issues
has_many :merge_requests
+ scope :active, where(closed: false)
+ scope :closed, where(closed: true)
+
validates :title, presence: true
validates :project, presence: true
validates :closed, inclusion: { in: [true, false] }
- def self.active
- where("due_date > ? OR due_date IS NULL", Date.today)
+ def expired?
+ if due_date
+ due_date < Date.today
+ else
+ false
+ end
end
def participants
@@ -52,4 +59,12 @@ class Milestone < ActiveRecord::Base
def expires_at
"expires at #{due_date.stamp("Aug 21, 2011")}" if due_date
end
+
+ def can_be_closed?
+ issues.count > 0 && open? && issues.opened.count.zero?
+ end
+
+ def open?
+ !closed
+ end
end
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 997c19bdb6b..8d7eb788abb 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -22,7 +22,7 @@ class Snippet < ActiveRecord::Base
belongs_to :author, class_name: "User"
has_many :notes, as: :noteable, dependent: :destroy
- delegate :name, :email, to: :author, prefix: true
+ delegate :name, :email, to: :author, prefix: true, allow_nil: true
validates :author, presence: true
validates :project, presence: true
diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml
index 8aa92ebfd6a..ca8cdf704a9 100644
--- a/app/views/issues/_show.html.haml
+++ b/app/views/issues/_show.html.haml
@@ -28,7 +28,7 @@
%p= link_to_gfm truncate(issue.title, length: 100), project_issue_path(issue.project, issue), class: "row_title"
%span.update-author
- %small.cdark= "##{issue.id}"
+ %span.cdark= "##{issue.id}"
- if issue.assignee
assigned to #{issue.assignee_name}
- else
diff --git a/app/views/milestones/_milestone.html.haml b/app/views/milestones/_milestone.html.haml
index 7c4c0e67d7c..462b9e395a1 100644
--- a/app/views/milestones/_milestone.html.haml
+++ b/app/views/milestones/_milestone.html.haml
@@ -1,11 +1,13 @@
-%li{class: "milestone", id: dom_id(milestone) }
+%li{class: "milestone milestone-#{milestone.closed ? 'closed' : 'open'}", id: dom_id(milestone) }
.right
- - if can? current_user, :admin_milestone, milestone.project
+ - if can?(current_user, :admin_milestone, milestone.project) and milestone.open?
= link_to edit_project_milestone_path(milestone.project, milestone), class: "btn small edit-milestone-link grouped" do
%i.icon-edit
Edit
%h4
= link_to_gfm truncate(milestone.title, length: 100), project_milestone_path(milestone.project, milestone)
+ - if milestone.expired? and not milestone.closed
+ %span.cred (Expired)
%small
= milestone.expires_at
.row
diff --git a/app/views/milestones/index.html.haml b/app/views/milestones/index.html.haml
index c5333b08fdc..813fb362e25 100644
--- a/app/views/milestones/index.html.haml
+++ b/app/views/milestones/index.html.haml
@@ -11,6 +11,9 @@
%li{class: ("active" if (params[:f] == "active" || !params[:f]))}
= link_to project_milestones_path(@project, f: "active") do
Active
+ %li{class: ("active" if params[:f] == "closed")}
+ = link_to project_milestones_path(@project, f: "closed") do
+ Closed
%li{class: ("active" if params[:f] == "all")}
= link_to project_milestones_path(@project, f: "all") do
All
@@ -19,7 +22,7 @@
= render @milestones
- if @milestones.present?
- %li.bottom= paginate @milestones, remote: true, theme: "gitlab"
+ %li.bottom= paginate @milestones, theme: "gitlab"
- else
%li
%h3.nothing_here_message Nothing to show here
diff --git a/app/views/milestones/show.html.haml b/app/views/milestones/show.html.haml
index b8bc788c953..1f191f5ad3c 100644
--- a/app/views/milestones/show.html.haml
+++ b/app/views/milestones/show.html.haml
@@ -1,31 +1,41 @@
-%h3.page_title
- Milestone ##{@milestone.id}
- %small
- = @milestone.expires_at
+.row
+ .span6
+ %h3.page_title
+ Milestone ##{@milestone.id}
+ %small
+ = @milestone.expires_at
+ .back_link
+ = link_to project_milestones_path(@project) do
+ &larr; To milestones list
+ .span6
+ .right
+ - unless @milestone.closed
+ = link_to new_project_issue_path(@project, issue: { milestone_id: @milestone.id }), class: "btn small grouped", title: "New Issue" do
+ %i.icon-plus
+ New Issue
+ = link_to 'Browse Issues', project_issues_path(@milestone.project, milestone_id: @milestone.id), class: "btn edit-milestone-link small grouped"
+ - if can?(current_user, :admin_milestone, @project)
+ = link_to edit_project_milestone_path(@project, @milestone), class: "btn small grouped" do
+ %i.icon-edit
+ Edit
- %span.right
- = link_to new_project_issue_path(@project, issue: { milestone_id: @milestone.id }), class: "btn small grouped", title: "New Issue" do
- %i.icon-plus
- New Issue
- = link_to 'Browse Issues', project_issues_path(@milestone.project, milestone_id: @milestone.id), class: "btn edit-milestone-link small grouped"
- - if can?(current_user, :admin_milestone, @project)
- = link_to edit_project_milestone_path(@project, @milestone), class: "btn small grouped" do
- %i.icon-edit
- Edit
-.back_link
- = link_to project_milestones_path(@project) do
- &larr; To milestones list
+
+- if @milestone.can_be_closed?
+ %hr
+ %p
+ %span All issues for this milestone are closed. You may close milestone now.
+ = link_to 'Close Milestone', project_milestone_path(@project, @milestone, milestone: {closed: true }), method: :put, class: "btn small danger"
.main_box
.top_box_content
- %h5
+ %h4.box-title
- if @milestone.closed
- .alert-message.error.status_info Closed
- - else
- .alert-message.success.status_info Open
+ .error.status_info Closed
+ - elsif @milestone.expired?
+ .error.status_info Expired
+
= gfm escape_once(@milestone.title)
- %small.right= @milestone.expires_at
.middle_box_content
%h5
@@ -34,6 +44,7 @@
#{@milestone.closed_items_count} closed
&ndash;
#{@milestone.open_items_count} open
+ %span.right= @milestone.expires_at
.progress.progress-info
.bar{style: "width: #{@milestone.percent_complete}%;"}
@@ -43,6 +54,7 @@
= preserve do
= markdown @milestone.description
+
.row
.span6
%table.milestone-issue-filter