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.28 -r1.29 --- openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 20 Apr 2004 21:12:20 -0000 1.28 +++ openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 27 Apr 2004 00:49:29 -0000 1.29 @@ -36,7 +36,7 @@ task_item_id:array,optional task_title:array,optional {process_id:integer ""} - description:array,optional + description:html,array,optional name:array,optional end_date:array,optional percent_complete:array,optional @@ -50,6 +50,7 @@ dependency_task_id:array,optional skip_task_p:array,optional {using_process_p "f"} + {return_url ""} } -properties { @@ -90,6 +91,7 @@ set package_id [ad_conn package_id] + # --------------------------------------------------------------- # # terminology # --------------------------------------------------------------- # @@ -105,6 +107,12 @@ } + +# ns_log Notice "return_url: $return_url" + + + + # -------------------------------------------------------------------- # 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 @@ -128,12 +136,27 @@ set estimated_hours_work_max_v($process_tid) $estimated_hours_work_max set dependency_v($process_tid) $process_parent_task + # make sure that we don't have empty values for estimated + # hours work + if {[empty_string_p $estimated_hours_work_v($process_tid)]} { + set estimated_hours_work_v($process_tid) 0 + } + if {[empty_string_p $estimated_hours_work_min_v($process_tid)]} { + set estimated_hours_work_min_v($process_tid) 0 + } + if {[empty_string_p $estimated_hours_work_max_v($process_tid)]} { + set estimated_hours_work_max_v($process_tid) 0 + } + + lappend process_tasks $process_tid } set number [llength $process_tasks] } + + # --------------------------------------------------------------- # @@ -205,19 +228,72 @@ set keyname [array nextelement end_date $searchToken] set keyvalu $end_date($keyname) + # ns_log Notice "keyname: $keyname keyvalu: $keyvalu" + # element_num is 1...n, element_type is year, format, day, month regexp {(.*)\.(.*)} $keyname match element_num element_type + # ns_log Notice "element_num: $element_num element_type: $element_type" + set end_date_[set element_type]($element_num) $keyvalu + # ns_log notice "set end_date_[set element_type] to $keyvalu" } for {set i 1} {$i <= $number} {incr i} { # set up date variable names set end_date_$i [list $end_date_year($i) $end_date_month($i) $end_date_day($i) {} {} {}] + # ns_log Notice "end_date_$i: [set end_date_$i]" } } +# ------------------------------------------------------- # +# The second evilest hack of all time. +# ------------------------------------------------------- +# This is a workaround the fact that using multiple richtext items +# with ad_form is extremely difficult. The description field +# will come in like an array, with values like +# description.1 = 1234 bold +# description.1.format = text/enhanced +# description.1.spellcheck = :nospell: +# The problem is we want +# to have multiple descriptions. +# +# What this loop does is go through the array, and rename the +# values into other variables. We then feed these variables into +# the SQL function that creates the new tasks. This works. I'm +# sure there must be a better way to do it. +# ------------------------------------------------------- # + +if {[info exists description] && ![exists_and_not_null process_id]} { + + set searchToken [array startsearch description] + + while {[array anymore description $searchToken]} { + + # these next two lines are important + set element_num "" + set element_type "" + + set keyname [array nextelement description $searchToken] + set keyvalu $description($keyname) + + # ns_log Notice "keyname: $keyname keyvalu: $keyvalu" + + # element_num is 1...n, element_type is format, spellcheck + regexp {(.*)\.(.*)} $keyname match element_num element_type + + # ns_log Notice "element_num: $element_num element_type: $element_type" + + set description_[set element_type]($element_num) $keyvalu + + # ns_log notice "set description_[set element_type] to $keyvalu" + + } + +} + + # --------------------------------------------------------------- # # permissions and title setup, etc # we should update the permissions to not just use package_id, so @@ -266,6 +342,10 @@ {value $task_id_pass} } + {return_url:text(hidden) + {value $return_url} + } + {project_id:text(hidden) {value $project_id} } @@ -281,6 +361,13 @@ # we set the values for edited tasks # ---------------------------------- + +# we set the initial value to 0, because we need at least one value to +# pass to SQL. Otherwise, when we do the IN (123, 234, 455), there +# won't be any values inside, and it will fail. +set my_dependencies [list 0] + + if {![ad_form_new_p -key task_id]} { set i 1 @@ -289,14 +376,34 @@ set task_title_arr($i) $my_task_title set description_arr($i) $my_description + set mime_type_arr($i) $my_mime_type + set template_arr($i) [list $my_description $my_mime_type] set estimated_hours_arr($i) $my_estimated_work set estimated_hours_min_arr($i) $my_estimated_work_min set estimated_hours_max_arr($i) $my_estimated_work_max - set end_date_arr($i) $my_end_date + + # We need the date to be in the right format in order to pass + # through the validate filter. + + # the end date comes in this format 2004 05 17 + # we need to get it in the {2004} {05} {17} {} {} {} format + regexp {(.*) (.*) (.*)} $my_end_date match year month day + if {[exists_and_not_null year]} { + set end_date_arr($i) "$year $month $day {} {} {}" + } else { + set end_date_arr($i) "{} {} {} {} {} {}" + } + set percent_complete_arr($i) $my_percent_complete set actual_hours_worked_arr($i) $my_actual_hours_worked 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 + # are from closed tasks are still shown on the list of + # possible dependencies to select from + if {[exists_and_not_null my_dependency]} { + lappend my_dependencies $my_dependency + } # we are not using a process set process_task_id_arr($i) "" @@ -352,6 +459,8 @@ for {set i 1} {$i <= $number} {incr i} { set task_title_arr($i) "" set description_arr($i) "" + set mime_type_arr($i) "text/plain" + set template_arr($i) [list "" "text/plain"] set estimated_hours_arr($i) "0" set estimated_hours_min_arr($i) "0" set estimated_hours_max_arr($i) "0" @@ -534,15 +643,22 @@ # make sure we're not dependent on ourselves if {![string equal $task_item_id_arr($i) $dependency_options($key)]} { - append dependency_options_full "{\"$key\" $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 { - append dependency_options_full "{\"$key\" $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)} " } } + # ns_log Notice "end_date.$i : $end_date_arr($i)" + ad_form -extend \ -name add_edit \ -form \ @@ -562,10 +678,10 @@ {value {$process_task_id_arr($i)}} \ ] \ [list \ - description.$i:text(textarea),optional \ + description.$i:richtext,optional,nospell \ {label "Description"} \ {html {rows 7 cols 40}} \ - {value {$description_arr($i)}} \ + {value {$template_arr($i)}} \ ] \ [list \ end_date.$i:date,to_sql(linear_date),optional \ @@ -587,21 +703,21 @@ {value {$dependency_arr($i)}} \ {help_text {$task_term the dependency is based on}} \ ] \ - ] + ] if {$use_uncertain_completion_times_p} { ad_form -extend \ -name add_edit \ -form \ [list \ [list \ - estimated_hours_work_min.$i:integer \ + estimated_hours_work_min.$i:text \ {label "Hours estimate - min"} \ {html {size 5}} \ {value {$estimated_hours_min_arr($i)}} \ ] \ [list \ - estimated_hours_work_max.$i:integer \ + estimated_hours_work_max.$i:text \ {label "Hours estimate - max"} \ {html {size 5}} \ {value {$estimated_hours_max_arr($i)}} \ @@ -612,7 +728,7 @@ -form \ [list \ [list \ - estimated_hours_work.$i:integer \ + estimated_hours_work.$i:text \ {label "Hours estimate"} \ {html {size 5}} \ {value {$estimated_hours_arr($i)}} \ @@ -623,6 +739,7 @@ + ad_form -extend -name add_edit -select_query_name task_query -on_submit { set user_id [ad_conn user_id] @@ -652,12 +769,19 @@ if {![exists_and_not_null end_date_$i]} { - set end_date_$i [db_null] + set end_date_$i "{} {} {} {} {} {}" } # set up variables, pulling from arrays set p_task_title $task_title($i) + set p_description $description($i) + + # ns_log Notice "Format: $description_format($i)" + + + set p_mime_type $description_format($i) + set p_work $estimated_hours_work($i) set p_work_min $estimated_hours_work_min($i) set p_work_max $estimated_hours_work_max($i) @@ -666,21 +790,16 @@ set p_parent_task_id $dependency_task_id($i) set p_skip_p $skip_task_p($i) - ns_log Notice "end date: $p_end_date" + # ns_log Notice "end date: $p_end_date" - # Make sure we do not insert bogus stuff into the database. - - if {$p_end_date == "{} {} {} {} {} {}"} { - set p_end_date [db_null] - } - # add in the new task if {[string equal $p_skip_p "f"]} { set this_revision_id [pm::task::new \ -project_id $project_item_id \ -title $p_task_title \ -description $p_description \ + -mime_type $p_mime_type \ -end_date $p_end_date \ -percent_complete "0" \ -estimated_hours_work $p_work \ @@ -692,8 +811,6 @@ set this_task_id [db_string get_task_item_id {}] - - set dependent_task_id($i) $this_task_id if {[exists_and_not_null p_parent_task_id]} { @@ -751,8 +868,6 @@ } - pm::project::compute_parent_status $project_item_id - } -edit_data { set timestamp_ansi [db_string get_today " @@ -785,6 +900,8 @@ set p_task_item_id $task_item_id($i) set p_task_title $task_title($i) set p_description $description($i) + set p_mime_type $description_format($i) + set p_percent $percent_complete($i) set p_work $estimated_hours_work($i) set p_work_min $estimated_hours_work_min($i) @@ -828,6 +945,7 @@ -project_item_id $project_item_id \ -title $p_task_title \ -description $p_description \ + -mime_type $p_mime_type \ -end_date "[set end_date_[set i]]" \ -percent_complete $p_percent \ -estimated_hours_work $p_work \ @@ -855,11 +973,13 @@ } - pm::project::compute_parent_status $project_item_id - } -after_submit { - ad_returnredirect "task-assign-add-edit?[export_vars -url {project_item_id process_task_id:multiple revisions:multiple task_id:multiple}]" + # ns_log Notice "tae: return_url: $return_url" + + ad_returnredirect "task-assign-add-edit?[export_vars -url {project_item_id return_url process_task_id:multiple revisions:multiple task_id:multiple}]" + pm::project::compute_parent_status $project_item_id + ad_script_abort }