Index: openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/task-add-edit.tcl,v diff -u -r1.32 -r1.33 --- openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 12 May 2004 21:50:42 -0000 1.32 +++ openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 14 May 2004 23:08:57 -0000 1.33 @@ -2,6 +2,13 @@ Add/edit form for tasks +

+ + I plan to eventually get rid of the task-select-project page, because + the ability to choose the project is now within this page. However, + I'm waiting to do that until after my company updates our projects + with the customer in each field. + @author jader@bread.com @creation-date 2003-07-28 @cvs-id $Id$ @@ -12,24 +19,41 @@ @return edit_p if t then we are editing. Used to show different portions of the form @param process_task_ids Specifies what process task ids were used if a process were used. We pass this on to future pages to determine things such as assignments - @param project_item_id Specifies which project this task is associated with - @param project_id Specifies which project revision this task is associated with + @param project_item_id Specifies which project each task is associated with. If this is a new task, this specifies the project that it will be assigned under. + @param my_key if set, then ad_form knows that this is an edit + @param process_task_ids + @param project_item_id This is optionally passed in to this page to + indictate the project that the tasks should be associated with. + @param project_item_ids Used internally to keep track of the projects + associated with each task @param number The number of Tasks to create - @param added_tasks @param task_revision_id Specifies the revision this task represents (each revision of a task has a separate id) @param task_id Specifies the item for the task (every revision of a task shares the same task_id) Also used as the key for the ad_form. For this reason, when editing, we have to pass in task_iid instead - @param my_key if set, then ad_form knows that this is an edit @param task_title - @param skip_task_p Whether or not to skip this particular task. Used by processes, if t, then the task is not created @param process_id The process we're using to create this task - @param use_uncertain_completion_times_p Whether or not to use PERT-style completion time uncertainty 1 = yes - @return using_process_p Lets the UI know if there is a process being used (t if so) + @param description + @param old_description + @param comment + @param name + @param end_date + @param percent_complete + @param actual_hours_worked + @param new_hours_logged + @param new_description_logged + @param estimated_hours_work + @param estimated_hours_work_min + @param estimated_hours_work_max + @param dependency_type + @param dependency_task_id + @param skip_task_p Whether or not to skip this particular task. Used by processes, if t, then the task is not created + @param using_process_p Lets the UI know if there is a process being used (t if so) + } { my_key:integer,optional process_task_ids:array,optional - project_item_id:integer,optional - project_id:integer,optional + {project_item_id:integer ""} + project_item_ids:array,optional {number:integer "1"} task_revision_id:integer,optional {task_id:multiple ""} @@ -64,12 +88,6 @@ using_process_p:onevalue } -validate { - project_exists { - if {![exists_and_not_null project_item_id] && \ - ![exists_and_not_null project_id]} { - ad_complain - } - } number_is_in_range -requires {number:integer} { # todo: make 100 a parameter if {$number < 1 || $number > 100} { @@ -103,11 +121,6 @@ # --------------------------------------------------------------- # -if {![exists_and_not_null project_id]} { - set project_id [db_string get_project_id { }] -} - - # -------------------------------------------------------------------- # If we are using a process, then we need to get the information on # the process now. This is necessary because we need to do things like @@ -376,7 +389,7 @@ if {[exists_and_not_null task_id]} { set title "Edit a $task_term_lower" - set context [list [list "one?item_id=$project_item_id&project_id=$project_id" "One $project_term"] "Edit $task_term"] + set context [list [list $return_url "Go back"] "Edit $task_term"] permission::require_permission \ -party_id $user_id \ -object_id $package_id \ @@ -385,7 +398,7 @@ } else { set title "Add a $task_term_lower" - set context [list [list "one?item_id=$project_item_id&project_id=$project_id" "One $project_term"] "New $task_term"] + set context [list [list "one?item_id=$project_item_id" "One $project_term"] "New $task_term"] permission::require_permission \ -party_id $user_id \ -object_id $package_id \ @@ -396,18 +409,17 @@ # we use this to pass through the task_ids set task_id_pass [string map {" " "-"} $task_id] +# set up options for editing projects +set project_options [pm::project::get_list_of_open] + # --------------------------------------------------------------- # # Begin our form # --------------------------------------------------------------- # ad_form -name add_edit -form { my_key:key(acs_object_id_seq) - {project_item_id:text(hidden) - {value $project_item_id} - } - {task_id:text(hidden) {value $task_id_pass} } @@ -420,10 +432,6 @@ {value $return_url} } - {project_id:text(hidden) - {value $project_id} - } - {number:text(hidden) {value $number} } @@ -475,6 +483,7 @@ set percent_complete_arr($i) $my_percent_complete set actual_hours_worked_arr($i) $my_actual_hours_worked + set project_item_id_arr($i) $my_project_item_id set task_item_id_arr($i) [lindex $task_id [expr $i - 1]] set dependency_arr($i) $my_dependency # we keep track of this to make sure that depedencies that @@ -577,6 +586,7 @@ set end_date_arr($i) "" set percent_complete_arr($i) 0 set actual_hours_worked_arr($i) 0 + set project_item_id_arr($i) $project_item_id set task_item_id_arr($i) "" set process_task_id_arr($i) "" set dependency_arr($i) "" @@ -687,21 +697,7 @@ # lappend options "{\"$dependencies(description)\" $dependencies(short_name)}" #} -# get tasks this task can depend on -set dependency_keys [list] - -db_foreach get_dependency_tasks { } -column_array dependency_tasks { - - set dependency_options($dependency_tasks(task_title)) $dependency_tasks(item_id) - lappend dependency_keys $dependency_tasks(task_title) -} - -set dependency_keys [lsort $dependency_keys] - - - - # ---------------------------------------------- # extend the form with all the items that repeat # ---------------------------------------------- @@ -723,9 +719,6 @@ # any loops! # --------------------------------------------------- - set dependency_options_full "" - append dependency_options_full "{\"--None--\" \"\"} " - if {[string equal $edit_p f]} { # if we have a process, we need to bring in the dependencies @@ -767,40 +760,18 @@ } - # now set up dependency options - for {set j 1} {$j <= $number} {incr j} { - if {![string equal $i $j]} { - append dependency_options_full "{\"New Task \#$j\" \"num$j\"} " - } - } - } - # for editing tasks, we skip ourselves (because depending on - # ourselves just sometimes isn't an option) - if {[string equal $edit_p t]} { - foreach key $dependency_keys { - # make sure we're not dependent on ourselves + set dependency_options_full [pm::task::dependency_options \ + -edit_p $edit_p \ + -task_item_id $task_item_id_arr($i) \ + -project_item_id $project_item_id_arr($i) \ + -dependency_task_ids "$my_dependencies" \ + -number $number \ + -current_number $i] - if {![string equal $task_item_id_arr($i) $dependency_options($key)]} { - # check for case when there is a quote in the name of - # a task. We have to filter this out, or we get an error. - append dependency_options_full "{{$key} $dependency_options($key)} " - } - } - } else { - foreach key $dependency_keys { - - # check for case when there is a quote in the name of - # a task. We have to filter this out, or we get an error. - append dependency_options_full "{{$key} $dependency_options($key)} " - } - } - - # ns_log Notice "end_date.$i : $end_date_arr($i)" - ad_form -extend \ -name add_edit \ -form \ @@ -811,6 +782,11 @@ {html {size 40}} \ {value {$task_title_arr($i)}} ] \ + [list project_item_ids.$i:text(select) \ + {label "Project"} \ + {options $project_options} \ + {value {$project_item_id_arr($i)}} \ + ] \ [list task_item_id.$i:text(hidden) \ {label "Task item id"} \ {value {$task_item_id_arr($i)}} \ @@ -914,6 +890,8 @@ } # set up variables, pulling from arrays + set p_project_item_id $project_item_ids($i) + set p_task_title $task_title($i) set p_description $description($i) @@ -940,7 +918,7 @@ if {[string equal $p_skip_p "f"]} { set this_revision_id [pm::task::new \ - -project_id $project_item_id \ + -project_id $p_project_item_id \ -title $p_task_title \ -description $p_description \ -mime_type $p_mime_type \ @@ -979,7 +957,7 @@ -task_item_id $this_task_id \ -parent_id $p_parent_task_id \ -dependency_type $p_dep_type \ - -project_item_id $project_item_id + -project_item_id $p_project_item_id } } @@ -1005,7 +983,7 @@ -task_item_id $this_task_id \ -parent_id $parent_task_id \ -dependency_type $p_dep_type \ - -project_item_id $project_item_id + -project_item_id $p_project_item_id } } @@ -1044,6 +1022,8 @@ } # set up variables, pulling from arrays + set p_project_item_id $project_item_ids($i) + set p_task_item_id $task_item_id($i) set p_task_title $task_title($i) set p_description $description($i) @@ -1065,7 +1045,7 @@ $p_new_hours > 0} { set logger_project [pm::project::get_logger_project \ - -project_item_id $project_item_id] + -project_item_id $p_project_item_id] set variable_id [logger::variable::get_default_variable_id] # add in the new log entry @@ -1076,7 +1056,7 @@ -description $p_new_description \ -timestamp_ansi $timestamp_ansi \ -task_item_id $p_task_item_id \ - -project_item_id $project_item_id \ + -project_item_id $p_project_item_id \ -update_status_p f] if {[string equal p_hours -1]} { @@ -1092,7 +1072,7 @@ # do the actual edit set this_revision_id [pm::task::edit \ -task_item_id $p_task_item_id \ - -project_item_id $project_item_id \ + -project_item_id $p_project_item_id \ -title $p_task_title \ -description $p_description \ -mime_type $p_mime_type \ @@ -1118,7 +1098,7 @@ -task_item_id $p_task_item_id \ -parent_id $p_parent_task_id \ -dependency_type jfdsafesa\ - -project_item_id $project_item_id + -project_item_id $p_project_item_id } # add in general comments for the task @@ -1192,9 +1172,27 @@ } -after_submit { - ad_returnredirect "task-assign-add-edit?[export_vars -url {project_item_id comment_list edit_p return_url process_task_id:multiple revisions:multiple task_id:multiple old_description}]" - pm::project::compute_parent_status $project_item_id + ad_returnredirect "task-assign-add-edit?[export_vars -url {comment_list edit_p return_url process_task_id:multiple revisions:multiple task_id:multiple old_description}]" + # compile a list of which projects the tasks are assigned to + # there is a bug here, because we don't update a project when a + # task is edited and changed to another project. + + set project_item_id_list [list] + for {set i 1} {$i <= $number} {incr i} { + + if {[string equal [lsearch $project_item_id_list $project_item_ids($i)] -1]} { + lappend project_item_id_list $project_item_ids($i) + } + + } + + foreach proj_item $project_item_id_list { + + pm::project::compute_parent_status $proj_item + + } + ad_script_abort }