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 -r1.8 -r1.9 --- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 10 Dec 2003 10:05:19 -0000 1.8 +++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 11 Dec 2003 14:24:29 -0000 1.9 @@ -153,7 +153,9 @@ } ad_proc -public simulation::template::clone { {-workflow_id:required} - {-pretty_name:required} + {-package_key {}} + {-object_id {}} + {-array {}} } { Create a new simulation template which is a clone of the template with given id. The clone will be mapped to the package of the current request. @@ -165,38 +167,37 @@ @author Peter Marklund } { - # If we set object_id here and leave short_name unchanged we - # get a unique constraint violation - set clone_workflow_id [workflow::fsm::clone \ - -workflow_id $workflow_id] - - # Set names of clones workflow and update the object_id - # TODO: create workflow::edit proc - set clone_short_name [util_text_to_url -replacement "_" $pretty_name] - set object_id [ad_conn package_id] - db_dml update_short_name { - update workflows - set short_name = :clone_short_name, - pretty_name = :pretty_name, - object_id = :object_id - where workflow_id = :clone_workflow_id + if { ![empty_string_p $array] } { + upvar 1 $array row + set array row } - # Add the role_id:s to the sim_roles table - set role_id_list [workflow::get_roles -workflow_id $clone_workflow_id] - foreach role_id $role_id_list { - db_dml insert_sim_role { - insert into sim_roles (role_id) values (:role_id) + db_transaction { + + # If we set object_id here and leave short_name unchanged we + # get a unique constraint violation + set clone_workflow_id [workflow::fsm::clone \ + -workflow_id $workflow_id \ + -package_key $package_key \ + -object_id $object_id \ + -array $array] + + # Add the role_id:s to the sim_roles table + set role_id_list [workflow::get_roles -workflow_id $clone_workflow_id] + foreach role_id $role_id_list { + db_dml insert_sim_role { + insert into sim_roles (role_id) values (:role_id) + } } + + # Clone the values in the simulation table + simulation::template::get -workflow_id $workflow_id -array workflow + insert_sim \ + -workflow_id $clone_workflow_id \ + -sim_type $workflow(sim_type) \ + -suggested_duration $workflow(suggested_duration) } - # Clone the values in the simulation table - get -workflow_id $workflow_id -array workflow - insert_sim \ - -workflow_id $clone_workflow_id \ - -sim_type $workflow(sim_type) \ - -suggested_duration $workflow(suggested_duration) - return $clone_workflow_id } Index: openacs-4/contrib/packages/simulation/www/simulation-master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/simulation-master.adp,v diff -u -r1.7 -r1.8 --- openacs-4/contrib/packages/simulation/www/simulation-master.adp 11 Dec 2003 13:21:52 -0000 1.7 +++ openacs-4/contrib/packages/simulation/www/simulation-master.adp 11 Dec 2003 14:24:29 -0000 1.8 @@ -2,6 +2,7 @@ @title;noquote@ @context;noquote@ @subnavbar_link;noquote@ +@focus;noquote@ Index: openacs-4/contrib/packages/simulation/www/simbuild/template-clone.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/template-clone.adp,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/simbuild/template-clone.adp 11 Dec 2003 13:21:53 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/simbuild/template-clone.adp 11 Dec 2003 14:24:29 -0000 1.3 @@ -1,9 +1,10 @@ @page_title;noquote@ @context;noquote@ + clone.pretty_name -New Template Name: + +

Make a copy of the selected template, including all tasks and roles, but not any objects. (At the moment, there shouldn't be any objects associated with a template, but that might change. If so, Index: openacs-4/contrib/packages/simulation/www/simbuild/template-clone.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/template-clone.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/simbuild/template-clone.tcl 2 Dec 2003 17:24:32 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/simbuild/template-clone.tcl 11 Dec 2003 14:24:29 -0000 1.3 @@ -4,9 +4,34 @@ workflow_id:integer } -set page_title "Clone a template" +permission::require_permission -object_id [ad_conn package_id] -privilege sim_template_create -set context [list $page_title] -set package_id [ad_conn package_id] +workflow::get -workflow_id $workflow_id -array workflow_array -permission::require_permission -object_id $package_id -privilege sim_template_create +set page_title "Clone $workflow_array(pretty_name)" + +set context [list [list "." "SimBuild"] $page_title] + +set pretty_name "Clone of $workflow_array(pretty_name)" + +ad_form -name clone -export { workflow_id } -edit_buttons [list [list "Clone" ok]] -form { + {pretty_name:text + {label "Name"} + {html {size 50}} + } +} -on_request { + +} -on_submit { + set new_workflow_array(pretty_name) $pretty_name + set new_workflow_array(short_name) {} + + simulation::template::clone \ + -workflow_id $workflow_id \ + -package_key "simulation" \ + -object_id [ad_conn package_id] \ + -array new_workflow_array + + ad_returnredirect . + ad_script_abort +} + Index: openacs-4/contrib/packages/simulation/www/simbuild/template-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/template-edit.adp,v diff -u -r1.8 -r1.9 --- openacs-4/contrib/packages/simulation/www/simbuild/template-edit.adp 11 Dec 2003 13:21:53 -0000 1.8 +++ openacs-4/contrib/packages/simulation/www/simbuild/template-edit.adp 11 Dec 2003 14:24:29 -0000 1.9 @@ -19,7 +19,10 @@

Tasks

- + +

TODO: Allow reordering of roles, states, tasks.

-

TODO: Allow sorting of roles, states, tasks.

- +

+ » Download a specification for this template +

+ Index: openacs-4/contrib/packages/simulation/www/simbuild/template-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/template-edit.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/contrib/packages/simulation/www/simbuild/template-edit.tcl 10 Dec 2003 13:51:06 -0000 1.8 +++ openacs-4/contrib/packages/simulation/www/simbuild/template-edit.tcl 11 Dec 2003 14:24:29 -0000 1.9 @@ -146,3 +146,6 @@ set context [list [list "." "SimBuild"] $page_title] set delete_url [export_vars -base template-delete { workflow_id }] + +set spec_url [export_vars -base template-spec { workflow_id }] + 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 -r1.8 -r1.9 --- openacs-4/packages/simulation/tcl/template-procs.tcl 10 Dec 2003 10:05:19 -0000 1.8 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 11 Dec 2003 14:24:29 -0000 1.9 @@ -153,7 +153,9 @@ } ad_proc -public simulation::template::clone { {-workflow_id:required} - {-pretty_name:required} + {-package_key {}} + {-object_id {}} + {-array {}} } { Create a new simulation template which is a clone of the template with given id. The clone will be mapped to the package of the current request. @@ -165,38 +167,37 @@ @author Peter Marklund } { - # If we set object_id here and leave short_name unchanged we - # get a unique constraint violation - set clone_workflow_id [workflow::fsm::clone \ - -workflow_id $workflow_id] - - # Set names of clones workflow and update the object_id - # TODO: create workflow::edit proc - set clone_short_name [util_text_to_url -replacement "_" $pretty_name] - set object_id [ad_conn package_id] - db_dml update_short_name { - update workflows - set short_name = :clone_short_name, - pretty_name = :pretty_name, - object_id = :object_id - where workflow_id = :clone_workflow_id + if { ![empty_string_p $array] } { + upvar 1 $array row + set array row } - # Add the role_id:s to the sim_roles table - set role_id_list [workflow::get_roles -workflow_id $clone_workflow_id] - foreach role_id $role_id_list { - db_dml insert_sim_role { - insert into sim_roles (role_id) values (:role_id) + db_transaction { + + # If we set object_id here and leave short_name unchanged we + # get a unique constraint violation + set clone_workflow_id [workflow::fsm::clone \ + -workflow_id $workflow_id \ + -package_key $package_key \ + -object_id $object_id \ + -array $array] + + # Add the role_id:s to the sim_roles table + set role_id_list [workflow::get_roles -workflow_id $clone_workflow_id] + foreach role_id $role_id_list { + db_dml insert_sim_role { + insert into sim_roles (role_id) values (:role_id) + } } + + # Clone the values in the simulation table + simulation::template::get -workflow_id $workflow_id -array workflow + insert_sim \ + -workflow_id $clone_workflow_id \ + -sim_type $workflow(sim_type) \ + -suggested_duration $workflow(suggested_duration) } - # Clone the values in the simulation table - get -workflow_id $workflow_id -array workflow - insert_sim \ - -workflow_id $clone_workflow_id \ - -sim_type $workflow(sim_type) \ - -suggested_duration $workflow(suggested_duration) - return $clone_workflow_id } Index: openacs-4/packages/simulation/www/simulation-master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simulation-master.adp,v diff -u -r1.7 -r1.8 --- openacs-4/packages/simulation/www/simulation-master.adp 11 Dec 2003 13:21:52 -0000 1.7 +++ openacs-4/packages/simulation/www/simulation-master.adp 11 Dec 2003 14:24:29 -0000 1.8 @@ -2,6 +2,7 @@ @title;noquote@ @context;noquote@ @subnavbar_link;noquote@ +@focus;noquote@ Index: openacs-4/packages/simulation/www/simbuild/template-clone.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/template-clone.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/www/simbuild/template-clone.adp 11 Dec 2003 13:21:53 -0000 1.2 +++ openacs-4/packages/simulation/www/simbuild/template-clone.adp 11 Dec 2003 14:24:29 -0000 1.3 @@ -1,9 +1,10 @@ @page_title;noquote@ @context;noquote@ + clone.pretty_name -New Template Name: + +

Make a copy of the selected template, including all tasks and roles, but not any objects. (At the moment, there shouldn't be any objects associated with a template, but that might change. If so, Index: openacs-4/packages/simulation/www/simbuild/template-clone.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/template-clone.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/www/simbuild/template-clone.tcl 2 Dec 2003 17:24:32 -0000 1.2 +++ openacs-4/packages/simulation/www/simbuild/template-clone.tcl 11 Dec 2003 14:24:29 -0000 1.3 @@ -4,9 +4,34 @@ workflow_id:integer } -set page_title "Clone a template" +permission::require_permission -object_id [ad_conn package_id] -privilege sim_template_create -set context [list $page_title] -set package_id [ad_conn package_id] +workflow::get -workflow_id $workflow_id -array workflow_array -permission::require_permission -object_id $package_id -privilege sim_template_create +set page_title "Clone $workflow_array(pretty_name)" + +set context [list [list "." "SimBuild"] $page_title] + +set pretty_name "Clone of $workflow_array(pretty_name)" + +ad_form -name clone -export { workflow_id } -edit_buttons [list [list "Clone" ok]] -form { + {pretty_name:text + {label "Name"} + {html {size 50}} + } +} -on_request { + +} -on_submit { + set new_workflow_array(pretty_name) $pretty_name + set new_workflow_array(short_name) {} + + simulation::template::clone \ + -workflow_id $workflow_id \ + -package_key "simulation" \ + -object_id [ad_conn package_id] \ + -array new_workflow_array + + ad_returnredirect . + ad_script_abort +} + Index: openacs-4/packages/simulation/www/simbuild/template-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/template-edit.adp,v diff -u -r1.8 -r1.9 --- openacs-4/packages/simulation/www/simbuild/template-edit.adp 11 Dec 2003 13:21:53 -0000 1.8 +++ openacs-4/packages/simulation/www/simbuild/template-edit.adp 11 Dec 2003 14:24:29 -0000 1.9 @@ -19,7 +19,10 @@

Tasks

- + +

TODO: Allow reordering of roles, states, tasks.

-

TODO: Allow sorting of roles, states, tasks.

- +

+ » Download a specification for this template +

+ Index: openacs-4/packages/simulation/www/simbuild/template-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/template-edit.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/simulation/www/simbuild/template-edit.tcl 10 Dec 2003 13:51:06 -0000 1.8 +++ openacs-4/packages/simulation/www/simbuild/template-edit.tcl 11 Dec 2003 14:24:29 -0000 1.9 @@ -146,3 +146,6 @@ set context [list [list "." "SimBuild"] $page_title] set delete_url [export_vars -base template-delete { workflow_id }] + +set spec_url [export_vars -base template-spec { workflow_id }] +