Index: openacs-4/contrib/packages/simulation/lib/template-clone.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/template-clone.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/lib/template-clone.adp 23 Jan 2004 14:31:36 -0000 1.1
@@ -0,0 +1,6 @@
+
+ Make a copy of the selected template, including all tasks and + roles, but not any objects. +
\ No newline at end of file Index: openacs-4/contrib/packages/simulation/lib/template-clone.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/template-clone.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/lib/template-clone.tcl 23 Jan 2004 14:31:36 -0000 1.1 @@ -0,0 +1,47 @@ + +simulation::template::get -workflow_id $workflow_id -array simulation + +set pretty_name "Clone of $simulation(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 unique_p [simulation::template::pretty_name_unique_p \ + -package_id [ad_conn package_id] \ + -pretty_name $pretty_name] + + if { !$unique_p } { + form set_error clone pretty_name "This name is already used by another simulation" + break + } + + set new_simulation(pretty_name) $pretty_name + set new_simulation(short_name) {} + set new_simulation(sim_type) {dev_template} + + switch $simulation(sim_type) { + "dev_template" - "ready_template" { + set new_simulation(sim_type) "dev_template" + } + "dev_sim" { + set new_simulation(sim_type) "dev_sim" + } + default { + error "Cloning of template with sim_type=$simulation(sim_type) not supported" + } + } + + simulation::template::clone \ + -workflow_id $workflow_id \ + -package_key "simulation" \ + -object_id [ad_conn package_id] \ + -array new_simulation + + ad_returnredirect . + ad_script_abort +} Index: openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/sim-action-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl 23 Jan 2004 12:14:12 -0000 1.4 +++ openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl 23 Jan 2004 14:31:36 -0000 1.5 @@ -14,6 +14,7 @@ {-workflow_id {}} {-array {}} {-internal:boolean} + {-no_complain:boolean} } { Edit an action. @@ -31,6 +32,8 @@ for a particular workflow model. Will cause this proc to not flush the cache or call workflow::definition_changed_handler, which the caller must then do. + @param no_complain Silently ignore extra attributes that we don't know how to handle. + @return action_id @see workflow::action::fsm::edit Index: openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/sim-role-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl 23 Jan 2004 11:16:15 -0000 1.6 +++ openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl 23 Jan 2004 14:31:36 -0000 1.7 @@ -14,6 +14,7 @@ {-workflow_id {}} {-array {}} {-internal:boolean} + {-no_complain:boolean} } { Edit a role. @@ -31,6 +32,8 @@ for a particular workflow model. Will cause this proc to not flush the cache or call workflow::definition_changed_handler, which the caller must then do. + @param no_complain Silently ignore extra attributes that we don't know how to handle. + @return role_id @see workflow::role::fsm::edit 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.3 -r1.4 --- openacs-4/contrib/packages/simulation/www/simbuild/template-clone.adp 11 Dec 2003 14:24:29 -0000 1.3 +++ openacs-4/contrib/packages/simulation/www/simbuild/template-clone.adp 23 Jan 2004 14:31:36 -0000 1.4 @@ -3,9 +3,4 @@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,
-copy links to objects but not the objects themselves.)
+
+ Make a copy of the selected template, including all tasks and
+ roles, but not any objects.
+ 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,
-copy links to objects but not the objects themselves.)
+
}
+ link_url_col clone_url
+ link_html { title "Clone this template" }
}
delete {
sub_class narrow
@@ -65,7 +67,7 @@
set sim_in_dev_filter_sql "and ao.creation_user = :user_id"
}
-db_multirow -extend { state state_pretty cast_url map_roles_url map_props_url sim_tasks_url delete_url prop_empty_count } dev_sims select_dev_sims "
+db_multirow -extend { state state_pretty clone_url cast_url map_roles_url map_props_url sim_tasks_url delete_url prop_empty_count } dev_sims select_dev_sims "
select w.workflow_id,
w.pretty_name,
w.description,
@@ -105,6 +107,8 @@
set sim_tasks_url [export_vars -base "${base_url}siminst/map-tasks" { workflow_id }]
set delete_url [export_vars -base "${base_url}siminst/simulation-delete" { workflow_id }]
set state_pretty [simulation::template::get_state_pretty -state $state]
+
+ set clone_url [export_vars -base "${base_url}siminst/template-clone" { workflow_id }]
}
Index: openacs-4/contrib/packages/simulation/www/siminst/map-tasks.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/map-tasks.tcl,v
diff -u -r1.12 -r1.13
--- openacs-4/contrib/packages/simulation/www/siminst/map-tasks.tcl 14 Jan 2004 15:10:54 -0000 1.12
+++ openacs-4/contrib/packages/simulation/www/siminst/map-tasks.tcl 23 Jan 2004 14:31:36 -0000 1.13
@@ -29,56 +29,63 @@
a.description,
a.description_mime_type,
st.attachment_num,
- (select pretty_name from workflow_roles where role_id = a.assigned_role) as assigned_role_pretty,
- (select pretty_name from workflow_roles where role_id = st.recipient) as recipient_role_pretty,
- (select count(*) from workflow_initial_action where action_id = a.action_id) as initial_p
+ (select pretty_name from workflow_roles where role_id = a.assigned_role) as assigned_role_pretty
from workflow_actions a,
sim_tasks st
where a.workflow_id = :workflow_id
and st.task_id = a.action_id
+ and a.trigger_type = 'user'
order by a.sort_order
} -column_array row {
- if { !$row(initial_p) } {
- set section_name "Task $row(pretty_name)"
- if { ![empty_string_p $row(assigned_role_pretty)] || ![empty_string_p $row(recipient_role_pretty)] } {
- append section_name " ("
- if { ![empty_string_p $row(assigned_role_pretty)] } {
- append section_name $row(assigned_role_pretty)
- }
- if { ![empty_string_p $row(recipient_role_pretty)] } {
- append section_name "-> $row(recipient_role_pretty))"
- }
+ set section_name "Task $row(pretty_name)"
+ # TODO B: use a grouping query instead of this query in a query
+ set action_id $row(action_id)
+ set recipient_role_list [db_list select_recipient_roles {
+ select wr.pretty_name
+ from sim_task_recipients str,
+ workflow_roles wr
+ where str.task_id = :action_id
+ and str.recipient = wr.role_id
+ }]
+ set recipient_role_pretty [join $recipient_role_list ", "]
+ if { ![empty_string_p $row(assigned_role_pretty)] || ![empty_string_p $recipient_role_pretty] } {
+ append section_name " ("
+ if { ![empty_string_p $row(assigned_role_pretty)] } {
+ append section_name $row(assigned_role_pretty)
}
-
- ad_form -extend -name tasks -form \
- [list [list description_$row(action_id):richtext,optional \
- {label "Task Description"} \
- {help_text "This is the text that users will see while attempting to complete a task."} \
- {html {cols 60 rows 4}} \
- {section $section_name} ]]
- set description_$row(action_id) [template::util::richtext::create $row(description) $row(description_mime_type)]
-
- # Save attachment_num for later
- ad_form -extend -name tasks -form \
- [list [list attachment_num_$row(action_id):integer(hidden),optional \
- {value $row(attachment_num)}]]
+ if { ![empty_string_p $recipient_role_pretty] } {
+ append section_name "-> $recipient_role_pretty)"
+ }
+ }
+
+ ad_form -extend -name tasks -form \
+ [list [list description_$row(action_id):richtext,optional \
+ {label "Task Description"} \
+ {help_text "This is the text that users will see while attempting to complete a task."} \
+ {html {cols 60 rows 4}} \
+ {section $section_name} ]]
+ set description_$row(action_id) [template::util::richtext::create $row(description) $row(description_mime_type)]
+
+ # Save attachment_num for later
+ ad_form -extend -name tasks -form \
+ [list [list attachment_num_$row(action_id):integer(hidden),optional \
+ {value $row(attachment_num)}]]
- for { set i 1 } { $i <= $row(attachment_num) } { incr i } {
- if { $prop_count == "1" } {
- set missing_props_p 1
- break
- }
+ for { set i 1 } { $i <= $row(attachment_num) } { incr i } {
+ if { $prop_count == "1" } {
+ set missing_props_p 1
+ break
+ }
- ad_form -extend -name tasks -form \
- [list [list attachment_$row(action_id)_${i}:integer(select) \
- {label "Attachment $i"} \
- {options $prop_options} \
- {help_text "Select from existing attachments or add a new prop and refresh this page."}]]
- }
+ ad_form -extend -name tasks -form \
+ [list [list attachment_$row(action_id)_${i}:integer(select) \
+ {label "Attachment $i"} \
+ {options $prop_options} \
+ {help_text "Select from existing attachments or add a new prop and refresh this page."}]]
+ }
- lappend actions $row(action_id)
- }
+ lappend actions $row(action_id)
}
if { $missing_props_p } {
Index: openacs-4/contrib/packages/simulation/www/siminst/template-clone.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/template-clone.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/siminst/template-clone.adp 23 Jan 2004 14:31:36 -0000 1.1
@@ -0,0 +1,6 @@
+
}
+ link_url_col clone_url
+ link_html { title "Clone this template" }
}
delete {
sub_class narrow
@@ -65,7 +67,7 @@
set sim_in_dev_filter_sql "and ao.creation_user = :user_id"
}
-db_multirow -extend { state state_pretty cast_url map_roles_url map_props_url sim_tasks_url delete_url prop_empty_count } dev_sims select_dev_sims "
+db_multirow -extend { state state_pretty clone_url cast_url map_roles_url map_props_url sim_tasks_url delete_url prop_empty_count } dev_sims select_dev_sims "
select w.workflow_id,
w.pretty_name,
w.description,
@@ -105,6 +107,8 @@
set sim_tasks_url [export_vars -base "${base_url}siminst/map-tasks" { workflow_id }]
set delete_url [export_vars -base "${base_url}siminst/simulation-delete" { workflow_id }]
set state_pretty [simulation::template::get_state_pretty -state $state]
+
+ set clone_url [export_vars -base "${base_url}siminst/template-clone" { workflow_id }]
}
Index: openacs-4/packages/simulation/www/siminst/map-tasks.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/map-tasks.tcl,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/simulation/www/siminst/map-tasks.tcl 14 Jan 2004 15:10:54 -0000 1.12
+++ openacs-4/packages/simulation/www/siminst/map-tasks.tcl 23 Jan 2004 14:31:36 -0000 1.13
@@ -29,56 +29,63 @@
a.description,
a.description_mime_type,
st.attachment_num,
- (select pretty_name from workflow_roles where role_id = a.assigned_role) as assigned_role_pretty,
- (select pretty_name from workflow_roles where role_id = st.recipient) as recipient_role_pretty,
- (select count(*) from workflow_initial_action where action_id = a.action_id) as initial_p
+ (select pretty_name from workflow_roles where role_id = a.assigned_role) as assigned_role_pretty
from workflow_actions a,
sim_tasks st
where a.workflow_id = :workflow_id
and st.task_id = a.action_id
+ and a.trigger_type = 'user'
order by a.sort_order
} -column_array row {
- if { !$row(initial_p) } {
- set section_name "Task $row(pretty_name)"
- if { ![empty_string_p $row(assigned_role_pretty)] || ![empty_string_p $row(recipient_role_pretty)] } {
- append section_name " ("
- if { ![empty_string_p $row(assigned_role_pretty)] } {
- append section_name $row(assigned_role_pretty)
- }
- if { ![empty_string_p $row(recipient_role_pretty)] } {
- append section_name "-> $row(recipient_role_pretty))"
- }
+ set section_name "Task $row(pretty_name)"
+ # TODO B: use a grouping query instead of this query in a query
+ set action_id $row(action_id)
+ set recipient_role_list [db_list select_recipient_roles {
+ select wr.pretty_name
+ from sim_task_recipients str,
+ workflow_roles wr
+ where str.task_id = :action_id
+ and str.recipient = wr.role_id
+ }]
+ set recipient_role_pretty [join $recipient_role_list ", "]
+ if { ![empty_string_p $row(assigned_role_pretty)] || ![empty_string_p $recipient_role_pretty] } {
+ append section_name " ("
+ if { ![empty_string_p $row(assigned_role_pretty)] } {
+ append section_name $row(assigned_role_pretty)
}
-
- ad_form -extend -name tasks -form \
- [list [list description_$row(action_id):richtext,optional \
- {label "Task Description"} \
- {help_text "This is the text that users will see while attempting to complete a task."} \
- {html {cols 60 rows 4}} \
- {section $section_name} ]]
- set description_$row(action_id) [template::util::richtext::create $row(description) $row(description_mime_type)]
-
- # Save attachment_num for later
- ad_form -extend -name tasks -form \
- [list [list attachment_num_$row(action_id):integer(hidden),optional \
- {value $row(attachment_num)}]]
+ if { ![empty_string_p $recipient_role_pretty] } {
+ append section_name "-> $recipient_role_pretty)"
+ }
+ }
+
+ ad_form -extend -name tasks -form \
+ [list [list description_$row(action_id):richtext,optional \
+ {label "Task Description"} \
+ {help_text "This is the text that users will see while attempting to complete a task."} \
+ {html {cols 60 rows 4}} \
+ {section $section_name} ]]
+ set description_$row(action_id) [template::util::richtext::create $row(description) $row(description_mime_type)]
+
+ # Save attachment_num for later
+ ad_form -extend -name tasks -form \
+ [list [list attachment_num_$row(action_id):integer(hidden),optional \
+ {value $row(attachment_num)}]]
- for { set i 1 } { $i <= $row(attachment_num) } { incr i } {
- if { $prop_count == "1" } {
- set missing_props_p 1
- break
- }
+ for { set i 1 } { $i <= $row(attachment_num) } { incr i } {
+ if { $prop_count == "1" } {
+ set missing_props_p 1
+ break
+ }
- ad_form -extend -name tasks -form \
- [list [list attachment_$row(action_id)_${i}:integer(select) \
- {label "Attachment $i"} \
- {options $prop_options} \
- {help_text "Select from existing attachments or add a new prop and refresh this page."}]]
- }
+ ad_form -extend -name tasks -form \
+ [list [list attachment_$row(action_id)_${i}:integer(select) \
+ {label "Attachment $i"} \
+ {options $prop_options} \
+ {help_text "Select from existing attachments or add a new prop and refresh this page."}]]
+ }
- lappend actions $row(action_id)
- }
+ lappend actions $row(action_id)
}
if { $missing_props_p } {
Index: openacs-4/packages/simulation/www/siminst/template-clone.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/template-clone.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/www/siminst/template-clone.adp 23 Jan 2004 14:31:36 -0000 1.1
@@ -0,0 +1,6 @@
+