Skip to content

Commit

Permalink
Cleaning up project after demo, adding little touches
Browse files Browse the repository at this point in the history
  • Loading branch information
bidsync committed Sep 15, 2009
1 parent 5c4ab27 commit ffd310b
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 37 deletions.
5 changes: 3 additions & 2 deletions app/helpers/projects.rb
@@ -1,7 +1,7 @@
class Main
helpers do

def show_date(datetime)
def show_date(datetime, warn_date_is_past=true)
if (datetime.nil?)
haml "%span.emphasis none", :layout => false
else
Expand All @@ -13,7 +13,8 @@ def show_date(datetime)
raise ArgumentError, "Invalid object passed to show_date"
end
full_date = datetime.strftime("%m.%d.%Y")
haml "%span{:title => \"#{full_date}\"} #{nice_date(datetime)}", :layout => false
@warn = (warn_date_is_past && Date.today > datetime.to_date)
haml "%span{:title => \"#{full_date}\", :class => \"#{@warn ? "warn" : ""}\"} #{nice_date(datetime)}", :layout => false
end
end

Expand Down
11 changes: 1 addition & 10 deletions app/models/project_meta.rb
Expand Up @@ -12,7 +12,7 @@ class ProjectMeta < ActiveRecord::Base
validates_numericality_of :developer_id, :department_id, :num_stories, :num_completed_stories, { :allow_nil => true }

# named scopes
named_scope :all_sorted, :order => "name ASC"
named_scope :all_sorted, :order => "current_target_date ASC, name ASC"
named_scope :active, :conditions => {:is_active => true}
named_scope :inactive, :conditions => {:is_active => false}

Expand Down Expand Up @@ -49,15 +49,6 @@ def department
Department.find department_id if !department_id.nil?
end

def original_target_date=(date)
raise ArgumentError, "Cannot change original target date, it has already been changed" unless self.original_target_date.nil?;
self[:original_target_date] = date
end

def reset_original_target_date
self[:original_target_date] = nil
end

def sync(project)
raise ArgumentError, "Cannot sync with invalid project object" if project.nil? || !project.is_a?(Project)
self[:name] = project.name
Expand Down
7 changes: 2 additions & 5 deletions app/routes/projects.rb
Expand Up @@ -62,11 +62,8 @@ class Main
unless @project.nil?
@project.developer_id = params[:developer_id]
@project.department_id = params[:department_id]
if params.include?("original_target_date") && !params["original_target_date"].strip.empty?
@project.original_target_date = params[:original_target_date]
elsif params.include?("clear_original_target_date")
@project.reset_original_target_date
end
@project.original_target_date = nil if params.include?("clear_original_target_date")
@project.original_target_date = params[:original_target_date].strip unless !params.include?("original_target_date") || params["original_target_date"].strip.empty?
@project.save!
add_message "Successfully updated project settings."
else
Expand Down
6 changes: 5 additions & 1 deletion app/views/css/main.sass
Expand Up @@ -87,7 +87,7 @@ form.inline-button
#wrapper
+cf
:margin 0 auto
:width 800px
:width 1000px
:border 3px solid #333
:border-style none solid
:background #ccc
Expand Down Expand Up @@ -194,5 +194,9 @@ table.data-vertical
:background #EB938E
:border 1px solid #881A15

.warn
:color #FF7F00


.center
:text-align center
2 changes: 2 additions & 0 deletions app/views/layout.haml
Expand Up @@ -5,6 +5,8 @@
%meta{:"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"}/
%link{:rel => "stylesheet", :href => "/css/reset.css", :type => "text/css"}/
%link{:rel => "stylesheet", :href => "/css/main.css", :type => "text/css"}/
%script{:type => "text/javascript", :src => "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"}
%script{:type => "text/javascript", :src => "/js/application.js"}
%body
#wrapper
Expand Down
8 changes: 5 additions & 3 deletions app/views/partials/project_list.haml
Expand Up @@ -3,6 +3,7 @@
%th Name
%th Dev.
%th Dept.
%th Original
%th Current
%th Completion
%th Actions
Expand All @@ -13,16 +14,17 @@
%a{:href => external_project_link(project), :title => "Project on Pivotal Tracker (External link)", :target => "_blank"} &#x2B00;
%td!= link_to_developer(project.developer)
%td!= link_to_department(project.department)
- if false || !has_stories?(project) || all_stories_completed?(project)
%td{:colspan => 2, :class => "center"}
- if !has_stories?(project) || all_stories_completed?(project)
%td{:colspan => 3, :class => "center"}
- if !has_stories?(project)
%span.emphasis No Stories
- unless project.developer.nil?
&#151;
%a{:href => "mailto:#{project.developer.email}?subject=Provide%20Stories&body=Please%20provide%20stories%20for%20pivotal%20project%20#{project.url}"} Notify
%a{:href => "mailto:#{project.developer.email}?subject=Provide%20Stories&body=Please%20provide%20stories%20for%20pivotal%20project%20#{external_project_link(project)}"} Notify
- elsif all_stories_completed?(project)
.emphasis Completed
- else
%td!= show_date(project.original_target_date)
%td!= show_date(project.current_target_date)
%td= "#{show_float project.completion_ratio}%"
%td
Expand Down
18 changes: 11 additions & 7 deletions app/views/projects/edit.haml
Expand Up @@ -13,16 +13,20 @@
.row
.label Original Target Date
.input
- if @project.original_target_date.nil?
#original-date-input{:style => (@project.original_target_date.nil? ? nil : "display:none;")}
%input{:type => "text", :name => "original_target_date", :value => @project.current_target_date.strftime("%m/%d/%Y")}
(
%a{:href => "javascript:void(0);", :onclick => "document.forms[0].original_target_date.value = '';", :title => "Clear Original Date"} Clear
)
- else
!= show_date @project.current_target_date
(
%input{:type => "checkbox", :name => "clear_original_target_date", :value => "1"} Clear
%a{:href => "javascript:void(0);", :onclick => "$('input[name=original_target_date]').val('');", :title => "Clear Original Date"} Clear
,
%a{:href => "javascript:void(0);", :onclick => "$('input[name=original_target_date]').val('#{@project.current_target_date.strftime("%m/%d/%Y")}');", :title => "Reset to Original Date"} Original
)
- unless @project.original_target_date.nil?
#original-date-display
!= show_date @project.current_target_date
(
%label
%input{:type => "checkbox", :name => "clear_original_target_date", :value => "1"} Clear
)
.row
.label &nbsp;
.input
Expand Down
2 changes: 2 additions & 0 deletions app/views/projects/index.haml
Expand Up @@ -6,6 +6,8 @@

- unless @projects.nil? || @projects.empty?
.context-nav.right
%a{:href => "http://www.pivotaltracker.com/dashboard", :title => "New Project on Pivotal", :target => "_blank"} New
|
- if @archive_view
%a{:href => "/projects", :title => "Show Active Projects"} Active
- else
Expand Down
34 changes: 25 additions & 9 deletions app/views/projects/show.haml
Expand Up @@ -22,12 +22,28 @@
%tr{:class => alt_row_color}
%th Department
%td!= link_to_department(@project.department)
%tr{:class => alt_row_color}
%th Original Target
%td!= show_date(@project.original_target_date)
%tr{:class => alt_row_color}
%th Current Target
%td!= show_date(@project.current_target_date)
%tr{:class => alt_row_color}
%th Completion
%td= "#{@project.num_completed_stories}/#{@project.num_stories} (#{show_float @project.completion_ratio}%)"
- if !has_stories?(@project) || all_stories_completed?(@project)
%tr
%th Original Target
%td{:rowspan => 3, :class => "center"}
- if !has_stories?(@project)
%span.emphasis No Stories
- unless @project.developer.nil?
&#151;
%a{:href => "mailto:#{@project.developer.email}?subject=Provide%20Stories&body=Please%20provide%20stories%20for%20pivotal%20project%20#{external_project_link(@project)}"} Notify
- elsif all_stories_completed?(@project)
.emphasis Completed
%tr
%th Current Target
%tr
%th Completion
- else
%tr{:class => alt_row_color}
%th Original Target
%td!= show_date(@project.original_target_date)
%tr{:class => alt_row_color}
%th Current Target
%td!= show_date(@project.current_target_date)
%tr{:class => alt_row_color}
%th Completion
%td= "#{@project.num_completed_stories}/#{@project.num_stories} (#{show_float @project.completion_ratio}%)"
10 changes: 10 additions & 0 deletions public/js/application.js
@@ -0,0 +1,10 @@
$(document).ready(function(){
$("input[name='clear_original_target_date']:checkbox").click(function(){
if ($(this).attr("checked"))
{
$("#original-date-display").hide();
$("#original-date-input").show();
$("#original-date-input input").select();
}
});
});

0 comments on commit ffd310b

Please sign in to comment.