Index: openacs-4/packages/simulation/lib/tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/tasks.tcl,v diff -u -N -r1.13 -r1.14 --- openacs-4/packages/simulation/lib/tasks.tcl 23 Jan 2004 15:35:18 -0000 1.13 +++ openacs-4/packages/simulation/lib/tasks.tcl 4 Mar 2004 12:09:43 -0000 1.14 @@ -14,12 +14,19 @@ role_id { default_value "" } + workflow_id { + default_value "" + } } if { [empty_string_p $case_id] } { unset case_id } +if { [empty_string_p $user_id] } { + set user_id [ad_conn user_id] +} + set package_id [ad_conn package_id] set adminplayer_p [permission::permission_p -object_id $package_id -privilege sim_adminplayer] @@ -60,11 +67,83 @@ } } +set bulk_actions "" +set role_values "" +set task_values "" +set bulk_p 0 +if { ![empty_string_p $workflow_id] } { + # We are listing tasks across cases in a workflow. + # Enable the role filter. + + set role_values [db_list_of_lists select_roles { + select wr.pretty_name, + wr.role_id + from workflow_roles wr + where wr.workflow_id = :workflow_id + and exists (select 1 + from workflow_case_role_user_map wcrum, + workflow_case_assigned_actions wcaa + where wcrum.case_id = wcaa.case_id + and wcrum.role_id = wcaa.role_id + and wcrum.role_id = wr.role_id + and wcrum.user_id = :user_id + ) + }] + + if { [llength $role_values] <= 1 } { + # Don't display a filter with one option + set role_values {} + } + + set task_values [db_list_of_lists select_tasks { + select wa.pretty_name, + wa.action_id + from workflow_actions wa + where wa.workflow_id = :workflow_id + and exists (select 1 + from workflow_case_role_user_map wcrum, + workflow_case_assigned_actions wcaa + where wcrum.case_id = wcaa.case_id + and wcrum.role_id = wcaa.role_id + and wcaa.action_id = wa.action_id + and wcrum.user_id = :user_id + ) + }] + + if { [llength $task_values] <= 1 } { + # Don't display a filter with one option + set task_values {} + } + + set bulk_actions { + "Respond" task-detail "Take action on selected tasks" + } + set bulk_p 1 +} + template::list::create \ -name tasks \ -multirow tasks \ -no_data "You don't have any tasks." \ - -elements $elements + -key "enabled_action_id" \ + -elements $elements \ + -filters { + role_id { + label "Role" + values $role_values + hide_p {[ad_decode [llength $role_values] 0 t f]} + } + task_id { + label "Task" + values $task_values + hide_p {[ad_decode [llength $task_values] 0 t f]} + } + workflow_id { + hide_p t + } + } \ + -bulk_actions $bulk_actions \ + -bulk_action_export_vars { bulk_p } # NOTE: Our "pick case and role" design of simplay doesn't work if a child workflow uses per_user mapping # because the role in the child workflow will then no longer match any role in the top case. @@ -88,6 +167,7 @@ and sc.sim_case_id = topwc.object_id and w.workflow_id = topwc.workflow_id and wr.role_id = wcaa.role_id + [ad_decode [exists_and_not_null workflow_id] 1 "and w.workflow_id = :workflow_id" ""] [ad_decode [exists_and_not_null role_id] 1 "and wcaa.role_id = :role_id" ""] [ad_decode [exists_and_not_null case_id] 1 "and wcaa.case_id = :case_id" "and exists (select 1 from workflow_case_role_user_map @@ -96,7 +176,5 @@ and user_id = :user_id)"] order by wa.sort_order " { - set task_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/task-detail" { enabled_action_id case_id role_id }] + set task_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/task-detail" { enabled_action_id case_id role_id bulk_p }] } - -