Index: openacs-4/contrib/packages/simulation/lib/sim-template-roles.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-roles.tcl,v
diff -u -r1.9 -r1.10
--- openacs-4/contrib/packages/simulation/lib/sim-template-roles.tcl 9 Dec 2003 15:58:12 -0000 1.9
+++ openacs-4/contrib/packages/simulation/lib/sim-template-roles.tcl 10 Dec 2003 16:06:46 -0000 1.10
@@ -44,6 +44,7 @@
name {
label "Name"
display_col pretty_name
+ link_url_col edit_url
}
delete {
sub_class narrow
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 -r1.8 -r1.9
--- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 9 Dec 2003 15:58:12 -0000 1.8
+++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 10 Dec 2003 16:06:46 -0000 1.9
@@ -37,7 +37,8 @@
# how is type going to work? open question pending prototyping
if { $display_mode == "edit"} {
- set actions [list "Add a Task" [export_vars -base task-edit {workflow_id} ]]
+ set actions [list "Add a Task" [export_vars -base task-edit {workflow_id} ] {}]
+ lappend actions "Add a State" [export_vars -base state-edit { workflow_id}] {}
} else {
set actions ""
}
@@ -69,6 +70,11 @@
link_url_col {[ad_decode $display_mode edit view_url ""]}
}
+lappend elements assigned_name {
+ label "Assignee"
+ link_url_col assigned_role_edit_url
+}
+
set states [list]
db_foreach select_states {
@@ -86,15 +92,19 @@
display_template "
- Assigned
+ ◊
+ ♦
- Enabled
+ ◊
+
+ ↑
+
"]
lappend states $state_id
@@ -104,7 +114,7 @@
label {
}
display_template { }
@@ -132,17 +142,17 @@
#-------------------------------------------------------------
# tasks db_multirow
#-------------------------------------------------------------
-# TODO: fix this so it returns rows when it should
set initial_action_id [workflow::get_element \
-workflow_id $workflow_id \
-element initial_action_id]
set extend [list]
-lappend extend edit_url view_url delete_url initial_p set_initial_url
+lappend extend edit_url view_url delete_url initial_p set_initial_url assigned_role_edit_url
foreach state_id $states {
lappend extend state_$state_id
+ lappend extend move_to_$state_id
}
array set enabled_in_state [list]
@@ -161,45 +171,48 @@
set enabled_in_state($action_id,$state_id) $assigned_p
}
-ds_comment [array get enabled_in_state]
-
-
db_multirow -extend $extend tasks select_tasks "
select wa.action_id,
wa.pretty_name,
+ wa.assigned_role,
(select pretty_name
from workflow_roles
where role_id = wa.assigned_role) as assigned_name,
(select pretty_name
from workflow_roles
where role_id = st.recipient) as recipient_name,
wa.sort_order,
- wa.always_enabled_p
+ wa.always_enabled_p,
+ wfa.new_state
from workflow_actions wa,
+ workflow_fsm_actions wfa,
sim_tasks st
where wa.workflow_id = :workflow_id
+ and wfa.action_id = wa.action_id
and st.task_id = wa.action_id
order by wa.sort_order
" {
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 delete_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url [ad_return_url]} }]
+
+ set assigned_role_edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { { role_id $assigned_role } }]
+
set initial_p [string equal $initial_action_id $action_id]
set set_initial_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/initial-action-set" { action_id {return_url [ad_return_url]} }]
foreach state_id $states {
- ds_comment "enabled_in_state($action_id,$state_id)"
if { [info exists enabled_in_state($action_id,$state_id)] } {
if { [template::util::is_true $enabled_in_state($action_id,$state_id)] } {
- ds_comment "Assigned"
set state_$state_id assigned
- ds_comment "set state_$state_id assigned -- $extend"
} else {
- ds_comment "Enabled"
set state_$state_id enabled
- ds_comment "set state_$state_id enabled -- $extend"
}
}
+ if { $new_state == $state_id } {
+ set move_to_$state_id 1
+ }
}
}
+
Index: openacs-4/contrib/packages/simulation/tcl/action-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/action-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/simulation/tcl/action-procs.tcl 9 Dec 2003 15:58:12 -0000 1.3
+++ openacs-4/contrib/packages/simulation/tcl/action-procs.tcl 10 Dec 2003 16:06:46 -0000 1.4
@@ -21,10 +21,13 @@
db_transaction {
if { [info exists row(recipient_role)] } {
- set recipient_role_id [workflow::role::get_id \
- -workflow_id $workflow_id \
- -short_name $row(recipient_role)]
-
+ if { ![empty_string_p $row(recipient_role)] } {
+ set recipient_role_id [workflow::role::get_id \
+ -workflow_id $workflow_id \
+ -short_name $row(recipient_role)]
+ } else {
+ set recipient_role_id [db_null]
+ }
db_dml edit_sim_role {
update sim_tasks
set recipient = :recipient_role_id
Index: openacs-4/contrib/packages/simulation/tcl/role-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/role-procs.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/contrib/packages/simulation/tcl/role-procs.tcl 28 Nov 2003 16:55:52 -0000 1.5
+++ openacs-4/contrib/packages/simulation/tcl/role-procs.tcl 10 Dec 2003 16:06:46 -0000 1.6
@@ -10,8 +10,8 @@
ad_proc -public simulation::role::new {
{-template_id:required}
- {-role_short_name:required}
- {-role_pretty_name:required}
+ {-short_name {}}
+ {-pretty_name:required}
} {
Create a new simulation role for a given simulation template.
Will map the character to the template if this
@@ -20,11 +20,10 @@
@author Peter Marklund
} {
db_transaction {
- set role_short_name [util_text_to_url -replacement "_" $role_short_name]
set role_id [workflow::role::new \
-workflow_id $template_id \
- -short_name $role_short_name \
- -pretty_name $role_pretty_name]
+ -short_name $short_name \
+ -pretty_name $pretty_name]
db_dml insert_sim_role {
insert into sim_roles (role_id) values (:role_id)
Index: openacs-4/contrib/packages/simulation/www/simbuild/role-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/role-edit.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/www/simbuild/role-edit.adp 1 Dec 2003 10:20:16 -0000 1.2
+++ openacs-4/contrib/packages/simulation/www/simbuild/role-edit.adp 10 Dec 2003 16:06:46 -0000 1.3
@@ -1,6 +1,6 @@
@page_title;noquote@
@context;noquote@
- role.name
+ role.pretty_name
Index: openacs-4/contrib/packages/simulation/www/simbuild/role-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/role-edit.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/contrib/packages/simulation/www/simbuild/role-edit.tcl 9 Dec 2003 09:52:44 -0000 1.5
+++ openacs-4/contrib/packages/simulation/www/simbuild/role-edit.tcl 10 Dec 2003 16:06:46 -0000 1.6
@@ -38,20 +38,20 @@
# role form
#---------------------------------------------------------------------
-ad_form -name role -cancel_url index -form {
+ad_form -name role -form {
{role_id:key}
{workflow_id:integer(hidden),optional}
- {name:text
+ {pretty_name:text
{label "Role Name"}
{html {size 20}}
}
} -edit_request {
workflow::role::get -role_id $role_id -array role_array
set workflow_id $role_array(workflow_id)
permission::require_write_permission -object_id $workflow_id
- set name $role_array(pretty_name)
+ set pretty_name $role_array(pretty_name)
workflow::get -workflow_id $workflow_id -array sim_template_array
- set page_title "Edit Role template $name"
+ set page_title "Edit Role template $pretty_name"
set context [list [list "." "Sim Templates"] [list "template-edit?workflow_id=$workflow_id" "$sim_template_array(pretty_name)"] $page_title]
} -new_request {
@@ -64,8 +64,7 @@
permission::require_write_permission -object_id $workflow_id
simulation::role::new \
-template_id $workflow_id \
- -role_short_name $name \
- -role_pretty_name $name
+ -pretty_name $pretty_name
} -edit_data {
workflow::role::get -role_id $role_id -array role_array
@@ -74,12 +73,13 @@
# could be spoofed
permission::require_write_permission -object_id $role_array(workflow_id)
- set role_array(pretty_name) $name
+ set row(pretty_name) $pretty_name
+ set row(short_name) {}
workflow::role::edit \
-role_id $role_id \
-workflow_id $workflow_id \
- -array role_array
+ -array row
} -after_submit {
ad_returnredirect [export_vars -base "template-edit" { workflow_id }]
Index: openacs-4/contrib/packages/simulation/www/simbuild/task-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/task-edit.adp,v
diff -u -r1.5 -r1.6
--- openacs-4/contrib/packages/simulation/www/simbuild/task-edit.adp 9 Dec 2003 15:58:13 -0000 1.5
+++ openacs-4/contrib/packages/simulation/www/simbuild/task-edit.adp 10 Dec 2003 16:06:46 -0000 1.6
@@ -1,7 +1,7 @@
@page_title;noquote@
@context;noquote@
- task.name
+ task.pretty_name
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 -r1.7 -r1.8
--- openacs-4/contrib/packages/simulation/www/simbuild/task-edit.tcl 9 Dec 2003 15:58:13 -0000 1.7
+++ openacs-4/contrib/packages/simulation/www/simbuild/task-edit.tcl 10 Dec 2003 16:06:46 -0000 1.8
@@ -26,6 +26,7 @@
if { ![ad_form_new_p -key action_id] } {
workflow::action::fsm::get -action_id $action_id -array task_array
+
set workflow_id $task_array(workflow_id)
}
@@ -65,11 +66,11 @@
{label "Task Name"}
{html {size 20}}
}
- {assigned_role:text(select)
+ {assigned_role:text(select),optional
{label "Assigned To"}
{options $role_options}
}
- {recipient_role:text(select)
+ {recipient_role:text(select),optional
{label "Recipient"}
{options $role_options}
}
@@ -80,15 +81,18 @@
}
set enabled_options [list]
+set state_options [list]
+lappend state_options [list "--Unchanged--" {}]
foreach state_id [workflow::fsm::get_states -workflow_id $workflow_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 {
{assigned_state_ids:text(checkbox),optional,multiple
- {label "Assigned"}
+ {label "Assigned
TODO: Find a better
way to show the
assigned/enabled states"}
{options $enabled_options}
}
{enabled_state_ids:text(checkbox),optional,multiple
@@ -97,17 +101,28 @@
}
}
-ad_form -extend -name task -edit_request {
+ad_form -extend -name task -form {
+ {new_state_id:integer(select),optional
+ {label "New state"}
+ {options $state_options}
+ }
+} -edit_request {
set workflow_id $task_array(workflow_id)
permission::require_write_permission -object_id $workflow_id
set pretty_name $task_array(pretty_name)
set description [template::util::richtext::create $task_array(description) $task_array(description_mime_type)]
+ set new_state_id $task_array(new_state_id)
+
set recipient_role_id [db_string select_recipient {
select recipient
from sim_tasks
where task_id = :action_id
}]
- set recipient_role [workflow::role::get_element -role_id $recipient_role_id -element short_name]
+ if { ![empty_string_p $recipient_role_id] } {
+ set recipient_role [workflow::role::get_element -role_id $recipient_role_id -element short_name]
+ } else {
+ set recipient_role {}
+ }
set assigned_role $task_array(assigned_role)
@@ -120,32 +135,40 @@
set description_mime_type [template::util::richtext::get_property format $description]
set description [template::util::richtext::get_property contents $description]
+ if { ![empty_string_p $recipient_role] } {
+ set recipient_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $recipient_role]
+ } else {
+ set recipient_role_id [db_null]
+ }
} -new_data {
permission::require_write_permission -object_id $workflow_id
# create the task
# TODO IMPORTANT:
# Set short_name right -- or leave blank and have the workflow API construct a short_name
- set action_id [workflow::action::fsm::new \
- -workflow_id $workflow_id \
- -pretty_name $pretty_name \
- -assigned_role $assigned_role \
- -description $description_content \
- -description_mime_type $description_mime_type \
- -enabled_state_ids $enabled_state_ids \
- -assigned_state_ids $assigned_state_ids]
+ db_transaction {
- # TODO: enabled_states, assigned_states
-
- # TODO - put this stuff into simulation api and change previous call
- # and then add extra data for simulation
- # because workflow::action::fsm::new wants role.short_name instead of
- # role_id, we stay consistent for recipient_role
- set recipient_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $recipient_role]
- db_dml set_role_recipient {
- insert into sim_tasks
- values (:action_id, :recipient_role_id)
+ set action_id [workflow::action::fsm::new \
+ -workflow_id $workflow_id \
+ -pretty_name $pretty_name \
+ -assigned_role $assigned_role \
+ -description $description \
+ -description_mime_type $description_mime_type \
+ -enabled_state_ids $enabled_state_ids \
+ -assigned_state_ids $assigned_state_ids \
+ -new_state_id $new_state_id]
+
+ # TODO: enabled_states, assigned_states
+
+ # TODO - put this stuff into simulation api and change previous call
+ # and then add extra data for simulation
+ # because workflow::action::fsm::new wants role.short_name instead of
+ # role_id, we stay consistent for recipient_role
+ db_dml set_role_recipient {
+ insert into sim_tasks
+ values (:action_id, :recipient_role_id)
+ }
}
} -edit_data {
# We use task_array(workflow_id) here, which is gotten from the DB, and not
@@ -162,6 +185,7 @@
set row($col) [set $col]
}
set row(short_name) {}
+ set row(new_state_id) $new_state_id
simulation::action::edit \
-action_id $action_id \
Index: openacs-4/packages/simulation/lib/sim-template-roles.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-roles.tcl,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/simulation/lib/sim-template-roles.tcl 9 Dec 2003 15:58:12 -0000 1.9
+++ openacs-4/packages/simulation/lib/sim-template-roles.tcl 10 Dec 2003 16:06:46 -0000 1.10
@@ -44,6 +44,7 @@
name {
label "Name"
display_col pretty_name
+ link_url_col edit_url
}
delete {
sub_class narrow
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 -r1.8 -r1.9
--- openacs-4/packages/simulation/lib/sim-template-tasks.tcl 9 Dec 2003 15:58:12 -0000 1.8
+++ openacs-4/packages/simulation/lib/sim-template-tasks.tcl 10 Dec 2003 16:06:46 -0000 1.9
@@ -37,7 +37,8 @@
# how is type going to work? open question pending prototyping
if { $display_mode == "edit"} {
- set actions [list "Add a Task" [export_vars -base task-edit {workflow_id} ]]
+ set actions [list "Add a Task" [export_vars -base task-edit {workflow_id} ] {}]
+ lappend actions "Add a State" [export_vars -base state-edit { workflow_id}] {}
} else {
set actions ""
}
@@ -69,6 +70,11 @@
link_url_col {[ad_decode $display_mode edit view_url ""]}
}
+lappend elements assigned_name {
+ label "Assignee"
+ link_url_col assigned_role_edit_url
+}
+
set states [list]
db_foreach select_states {
@@ -86,15 +92,19 @@
display_template "
- Assigned
+ ◊
+ ♦
- Enabled
+ ◊
+
+ ↑
+
"]
lappend states $state_id
@@ -104,7 +114,7 @@
label {
}
display_template { }
@@ -132,17 +142,17 @@
#-------------------------------------------------------------
# tasks db_multirow
#-------------------------------------------------------------
-# TODO: fix this so it returns rows when it should
set initial_action_id [workflow::get_element \
-workflow_id $workflow_id \
-element initial_action_id]
set extend [list]
-lappend extend edit_url view_url delete_url initial_p set_initial_url
+lappend extend edit_url view_url delete_url initial_p set_initial_url assigned_role_edit_url
foreach state_id $states {
lappend extend state_$state_id
+ lappend extend move_to_$state_id
}
array set enabled_in_state [list]
@@ -161,45 +171,48 @@
set enabled_in_state($action_id,$state_id) $assigned_p
}
-ds_comment [array get enabled_in_state]
-
-
db_multirow -extend $extend tasks select_tasks "
select wa.action_id,
wa.pretty_name,
+ wa.assigned_role,
(select pretty_name
from workflow_roles
where role_id = wa.assigned_role) as assigned_name,
(select pretty_name
from workflow_roles
where role_id = st.recipient) as recipient_name,
wa.sort_order,
- wa.always_enabled_p
+ wa.always_enabled_p,
+ wfa.new_state
from workflow_actions wa,
+ workflow_fsm_actions wfa,
sim_tasks st
where wa.workflow_id = :workflow_id
+ and wfa.action_id = wa.action_id
and st.task_id = wa.action_id
order by wa.sort_order
" {
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 delete_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url [ad_return_url]} }]
+
+ set assigned_role_edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { { role_id $assigned_role } }]
+
set initial_p [string equal $initial_action_id $action_id]
set set_initial_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/initial-action-set" { action_id {return_url [ad_return_url]} }]
foreach state_id $states {
- ds_comment "enabled_in_state($action_id,$state_id)"
if { [info exists enabled_in_state($action_id,$state_id)] } {
if { [template::util::is_true $enabled_in_state($action_id,$state_id)] } {
- ds_comment "Assigned"
set state_$state_id assigned
- ds_comment "set state_$state_id assigned -- $extend"
} else {
- ds_comment "Enabled"
set state_$state_id enabled
- ds_comment "set state_$state_id enabled -- $extend"
}
}
+ if { $new_state == $state_id } {
+ set move_to_$state_id 1
+ }
}
}
+
Index: openacs-4/packages/simulation/tcl/action-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/Attic/action-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/simulation/tcl/action-procs.tcl 9 Dec 2003 15:58:12 -0000 1.3
+++ openacs-4/packages/simulation/tcl/action-procs.tcl 10 Dec 2003 16:06:46 -0000 1.4
@@ -21,10 +21,13 @@
db_transaction {
if { [info exists row(recipient_role)] } {
- set recipient_role_id [workflow::role::get_id \
- -workflow_id $workflow_id \
- -short_name $row(recipient_role)]
-
+ if { ![empty_string_p $row(recipient_role)] } {
+ set recipient_role_id [workflow::role::get_id \
+ -workflow_id $workflow_id \
+ -short_name $row(recipient_role)]
+ } else {
+ set recipient_role_id [db_null]
+ }
db_dml edit_sim_role {
update sim_tasks
set recipient = :recipient_role_id
Index: openacs-4/packages/simulation/tcl/role-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/Attic/role-procs.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/simulation/tcl/role-procs.tcl 28 Nov 2003 16:55:52 -0000 1.5
+++ openacs-4/packages/simulation/tcl/role-procs.tcl 10 Dec 2003 16:06:46 -0000 1.6
@@ -10,8 +10,8 @@
ad_proc -public simulation::role::new {
{-template_id:required}
- {-role_short_name:required}
- {-role_pretty_name:required}
+ {-short_name {}}
+ {-pretty_name:required}
} {
Create a new simulation role for a given simulation template.
Will map the character to the template if this
@@ -20,11 +20,10 @@
@author Peter Marklund
} {
db_transaction {
- set role_short_name [util_text_to_url -replacement "_" $role_short_name]
set role_id [workflow::role::new \
-workflow_id $template_id \
- -short_name $role_short_name \
- -pretty_name $role_pretty_name]
+ -short_name $short_name \
+ -pretty_name $pretty_name]
db_dml insert_sim_role {
insert into sim_roles (role_id) values (:role_id)
Index: openacs-4/packages/simulation/www/simbuild/role-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/role-edit.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/simulation/www/simbuild/role-edit.adp 1 Dec 2003 10:20:16 -0000 1.2
+++ openacs-4/packages/simulation/www/simbuild/role-edit.adp 10 Dec 2003 16:06:46 -0000 1.3
@@ -1,6 +1,6 @@
@page_title;noquote@
@context;noquote@
- role.name
+ role.pretty_name
Index: openacs-4/packages/simulation/www/simbuild/role-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/role-edit.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/simulation/www/simbuild/role-edit.tcl 9 Dec 2003 09:52:44 -0000 1.5
+++ openacs-4/packages/simulation/www/simbuild/role-edit.tcl 10 Dec 2003 16:06:46 -0000 1.6
@@ -38,20 +38,20 @@
# role form
#---------------------------------------------------------------------
-ad_form -name role -cancel_url index -form {
+ad_form -name role -form {
{role_id:key}
{workflow_id:integer(hidden),optional}
- {name:text
+ {pretty_name:text
{label "Role Name"}
{html {size 20}}
}
} -edit_request {
workflow::role::get -role_id $role_id -array role_array
set workflow_id $role_array(workflow_id)
permission::require_write_permission -object_id $workflow_id
- set name $role_array(pretty_name)
+ set pretty_name $role_array(pretty_name)
workflow::get -workflow_id $workflow_id -array sim_template_array
- set page_title "Edit Role template $name"
+ set page_title "Edit Role template $pretty_name"
set context [list [list "." "Sim Templates"] [list "template-edit?workflow_id=$workflow_id" "$sim_template_array(pretty_name)"] $page_title]
} -new_request {
@@ -64,8 +64,7 @@
permission::require_write_permission -object_id $workflow_id
simulation::role::new \
-template_id $workflow_id \
- -role_short_name $name \
- -role_pretty_name $name
+ -pretty_name $pretty_name
} -edit_data {
workflow::role::get -role_id $role_id -array role_array
@@ -74,12 +73,13 @@
# could be spoofed
permission::require_write_permission -object_id $role_array(workflow_id)
- set role_array(pretty_name) $name
+ set row(pretty_name) $pretty_name
+ set row(short_name) {}
workflow::role::edit \
-role_id $role_id \
-workflow_id $workflow_id \
- -array role_array
+ -array row
} -after_submit {
ad_returnredirect [export_vars -base "template-edit" { workflow_id }]
Index: openacs-4/packages/simulation/www/simbuild/task-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/task-edit.adp,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/simulation/www/simbuild/task-edit.adp 9 Dec 2003 15:58:13 -0000 1.5
+++ openacs-4/packages/simulation/www/simbuild/task-edit.adp 10 Dec 2003 16:06:46 -0000 1.6
@@ -1,7 +1,7 @@
@page_title;noquote@
@context;noquote@
- task.name
+ task.pretty_name
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 -r1.7 -r1.8
--- openacs-4/packages/simulation/www/simbuild/task-edit.tcl 9 Dec 2003 15:58:13 -0000 1.7
+++ openacs-4/packages/simulation/www/simbuild/task-edit.tcl 10 Dec 2003 16:06:46 -0000 1.8
@@ -26,6 +26,7 @@
if { ![ad_form_new_p -key action_id] } {
workflow::action::fsm::get -action_id $action_id -array task_array
+
set workflow_id $task_array(workflow_id)
}
@@ -65,11 +66,11 @@
{label "Task Name"}
{html {size 20}}
}
- {assigned_role:text(select)
+ {assigned_role:text(select),optional
{label "Assigned To"}
{options $role_options}
}
- {recipient_role:text(select)
+ {recipient_role:text(select),optional
{label "Recipient"}
{options $role_options}
}
@@ -80,15 +81,18 @@
}
set enabled_options [list]
+set state_options [list]
+lappend state_options [list "--Unchanged--" {}]
foreach state_id [workflow::fsm::get_states -workflow_id $workflow_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 {
{assigned_state_ids:text(checkbox),optional,multiple
- {label "Assigned"}
+ {label "Assigned
TODO: Find a better
way to show the
assigned/enabled states"}
{options $enabled_options}
}
{enabled_state_ids:text(checkbox),optional,multiple
@@ -97,17 +101,28 @@
}
}
-ad_form -extend -name task -edit_request {
+ad_form -extend -name task -form {
+ {new_state_id:integer(select),optional
+ {label "New state"}
+ {options $state_options}
+ }
+} -edit_request {
set workflow_id $task_array(workflow_id)
permission::require_write_permission -object_id $workflow_id
set pretty_name $task_array(pretty_name)
set description [template::util::richtext::create $task_array(description) $task_array(description_mime_type)]
+ set new_state_id $task_array(new_state_id)
+
set recipient_role_id [db_string select_recipient {
select recipient
from sim_tasks
where task_id = :action_id
}]
- set recipient_role [workflow::role::get_element -role_id $recipient_role_id -element short_name]
+ if { ![empty_string_p $recipient_role_id] } {
+ set recipient_role [workflow::role::get_element -role_id $recipient_role_id -element short_name]
+ } else {
+ set recipient_role {}
+ }
set assigned_role $task_array(assigned_role)
@@ -120,32 +135,40 @@
set description_mime_type [template::util::richtext::get_property format $description]
set description [template::util::richtext::get_property contents $description]
+ if { ![empty_string_p $recipient_role] } {
+ set recipient_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $recipient_role]
+ } else {
+ set recipient_role_id [db_null]
+ }
} -new_data {
permission::require_write_permission -object_id $workflow_id
# create the task
# TODO IMPORTANT:
# Set short_name right -- or leave blank and have the workflow API construct a short_name
- set action_id [workflow::action::fsm::new \
- -workflow_id $workflow_id \
- -pretty_name $pretty_name \
- -assigned_role $assigned_role \
- -description $description_content \
- -description_mime_type $description_mime_type \
- -enabled_state_ids $enabled_state_ids \
- -assigned_state_ids $assigned_state_ids]
+ db_transaction {
- # TODO: enabled_states, assigned_states
-
- # TODO - put this stuff into simulation api and change previous call
- # and then add extra data for simulation
- # because workflow::action::fsm::new wants role.short_name instead of
- # role_id, we stay consistent for recipient_role
- set recipient_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $recipient_role]
- db_dml set_role_recipient {
- insert into sim_tasks
- values (:action_id, :recipient_role_id)
+ set action_id [workflow::action::fsm::new \
+ -workflow_id $workflow_id \
+ -pretty_name $pretty_name \
+ -assigned_role $assigned_role \
+ -description $description \
+ -description_mime_type $description_mime_type \
+ -enabled_state_ids $enabled_state_ids \
+ -assigned_state_ids $assigned_state_ids \
+ -new_state_id $new_state_id]
+
+ # TODO: enabled_states, assigned_states
+
+ # TODO - put this stuff into simulation api and change previous call
+ # and then add extra data for simulation
+ # because workflow::action::fsm::new wants role.short_name instead of
+ # role_id, we stay consistent for recipient_role
+ db_dml set_role_recipient {
+ insert into sim_tasks
+ values (:action_id, :recipient_role_id)
+ }
}
} -edit_data {
# We use task_array(workflow_id) here, which is gotten from the DB, and not
@@ -162,6 +185,7 @@
set row($col) [set $col]
}
set row(short_name) {}
+ set row(new_state_id) $new_state_id
simulation::action::edit \
-action_id $action_id \