Index: openacs-4/contrib/packages/simulation/www/simbuild/template-object-reorder.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/template-object-reorder.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/simbuild/template-object-reorder.tcl 12 Jan 2004 11:31:01 -0000 1.1
@@ -0,0 +1,58 @@
+ad_page_contract {
+ Move workflow object up/down. Handles states, actions, roles.
+} {
+ type:notnull
+ state_id:optional
+ action_id:optional
+ role_id:optional
+ {direction down}
+ {return_url "."}
+}
+
+# 1. find the sort_order of the object before or after this one
+# 2. set the sort order of this object to that object's sort order (if up), or that + 1 (if down)
+# 3.
+
+switch $type {
+ state {
+ set workflow_id [workflow::state::fsm::get_element -state_id $state_id -element workflow_id]
+
+ set state_ids [workflow::state::fsm::get_ids -workflow_id $workflow_id]
+
+ set cur_index [lsearch -exact $state_ids $state_id]
+
+ switch $direction {
+ up {
+ set new_index [expr $cur_index - 1]
+ }
+ down {
+ set new_index [expr $cur_index + 1]
+ }
+ }
+
+ if { $new_index >= 0 && $new_index < [llength $state_ids] } {
+ set new_sort_order [workflow::state::fsm::get_element -state_id [lindex $state_ids $new_index] -element sort_order]
+
+ if { [string equal $direction "down"] } {
+ set new_sort_order [expr $new_sort_order + 1]
+ }
+
+ set row(sort_order) $new_sort_order
+
+ workflow::state::fsm::edit \
+ -state_id $state_id \
+ -workflow_id $workflow_id \
+ -array row
+ }
+ }
+ role {
+
+ }
+ action {
+
+ }
+}
+
+
+
+ad_returnredirect $return_url
Index: openacs-4/packages/simulation/lib/sim-template-states.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-states.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/simulation/lib/sim-template-states.tcl 9 Jan 2004 10:53:06 -0000 1.1
+++ openacs-4/packages/simulation/lib/sim-template-states.tcl 12 Jan 2004 11:31:01 -0000 1.2
@@ -29,6 +29,22 @@
}
}
+ down {
+ sub_class narrow
+ display_template {
+
+
+
+ }
+ }
+ up {
+ sub_class narrow
+ display_template {
+
+
+
+ }
+ }
name {
label "Name"
display_col pretty_name
@@ -46,14 +62,24 @@
#-------------------------------------------------------------
# states db_multirow
#-------------------------------------------------------------
-set return_url "[ad_conn url]?[ad_conn query]"
-db_multirow -extend { edit_url char_url delete_url } states select_states "
+set counter 0
+db_multirow -extend { edit_url char_url delete_url up_url down_url } states select_states "
select ws.state_id,
- ws.pretty_name
+ ws.pretty_name,
+ ws.sort_order
from workflow_fsm_states ws
where ws.workflow_id = :workflow_id
order by ws.sort_order
" {
+ incr counter
set edit_url [export_vars -base "[ad_conn package_url]simbuild/state-edit" { state_id }]
- set delete_url [export_vars -base "[ad_conn package_url]simbuild/state-delete" { state_id return_url }]
+ set delete_url [export_vars -base "[ad_conn package_url]simbuild/state-delete" { state_id { return_url [ad_return_url] } }]
+ if { $counter > 1 } {
+ set up_url [export_vars -base "[ad_conn package_url]simbuild/template-object-reorder" { { type state } state_id { direction up } { return_url [ad_return_url] } }]
+ }
+ set down_url [export_vars -base "[ad_conn package_url]simbuild/template-object-reorder" { { type state } state_id { direction down } { return_url [ad_return_url] } }]
}
+
+
+# Get rid of the last down_url
+set states:${counter}(down_url) {}
Index: openacs-4/packages/simulation/lib/sim-template-tasks.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-tasks.adp,v
diff -u -r1.10 -r1.11
--- openacs-4/packages/simulation/lib/sim-template-tasks.adp 12 Jan 2004 10:58:37 -0000 1.10
+++ openacs-4/packages/simulation/lib/sim-template-tasks.adp 12 Jan 2004 11:31:01 -0000 1.11
@@ -1,6 +1,4 @@
-
TODO A (1h): Allow reordering of states.
-
TODO B (1h): Allow reordering of roles, tasks.
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.21 -r1.22
--- openacs-4/packages/simulation/www/simbuild/template-edit.adp 12 Jan 2004 10:58:37 -0000 1.21
+++ openacs-4/packages/simulation/www/simbuild/template-edit.adp 12 Jan 2004 11:31:01 -0000 1.22
@@ -38,7 +38,7 @@