Index: openacs-4/contrib/packages/project-manager/www/process-task-add-edit-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/process-task-add-edit-2.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/contrib/packages/project-manager/www/process-task-add-edit-2.tcl 22 Jun 2004 00:25:55 -0000 1.9 +++ openacs-4/contrib/packages/project-manager/www/process-task-add-edit-2.tcl 25 Jun 2004 00:04:43 -0000 1.10 @@ -17,18 +17,44 @@ } { process_id:integer,notnull - {task_title:multiple ""} - {description:multiple ""} - {estimated_hours_work:multiple ""} - {estimated_hours_work_min:multiple ""} - {estimated_hours_work_max:multiple ""} + {task_title:array ""} + {description:array ""} + {estimated_hours_work:array ""} + {estimated_hours_work_min:array ""} + {estimated_hours_work_max:array ""} + {ordering:array ""} + {assignee:multiple ""} process_task_id:integer,multiple - {use_dependency:integer,multiple ""} + {use_dependency:array ""} } -validate { no_estimated_hours { - if {![exists_and_not_null estimated_hours_work] && ![exists_and_not_null estimated_hours_work_min] && ![exists_and_not_null estimated_hours_work_max]} { + + set flag1 0 + set flag2 0 + + foreach {index value} [array get estimated_hours_work] { + if {[empty_string_p $value]} { + set flag1 1 + } + } + + foreach {index value} [array get estimated_hours_work_min] { + if {[empty_string_p $value]} { + set flag2 1 + } + } + + foreach {index value} [array get estimated_hours_work_max] { + if {[empty_string_p $value]} { + set flag2 1 + } + } + + if {[string is true $flag1] && [string is false $flag2]} { ad_complain + } elseif {[string is false $flag1] && [string is true $flag2]} { + ad_complain } } process_id_missing { @@ -37,21 +63,28 @@ } } task_title_too_long { - foreach tt $task_title { + foreach {index tt} [array get task_title] { if {[string length $tt] > 198} { ad_complain } } } description_too_long { - foreach d $description { + foreach {index d} [array get description] { if {[string length $d] > 3998} { ad_complain } } } + description_empty { + foreach {index d} [array get description] { + if {[empty_string_p $d]} { + ad_complain + } + } + } bad_estimated_hours_work_range { - foreach wr $estimated_hours_work { + foreach {index wr} [array get estimated_hours_work] { if {$wr > 500 || $wr < 0} { ad_complain } @@ -65,11 +98,11 @@ } } } -errors { - no_estimated_hours {You must enter estimated hours. If nothing - else, enter 0 for the estimated hours} + no_estimated_hours {You must enter estimated hours. If nothing else, enter 0 for the estimated hours} process_id_missing {I don't know which process these tasks are for!} task_title_too_long {A task subject is too long. It must be 198 characters or less} description_too_long {A description subject is too long. It must be 3998 characters or less} + description_empty {The description may not be empty} bad_estimated_hours_work_range {The estimated hours must be between 0 and 499 hours} process_task_id_missing {I don't know which process task is being added or edited!} } @@ -99,20 +132,25 @@ # ----------------------------- set index 0 + set array_index 0 + foreach ptid $process_task_id { + + set array_index [expr $index +1] # set up the values set task_id [lindex $process_task_id $index] - set one_line [lindex $task_title $index] - set desc [lindex $description $index] + set one_line $task_title($array_index) + set desc $description($array_index) + set order $ordering($array_index) if {[string equal $use_uncertain_completion_times_p "1"]} { - set work_min [lindex $estimated_hours_work_min $index] - set work_max [lindex $estimated_hours_work_max $index] + set work_min $estimated_hours_work_min($array_index) + set work_max $estimated_hours_work_max($array_index) set work [expr .5 * [expr $work_max - $work_min] + $work_min] } else { - set work [lindex $estimated_hours_work $index] + set work $estimated_hours_work($array_index) set work_min $work set work_max $work } @@ -131,20 +169,25 @@ # ----------------------------- set index 0 + set array_index 0 + foreach ptid $process_task_id { + set array_index [expr $index +1] + # set up the values set task_id [lindex $process_task_id $index] - set one_line [lindex $task_title $index] - set desc [lindex $description $index] + set one_line $task_title($array_index) + set desc $description($array_index) + set order $ordering($array_index) if {[string equal $use_uncertain_completion_times_p "1"]} { - set work_min [lindex $estimated_hours_work_min $index] - set work_max [lindex $estimated_hours_work_max $index] + set work_min $estimated_hours_work_min($array_index) + set work_max $estimated_hours_work_max($array_index) set work [expr .5 * [expr $work_max - $work_min] + $work_min] } else { - set work [lindex $estimated_hours_work $index] + set work $estimated_hours_work($array_index) set work_min $work set work_max $work } @@ -154,38 +197,38 @@ } } -if {1 == 0} { - set revision_has_dependencies [list] - set revision_no_dependencies [list] +# remove assignments +foreach ptid $process_task_id { - for {set i 1} {$i <= $number} {incr i} { - - if {![exists_and_not_null estimated_hours_work($i)]} { - set estimated_hours_work($i) [expr .5 * ($estimated_hours_work_max($i) - $estimated_hours_work_min($i)) + $estimated_hours_work_min($i)] - } + pm::process::remove_assignees \ + -process_task_id $process_task_id - if {![exists_and_not_null estimated_hours_work_min($i)]} { - set estimated_hours_work_min($i) $estimated_hours_work($i) - } +} - if {![exists_and_not_null estimated_hours_work_max($i)]} { - set estimated_hours_work_max($i) $estimated_hours_work($i) - } +foreach ass $assignee { - # do the actual edit - db_dml edit_task { } + regexp {(.*)-(.*)-(.*)} $ass match process_task party_id role_id - if {[info exists use_dependency_p($i)] && [string equal $use_dependency_p($i) "t"]} { - lappend revision_has_dependencies $this_revision_id - } else { - lappend revision_no_dependencies $this_revision_id - } + pm::process::assign \ + -process_task_id $process_task \ + -party_id $party_id \ + -role_id $role_id - } +} +if {[llength $process_task_id] > 1} { + set task_tasks tasks +} else { + set task_tasks task } +if {[llength [array get use_dependency]] > 0} { + set dep_msg "Now set up dependencies" +} else { + set dep_msg "" +} -ad_returnredirect -message "Process task saved" "process-task-assign-add-edit?[export_vars -url {use_dependency:multiple process_id process_task_id:multiple}]" +ad_returnredirect -message "Process $task_tasks saved. $dep_msg" "process-dependency-add-edit?[export_vars -url {process_task_id:multiple process_id use_dependency:array}]" + ad_script_abort