Index: openacs-4/contrib/packages/simulation/lib/sim-template-tasks.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-tasks.adp,v diff -u -N -r1.6 -r1.7 --- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.adp 7 Jan 2004 14:44:08 -0000 1.6 +++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.adp 8 Jan 2004 10:50:34 -0000 1.7 @@ -1,3 +1,6 @@ - + + +

+ +
- 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 -N -r1.20 -r1.21 --- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 8 Jan 2004 09:30:50 -0000 1.20 +++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 8 Jan 2004 10:50:34 -0000 1.21 @@ -37,10 +37,10 @@ # how is type going to work? open question pending prototyping if { $display_mode == "edit"} { - set actions [list "Add a State" [export_vars -base state-edit { workflow_id}] {}] - lappend actions "Add a Task" [export_vars -base task-edit {workflow_id} ] {} + set list_actions [list "Add a State" [export_vars -base state-edit { workflow_id}] {}] + lappend list_actions "Add a Task" [export_vars -base task-edit {workflow_id} ] {} } else { - set actions "" + set list_actions [list] } set elements [list] @@ -53,25 +53,36 @@ } } lappend elements name { - label "Name" + label "
Name" display_col pretty_name link_url_col {[ad_decode $display_mode edit view_url ""]} } lappend elements assigned_name { - label "Assignee" + label "
Assignee" link_url_col assigned_role_edit_url } lappend elements recipient_name { - label "Recipient" + label "
Recipient" link_url_col recipient_role_edit_url } +lappend elements delete { + sub_class narrow + hide_p {[ad_decode $display_mode edit 0 1]} + display_template { + + Edit + + } +} + lappend elements state_spacer { - label "|   States:" + label "
States:" sub_class narrow display_template " " + html { style "border-left: 2px dotted #A0BDEB;" } } set states [list] @@ -86,10 +97,15 @@ } { set "label_state_$state_id" $pretty_name lappend elements state_$state_id \ - [list label "\${label_state_$state_id}
\"Edit\"\"Delete\"" \ + [list label "\"Edit\"\"Delete\"
\${label_state_$state_id}" \ html { align center } \ display_template " - + + + + + + "] lappend states $state_id @@ -101,22 +117,13 @@ } } -lappend elements delete { - sub_class narrow - hide_p {[ad_decode $display_mode edit 0 1]} - display_template { - - Edit - - } -} template::list::create \ -name tasks \ -multirow tasks \ -no_data "No tasks in this Simulation Template" \ -sub_class narrow \ - -actions $actions \ + -actions $list_actions \ -elements $elements #------------------------------------------------------------- @@ -151,6 +158,17 @@ set enabled_in_state($action_id,$state_id) $assigned_p } +ad_form -name enabled_tasks -form { + {workflow_id:integer(hidden) {value $workflow_id}} +} -edit_buttons { + { "Save changes" ok } +} + + + + +set actions [list] + db_multirow -extend $extend tasks select_tasks " select wa.action_id, wa.pretty_name, @@ -187,7 +205,12 @@ 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 { + + ad_form -extend -name enabled_tasks -form \ + [list [list __enabled__${action_id}__${state_id}:text,optional]] + if { [info exists enabled_in_state($action_id,$state_id)] } { + set __enabled__${action_id}__${state_id} "t" if { [template::util::is_true $enabled_in_state($action_id,$state_id)] } { set state_$state_id assigned } else { @@ -198,6 +221,57 @@ set move_to_$state_id 1 } } + + lappend actions $action_id } +ad_form \ + -extend \ + -name enabled_tasks \ + -form { + {actions:text(hidden),optional {value $actions}} + {states:text(hidden),optional {value $states}} + } \ + -on_request { + # Grab values from local vars + #error request + } \ + -on_submit { + db_transaction { + foreach state_id $states { + foreach action_id $actions { + set currently_enabled_p [db_string enabled_p { + select 1 + from workflow_fsm_action_en_in_st + where action_id = :action_id + and state_id = :state_id + } -default 0] + + set should_be_enabled_p [exists_and_equal __enabled__${action_id}__${state_id} "t"] + ds_comment "Action=$action_id, State=$state_id. Today=$currently_enabled_p, Tomorrow=$should_be_enabled_p" + + if { $currently_enabled_p != $should_be_enabled_p} { + if { $should_be_enabled_p } { + db_dml enabled { + insert into workflow_fsm_action_en_in_st (action_id, state_id, assigned_p) + values (:action_id, :state_id, 't') + } + } else { + db_dml disable { + delete + from workflow_fsm_action_en_in_st + where action_id = :action_id + and state_id = :state_id + } + } + } + } + } + } + + } -after_submit { + ad_returnredirect [export_vars -base [ad_conn url] { workflow_id }] + 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 -N -r1.16 -r1.17 --- openacs-4/contrib/packages/simulation/www/simbuild/template-edit.adp 7 Jan 2004 13:12:17 -0000 1.16 +++ openacs-4/contrib/packages/simulation/www/simbuild/template-edit.adp 8 Jan 2004 10:50:34 -0000 1.17 @@ -17,16 +17,18 @@

-

TODO: B: Allow reordering of roles, tasks.

-

TODO: Hide the init state and init task. Auto-create and - maintain an init task pointing to the first state column. -

TODO: Allow reordering of state columns. -

TODO: B: When Ready for Use Checkbox is in display (not edit) - mode, show only the text "yes" or "no" instead of showing a disabled checkbox

- TODO: If !ready_p, display "Mark this template ready for use" link +

TODO: B: Allow reordering of roles, tasks, states.

+ Download a specification for this template + + + Mark this template ready for use + + Start a simulation with this template + Delete 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 -N -r1.14 -r1.15 --- openacs-4/contrib/packages/simulation/www/simbuild/template-edit.tcl 7 Jan 2004 13:12:17 -0000 1.14 +++ openacs-4/contrib/packages/simulation/www/simbuild/template-edit.tcl 8 Jan 2004 10:50:34 -0000 1.15 @@ -42,11 +42,20 @@ } if { ![ad_form_new_p -key workflow_id] } { - ad_form -extend -name sim_template -form { - {template_ready_p:boolean(checkbox),optional - {label "Ready for use?"} - {options {{"Yes" t}}} + if { [empty_string_p [form get_action sim_template]] } { + ad_form -extend -name sim_template -form { + {template_ready_p:boolean(select),optional + {label "Ready for use?"} + {options {{"Yes" t} { "No" f }}} + } } + } else { + ad_form -extend -name sim_template -form { + {template_ready_p:boolean(checkbox),optional + {label "Ready for use?"} + {options {{"Yes" t}}} + } + } } } else { ad_form -extend -name sim_template -form { @@ -163,3 +172,7 @@ set spec_url [export_vars -base template-spec { workflow_id }] + +if { [string equal $sim_template_array(sim_type) "dev_template"] } { + set mark_ready_url [export_vars -base "template-sim-type-update" { workflow_id }] +} Index: openacs-4/contrib/packages/simulation/www/simbuild/template-sim-type-update.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/template-sim-type-update.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/simbuild/template-sim-type-update.tcl 8 Jan 2004 10:50:34 -0000 1.1 @@ -0,0 +1,17 @@ +ad_page_contract { + Mark a template ready for use +} { + workflow_id:integer + {sim_type "ready_template"} + {return_url {[export_vars -base "template-edit" { workflow_id }]}} +} + +permission::require_write_permission -object_id $workflow_id + +set row(sim_type) $sim_type + +simulation::template::edit \ + -workflow_id $workflow_id \ + -array row + +ad_returnredirect $return_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 -N -r1.6 -r1.7 --- openacs-4/packages/simulation/lib/sim-template-tasks.adp 7 Jan 2004 14:44:08 -0000 1.6 +++ openacs-4/packages/simulation/lib/sim-template-tasks.adp 8 Jan 2004 10:50:34 -0000 1.7 @@ -1,3 +1,6 @@ - + + +

+ +
- 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 -N -r1.20 -r1.21 --- openacs-4/packages/simulation/lib/sim-template-tasks.tcl 8 Jan 2004 09:30:50 -0000 1.20 +++ openacs-4/packages/simulation/lib/sim-template-tasks.tcl 8 Jan 2004 10:50:34 -0000 1.21 @@ -37,10 +37,10 @@ # how is type going to work? open question pending prototyping if { $display_mode == "edit"} { - set actions [list "Add a State" [export_vars -base state-edit { workflow_id}] {}] - lappend actions "Add a Task" [export_vars -base task-edit {workflow_id} ] {} + set list_actions [list "Add a State" [export_vars -base state-edit { workflow_id}] {}] + lappend list_actions "Add a Task" [export_vars -base task-edit {workflow_id} ] {} } else { - set actions "" + set list_actions [list] } set elements [list] @@ -53,25 +53,36 @@ } } lappend elements name { - label "Name" + label "
Name" display_col pretty_name link_url_col {[ad_decode $display_mode edit view_url ""]} } lappend elements assigned_name { - label "Assignee" + label "
Assignee" link_url_col assigned_role_edit_url } lappend elements recipient_name { - label "Recipient" + label "
Recipient" link_url_col recipient_role_edit_url } +lappend elements delete { + sub_class narrow + hide_p {[ad_decode $display_mode edit 0 1]} + display_template { + + Edit + + } +} + lappend elements state_spacer { - label "|   States:" + label "
States:" sub_class narrow display_template " " + html { style "border-left: 2px dotted #A0BDEB;" } } set states [list] @@ -86,10 +97,15 @@ } { set "label_state_$state_id" $pretty_name lappend elements state_$state_id \ - [list label "\${label_state_$state_id}
\"Edit\"\"Delete\"" \ + [list label "\"Edit\"\"Delete\"
\${label_state_$state_id}" \ html { align center } \ display_template " - + + + + + + "] lappend states $state_id @@ -101,22 +117,13 @@ } } -lappend elements delete { - sub_class narrow - hide_p {[ad_decode $display_mode edit 0 1]} - display_template { - - Edit - - } -} template::list::create \ -name tasks \ -multirow tasks \ -no_data "No tasks in this Simulation Template" \ -sub_class narrow \ - -actions $actions \ + -actions $list_actions \ -elements $elements #------------------------------------------------------------- @@ -151,6 +158,17 @@ set enabled_in_state($action_id,$state_id) $assigned_p } +ad_form -name enabled_tasks -form { + {workflow_id:integer(hidden) {value $workflow_id}} +} -edit_buttons { + { "Save changes" ok } +} + + + + +set actions [list] + db_multirow -extend $extend tasks select_tasks " select wa.action_id, wa.pretty_name, @@ -187,7 +205,12 @@ 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 { + + ad_form -extend -name enabled_tasks -form \ + [list [list __enabled__${action_id}__${state_id}:text,optional]] + if { [info exists enabled_in_state($action_id,$state_id)] } { + set __enabled__${action_id}__${state_id} "t" if { [template::util::is_true $enabled_in_state($action_id,$state_id)] } { set state_$state_id assigned } else { @@ -198,6 +221,57 @@ set move_to_$state_id 1 } } + + lappend actions $action_id } +ad_form \ + -extend \ + -name enabled_tasks \ + -form { + {actions:text(hidden),optional {value $actions}} + {states:text(hidden),optional {value $states}} + } \ + -on_request { + # Grab values from local vars + #error request + } \ + -on_submit { + db_transaction { + foreach state_id $states { + foreach action_id $actions { + set currently_enabled_p [db_string enabled_p { + select 1 + from workflow_fsm_action_en_in_st + where action_id = :action_id + and state_id = :state_id + } -default 0] + + set should_be_enabled_p [exists_and_equal __enabled__${action_id}__${state_id} "t"] + ds_comment "Action=$action_id, State=$state_id. Today=$currently_enabled_p, Tomorrow=$should_be_enabled_p" + + if { $currently_enabled_p != $should_be_enabled_p} { + if { $should_be_enabled_p } { + db_dml enabled { + insert into workflow_fsm_action_en_in_st (action_id, state_id, assigned_p) + values (:action_id, :state_id, 't') + } + } else { + db_dml disable { + delete + from workflow_fsm_action_en_in_st + where action_id = :action_id + and state_id = :state_id + } + } + } + } + } + } + + } -after_submit { + ad_returnredirect [export_vars -base [ad_conn url] { workflow_id }] + 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 -N -r1.16 -r1.17 --- openacs-4/packages/simulation/www/simbuild/template-edit.adp 7 Jan 2004 13:12:17 -0000 1.16 +++ openacs-4/packages/simulation/www/simbuild/template-edit.adp 8 Jan 2004 10:50:34 -0000 1.17 @@ -17,16 +17,18 @@

-

TODO: B: Allow reordering of roles, tasks.

-

TODO: Hide the init state and init task. Auto-create and - maintain an init task pointing to the first state column. -

TODO: Allow reordering of state columns. -

TODO: B: When Ready for Use Checkbox is in display (not edit) - mode, show only the text "yes" or "no" instead of showing a disabled checkbox

- TODO: If !ready_p, display "Mark this template ready for use" link +

TODO: B: Allow reordering of roles, tasks, states.

+ Download a specification for this template + + + Mark this template ready for use + + Start a simulation with this template + Delete 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 -N -r1.14 -r1.15 --- openacs-4/packages/simulation/www/simbuild/template-edit.tcl 7 Jan 2004 13:12:17 -0000 1.14 +++ openacs-4/packages/simulation/www/simbuild/template-edit.tcl 8 Jan 2004 10:50:34 -0000 1.15 @@ -42,11 +42,20 @@ } if { ![ad_form_new_p -key workflow_id] } { - ad_form -extend -name sim_template -form { - {template_ready_p:boolean(checkbox),optional - {label "Ready for use?"} - {options {{"Yes" t}}} + if { [empty_string_p [form get_action sim_template]] } { + ad_form -extend -name sim_template -form { + {template_ready_p:boolean(select),optional + {label "Ready for use?"} + {options {{"Yes" t} { "No" f }}} + } } + } else { + ad_form -extend -name sim_template -form { + {template_ready_p:boolean(checkbox),optional + {label "Ready for use?"} + {options {{"Yes" t}}} + } + } } } else { ad_form -extend -name sim_template -form { @@ -163,3 +172,7 @@ set spec_url [export_vars -base template-spec { workflow_id }] + +if { [string equal $sim_template_array(sim_type) "dev_template"] } { + set mark_ready_url [export_vars -base "template-sim-type-update" { workflow_id }] +} Index: openacs-4/packages/simulation/www/simbuild/template-sim-type-update.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/template-sim-type-update.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/simbuild/template-sim-type-update.tcl 8 Jan 2004 10:50:34 -0000 1.1 @@ -0,0 +1,17 @@ +ad_page_contract { + Mark a template ready for use +} { + workflow_id:integer + {sim_type "ready_template"} + {return_url {[export_vars -base "template-edit" { workflow_id }]}} +} + +permission::require_write_permission -object_id $workflow_id + +set row(sim_type) $sim_type + +simulation::template::edit \ + -workflow_id $workflow_id \ + -array row + +ad_returnredirect $return_url