Permalink
Browse files

make schedule independent of project; hide collapseable columns by cs…

…s in sprint view
  • Loading branch information...
1 parent 94234ce commit ba9e17b9f4b1e83006dea64caf3b53617cb70d88 Sven Fuchs committed Oct 24, 2008
View
4 NOTES
@@ -1,4 +1,6 @@
-make ticket lists filterable
+
+make schedule independent from project
+make team members independent from project
rake task for regularly synch'ing from lighthouse
@@ -1,27 +1,22 @@
class ScheduleController < ApplicationController
- before_filter :set_project
before_filter :set_schedule, :only => :index
def index
- @members = @project.members.sort_by &:first_name
+ @members = Project.all.map(&:members).flatten.uniq.sort_by(&:first_name)
end
def update
- project_id, user_id, day = params[:project_id], params[:user_id], params[:id]
- conditions = ["project_id = ? and user_id = ? and date(day) = ?", project_id, user_id, day]
+ user_id, day = params[:user_id], params[:id]
+ conditions = ["user_id = ? and date(day) = ?", user_id, day]
day = ScheduledDay.find(:first, :conditions => conditions) ||
- ScheduledDay.new(:project_id => project_id, :user_id => user_id, :day => day)
+ ScheduledDay.new(:user_id => user_id, :day => day)
day.hours = params[:hours]
day.save!
head :ok
end
protected
- def set_project
- @project = Project.find params[:project_id]
- end
-
def set_schedule
@schedule = Schedule.new first_week_day, first_week_day + 4.weeks
end
@@ -1,5 +1,5 @@
module ScheduleHelper
def schedule_id(schedule, user, day)
- "schedule-#{schedule.project.id}-#{user.id}-#{day.strftime('%Y-%m-%d')}"
+ "schedule-#{user.id}-#{day.strftime('%Y-%m-%d')}"
end
end
View
@@ -2,7 +2,6 @@ class Project < ActiveRecord::Base
has_many :components, :dependent => :destroy, :order => 'name'
has_many :categories, :dependent => :destroy
has_many :releases, :dependent => :destroy
- has_many :scheduled_days
has_many :memberships, :dependent => :destroy
has_many :members, :through => :memberships, :source => :user
@@ -2,7 +2,7 @@ class ScheduledDay < ActiveRecord::Base
belongs_to :user
def hours=(hours)
- self.minutes = hours * 60
+ self.minutes = hours.to_f * 60
end
def hours
@@ -9,6 +9,9 @@
<%= javascript_include_tag 'jquery-1.2.6.min', 'jquery.jeditable.mini', 'jquery.tablednd_0_5.js', :cache => true %>
<style>
+ #tickets .collapse {
+ display: none;
+ }
#main th.collapse-days {
padding: 0px;
}
@@ -67,11 +70,10 @@
update_scheduled_hours = function(hours, settings) {
var tokens = this.id.split('-');
- var project_id = tokens[1];
- var user_id = tokens[2];
- var day = tokens.slice(3, 6).join('-');
+ var user_id = tokens[1];
+ var day = tokens.slice(2, 5).join('-');
var params = { '_method': 'put', 'authenticity_token': authenticity_token, user_id: user_id, hours: hours };
- $.post("/projects/" + project_id + "/schedule/" + day + ".xml", params);
+ $.post("/schedule/" + day + ".xml", params);
return hours;
}
@@ -115,7 +117,7 @@
}
var collapsable_day_cells = Array();
- var collapse_day_columns = false;
+ var collapse_day_columns = true;
function init_collapse_day_columns() {
var table = $('#tickets');
@@ -128,8 +130,8 @@
$('td.day', tr).slice(0, days_count - 7).each(collect_days);
});
collapsable_day_cells = $(collapsable_day_cells);
-
- toggle_collapse_day_columns();
+
+ update_collapse_days_link();
}
}
@@ -139,7 +141,11 @@
collapsable_day_cells.each(function(i, element) {
collapse_day_columns ? $(element).hide() : $(element).show();
});
+
+ update_collapse_days_link();
+ }
+ function update_collapse_days_link() {
$('th.collapse-days a').remove();
if(collapse_day_columns) {
$('th.collapse-days').append('<a href="#" id="expand-days" class="toggle-days">«</a>');
@@ -14,8 +14,8 @@
<% if tracking %>
<th><%= link_to 'Hours', sorted_sprint_path(:hours) %></th>
<th>Actual</th>
- <% @sprint.schedule.used_days.each do |day| %>
- <th class="day"><%= day.strftime('%d.%m.') %></th>
+ <% @sprint.schedule.used_days.each_with_index do |day, i| %>
+ <th class="day<%= ' collapse' if i < @sprint.schedule.used_days.size - 7 %>"><%= day.strftime('%d.%m.') %></th>
<% end %>
<% else %>
<th>Hours</th>
@@ -29,12 +29,12 @@
<% if user %>
<tr class="totals">
<th><%= user.first_name %></th>
- <th><%= link_to 'scheduled', schedule_index_path(@project) %></th>
+ <th><%= link_to 'scheduled', schedule_index_path %></th>
<th></th>
<td class="scheduled"><%= @sprint.schedule.hours(user) %></td>
- <% @sprint.schedule.used_days.each do |day| %>
+ <% @sprint.schedule.used_days.each_with_index do |day, i| %>
<% if day <= Time.zone.today %>
- <td class="scheduled day"><%= @sprint.schedule.hours(user, day).to_i %></td>
+ <td class="scheduled day<%= ' collapse' if i < @sprint.schedule.used_days.size - 7 %>"><%= @sprint.schedule.hours(user, day).to_i %></td>
<% end %>
<% end %>
<td></td>
@@ -49,8 +49,8 @@
<td class="ticket"><%= link_to ticket.title, edit_ticket_path(ticket, :return_to => request.url) %></td>
<td class="estimated"><%= hours ticket.estimated, :zero => '-' %></td>
<td class="actual"><%= to_hours ticket.activities.total(*@sprint.period), :zero => '-' %></td>
- <% @sprint.schedule.used_days.each do |day| %>
- <td class="day"><%= to_hours ticket.activities.total(day) %></td>
+ <% @sprint.schedule.used_days.each_with_index do |day, i| %>
+ <td class="day<%= ' collapse' if i < @sprint.schedule.used_days.size - 7 %>"><%= to_hours ticket.activities.total(day) %></td>
<% end %>
<td class="activity-toggle"><%= toggle_ticket_activity_link(ticket) %></td>
</tr>
@@ -61,13 +61,13 @@
</th>
<td class="estimated"><%= tickets.map{|t| t.estimated.to_f }.sum %></td>
<td class="actual"><%= to_hours tickets.map{|t| t.activities.total(*@sprint.period) }.sum %></td>
- <% @sprint.schedule.used_days.each do |day| %>
- <td class="day"><%= to_hours tickets.map{|t| t.activities.total(day) }.sum %></td>
+ <% @sprint.schedule.used_days.each_with_index do |day, i| %>
+ <td class="day<%= ' collapse' if i < @sprint.schedule.used_days.size - 7 %>"><%= to_hours tickets.map{|t| t.activities.total(day) }.sum %></td>
<% end %>
<td></td>
</tr>
<% if user and @ticket_groups.last.first != user %>
- <tr><td colspan="<%= 5 + @sprint.schedule.used_days.size %>">&nbsp;</td></tr>
+ <tr><td colspan="<%= 5 + [@sprint.schedule.used_days.size, 7].min %>">&nbsp;</td></tr>
<% end %>
</tbody>
<% end %>
View
@@ -9,7 +9,7 @@
map.resources :components
map.resources :categories
map.resources :synchronizers
- map.resources :schedule, :path_prefix => "projects/:project_id"
+ map.resources :schedule
map.resources :activities
map.tickets_update_all "/tickets", :controller => 'tickets', :action => 'update_all', :conditions => {:method => :put}
@@ -27,9 +27,6 @@ h1 {
line-height: 36px;
clear: both;
}
-#tickets .inline-edit {
- width: 20px !important;
-}
#tickets .dragging,
#tickets .dragging td {
background-color: #ffffdd !important;
@@ -125,8 +122,13 @@ form:not(#filter) textarea.small {
border: auto;
font-size: 11px;
}
+/*#tickets .inline-edit {
+ width: 100%;
+}*/
#main .inline-edit {
- position: absolute !important;
+ position: relative !important;
+ width: 125% !important;
+ margin-right: -20px;
}
#main .inline-edit input {
width: 100% !important;
@@ -46,7 +46,7 @@
it_assigns :release, :flash => { :notice => :not_nil }
it_redirects_to { release_path(@release) }
-
+
it "syncs the release to its remote milestone" do
@release.should_receive(:push!)
act!
@@ -55,11 +55,11 @@
describe "(unsuccessful creation)" do
act! { post :create, :release => @attributes }
-
+
before do
@release.stub!(:save).and_return(false)
end
-
+
it_assigns :release
it_renders :template, :new
end
@@ -93,7 +93,7 @@
it_assigns :release, :flash => { :notice => :not_nil }
it_redirects_to { release_path(@release) }
-
+
it "syncs the release to its remote milestone" do
@release.should_receive(:push!)
act!
@@ -125,20 +125,20 @@
it_redirects_to { project_path(@release.project) }
end
-describe ReleasesController, "#filter" do
- before :each do
- controller.params = {:filter => {:state => ['resolved'], :release => ['1'], :sprint => ['1']}}
- end
-
- it "creates a state condition from the request params" do
- controller.send(:filter).should =~ /state IN \('resolved'\)/
- end
-
- it "creates a release condition from the request params" do
- controller.send(:filter).should =~ /release_id IN \(1\)/
- end
-
- it "creates a release condition from the request params" do
- controller.send(:filter).should =~ /sprint_id IN \(1\)/
- end
-end
+# describe ReleasesController, "#filter" do
+# before :each do
+# controller.params = {:filter => {:state => ['resolved'], :release => ['1'], :sprint => ['1']}}
+# end
+#
+# it "creates a state condition from the request params" do
+# controller.send(:filter).should =~ /state IN \('resolved'\)/
+# end
+#
+# it "creates a release condition from the request params" do
+# controller.send(:filter).should =~ /release_id IN \(1\)/
+# end
+#
+# it "creates a release condition from the request params" do
+# controller.send(:filter).should =~ /sprint_id IN \(1\)/
+# end
+# end

0 comments on commit ba9e17b

Please sign in to comment.