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.8 -r1.9
--- openacs-4/contrib/packages/simulation/lib/sim-template-roles.tcl 1 Dec 2003 10:16:56 -0000 1.8
+++ openacs-4/contrib/packages/simulation/lib/sim-template-roles.tcl 9 Dec 2003 15:58:12 -0000 1.9
@@ -64,7 +64,7 @@
wr.sort_order
from workflow_roles wr
where wr.workflow_id = :workflow_id
- order by lower(pretty_name)
+ order by wr.sort_order
" {
set edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { role_id }]
set delete_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-delete" { role_id 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 -r1.7 -r1.8
--- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 1 Dec 2003 10:16:56 -0000 1.7
+++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 9 Dec 2003 15:58:12 -0000 1.8
@@ -42,48 +42,129 @@
set actions ""
}
+set elements [list]
+lappend elements edit {
+ hide_p {[ad_decode $display_mode edit 0 1]}
+ sub_class narrow
+ link_url_col edit_url
+ display_template {
+
+ }
+}
+lappend elements initialize {
+ label "Initialize"
+ display_template {
+
+
+
+
+
+
+ }
+ html { align center }
+}
+lappend elements name {
+ label "Name"
+ display_col pretty_name
+ link_url_col {[ad_decode $display_mode edit view_url ""]}
+}
+
+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 " \${label_state_$state_id}" \
+ html { align center } \
+ display_template "
+
+
+ Assigned
+
+
+ Enabled
+
+
+
+
+
+ "]
+
+ lappend states $state_id
+}
+
+lappend elements add_state {
+ label {
+
+ }
+ display_template { }
+}
+
+
+
+lappend elements delete {
+ sub_class narrow
+ hide_p {[ad_decode $display_mode edit 0 1]}
+ display_template {
+
+
+
+ }
+}
+
template::list::create \
-name tasks \
-multirow tasks \
-no_data "No tasks in this Simulation Template" \
-actions $actions \
- -elements {
- edit {
- hide_p {[ad_decode $display_mode edit 0 1]}
- sub_class narrow
- link_url_col edit_url
- display_template {
-
- }
- }
- name {
- label "Name"
- display_col pretty_name
- link_url_col {[ad_decode $display_mode edit view_url ""]}
- }
- assigned_name {
- label "Assigned to"
- }
- recipient_name {
- label "Recipient"
- }
- delete {
- sub_class narrow
- hide_p {[ad_decode $display_mode edit 0 1]}
- display_template {
-
-
-
- }
- }
- }
+ -elements $elements
#-------------------------------------------------------------
# tasks db_multirow
#-------------------------------------------------------------
-# TODO: fix this so it returns rows when it should
-set return_url "[ad_conn url]?[ad_conn query]"
-db_multirow -extend { edit_url view_url delete_url } tasks select_tasks "
+# 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
+
+foreach state_id $states {
+ lappend extend state_$state_id
+}
+
+array set enabled_in_state [list]
+
+# Ordering by assigned_p, so we get assigned states ('t') last
+db_foreach select_enabled_in_states {
+ select aeis.action_id,
+ aeis.state_id,
+ aeis.assigned_p
+ from workflow_actions a,
+ workflow_fsm_action_en_in_st aeis
+ where a.workflow_id = :workflow_id
+ and aeis.action_id = a.action_id
+ order by aeis.assigned_p
+} {
+ 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,
(select pretty_name
@@ -92,15 +173,33 @@
(select pretty_name
from workflow_roles
where role_id = st.recipient) as recipient_name,
- wa.sort_order
+ wa.sort_order,
+ wa.always_enabled_p
from workflow_actions wa,
sim_tasks st
where wa.workflow_id = :workflow_id
and st.task_id = wa.action_id
- order by lower(pretty_name)
+ 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 }]
+ set delete_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url [ad_return_url]} }]
+ 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"
+ }
+ }
+ }
}
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.2 -r1.3
--- openacs-4/contrib/packages/simulation/tcl/action-procs.tcl 1 Dec 2003 10:16:56 -0000 1.2
+++ openacs-4/contrib/packages/simulation/tcl/action-procs.tcl 9 Dec 2003 15:58:12 -0000 1.3
@@ -10,61 +10,42 @@
ad_proc -public simulation::action::edit {
{-action_id:required}
- {-sort_order {}}
- {-short_name:required}
- {-pretty_name:required}
- {-pretty_past_tense {}}
- {-edit_fields {}}
- {-allowed_roles {}}
- {-assigned_role {}}
- {-privileges {}}
- {-enabled_states {}}
- {-assigned_states {}}
- {-new_state {}}
- {-callbacks {}}
- {-always_enabled_p f}
- {-initial_action_p f}
- {-recipient_role:required {}}
- {-description {}}
- {-description_mime_type {}}
+ {-workflow_id {}}
+ {-array:required}
+ {-internal:boolean}
} {
- Edit an action. Mostly a wrapper for fsm, plus some simulation-specific stuff.
+ Edit an action. Mostly a wrapper for FSM, plus some simulation-specific stuff.
} {
-
- # should call API, but API doesn't exist yet
- # deferring at the moment since we're only changing two fields in this
- # prototype UI anyway. But it would look like this:
-
- # workflow::action::fsm::edit \
- # -workflow_id $workflow_id
- # -short_name $name \
- # -pretty_name $name \
- # -assigned_role $assigned_role
-
+ upvar 1 $array org_row
+ array set row [array get org_row]
-
-
- set workflow_id [workflow::action::get_workflow_id -action_id $action_id]
-
-
-
db_transaction {
- foreach col { short_name pretty_name assigned_role description description_mime_type } {
- set action_array($col) [set $col]
+ if { [info exists row(recipient_role)] } {
+ set recipient_role_id [workflow::role::get_id \
+ -workflow_id $workflow_id \
+ -short_name $row(recipient_role)]
+
+ db_dml edit_sim_role {
+ update sim_tasks
+ set recipient = :recipient_role_id
+ where task_id = :action_id
+ }
+
+ unset row(recipient_role)
}
-
+
workflow::action::fsm::edit \
+ -internal \
-action_id $action_id \
- -array action_array
+ -workflow_id $workflow_id \
+ -array row
- set recipient_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $recipient_role]
- db_dml edit_sim_role {
- update sim_tasks
- set recipient = :recipient_role_id
- where task_id = :action_id
+ if { !$internal_p } {
+ workflow::definition_changed_handler -workflow_id $workflow_id
}
}
- workflow::definition_changed_handler -workflow_id $workflow_id
- workflow::action::flush_cache -workflow_id $workflow_id
+ if { !$internal_p } {
+ workflow::flush_cache -workflow_id $workflow_id
+ }
}
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.6 -r1.7
--- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 1 Dec 2003 10:16:56 -0000 1.6
+++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 9 Dec 2003 15:58:12 -0000 1.7
@@ -33,16 +33,6 @@
-package_key $package_key \
-object_id $object_id]
- # TODO: this step should be rendered obsolete by updates to workflow
- # and then this step should be removed
- # create a dummy action with initial action setting because
- # workflow::get doesn't work on bare workflows
- workflow::action::fsm::new \
- -initial_action_p t \
- -workflow_id $workflow_id \
- -short_name "dummy action" \
- -pretty_name "dummy action"
-
insert_sim \
-workflow_id $workflow_id \
-ready_p $ready_p \
Index: openacs-4/contrib/packages/simulation/www/simbuild/initial-action-set.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/initial-action-set.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/simbuild/initial-action-set.tcl 9 Dec 2003 15:58:13 -0000 1.1
@@ -0,0 +1,15 @@
+ad_page_contract {
+ Set the initial action of a workflow.
+} {
+ action_id:integer
+ return_url
+}
+
+set row(initial_action_p) 1
+
+workflow::action::edit \
+ -action_id $action_id \
+ -array row
+
+ad_returnredirect $return_url
+
Index: openacs-4/contrib/packages/simulation/www/simbuild/state-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/state-edit.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/simbuild/state-edit.adp 9 Dec 2003 15:58:13 -0000 1.1
@@ -0,0 +1,7 @@
+
+ @page_title;noquote@
+ @context;noquote@
+ state.pretty_name
+
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/simbuild/state-edit.tcl 9 Dec 2003 15:58:13 -0000 1.1
@@ -0,0 +1,101 @@
+ad_page_contract {
+ Add/edit FSM state.
+
+ @creation-date 2003-12-09
+ @cvs-id $Id: state-edit.tcl,v 1.1 2003/12/09 15:58:13 lars Exp $
+} {
+ {workflow_id:integer ""}
+ state_id:integer,optional
+} -validate {
+ workflow_id_or_state_id {
+ if { ![exists_and_not_null workflow_id] &&
+ ![exists_and_not_null state_id]} {
+ ad_complain "Either state_id or workflow_id is required."
+ }
+ }
+}
+
+######################################################################
+#
+# preparation
+#
+######################################################################
+
+set package_key [ad_conn package_key]
+set package_id [ad_conn package_id]
+
+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)
+}
+
+workflow::get -workflow_id $workflow_id -array sim_template_array
+
+if { ![ad_form_new_p -key state_id] } {
+ set page_title "Edit State $state_array(pretty_name)"
+} else {
+
+ set page_title "Add State to $sim_template_array(pretty_name)"
+}
+set context [list [list "." "SimBuild"] [list [export_vars -base "template-edit" { workflow_id }] "$sim_template_array(pretty_name)"] $page_title]
+
+#---------------------------------------------------------------------
+# Get a list of relevant roles
+#---------------------------------------------------------------------
+set role_options [workflow::role::get_options -workflow_id $workflow_id]
+
+######################################################################
+#
+# state
+#
+# a form showing fields for a state in a workflow
+# includes add and edit modes and handles form submission
+# display mode is only in list form via template-edit
+#
+######################################################################
+
+#---------------------------------------------------------------------
+# 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 {
+ {state_id:key}
+ {workflow_id:integer(hidden)
+ {value $workflow_id}
+ }
+ {pretty_name:text
+ {label "State Name"}
+ {html {size 20}}
+ }
+} -edit_request {
+ set workflow_id $state_array(workflow_id)
+ permission::require_write_permission -object_id $workflow_id
+ set pretty_name $state_array(pretty_name)
+} -new_request {
+ permission::require_write_permission -object_id $workflow_id
+} -new_data {
+ permission::require_write_permission -object_id $workflow_id
+ # create the state
+
+ set state_id [workflow::state::fsm::new \
+ -workflow_id $workflow_id \
+ -pretty_name $pretty_name]
+
+} -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
+ # could be spoofed
+ permission::require_write_permission -object_id $state_array(workflow_id)
+
+ set row(pretty_name) $pretty_name
+ set row(short_name) {}
+
+ workflow::state::fsm::edit \
+ -state_id $state_id \
+ -workflow_id $state_array(workflow_id) \
+ -array row
+
+} -after_submit {
+ ad_returnredirect [export_vars -base "template-edit" { workflow_id }]
+ ad_script_abort
+}
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.4 -r1.5
--- openacs-4/contrib/packages/simulation/www/simbuild/task-edit.adp 1 Dec 2003 12:43:01 -0000 1.4
+++ openacs-4/contrib/packages/simulation/www/simbuild/task-edit.adp 9 Dec 2003 15:58:13 -0000 1.5
@@ -3,131 +3,5 @@
@context;noquote@task.name
-
TODO: selecting task type refreshes form (as in ../citybuild/sim-objects)
- AskInfo
- GiveInfo
- ReviewInfo
-
-
This is the master task editing form. For new tasks, we will
-instead have a two-part sequence: 1, pick a task type, such as
-"GiveInfo". 2) fill out certain pre-selected values relevant to that
-task type.
-
More info per task: MOCKUPS:
-
-
Simple Enabled if:
-
-
-
Task
-
Min Completions
-
Max Completions
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Fancy Enabled if:
-
-
-
-
Task
-
-
State
-
-
-
-
-
-
-
Is Is not
-
-
-
-
-
-
and or
-
-
-
-
Is Is not
-
-
-
-
-
-
and or
-
-
-
-
>
- >=
- =
- !=
- <=
- <
-
-
-
-
-
-
-
(B priority): additional recipients
-
Timeout: At duration after being enabled, task changes to state:
-
-
Repetitions. This task can be completed up to times.
-
Rating. Recipient (?) is given a list of choices to rate an
-input. Choices of choices: Pass/fail, letter grade, numeric grade.
-
-
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.6 -r1.7
--- openacs-4/contrib/packages/simulation/www/simbuild/task-edit.tcl 9 Dec 2003 09:52:45 -0000 1.6
+++ openacs-4/contrib/packages/simulation/www/simbuild/task-edit.tcl 9 Dec 2003 15:58:13 -0000 1.7
@@ -58,14 +58,10 @@
# task form
#---------------------------------------------------------------------
-ad_form -name task -edit_buttons [
- list [list [ad_decode [ad_form_new_p -key action_id] 1 [_ acs-kernel.common_add] [_ acs-kernel.common_edit]] ok]
- ] -form {
+
+ad_form -name task -export { workflow_id } -edit_buttons [list [list [ad_decode [ad_form_new_p -key action_id] 1 [_ acs-kernel.common_add] [_ acs-kernel.common_edit]] ok]] -form {
{action_id:key}
- {workflow_id:integer(hidden)
- {value $workflow_id}
- }
- {name:text
+ {pretty_name:text
{label "Task Name"}
{html {size 20}}
}
@@ -81,10 +77,30 @@
{label "Task Description"}
{html {cols 60 rows 8}}
}
-} -edit_request {
+}
+
+set enabled_options [list]
+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]
+}
+
+ad_form -extend -name task -form {
+ {assigned_state_ids:text(checkbox),optional,multiple
+ {label "Assigned"}
+ {options $enabled_options}
+ }
+ {enabled_state_ids:text(checkbox),optional,multiple
+ {label "Enabled"}
+ {options $enabled_options}
+ }
+}
+
+ad_form -extend -name task -edit_request {
set workflow_id $task_array(workflow_id)
permission::require_write_permission -object_id $workflow_id
- set name $task_array(pretty_name)
+ set pretty_name $task_array(pretty_name)
set description [template::util::richtext::create $task_array(description) $task_array(description_mime_type)]
set recipient_role_id [db_string select_recipient {
select recipient
@@ -93,26 +109,35 @@
}]
set recipient_role [workflow::role::get_element -role_id $recipient_role_id -element short_name]
- set assigned_role $task_array(assigned_role)
+ set assigned_role $task_array(assigned_role)
+
+ set assigned_state_ids $task_array(assigned_state_ids)
+ set enabled_state_ids $task_array(enabled_state_ids)
} -new_request {
permission::require_write_permission -object_id $workflow_id
} -on_submit {
- set description_content [template::util::richtext::get_property contents $description]
set description_mime_type [template::util::richtext::get_property format $description]
+ set description [template::util::richtext::get_property contents $description]
} -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 \
- -short_name $name \
- -pretty_name $name \
+ -pretty_name $pretty_name \
-assigned_role $assigned_role \
-description $description_content \
- -description_mime_type $description_mime_type]
+ -description_mime_type $description_mime_type \
+ -enabled_state_ids $enabled_state_ids \
+ -assigned_state_ids $assigned_state_ids]
+ # 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
@@ -127,14 +152,21 @@
# workflow_id, which is gotten from the form, because the workflow_id from the form
# could be spoofed
permission::require_write_permission -object_id $task_array(workflow_id)
+
+ # TODO IMPORTANT:
+ # Set short_name right -- or leave blank and have the workflow API construct a short_name
+
+ # TODO: enabled_states, assigned_states
+ array unset row
+ foreach col { pretty_name assigned_role recipient_role description description_mime_type enabled_state_ids assigned_state_ids } {
+ set row($col) [set $col]
+ }
+ set row(short_name) {}
+
simulation::action::edit \
-action_id $action_id \
- -short_name $name \
- -pretty_name $name \
- -assigned_role $assigned_role \
- -recipient_role $recipient_role \
- -description $description_content \
- -description_mime_type $description_mime_type
+ -workflow_id $task_array(workflow_id) \
+ -array row
} -after_submit {
ad_returnredirect [export_vars -base "template-edit" { workflow_id }]
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.5 -r1.6
--- openacs-4/contrib/packages/simulation/www/simbuild/template-edit.adp 9 Dec 2003 09:52:45 -0000 1.5
+++ openacs-4/contrib/packages/simulation/www/simbuild/template-edit.adp 9 Dec 2003 15:58:13 -0000 1.6
@@ -22,14 +22,6 @@
-
TODO: Allow sorting of roles, (states), tasks.
-
MOCKUP: workflow matrix
-
-
Talking to Client
Prepare Case
Submit
-Case
-
Ask information from Other Client
X
-
Respond to Ask information
X
-
INtervene
X
X
X
-
-
+
TODO: Allow sorting of roles, states, tasks.
+
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.8 -r1.9
--- openacs-4/packages/simulation/lib/sim-template-roles.tcl 1 Dec 2003 10:16:56 -0000 1.8
+++ openacs-4/packages/simulation/lib/sim-template-roles.tcl 9 Dec 2003 15:58:12 -0000 1.9
@@ -64,7 +64,7 @@
wr.sort_order
from workflow_roles wr
where wr.workflow_id = :workflow_id
- order by lower(pretty_name)
+ order by wr.sort_order
" {
set edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { role_id }]
set delete_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-delete" { role_id 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 -r1.7 -r1.8
--- openacs-4/packages/simulation/lib/sim-template-tasks.tcl 1 Dec 2003 10:16:56 -0000 1.7
+++ openacs-4/packages/simulation/lib/sim-template-tasks.tcl 9 Dec 2003 15:58:12 -0000 1.8
@@ -42,48 +42,129 @@
set actions ""
}
+set elements [list]
+lappend elements edit {
+ hide_p {[ad_decode $display_mode edit 0 1]}
+ sub_class narrow
+ link_url_col edit_url
+ display_template {
+
+ }
+}
+lappend elements initialize {
+ label "Initialize"
+ display_template {
+
+
+
+
+
+
+ }
+ html { align center }
+}
+lappend elements name {
+ label "Name"
+ display_col pretty_name
+ link_url_col {[ad_decode $display_mode edit view_url ""]}
+}
+
+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 " \${label_state_$state_id}" \
+ html { align center } \
+ display_template "
+
+
+ Assigned
+
+
+ Enabled
+
+
+
+
+
+ "]
+
+ lappend states $state_id
+}
+
+lappend elements add_state {
+ label {
+
+ }
+ display_template { }
+}
+
+
+
+lappend elements delete {
+ sub_class narrow
+ hide_p {[ad_decode $display_mode edit 0 1]}
+ display_template {
+
+
+
+ }
+}
+
template::list::create \
-name tasks \
-multirow tasks \
-no_data "No tasks in this Simulation Template" \
-actions $actions \
- -elements {
- edit {
- hide_p {[ad_decode $display_mode edit 0 1]}
- sub_class narrow
- link_url_col edit_url
- display_template {
-
- }
- }
- name {
- label "Name"
- display_col pretty_name
- link_url_col {[ad_decode $display_mode edit view_url ""]}
- }
- assigned_name {
- label "Assigned to"
- }
- recipient_name {
- label "Recipient"
- }
- delete {
- sub_class narrow
- hide_p {[ad_decode $display_mode edit 0 1]}
- display_template {
-
-
-
- }
- }
- }
+ -elements $elements
#-------------------------------------------------------------
# tasks db_multirow
#-------------------------------------------------------------
-# TODO: fix this so it returns rows when it should
-set return_url "[ad_conn url]?[ad_conn query]"
-db_multirow -extend { edit_url view_url delete_url } tasks select_tasks "
+# 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
+
+foreach state_id $states {
+ lappend extend state_$state_id
+}
+
+array set enabled_in_state [list]
+
+# Ordering by assigned_p, so we get assigned states ('t') last
+db_foreach select_enabled_in_states {
+ select aeis.action_id,
+ aeis.state_id,
+ aeis.assigned_p
+ from workflow_actions a,
+ workflow_fsm_action_en_in_st aeis
+ where a.workflow_id = :workflow_id
+ and aeis.action_id = a.action_id
+ order by aeis.assigned_p
+} {
+ 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,
(select pretty_name
@@ -92,15 +173,33 @@
(select pretty_name
from workflow_roles
where role_id = st.recipient) as recipient_name,
- wa.sort_order
+ wa.sort_order,
+ wa.always_enabled_p
from workflow_actions wa,
sim_tasks st
where wa.workflow_id = :workflow_id
and st.task_id = wa.action_id
- order by lower(pretty_name)
+ 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 }]
+ set delete_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url [ad_return_url]} }]
+ 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"
+ }
+ }
+ }
}
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.2 -r1.3
--- openacs-4/packages/simulation/tcl/action-procs.tcl 1 Dec 2003 10:16:56 -0000 1.2
+++ openacs-4/packages/simulation/tcl/action-procs.tcl 9 Dec 2003 15:58:12 -0000 1.3
@@ -10,61 +10,42 @@
ad_proc -public simulation::action::edit {
{-action_id:required}
- {-sort_order {}}
- {-short_name:required}
- {-pretty_name:required}
- {-pretty_past_tense {}}
- {-edit_fields {}}
- {-allowed_roles {}}
- {-assigned_role {}}
- {-privileges {}}
- {-enabled_states {}}
- {-assigned_states {}}
- {-new_state {}}
- {-callbacks {}}
- {-always_enabled_p f}
- {-initial_action_p f}
- {-recipient_role:required {}}
- {-description {}}
- {-description_mime_type {}}
+ {-workflow_id {}}
+ {-array:required}
+ {-internal:boolean}
} {
- Edit an action. Mostly a wrapper for fsm, plus some simulation-specific stuff.
+ Edit an action. Mostly a wrapper for FSM, plus some simulation-specific stuff.
} {
-
- # should call API, but API doesn't exist yet
- # deferring at the moment since we're only changing two fields in this
- # prototype UI anyway. But it would look like this:
-
- # workflow::action::fsm::edit \
- # -workflow_id $workflow_id
- # -short_name $name \
- # -pretty_name $name \
- # -assigned_role $assigned_role
-
+ upvar 1 $array org_row
+ array set row [array get org_row]
-
-
- set workflow_id [workflow::action::get_workflow_id -action_id $action_id]
-
-
-
db_transaction {
- foreach col { short_name pretty_name assigned_role description description_mime_type } {
- set action_array($col) [set $col]
+ if { [info exists row(recipient_role)] } {
+ set recipient_role_id [workflow::role::get_id \
+ -workflow_id $workflow_id \
+ -short_name $row(recipient_role)]
+
+ db_dml edit_sim_role {
+ update sim_tasks
+ set recipient = :recipient_role_id
+ where task_id = :action_id
+ }
+
+ unset row(recipient_role)
}
-
+
workflow::action::fsm::edit \
+ -internal \
-action_id $action_id \
- -array action_array
+ -workflow_id $workflow_id \
+ -array row
- set recipient_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $recipient_role]
- db_dml edit_sim_role {
- update sim_tasks
- set recipient = :recipient_role_id
- where task_id = :action_id
+ if { !$internal_p } {
+ workflow::definition_changed_handler -workflow_id $workflow_id
}
}
- workflow::definition_changed_handler -workflow_id $workflow_id
- workflow::action::flush_cache -workflow_id $workflow_id
+ if { !$internal_p } {
+ workflow::flush_cache -workflow_id $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.6 -r1.7
--- openacs-4/packages/simulation/tcl/template-procs.tcl 1 Dec 2003 10:16:56 -0000 1.6
+++ openacs-4/packages/simulation/tcl/template-procs.tcl 9 Dec 2003 15:58:12 -0000 1.7
@@ -33,16 +33,6 @@
-package_key $package_key \
-object_id $object_id]
- # TODO: this step should be rendered obsolete by updates to workflow
- # and then this step should be removed
- # create a dummy action with initial action setting because
- # workflow::get doesn't work on bare workflows
- workflow::action::fsm::new \
- -initial_action_p t \
- -workflow_id $workflow_id \
- -short_name "dummy action" \
- -pretty_name "dummy action"
-
insert_sim \
-workflow_id $workflow_id \
-ready_p $ready_p \
Index: openacs-4/packages/simulation/www/simbuild/initial-action-set.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/Attic/initial-action-set.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/www/simbuild/initial-action-set.tcl 9 Dec 2003 15:58:13 -0000 1.1
@@ -0,0 +1,15 @@
+ad_page_contract {
+ Set the initial action of a workflow.
+} {
+ action_id:integer
+ return_url
+}
+
+set row(initial_action_p) 1
+
+workflow::action::edit \
+ -action_id $action_id \
+ -array row
+
+ad_returnredirect $return_url
+
Index: openacs-4/packages/simulation/www/simbuild/state-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/state-edit.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/www/simbuild/state-edit.adp 9 Dec 2003 15:58:13 -0000 1.1
@@ -0,0 +1,7 @@
+
+ @page_title;noquote@
+ @context;noquote@
+ state.pretty_name
+
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/www/simbuild/state-edit.tcl 9 Dec 2003 15:58:13 -0000 1.1
@@ -0,0 +1,101 @@
+ad_page_contract {
+ Add/edit FSM state.
+
+ @creation-date 2003-12-09
+ @cvs-id $Id: state-edit.tcl,v 1.1 2003/12/09 15:58:13 lars Exp $
+} {
+ {workflow_id:integer ""}
+ state_id:integer,optional
+} -validate {
+ workflow_id_or_state_id {
+ if { ![exists_and_not_null workflow_id] &&
+ ![exists_and_not_null state_id]} {
+ ad_complain "Either state_id or workflow_id is required."
+ }
+ }
+}
+
+######################################################################
+#
+# preparation
+#
+######################################################################
+
+set package_key [ad_conn package_key]
+set package_id [ad_conn package_id]
+
+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)
+}
+
+workflow::get -workflow_id $workflow_id -array sim_template_array
+
+if { ![ad_form_new_p -key state_id] } {
+ set page_title "Edit State $state_array(pretty_name)"
+} else {
+
+ set page_title "Add State to $sim_template_array(pretty_name)"
+}
+set context [list [list "." "SimBuild"] [list [export_vars -base "template-edit" { workflow_id }] "$sim_template_array(pretty_name)"] $page_title]
+
+#---------------------------------------------------------------------
+# Get a list of relevant roles
+#---------------------------------------------------------------------
+set role_options [workflow::role::get_options -workflow_id $workflow_id]
+
+######################################################################
+#
+# state
+#
+# a form showing fields for a state in a workflow
+# includes add and edit modes and handles form submission
+# display mode is only in list form via template-edit
+#
+######################################################################
+
+#---------------------------------------------------------------------
+# 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 {
+ {state_id:key}
+ {workflow_id:integer(hidden)
+ {value $workflow_id}
+ }
+ {pretty_name:text
+ {label "State Name"}
+ {html {size 20}}
+ }
+} -edit_request {
+ set workflow_id $state_array(workflow_id)
+ permission::require_write_permission -object_id $workflow_id
+ set pretty_name $state_array(pretty_name)
+} -new_request {
+ permission::require_write_permission -object_id $workflow_id
+} -new_data {
+ permission::require_write_permission -object_id $workflow_id
+ # create the state
+
+ set state_id [workflow::state::fsm::new \
+ -workflow_id $workflow_id \
+ -pretty_name $pretty_name]
+
+} -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
+ # could be spoofed
+ permission::require_write_permission -object_id $state_array(workflow_id)
+
+ set row(pretty_name) $pretty_name
+ set row(short_name) {}
+
+ workflow::state::fsm::edit \
+ -state_id $state_id \
+ -workflow_id $state_array(workflow_id) \
+ -array row
+
+} -after_submit {
+ ad_returnredirect [export_vars -base "template-edit" { workflow_id }]
+ ad_script_abort
+}
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.4 -r1.5
--- openacs-4/packages/simulation/www/simbuild/task-edit.adp 1 Dec 2003 12:43:01 -0000 1.4
+++ openacs-4/packages/simulation/www/simbuild/task-edit.adp 9 Dec 2003 15:58:13 -0000 1.5
@@ -3,131 +3,5 @@
@context;noquote@task.name
-
TODO: selecting task type refreshes form (as in ../citybuild/sim-objects)
- AskInfo
- GiveInfo
- ReviewInfo
-
-
This is the master task editing form. For new tasks, we will
-instead have a two-part sequence: 1, pick a task type, such as
-"GiveInfo". 2) fill out certain pre-selected values relevant to that
-task type.
-
More info per task: MOCKUPS:
-
-
Simple Enabled if:
-
-
-
Task
-
Min Completions
-
Max Completions
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Fancy Enabled if:
-
-
-
-
Task
-
-
State
-
-
-
-
-
-
-
Is Is not
-
-
-
-
-
-
and or
-
-
-
-
Is Is not
-
-
-
-
-
-
and or
-
-
-
-
>
- >=
- =
- !=
- <=
- <
-
-
-
-
-
-
-
(B priority): additional recipients
-
Timeout: At duration after being enabled, task changes to state:
-
-
Repetitions. This task can be completed up to times.
-
Rating. Recipient (?) is given a list of choices to rate an
-input. Choices of choices: Pass/fail, letter grade, numeric grade.
-
-
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.6 -r1.7
--- openacs-4/packages/simulation/www/simbuild/task-edit.tcl 9 Dec 2003 09:52:45 -0000 1.6
+++ openacs-4/packages/simulation/www/simbuild/task-edit.tcl 9 Dec 2003 15:58:13 -0000 1.7
@@ -58,14 +58,10 @@
# task form
#---------------------------------------------------------------------
-ad_form -name task -edit_buttons [
- list [list [ad_decode [ad_form_new_p -key action_id] 1 [_ acs-kernel.common_add] [_ acs-kernel.common_edit]] ok]
- ] -form {
+
+ad_form -name task -export { workflow_id } -edit_buttons [list [list [ad_decode [ad_form_new_p -key action_id] 1 [_ acs-kernel.common_add] [_ acs-kernel.common_edit]] ok]] -form {
{action_id:key}
- {workflow_id:integer(hidden)
- {value $workflow_id}
- }
- {name:text
+ {pretty_name:text
{label "Task Name"}
{html {size 20}}
}
@@ -81,10 +77,30 @@
{label "Task Description"}
{html {cols 60 rows 8}}
}
-} -edit_request {
+}
+
+set enabled_options [list]
+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]
+}
+
+ad_form -extend -name task -form {
+ {assigned_state_ids:text(checkbox),optional,multiple
+ {label "Assigned"}
+ {options $enabled_options}
+ }
+ {enabled_state_ids:text(checkbox),optional,multiple
+ {label "Enabled"}
+ {options $enabled_options}
+ }
+}
+
+ad_form -extend -name task -edit_request {
set workflow_id $task_array(workflow_id)
permission::require_write_permission -object_id $workflow_id
- set name $task_array(pretty_name)
+ set pretty_name $task_array(pretty_name)
set description [template::util::richtext::create $task_array(description) $task_array(description_mime_type)]
set recipient_role_id [db_string select_recipient {
select recipient
@@ -93,26 +109,35 @@
}]
set recipient_role [workflow::role::get_element -role_id $recipient_role_id -element short_name]
- set assigned_role $task_array(assigned_role)
+ set assigned_role $task_array(assigned_role)
+
+ set assigned_state_ids $task_array(assigned_state_ids)
+ set enabled_state_ids $task_array(enabled_state_ids)
} -new_request {
permission::require_write_permission -object_id $workflow_id
} -on_submit {
- set description_content [template::util::richtext::get_property contents $description]
set description_mime_type [template::util::richtext::get_property format $description]
+ set description [template::util::richtext::get_property contents $description]
} -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 \
- -short_name $name \
- -pretty_name $name \
+ -pretty_name $pretty_name \
-assigned_role $assigned_role \
-description $description_content \
- -description_mime_type $description_mime_type]
+ -description_mime_type $description_mime_type \
+ -enabled_state_ids $enabled_state_ids \
+ -assigned_state_ids $assigned_state_ids]
+ # 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
@@ -127,14 +152,21 @@
# workflow_id, which is gotten from the form, because the workflow_id from the form
# could be spoofed
permission::require_write_permission -object_id $task_array(workflow_id)
+
+ # TODO IMPORTANT:
+ # Set short_name right -- or leave blank and have the workflow API construct a short_name
+
+ # TODO: enabled_states, assigned_states
+ array unset row
+ foreach col { pretty_name assigned_role recipient_role description description_mime_type enabled_state_ids assigned_state_ids } {
+ set row($col) [set $col]
+ }
+ set row(short_name) {}
+
simulation::action::edit \
-action_id $action_id \
- -short_name $name \
- -pretty_name $name \
- -assigned_role $assigned_role \
- -recipient_role $recipient_role \
- -description $description_content \
- -description_mime_type $description_mime_type
+ -workflow_id $task_array(workflow_id) \
+ -array row
} -after_submit {
ad_returnredirect [export_vars -base "template-edit" { workflow_id }]
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.5 -r1.6
--- openacs-4/packages/simulation/www/simbuild/template-edit.adp 9 Dec 2003 09:52:45 -0000 1.5
+++ openacs-4/packages/simulation/www/simbuild/template-edit.adp 9 Dec 2003 15:58:13 -0000 1.6
@@ -22,14 +22,6 @@
-