Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Gerry Bragg
RE: Perform date calculation on child on Upda [ reply ]  
2007-09-27 09:09
Did you get resolution on this? If so let us know what the issue was. Thanks!

By: nicole kelly
Perform date calculation on child on Update [ reply ]  
2007-08-29 19:22
Hi - I love the sublist plugin - I have a project management system that has projects (parent) and tasks (child). When I update the tasks (from within the project view via the sublist plugin), I'd like to perform a date calculation on two of the task fields that are entered into the database.

When I CREATE the project and subsequent tasks, the task start and end date calculations are as follows:

[code]
@projecttemplate.templatetasks.each do |t| #loop through tasks of the project template
@newtasks = @newproject.tasks.create(t.attributes) #build tasks for the new project from the templatetask attributes
@newtasks.statusID = 1
@newtasks.dateStart = @newproject.dateTargetEnd - @newtasks.leadTime
@newtasks.dateTargetEnd = @newtasks.dateStart + @newtasks.duration
@newtasks.save!
end
[/code]

I'm wondering how I add these calculations to the project update view (seen below)...
[code]
def update
@project = Project.find(params[:id])
@project.update_attributes(@params[:project])
success = true
success &&= initialize_tasks
success &&= @project.save
if success
flash[:notice] = 'Project successfully updated.'
redirect_to :action => 'show', :id => @project
else
prepare_tasks
render_action 'edit'
end
[/code]

Any help greatly appreciated!