Index: openacs-4/contrib/packages/simulation/lib/sim-template-states.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-states.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/contrib/packages/simulation/lib/sim-template-states.tcl 12 Jan 2004 13:43:14 -0000 1.3 +++ openacs-4/contrib/packages/simulation/lib/sim-template-states.tcl 23 Jan 2004 15:52:58 -0000 1.4 @@ -6,6 +6,9 @@ @cvs-id $Id$ } { workflow_id {} + parent_action_id { + default_value {} + } } set package_id [ad_conn package_id] @@ -14,12 +17,12 @@ # states list #------------------------------------------------------------- -set actions [list "Add a State" [export_vars -base state-edit { workflow_id}] {}] +set actions [list "Add a State" [export_vars -base state-edit { workflow_id parent_action_id {return_url [ad_return_url] } }] {}] template::list::create \ -name states \ -multirow states \ - -no_data "No states in this Simulation Template" \ + -no_data "No states in this [ad_decode $parent_action_id "" "Simulation Template" "sub-workflow"]" \ -actions $actions \ -elements { edit { @@ -69,10 +72,11 @@ ws.sort_order from workflow_fsm_states ws where ws.workflow_id = :workflow_id + and ws.parent_action_id [ad_decode $parent_action_id "" "is null" "= :parent_action_id"] order by ws.sort_order " { incr counter - set edit_url [export_vars -base "[ad_conn package_url]simbuild/state-edit" { state_id }] + set edit_url [export_vars -base "[ad_conn package_url]simbuild/state-edit" { state_id { return_url [ad_return_url] } }] set delete_url [export_vars -base "[ad_conn package_url]simbuild/state-delete" { state_id { return_url [ad_return_url] } }] if { $counter > 1 } { set up_url [export_vars -base "[ad_conn package_url]simbuild/template-object-reorder" { { type state } state_id { direction up } { return_url [ad_return_url] } }] Index: openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-tasks.tcl,v diff -u -N -r1.35 -r1.36 --- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 23 Jan 2004 15:01:27 -0000 1.35 +++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 23 Jan 2004 15:52:58 -0000 1.36 @@ -43,6 +43,14 @@ set list_actions [list] } +set show_states_p 1 +if { ![empty_string_p $parent_action_id] } { + simulation::action::get -action_id $parent_action_id -array parent_task_array + if { [lsearch -exact { parallel dynamic } $parent_task_array(trigger_type)] != -1 } { + set show_states_p 0 + } +} + set elements [list] lappend elements edit { hide_p {[ad_decode $display_mode edit 0 1]} @@ -97,54 +105,59 @@ } } -lappend elements state_spacer { - label "
Enabled in States:" - sub_class narrow - display_template " " - html { style "border-left: 2px dotted #A0BDEB;" } -} +if { !$show_states_p } { + set states [list] +} else { + lappend elements state_spacer { + label "
Enabled in States:" + sub_class narrow + display_template " " + html { style "border-left: 2px dotted #A0BDEB;" } + } -set states [list] + set states [list] -db_foreach select_states { - select s.state_id, - s.pretty_name, - s.short_name - from workflow_fsm_states s - where workflow_id = :workflow_id - order by s.sort_order -} { - set "label_state_$state_id" "$pretty_name" - lappend elements state_$state_id \ - [list label "\"Edit\"\"Delete\"
\${label_state_$state_id}" \ - html { align center } \ - display_template " - - - - - - - "] + db_foreach select_states { + select s.state_id, + s.pretty_name, + s.short_name + from workflow_fsm_states s + where workflow_id = :workflow_id + and ((:parent_action_id is null and s.parent_action_id is null) or (s.parent_action_id = :parent_action_id)) + order by s.sort_order + } { + set "label_state_$state_id" "$pretty_name" + lappend elements state_$state_id \ + [list label "\"Edit\"\"Delete\"
\${label_state_$state_id}" \ + html { align center } \ + display_template " + + + + + + + "] - lappend states $state_id -} if_no_rows { - lappend elements state_spacer3 { - label "
None. Template will not work until you add states." - sub_class narrow - display_template " " + lappend states $state_id + } if_no_rows { + lappend elements state_spacer3 { + label "
None. Template will not work until you add states." + sub_class narrow + display_template " " + } } -} -lappend elements new_state_pretty { - label "
Next state" - html { style "border-left: 2px dotted #A0BDEB;" } + lappend elements new_state_pretty { + label "
Next state" + html { style "border-left: 2px dotted #A0BDEB;" } + } } template::list::create \ -name tasks \ -multirow tasks \ - -no_data "No tasks in this Simulation Template" \ + -no_data "No [ad_decode $parent_action_id "" "tasks in this Simulation Template" "subtasks for this task"]" \ -sub_class narrow \ -actions $list_actions \ -elements $elements @@ -207,8 +220,8 @@ order by wa.sort_order " { incr counter - set edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id }] - set view_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id }] + set edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id {return_url [ad_return_url]} }] + set view_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id {return_url [ad_return_url]}}] set delete_url \ [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url [ad_return_url]} }] Index: openacs-4/contrib/packages/simulation/tcl/template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/template-procs.tcl,v diff -u -N -r1.59 -r1.60 --- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 23 Jan 2004 11:16:15 -0000 1.59 +++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 23 Jan 2004 15:52:58 -0000 1.60 @@ -1238,7 +1238,7 @@ {-workflow_id {}} } { Check if suggested pretty_name is unique. - + @return 1 if unique, 0 if not unique. } { set exists_p [db_string name_exists { Index: openacs-4/contrib/packages/simulation/www/simbuild/state-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/state-edit.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/contrib/packages/simulation/www/simbuild/state-edit.tcl 9 Jan 2004 11:52:41 -0000 1.3 +++ openacs-4/contrib/packages/simulation/www/simbuild/state-edit.tcl 23 Jan 2004 15:52:58 -0000 1.4 @@ -6,6 +6,8 @@ } { {workflow_id:integer ""} state_id:integer,optional + parent_action_id:integer,optional + return_url:optional } -validate { workflow_id_or_state_id { if { ![exists_and_not_null workflow_id] && @@ -27,6 +29,7 @@ if { ![ad_form_new_p -key state_id] } { workflow::state::fsm::get -state_id $state_id -array state_array set workflow_id $state_array(workflow_id) + set parent_action_id $state_array(parent_action_id) } workflow::get -workflow_id $workflow_id -array sim_template_array @@ -58,8 +61,29 @@ # state form #--------------------------------------------------------------------- -ad_form -name state -edit_buttons [list [list [ad_decode [ad_form_new_p -key state_id] 1 [_ acs-kernel.common_add] [_ acs-kernel.common_edit]] ok]] -form { +ad_form \ + -name state \ + -edit_buttons [list [list [ad_decode [ad_form_new_p -key state_id] 1 [_ acs-kernel.common_add] [_ acs-kernel.common_edit]] ok]] \ + -export { return_url } \ + -form { {state_id:key} +} + +if { [exists_and_not_null parent_action_id] } { + ad_form -extend -name state -form { + {parent_action_id:integer(select) + {label "Parent task"} + {mode display} + {options {[workflow::action::get_options -workflow_id $workflow_id]}} + } + } +} else { + ad_form -extend -name state -form { + {parent_action_id:integer(hidden),optional {value {}}} + } +} + +ad_form -extend -name state -form { {workflow_id:integer(hidden) {value $workflow_id} } @@ -78,6 +102,18 @@ permission::require_write_permission -object_id $workflow_id set operation "insert" +} -on_submit { + # Check that pretty_name is unique + set unique_p [workflow::state::fsm::pretty_name_unique_p \ + -workflow_id $workflow_id \ + -state_id $state_id \ + -pretty_name $pretty_name] + + if { !$unique_p } { + form set_error state pretty_name "This name is already used by another state" + break + } + } -edit_data { # We use state_array(workflow_id) here, which is gotten from the DB, and not # workflow_id, which is gotten from the form, because the workflow_id from the form @@ -87,6 +123,7 @@ set operation "update" } -after_submit { set row(pretty_name) $pretty_name + set row(parent_action_id) $parent_action_id set row(short_name) {} set state_id [workflow::state::fsm::edit \ @@ -95,6 +132,9 @@ -workflow_id $workflow_id \ -array row] - ad_returnredirect [export_vars -base "template-edit" { workflow_id }] + if { ![exists_and_not_null return_url] } { + set return_url [export_vars -base "template-edit" { workflow_id }] + } + ad_returnredirect $return_url ad_script_abort } Index: openacs-4/contrib/packages/simulation/www/simbuild/task-details.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/task-details.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/simbuild/task-details.adp 23 Jan 2004 15:01:27 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/simbuild/task-details.adp 23 Jan 2004 15:52:58 -0000 1.2 @@ -7,7 +7,7 @@
-

Template

+

Parent Task

@@ -20,12 +20,22 @@
+ + +
+

Sub-States

+
+ +
+
+ +
-

Tasks

+

Sub-Tasks

Index: openacs-4/contrib/packages/simulation/www/simbuild/task-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/task-edit.tcl,v diff -u -N -r1.31 -r1.32 --- openacs-4/contrib/packages/simulation/www/simbuild/task-edit.tcl 23 Jan 2004 15:01:27 -0000 1.31 +++ openacs-4/contrib/packages/simulation/www/simbuild/task-edit.tcl 23 Jan 2004 15:52:58 -0000 1.32 @@ -58,14 +58,6 @@ set role_options [workflow::role::get_options -workflow_id $workflow_id] set role_options_with_null [concat [list [list "--None--" ""]] $role_options] -#set child_workflow_options [simulation::template::get_options] - -set actions_options [db_list_of_lists foo { - select pretty_name, action_id - from workflow_actions - where workflow_id = :workflow_id -}] - #--------------------------------------------------------------------- # Logic to determine the current values of a few elements #--------------------------------------------------------------------- @@ -107,11 +99,12 @@ } if { [exists_and_not_null parent_action_id] } { + simulation::action::get -action_id $parent_action_id -array parent_task_array ad_form -extend -name task -form { {parent_action_id:integer(select) - {label "Parent action"} + {label "Parent task"} {mode display} - {options $actions_options} + {options {[workflow::action::get_options -workflow_id $workflow_id]}} } } } else { @@ -200,17 +193,23 @@ } default { ad_form -extend -name task -form { - {timeout_seconds:integer(text),optional} + {timeout_seconds:integer(hidden),optional} } } } -ad_form -extend -name task -form { - {description:richtext,optional - {label "Task Description"} - {html {cols 60 rows 8}} - {help_text "Suggested text; can be edited when template is instantiated."} +switch $trigger_type { + init { } + default { + ad_form -extend -name task -form { + {description:richtext,optional + {label "Task Description"} + {html {cols 60 rows 8}} + {help_text "Suggested text; can be edited when template is instantiated."} + } + } + } } if { [string equal $trigger_type "user"] } { @@ -230,19 +229,25 @@ set enabled_options [list] set state_options [list] lappend state_options [list "--Unchanged--" {}] -foreach state_id [workflow::fsm::get_states -workflow_id $workflow_id] { +foreach state_id [workflow::fsm::get_states -workflow_id $workflow_id -parent_action_id $parent_action_id] { array unset state_array workflow::state::fsm::get -state_id $state_id -array state_array lappend enabled_options [list $state_array(pretty_name) $state_id] lappend state_options [list $state_array(pretty_name) $state_id] } -ad_form -extend -name task -form { - {new_state_id:integer(select),optional - {label "Next state"} - {options $state_options} - {help_text "After this task is completed, change the template's state."} +if { [exists_and_equal parent_task_array(trigger_type) "parallel"] || [exists_and_equal parent_task_array(trigger_type) "dynamic"] } { + ad_form -extend -name task -form { + {new_state_id:integer(hidden),optional} } +} else { + ad_form -extend -name task -form { + {new_state_id:integer(select),optional + {label "Next state"} + {options $state_options} + {help_text "After this task is completed, change the template's state."} + } + } } set focus "task.pretty_name" @@ -252,7 +257,6 @@ permission::require_write_permission -object_id $workflow_id set description [template::util::richtext::create $task_array(description) $task_array(description_mime_type)] - # Removed: child_workflow_id foreach elm { pretty_name pretty_past_tense new_state_id assigned_role recipient_roles @@ -272,46 +276,43 @@ set focus {} } -on_submit { - set description_mime_type [template::util::richtext::get_property format $description] - set description [template::util::richtext::get_property contents $description] + # Check that pretty_name is unique + set unique_p [workflow::action::pretty_name_unique_p \ + -workflow_id $workflow_id \ + -action_id $action_id \ + -pretty_name $pretty_name] + + if { !$unique_p } { + form set_error task pretty_name "This name is already used by another task" + break + } - set child_role_map [list] + if { [info exists description] } { + set description_mime_type [template::util::richtext::get_property format $description] + set description [template::util::richtext::get_property contents $description] + } switch $task_type { message { - set child_workflow_id {} } normal { set recipient_roles {} - set child_workflow_id {} } - workflow { - set recipient_roles {} - - # we have: - # element parent_role__asker = lawyer - # element parent_role__giver = client - - foreach role_id [workflow::get_roles -workflow_id $child_workflow_id] { - set child_role_short_name [workflow::role::get_element -role_id $role_id -element short_name] - set parent_role_short_name [set "parent_role__$child_role_short_name"] - lappend child_role_map $child_role_short_name [list $parent_role_short_name "per_role"] - } - } } # Default pretty_past_tense if { [empty_string_p $pretty_past_tense] } { set pretty_past_tense $pretty_name } - # Removed: child_workflow_id child_role_map foreach elm { pretty_name pretty_past_tense assigned_role description description_mime_type new_state_id timeout_seconds recipient_roles attachment_num trigger_type parent_action_id } { - set row($elm) [set $elm] + if { [info exists $elm] } { + set row($elm) [set $elm] + } } set row(short_name) {} Index: openacs-4/packages/simulation/lib/sim-template-states.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-states.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/simulation/lib/sim-template-states.tcl 12 Jan 2004 13:43:14 -0000 1.3 +++ openacs-4/packages/simulation/lib/sim-template-states.tcl 23 Jan 2004 15:52:58 -0000 1.4 @@ -6,6 +6,9 @@ @cvs-id $Id$ } { workflow_id {} + parent_action_id { + default_value {} + } } set package_id [ad_conn package_id] @@ -14,12 +17,12 @@ # states list #------------------------------------------------------------- -set actions [list "Add a State" [export_vars -base state-edit { workflow_id}] {}] +set actions [list "Add a State" [export_vars -base state-edit { workflow_id parent_action_id {return_url [ad_return_url] } }] {}] template::list::create \ -name states \ -multirow states \ - -no_data "No states in this Simulation Template" \ + -no_data "No states in this [ad_decode $parent_action_id "" "Simulation Template" "sub-workflow"]" \ -actions $actions \ -elements { edit { @@ -69,10 +72,11 @@ ws.sort_order from workflow_fsm_states ws where ws.workflow_id = :workflow_id + and ws.parent_action_id [ad_decode $parent_action_id "" "is null" "= :parent_action_id"] order by ws.sort_order " { incr counter - set edit_url [export_vars -base "[ad_conn package_url]simbuild/state-edit" { state_id }] + set edit_url [export_vars -base "[ad_conn package_url]simbuild/state-edit" { state_id { return_url [ad_return_url] } }] set delete_url [export_vars -base "[ad_conn package_url]simbuild/state-delete" { state_id { return_url [ad_return_url] } }] if { $counter > 1 } { set up_url [export_vars -base "[ad_conn package_url]simbuild/template-object-reorder" { { type state } state_id { direction up } { return_url [ad_return_url] } }] Index: openacs-4/packages/simulation/lib/sim-template-tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-tasks.tcl,v diff -u -N -r1.35 -r1.36 --- openacs-4/packages/simulation/lib/sim-template-tasks.tcl 23 Jan 2004 15:01:27 -0000 1.35 +++ openacs-4/packages/simulation/lib/sim-template-tasks.tcl 23 Jan 2004 15:52:58 -0000 1.36 @@ -43,6 +43,14 @@ set list_actions [list] } +set show_states_p 1 +if { ![empty_string_p $parent_action_id] } { + simulation::action::get -action_id $parent_action_id -array parent_task_array + if { [lsearch -exact { parallel dynamic } $parent_task_array(trigger_type)] != -1 } { + set show_states_p 0 + } +} + set elements [list] lappend elements edit { hide_p {[ad_decode $display_mode edit 0 1]} @@ -97,54 +105,59 @@ } } -lappend elements state_spacer { - label "
Enabled in States:" - sub_class narrow - display_template " " - html { style "border-left: 2px dotted #A0BDEB;" } -} +if { !$show_states_p } { + set states [list] +} else { + lappend elements state_spacer { + label "
Enabled in States:" + sub_class narrow + display_template " " + html { style "border-left: 2px dotted #A0BDEB;" } + } -set states [list] + set states [list] -db_foreach select_states { - select s.state_id, - s.pretty_name, - s.short_name - from workflow_fsm_states s - where workflow_id = :workflow_id - order by s.sort_order -} { - set "label_state_$state_id" "$pretty_name" - lappend elements state_$state_id \ - [list label "\"Edit\"\"Delete\"
\${label_state_$state_id}" \ - html { align center } \ - display_template " - - - - - - - "] + db_foreach select_states { + select s.state_id, + s.pretty_name, + s.short_name + from workflow_fsm_states s + where workflow_id = :workflow_id + and ((:parent_action_id is null and s.parent_action_id is null) or (s.parent_action_id = :parent_action_id)) + order by s.sort_order + } { + set "label_state_$state_id" "$pretty_name" + lappend elements state_$state_id \ + [list label "\"Edit\"\"Delete\"
\${label_state_$state_id}" \ + html { align center } \ + display_template " + + + + + + + "] - lappend states $state_id -} if_no_rows { - lappend elements state_spacer3 { - label "
None. Template will not work until you add states." - sub_class narrow - display_template " " + lappend states $state_id + } if_no_rows { + lappend elements state_spacer3 { + label "
None. Template will not work until you add states." + sub_class narrow + display_template " " + } } -} -lappend elements new_state_pretty { - label "
Next state" - html { style "border-left: 2px dotted #A0BDEB;" } + lappend elements new_state_pretty { + label "
Next state" + html { style "border-left: 2px dotted #A0BDEB;" } + } } template::list::create \ -name tasks \ -multirow tasks \ - -no_data "No tasks in this Simulation Template" \ + -no_data "No [ad_decode $parent_action_id "" "tasks in this Simulation Template" "subtasks for this task"]" \ -sub_class narrow \ -actions $list_actions \ -elements $elements @@ -207,8 +220,8 @@ order by wa.sort_order " { incr counter - set edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id }] - set view_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id }] + set edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id {return_url [ad_return_url]} }] + set view_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id {return_url [ad_return_url]}}] set delete_url \ [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url [ad_return_url]} }] Index: openacs-4/packages/simulation/tcl/template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/template-procs.tcl,v diff -u -N -r1.59 -r1.60 --- openacs-4/packages/simulation/tcl/template-procs.tcl 23 Jan 2004 11:16:15 -0000 1.59 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 23 Jan 2004 15:52:58 -0000 1.60 @@ -1238,7 +1238,7 @@ {-workflow_id {}} } { Check if suggested pretty_name is unique. - + @return 1 if unique, 0 if not unique. } { set exists_p [db_string name_exists { Index: openacs-4/packages/simulation/www/simbuild/state-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/state-edit.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/simulation/www/simbuild/state-edit.tcl 9 Jan 2004 11:52:41 -0000 1.3 +++ openacs-4/packages/simulation/www/simbuild/state-edit.tcl 23 Jan 2004 15:52:58 -0000 1.4 @@ -6,6 +6,8 @@ } { {workflow_id:integer ""} state_id:integer,optional + parent_action_id:integer,optional + return_url:optional } -validate { workflow_id_or_state_id { if { ![exists_and_not_null workflow_id] && @@ -27,6 +29,7 @@ if { ![ad_form_new_p -key state_id] } { workflow::state::fsm::get -state_id $state_id -array state_array set workflow_id $state_array(workflow_id) + set parent_action_id $state_array(parent_action_id) } workflow::get -workflow_id $workflow_id -array sim_template_array @@ -58,8 +61,29 @@ # state form #--------------------------------------------------------------------- -ad_form -name state -edit_buttons [list [list [ad_decode [ad_form_new_p -key state_id] 1 [_ acs-kernel.common_add] [_ acs-kernel.common_edit]] ok]] -form { +ad_form \ + -name state \ + -edit_buttons [list [list [ad_decode [ad_form_new_p -key state_id] 1 [_ acs-kernel.common_add] [_ acs-kernel.common_edit]] ok]] \ + -export { return_url } \ + -form { {state_id:key} +} + +if { [exists_and_not_null parent_action_id] } { + ad_form -extend -name state -form { + {parent_action_id:integer(select) + {label "Parent task"} + {mode display} + {options {[workflow::action::get_options -workflow_id $workflow_id]}} + } + } +} else { + ad_form -extend -name state -form { + {parent_action_id:integer(hidden),optional {value {}}} + } +} + +ad_form -extend -name state -form { {workflow_id:integer(hidden) {value $workflow_id} } @@ -78,6 +102,18 @@ permission::require_write_permission -object_id $workflow_id set operation "insert" +} -on_submit { + # Check that pretty_name is unique + set unique_p [workflow::state::fsm::pretty_name_unique_p \ + -workflow_id $workflow_id \ + -state_id $state_id \ + -pretty_name $pretty_name] + + if { !$unique_p } { + form set_error state pretty_name "This name is already used by another state" + break + } + } -edit_data { # We use state_array(workflow_id) here, which is gotten from the DB, and not # workflow_id, which is gotten from the form, because the workflow_id from the form @@ -87,6 +123,7 @@ set operation "update" } -after_submit { set row(pretty_name) $pretty_name + set row(parent_action_id) $parent_action_id set row(short_name) {} set state_id [workflow::state::fsm::edit \ @@ -95,6 +132,9 @@ -workflow_id $workflow_id \ -array row] - ad_returnredirect [export_vars -base "template-edit" { workflow_id }] + if { ![exists_and_not_null return_url] } { + set return_url [export_vars -base "template-edit" { workflow_id }] + } + ad_returnredirect $return_url ad_script_abort } Index: openacs-4/packages/simulation/www/simbuild/task-details.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/task-details.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/simulation/www/simbuild/task-details.adp 23 Jan 2004 15:01:27 -0000 1.1 +++ openacs-4/packages/simulation/www/simbuild/task-details.adp 23 Jan 2004 15:52:58 -0000 1.2 @@ -7,7 +7,7 @@
-

Template

+

Parent Task

@@ -20,12 +20,22 @@
+ + +
+

Sub-States

+
+ +
+
+ +
-

Tasks

+

Sub-Tasks

Index: openacs-4/packages/simulation/www/simbuild/task-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/task-edit.tcl,v diff -u -N -r1.31 -r1.32 --- openacs-4/packages/simulation/www/simbuild/task-edit.tcl 23 Jan 2004 15:01:27 -0000 1.31 +++ openacs-4/packages/simulation/www/simbuild/task-edit.tcl 23 Jan 2004 15:52:58 -0000 1.32 @@ -58,14 +58,6 @@ set role_options [workflow::role::get_options -workflow_id $workflow_id] set role_options_with_null [concat [list [list "--None--" ""]] $role_options] -#set child_workflow_options [simulation::template::get_options] - -set actions_options [db_list_of_lists foo { - select pretty_name, action_id - from workflow_actions - where workflow_id = :workflow_id -}] - #--------------------------------------------------------------------- # Logic to determine the current values of a few elements #--------------------------------------------------------------------- @@ -107,11 +99,12 @@ } if { [exists_and_not_null parent_action_id] } { + simulation::action::get -action_id $parent_action_id -array parent_task_array ad_form -extend -name task -form { {parent_action_id:integer(select) - {label "Parent action"} + {label "Parent task"} {mode display} - {options $actions_options} + {options {[workflow::action::get_options -workflow_id $workflow_id]}} } } } else { @@ -200,17 +193,23 @@ } default { ad_form -extend -name task -form { - {timeout_seconds:integer(text),optional} + {timeout_seconds:integer(hidden),optional} } } } -ad_form -extend -name task -form { - {description:richtext,optional - {label "Task Description"} - {html {cols 60 rows 8}} - {help_text "Suggested text; can be edited when template is instantiated."} +switch $trigger_type { + init { } + default { + ad_form -extend -name task -form { + {description:richtext,optional + {label "Task Description"} + {html {cols 60 rows 8}} + {help_text "Suggested text; can be edited when template is instantiated."} + } + } + } } if { [string equal $trigger_type "user"] } { @@ -230,19 +229,25 @@ set enabled_options [list] set state_options [list] lappend state_options [list "--Unchanged--" {}] -foreach state_id [workflow::fsm::get_states -workflow_id $workflow_id] { +foreach state_id [workflow::fsm::get_states -workflow_id $workflow_id -parent_action_id $parent_action_id] { array unset state_array workflow::state::fsm::get -state_id $state_id -array state_array lappend enabled_options [list $state_array(pretty_name) $state_id] lappend state_options [list $state_array(pretty_name) $state_id] } -ad_form -extend -name task -form { - {new_state_id:integer(select),optional - {label "Next state"} - {options $state_options} - {help_text "After this task is completed, change the template's state."} +if { [exists_and_equal parent_task_array(trigger_type) "parallel"] || [exists_and_equal parent_task_array(trigger_type) "dynamic"] } { + ad_form -extend -name task -form { + {new_state_id:integer(hidden),optional} } +} else { + ad_form -extend -name task -form { + {new_state_id:integer(select),optional + {label "Next state"} + {options $state_options} + {help_text "After this task is completed, change the template's state."} + } + } } set focus "task.pretty_name" @@ -252,7 +257,6 @@ permission::require_write_permission -object_id $workflow_id set description [template::util::richtext::create $task_array(description) $task_array(description_mime_type)] - # Removed: child_workflow_id foreach elm { pretty_name pretty_past_tense new_state_id assigned_role recipient_roles @@ -272,46 +276,43 @@ set focus {} } -on_submit { - set description_mime_type [template::util::richtext::get_property format $description] - set description [template::util::richtext::get_property contents $description] + # Check that pretty_name is unique + set unique_p [workflow::action::pretty_name_unique_p \ + -workflow_id $workflow_id \ + -action_id $action_id \ + -pretty_name $pretty_name] + + if { !$unique_p } { + form set_error task pretty_name "This name is already used by another task" + break + } - set child_role_map [list] + if { [info exists description] } { + set description_mime_type [template::util::richtext::get_property format $description] + set description [template::util::richtext::get_property contents $description] + } switch $task_type { message { - set child_workflow_id {} } normal { set recipient_roles {} - set child_workflow_id {} } - workflow { - set recipient_roles {} - - # we have: - # element parent_role__asker = lawyer - # element parent_role__giver = client - - foreach role_id [workflow::get_roles -workflow_id $child_workflow_id] { - set child_role_short_name [workflow::role::get_element -role_id $role_id -element short_name] - set parent_role_short_name [set "parent_role__$child_role_short_name"] - lappend child_role_map $child_role_short_name [list $parent_role_short_name "per_role"] - } - } } # Default pretty_past_tense if { [empty_string_p $pretty_past_tense] } { set pretty_past_tense $pretty_name } - # Removed: child_workflow_id child_role_map foreach elm { pretty_name pretty_past_tense assigned_role description description_mime_type new_state_id timeout_seconds recipient_roles attachment_num trigger_type parent_action_id } { - set row($elm) [set $elm] + if { [info exists $elm] } { + set row($elm) [set $elm] + } } set row(short_name) {}