Index: openacs-4/contrib/packages/simulation/tcl/sim-case-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/sim-case-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/simulation/tcl/sim-case-procs.tcl 5 Jan 2004 14:10:05 -0000 1.3
+++ openacs-4/contrib/packages/simulation/tcl/sim-case-procs.tcl 6 Jan 2004 13:11:54 -0000 1.4
@@ -84,3 +84,28 @@
return $sim_case_id
}
+
+
+ad_proc -public simulation::case::attachment_options {
+ {-case_id:required}
+ {-role_id:required}
+} {
+ Get labels and ids of attachments associated with the given case and role.
+
+ @return A list of label-id pairs suitable for the options attribute of a form builder select widget.
+
+ @author Peter Marklund
+} {
+ return [db_list_of_lists attachment_for_role {
+ select cr.title as document_title,
+ scrom.object_id as document_id
+ from sim_case_role_object_map scrom,
+ cr_items ci,
+ cr_revisions cr
+ where scrom.case_id = :case_id
+ and scrom.role_id = :role_id
+ and scrom.object_id = ci.item_id
+ and ci.live_revision = cr.revision_id
+ order by scrom.order_n
+ }]
+}
Index: openacs-4/contrib/packages/simulation/www/simplay/message.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/message.tcl,v
diff -u -r1.12 -r1.13
--- openacs-4/contrib/packages/simulation/www/simplay/message.tcl 6 Jan 2004 09:55:06 -0000 1.12
+++ openacs-4/contrib/packages/simulation/www/simplay/message.tcl 6 Jan 2004 13:11:54 -0000 1.13
@@ -38,18 +38,7 @@
}
}
-set attachment_options [db_list_of_lists attachment_for_role {
- select cr.title as document_title,
- scrom.object_id as document_id
- from sim_case_role_object_map scrom,
- cr_items ci,
- cr_revisions cr
- where scrom.case_id = :case_id
- and scrom.role_id = :sender_role_id
- and scrom.object_id = ci.item_id
- and ci.live_revision = cr.revision_id
- order by scrom.order_n
-}]
+set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $sender_role_id]
set action [form::get_action message]
@@ -78,12 +67,14 @@
ad_returnredirect [export_vars -base [ad_conn url] { case_id sender_role_id recipient_role_id subject body_text body_mime_type }]
}
+set form_mode [ad_decode [ad_form_new_p -key item_id] 1 "edit" "display"]
+
ad_form \
-name message \
-edit_buttons { { Send ok } } \
-actions { { Reply reply } } \
-export { case_id } \
- -mode [ad_decode [ad_form_new_p -key item_id] 1 "edit" "display"] \
+ -mode $form_mode \
-form {
{sender_role_id:text(select)
{label "From"}
@@ -116,12 +107,23 @@
}
if { [llength $attachment_options] > 0 } {
- ad_form -extend -name message -form {
- {attachments:integer(checkbox),multiple,optional
- {label "Attachments"}
- {options $attachment_options}
+ if { ![string equal $form_mode "display"] } {
+ # edit/new mode - show checkboxes
+ ad_form -extend -name message -form {
+ {attachments:integer(checkbox),multiple,optional
+ {label "Attachments"}
+ {options $attachment_options}
+ }
}
+ } else {
+ # display mode - show a list of attached documents
+ ad_form -extend -name message -form {
+ {attachments:text(inform),optional
+ {label "Attachments"}
+ }
+ }
}
+
} else {
ad_form -extend -name message -form {
{attachments:integer(hidden),optional}
@@ -158,12 +160,25 @@
set body [template::util::richtext::create $content(text) $content(mime_type)]
set attachments_set_list [bcms::item::list_related_items \
- -item_id $item_id \
- -relation_tag attachment \
- -return_list]
- set attachments [list]
- foreach attachment_set $attachments_set_list {
- lappend attachments [ns_set get $attachment_set item_id]
+ -revision live \
+ -item_id $item_id \
+ -relation_tag attachment \
+ -return_list]
+
+ if { ![string equal $form_mode "display"] } {
+ # edit/new mode - set checkbox integer values
+ set attachments [list]
+ foreach attachment_set $attachments_set_list {
+ lappend attachments [ns_set get $attachment_set item_id]
+ }
+ } else {
+ # display mode - show a list of attached documents
+ set attachments ""
+ foreach attachment_set $attachments_set_list {
+ set object_url [simulation::object::url -name [ns_set get $attachment_set name]]
+ set object_title [ns_set get $attachment_set title]
+ append attachments "$object_title
"
+ }
}
} -on_submit {
Index: openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/task-detail.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl 6 Jan 2004 09:40:05 -0000 1.8
+++ openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl 6 Jan 2004 13:11:54 -0000 1.9
@@ -11,6 +11,10 @@
simulation::action::get -action_id $action_id -array action
+if { ![empty_string_p $action(assigned_role_id)] } {
+ set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $action(assigned_role_id)]
+}
+
set title "Task"
set context [list [list . "SimPlay"] [list [export_vars -base case { case_id }] "Case"] [list [export_vars -base tasks { case_id }] "Tasks"] $title]
@@ -25,12 +29,12 @@
{documents:text(inform),optional
{label "Documents"}
}
- {recipient_name:text(inform),optional
- {label "To"}
- }
{sender_name:text(inform),optional
{label "From"}
}
+ {recipient_name:text(inform),optional
+ {label "To"}
+ }
{subject:text
{label "Subject"}
{html {size 80}}
@@ -39,9 +43,9 @@
{label "Body"}
{html {cols 60 rows 20}}
}
- {attachments:text(inform)
+ {attachments:integer(checkbox),multiple,optional
{label "Attachments"}
- {value "TODO"}
+ {options $attachment_options}
}
} -on_request {
set pretty_name $action(pretty_name)
@@ -69,7 +73,8 @@
set recipient_name [simulation::role::get_element -role_id $action(recipient) -element pretty_name]
}
if { ![empty_string_p $action(assigned_role_id)] } {
- set sender_name [simulation::role::get_element -role_id $action(assigned_role_id) -element pretty_name]
+ simulation::role::get -role_id $action(assigned_role_id) -array sender_role
+ set sender_name $sender_role(pretty_name)
}
} -on_submit {
@@ -90,7 +95,8 @@
-case_id $case_id \
-subject $subject \
-body $body_text \
- -body_mime_type $body_mime_type
+ -body_mime_type $body_mime_type \
+ -attachments $attachments
}
ad_returnredirect [export_vars -base tasks { case_id }]
Index: openacs-4/packages/simulation/tcl/sim-case-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/sim-case-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/simulation/tcl/sim-case-procs.tcl 5 Jan 2004 14:10:05 -0000 1.3
+++ openacs-4/packages/simulation/tcl/sim-case-procs.tcl 6 Jan 2004 13:11:54 -0000 1.4
@@ -84,3 +84,28 @@
return $sim_case_id
}
+
+
+ad_proc -public simulation::case::attachment_options {
+ {-case_id:required}
+ {-role_id:required}
+} {
+ Get labels and ids of attachments associated with the given case and role.
+
+ @return A list of label-id pairs suitable for the options attribute of a form builder select widget.
+
+ @author Peter Marklund
+} {
+ return [db_list_of_lists attachment_for_role {
+ select cr.title as document_title,
+ scrom.object_id as document_id
+ from sim_case_role_object_map scrom,
+ cr_items ci,
+ cr_revisions cr
+ where scrom.case_id = :case_id
+ and scrom.role_id = :role_id
+ and scrom.object_id = ci.item_id
+ and ci.live_revision = cr.revision_id
+ order by scrom.order_n
+ }]
+}
Index: openacs-4/packages/simulation/www/simplay/message.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/message.tcl,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/simulation/www/simplay/message.tcl 6 Jan 2004 09:55:06 -0000 1.12
+++ openacs-4/packages/simulation/www/simplay/message.tcl 6 Jan 2004 13:11:54 -0000 1.13
@@ -38,18 +38,7 @@
}
}
-set attachment_options [db_list_of_lists attachment_for_role {
- select cr.title as document_title,
- scrom.object_id as document_id
- from sim_case_role_object_map scrom,
- cr_items ci,
- cr_revisions cr
- where scrom.case_id = :case_id
- and scrom.role_id = :sender_role_id
- and scrom.object_id = ci.item_id
- and ci.live_revision = cr.revision_id
- order by scrom.order_n
-}]
+set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $sender_role_id]
set action [form::get_action message]
@@ -78,12 +67,14 @@
ad_returnredirect [export_vars -base [ad_conn url] { case_id sender_role_id recipient_role_id subject body_text body_mime_type }]
}
+set form_mode [ad_decode [ad_form_new_p -key item_id] 1 "edit" "display"]
+
ad_form \
-name message \
-edit_buttons { { Send ok } } \
-actions { { Reply reply } } \
-export { case_id } \
- -mode [ad_decode [ad_form_new_p -key item_id] 1 "edit" "display"] \
+ -mode $form_mode \
-form {
{sender_role_id:text(select)
{label "From"}
@@ -116,12 +107,23 @@
}
if { [llength $attachment_options] > 0 } {
- ad_form -extend -name message -form {
- {attachments:integer(checkbox),multiple,optional
- {label "Attachments"}
- {options $attachment_options}
+ if { ![string equal $form_mode "display"] } {
+ # edit/new mode - show checkboxes
+ ad_form -extend -name message -form {
+ {attachments:integer(checkbox),multiple,optional
+ {label "Attachments"}
+ {options $attachment_options}
+ }
}
+ } else {
+ # display mode - show a list of attached documents
+ ad_form -extend -name message -form {
+ {attachments:text(inform),optional
+ {label "Attachments"}
+ }
+ }
}
+
} else {
ad_form -extend -name message -form {
{attachments:integer(hidden),optional}
@@ -158,12 +160,25 @@
set body [template::util::richtext::create $content(text) $content(mime_type)]
set attachments_set_list [bcms::item::list_related_items \
- -item_id $item_id \
- -relation_tag attachment \
- -return_list]
- set attachments [list]
- foreach attachment_set $attachments_set_list {
- lappend attachments [ns_set get $attachment_set item_id]
+ -revision live \
+ -item_id $item_id \
+ -relation_tag attachment \
+ -return_list]
+
+ if { ![string equal $form_mode "display"] } {
+ # edit/new mode - set checkbox integer values
+ set attachments [list]
+ foreach attachment_set $attachments_set_list {
+ lappend attachments [ns_set get $attachment_set item_id]
+ }
+ } else {
+ # display mode - show a list of attached documents
+ set attachments ""
+ foreach attachment_set $attachments_set_list {
+ set object_url [simulation::object::url -name [ns_set get $attachment_set name]]
+ set object_title [ns_set get $attachment_set title]
+ append attachments "$object_title
"
+ }
}
} -on_submit {
Index: openacs-4/packages/simulation/www/simplay/task-detail.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/task-detail.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/simulation/www/simplay/task-detail.tcl 6 Jan 2004 09:40:05 -0000 1.8
+++ openacs-4/packages/simulation/www/simplay/task-detail.tcl 6 Jan 2004 13:11:54 -0000 1.9
@@ -11,6 +11,10 @@
simulation::action::get -action_id $action_id -array action
+if { ![empty_string_p $action(assigned_role_id)] } {
+ set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $action(assigned_role_id)]
+}
+
set title "Task"
set context [list [list . "SimPlay"] [list [export_vars -base case { case_id }] "Case"] [list [export_vars -base tasks { case_id }] "Tasks"] $title]
@@ -25,12 +29,12 @@
{documents:text(inform),optional
{label "Documents"}
}
- {recipient_name:text(inform),optional
- {label "To"}
- }
{sender_name:text(inform),optional
{label "From"}
}
+ {recipient_name:text(inform),optional
+ {label "To"}
+ }
{subject:text
{label "Subject"}
{html {size 80}}
@@ -39,9 +43,9 @@
{label "Body"}
{html {cols 60 rows 20}}
}
- {attachments:text(inform)
+ {attachments:integer(checkbox),multiple,optional
{label "Attachments"}
- {value "TODO"}
+ {options $attachment_options}
}
} -on_request {
set pretty_name $action(pretty_name)
@@ -69,7 +73,8 @@
set recipient_name [simulation::role::get_element -role_id $action(recipient) -element pretty_name]
}
if { ![empty_string_p $action(assigned_role_id)] } {
- set sender_name [simulation::role::get_element -role_id $action(assigned_role_id) -element pretty_name]
+ simulation::role::get -role_id $action(assigned_role_id) -array sender_role
+ set sender_name $sender_role(pretty_name)
}
} -on_submit {
@@ -90,7 +95,8 @@
-case_id $case_id \
-subject $subject \
-body $body_text \
- -body_mime_type $body_mime_type
+ -body_mime_type $body_mime_type \
+ -attachments $attachments
}
ad_returnredirect [export_vars -base tasks { case_id }]