Permalink
Browse files

Milestone basic scaffold

  • Loading branch information...
1 parent 667edcd commit 23d950855d6d2524d00b1f0618c008e2529f06a4 @randx randx committed Apr 8, 2012
@@ -2,6 +2,7 @@ function switchToNewIssue(form){
$(".issues_content").hide("fade", { direction: "left" }, 150, function(){
$(".issues_content").after(form);
$('select#issue_assignee_id').chosen();
+ $('select#issue_milestone_id').chosen();
$("#new_issue_dialog").show("fade", { direction: "right" }, 150);
$('.top-tabs .add_new').hide();
});
@@ -11,6 +12,7 @@ function switchToEditIssue(form){
$(".issues_content").hide("fade", { direction: "left" }, 150, function(){
$(".issues_content").after(form);
$('select#issue_assignee_id').chosen();
+ $('select#issue_milestone_id').chosen();
$("#edit_issue_dialog").show("fade", { direction: "right" }, 150);
$('.add_new').hide();
});
@@ -45,6 +45,13 @@ a {
&:hover {
}
+
+ &.primary {
+ background:$link_color;
+ &:hover {
+ background:$blue_link;
+ }
+ }
}
a:focus {
@@ -0,0 +1,31 @@
+/**
+ * JQUERY UI datepicker
+ *
+ */
+.ui-datepicker {
+ border-color:#eee;
+ padding:20px;
+
+ .ui-state-default {
+ background:#f1f1f1;
+ padding:5px;
+ }
+ .ui-state-active {
+ background:#fff;
+ }
+}
+
+/**
+ * JQUERY UI progressbar
+ *
+ */
+.ui-progressbar {
+ border:1px solid #ddd;
+ height:6px;
+
+ .ui-progressbar-value {
+ background-color: #62C462;//$blue_link;
+ margin:0;
+ }
+}
+
@@ -116,3 +116,9 @@ $hover: #FDF5D9;
*
*/
@import "highlight.black.scss";
+
+/**
+ * JQUERY UI ext
+ *
+ */
+@import "jquery_ui.scss";
@@ -15,7 +15,7 @@ class IssuesController < ApplicationController
before_filter :authorize_write_issue!, :only => [:new, :create]
# Allow modify issue
- before_filter :authorize_modify_issue!, :only => [:close, :edit, :update, :sort]
+ before_filter :authorize_modify_issue!, :only => [:close, :edit, :update]
# Allow destroy issue
before_filter :authorize_admin_issue!, :only => [:destroy]
@@ -28,8 +28,10 @@ def index
when 2 then @project.issues.closed
when 3 then @project.issues.opened.assigned(current_user)
else @project.issues.opened
- end.page(params[:page]).per(20)
+ end
+ @issues = @issues.where(:milestone_id => params[:milestone_id]) if params[:milestone_id].present?
+ @issues = @issues.page(params[:page]).per(20)
@issues = @issues.includes(:author, :project).order("critical, updated_at")
respond_to do |format|
@@ -51,13 +53,6 @@ def edit
def show
@note = @project.notes.new(:noteable => @issue)
- @commits = if @issue.branch_name && @project.repo.heads.map(&:name).include?(@issue.branch_name)
- @project.repo.commits_between("master", @issue.branch_name)
- else
- []
- end
-
-
respond_to do |format|
format.html
format.js
@@ -102,6 +97,8 @@ def destroy
end
def sort
+ return render_404 unless can?(current_user, :admin_issue, @project)
+
@issues = @project.issues.where(:id => params['issue'])
@issues.each do |issue|
issue.position = params['issue'].index(issue.id.to_s) + 1
@@ -0,0 +1,94 @@
+class MilestonesController < ApplicationController
+ before_filter :authenticate_user!
+ before_filter :project
+ before_filter :module_enabled
+ before_filter :milestone, :only => [:edit, :update, :destroy, :show]
+ layout "project"
+
+ # Authorize
+ before_filter :add_project_abilities
+
+ # Allow read any milestone
+ before_filter :authorize_read_milestone!
+
+ # Allow admin milestone
+ before_filter :authorize_admin_milestone!, :except => [:index, :show]
+
+ respond_to :html
+
+ def index
+ @milestones = case params[:f].to_i
+ when 1; @project.milestones
+ else @project.milestones.active
+ end
+
+ @milestones = @milestones.includes(:project).order("due_date")
+ @milestones = @milestones.page(params[:page]).per(20)
+ end
+
+ def new
+ @milestone = @project.milestones.new
+ respond_with(@milestone)
+ end
+
+ def edit
+ respond_with(@milestone)
+ end
+
+ def show
+ respond_to do |format|
+ format.html
+ format.js
+ end
+ end
+
+ def create
+ @milestone = @project.milestones.new(params[:milestone])
+
+ if @milestone.save
+ redirect_to project_milestone_path(@project, @milestone)
+ else
+ render "new"
+ end
+ end
+
+ def update
+ @milestone.update_attributes(params[:milestone])
+
+ respond_to do |format|
+ format.js
+ format.html do
+ if @milestone.valid?
+ redirect_to [@project, @milestone]
+ else
+ render :edit
+ end
+ end
+ end
+ end
+
+ def destroy
+ return access_denied! unless can?(current_user, :admin_milestone, @milestone)
+
+ @milestone.destroy
+
+ respond_to do |format|
+ format.html { redirect_to project_milestones_path }
+ format.js { render :nothing => true }
+ end
+ end
+
+ protected
+
+ def milestone
+ @milestone ||= @project.milestones.find(params[:id])
+ end
+
+ def authorize_admin_milestone!
+ return render_404 unless can?(current_user, :admin_milestone, @project)
+ end
+
+ def module_enabled
+ return render_404 unless @project.issues_enabled
+ end
+end
@@ -0,0 +1,4 @@
+class MilestoneDecorator < ApplicationDecorator
+ decorates :milestone
+
+end
View
@@ -17,6 +17,7 @@ def self.project_abilities(user, project)
:read_project,
:read_wiki,
:read_issue,
+ :read_milestone,
:read_snippet,
:read_team_member,
:read_merge_request,
@@ -42,6 +43,7 @@ def self.project_abilities(user, project)
:modify_merge_request,
:admin_project,
:admin_issue,
+ :admin_milestone,
:admin_snippet,
:admin_team_member,
:admin_merge_request,
View
@@ -1,5 +1,6 @@
class Issue < ActiveRecord::Base
belongs_to :project
+ belongs_to :milestone
belongs_to :author, :class_name => "User"
belongs_to :assignee, :class_name => "User"
has_many :notes, :as => :noteable, :dependent => :destroy
View
@@ -0,0 +1,29 @@
+class Milestone < ActiveRecord::Base
+ belongs_to :project
+ has_many :issues
+
+ validates_presence_of :project_id
+ validates_presence_of :title
+
+ def self.active
+ where("due_date > ? ", Date.today)
+ end
+
+ def percent_complete
+ @percent_complete ||= begin
+ total_i = self.issues.count
+ closed_i = self.issues.closed.count
+ if total_i > 0
+ (closed_i * 100) / total_i
+ else
+ 100
+ end
+ rescue => ex
+ 0
+ end
+ end
+
+ def expires_at
+ "expires at #{due_date.stamp("Aug 21, 2011")}" if due_date
+ end
+end
View
@@ -12,6 +12,7 @@ class Project < ActiveRecord::Base
has_many :events, :dependent => :destroy
has_many :merge_requests, :dependent => :destroy
has_many :issues, :dependent => :destroy, :order => "position"
+ has_many :milestones, :dependent => :destroy
has_many :users_projects, :dependent => :destroy
has_many :notes, :dependent => :destroy
has_many :snippets, :dependent => :destroy
@@ -9,18 +9,25 @@
%li= msg
.clearfix
- = f.label :title, "Issue Subject"
- .input= f.text_field :title, :maxlength => 255, :class => "xxlarge"
-
+ = f.label :title, "Issue Subject *"
+ .input
+ = f.text_field :title, :maxlength => 255, :class => "xxlarge"
+
+ .clearfix
+ = f.label :assignee_id, "Assign to *"
+ .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Assign to user" })
+
.clearfix
= f.label :description, "Issue Details"
.input
= f.text_area :description, :maxlength => 2000, :class => "xxlarge", :rows => 10
%p.hint Markdown is enabled.
+
.clearfix
- = f.label :assignee_id
- .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Assign to user" })
+ = f.label :milestone_id
+ .input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { :include_blank => "Select milestone" })
+
.clearfix
= f.label :critical, "Critical"
@@ -1,4 +1,7 @@
.tabs
%li{:class => "#{'active' if current_page?(project_issues_path(@project))}"}
= link_to project_issues_path(@project), :class => "tab" do
- Issues
+ Browse Issues
+ %li{:class => "#{'active' if current_page?(project_milestones_path(@project))}"}
+ = link_to project_milestones_path(@project), :class => "tab" do
+ Milestones
@@ -10,3 +10,6 @@
.span10= paginate @issues, :remote => true, :theme => "gitlab"
.span4.right
%span.cgray.right #{@issues.total_count} issues for this filter
+- else
+ %li
+ %p.padded Nothing to show here
@@ -3,5 +3,6 @@
:javascript
$(function(){
$('select#issue_assignee_id').chosen();
+ $('select#issue_milestone_id').chosen();
});
Oops, something went wrong.

0 comments on commit 23d9508

Please sign in to comment.