Index: openacs-4/contrib/packages/simulation/tcl/ui-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/ui-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/tcl/ui-procs.tcl 21 Jan 2004 11:17:34 -0000 1.1 @@ -0,0 +1,82 @@ +ad_library { + UI related procs. + + @author Peter Marklund + @creation-date 2004-01-20 + @cvs-id $Id: ui-procs.tcl,v 1.1 2004/01/21 11:17:34 peterm Exp $ +} + +namespace eval simulation::ui {} +namespace eval simulation::ui::simplay {} +namespace eval simulation::ui::forms::document_upload {} + +ad_proc -public simulation::ui::forms::document_upload::form_block {} { + Return the form block for the document upload form. + + @author Peter Marklund +} { + return { + {item_id:key} + {document_file:file(file) + {label "Document file"} + } + {title:text(text) + {label "Title"} + {html {size 50}} + } + {description:text(textarea),optional + {label "Description"} + {html {cols 60 rows 8}} + } + } +} + +ad_proc -public simulation::ui::forms::document_upload::insert_document { + case_id + role_id + item_id + document_file + title + description +} { + Does the document insertion in the DB. + + @author Peter Marklund +} { + db_transaction { + + set parent_id [bcms::folder::get_id_by_package_id -parent_id 0] + + set existing_items [db_list select_items { select name from cr_items where parent_id = :parent_id }] + set name [util_text_to_url -existing_urls $existing_items -text $title] + + set content_type sim_prop + set storage_type file + + set item_id [bcms::item::create_item \ + -item_id $item_id \ + -item_name $name \ + -parent_id $parent_id \ + -content_type $content_type \ + -storage_type $storage_type] + + set revision_id [bcms::revision::upload_file_revision \ + -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -upload_file $document_file \ + -description $description] + + bcms::revision::set_revision_status \ + -revision_id $revision_id \ + -status "live" + + set relation_tag "portfolio" + db_dml add_document_to_portfolio { + insert into sim_case_role_object_map + (case_id, object_id, role_id, relation_tag) + values + (:case_id, :item_id, :role_id, :relation_tag) + } + } +} Index: openacs-4/contrib/packages/simulation/www/siminst/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/index.adp,v diff -u -r1.17 -r1.18 --- openacs-4/contrib/packages/simulation/www/siminst/index.adp 12 Jan 2004 13:43:14 -0000 1.17 +++ openacs-4/contrib/packages/simulation/www/siminst/index.adp 21 Jan 2004 11:17:34 -0000 1.18 @@ -12,6 +12,3 @@
TODO (1h): Merge the casting_sims list into the dev_sims list
Index: openacs-4/contrib/packages/simulation/www/simplay/document-upload.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/document-upload.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/simulation/www/simplay/document-upload.tcl 16 Jan 2004 10:20:39 -0000 1.6 +++ openacs-4/contrib/packages/simulation/www/simplay/document-upload.tcl 21 Jan 2004 11:17:34 -0000 1.7 @@ -20,62 +20,14 @@ lappend role_options [list [workflow::role::get_element -role_id $one_role_id -element pretty_name] $one_role_id] } -ad_form -name document -export { case_id role_id workflow_id } -html {enctype multipart/form-data} -form { - {item_id:key} -} - set focus "document.document_file" -ad_form -extend -name document -form { - {document_file:file(file) - {label "Document file"} - } - {title:text(text) - {label "Title"} - {html {size 50}} - } - {description:text(textarea),optional - {label "Description"} - {html {cols 60 rows 8}} - } -} -on_submit { +ad_form -name document -export { case_id role_id workflow_id } -html {enctype multipart/form-data} \ + -form [simulation::ui::forms::document_upload::form_block] \ + -on_submit { - db_transaction { + simulation::ui::forms::document_upload::insert_document \ + $case_id $role_id $item_id $document_file $title $description - set parent_id [bcms::folder::get_id_by_package_id -parent_id 0] - - set existing_items [db_list select_items { select name from cr_items where parent_id = :parent_id }] - set name [util_text_to_url -existing_urls $existing_items -text $title] - - set content_type sim_prop - set storage_type file - - set item_id [bcms::item::create_item \ - -item_id $item_id \ - -item_name $name \ - -parent_id $parent_id \ - -content_type $content_type \ - -storage_type $storage_type] - - set revision_id [bcms::revision::upload_file_revision \ - -item_id $item_id \ - -title $title \ - -content_type $content_type \ - -upload_file $document_file \ - -description $description] - - bcms::revision::set_revision_status \ - -revision_id $revision_id \ - -status "live" - - set relation_tag "portfolio" - db_dml add_document_to_portfolio { - insert into sim_case_role_object_map - (case_id, object_id, role_id, relation_tag) - values - (:case_id, :item_id, :role_id, :relation_tag) - } + ad_returnredirect [export_vars -base case { case_id role_id }] } - - ad_returnredirect [export_vars -base case { case_id role_id }] -} Index: openacs-4/contrib/packages/simulation/www/simplay/task-detail.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/task-detail.adp,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/simulation/www/simplay/task-detail.adp 12 Jan 2004 15:37:28 -0000 1.6 +++ openacs-4/contrib/packages/simulation/www/simplay/task-detail.adp 21 Jan 2004 11:17:34 -0000 1.7 @@ -1,14 +1,15 @@+@action.description@ +
-TODO (0.25h): Task should be part of heading
+
TODO (0.5h): description and "document" -link should be inline before the message form instead of being part of -the form - +
+ TODO (0.5h): show task attachment links beneath the action description +
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.11 -r1.12 --- openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl 16 Jan 2004 10:20:39 -0000 1.11 +++ openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl 21 Jan 2004 11:17:34 -0000 1.12 @@ -1,107 +1,146 @@ ad_page_contract { - Details for a task + Details for a task. If there is a recipient_role a message is created. If there + is not recipient role we upload a document instead. } { case_id:integer role_id:integer enabled_action_id:integer + item_id:optional } simulation::case::assert_user_may_play_role -case_id $case_id -role_id $role_id workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action - set action_id $enabled_action(action_id) - 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 page_title $action(pretty_name) +set context [list [list . "SimPlay"] [list [export_vars -base case { case_id role_id }] "Case"] [list [export_vars -base tasks { case_id role_id }] "Tasks"] $page_title] -set title "Task" -set context [list [list . "SimPlay"] [list [export_vars -base case { case_id role_id }] "Case"] [list [export_vars -base tasks { case_id role_id }] "Tasks"] $title] +set action(recipient_role) "" -ad_form -name action -edit_buttons { { Send ok } } -export { case_id role_id enabled_action_id } -form { - {pretty_name:text(inform) - {label "Task"} - } - {description:richtext,optional - {label "Description"} - {mode display} - } - {documents:text(inform),optional - {label "Documents"} - } - {sender_name:text(inform),optional - {label "From"} - } - {recipient_name:text(inform),optional - {label "To"} - } - {subject:text - {label "Subject"} - {html {size 80}} - } - {body:richtext - {label "Body"} - {html {cols 60 rows 20}} - } - {attachments:integer(checkbox),multiple,optional - {label "Attachments"} - {options $attachment_options} - } -} -on_request { - set pretty_name $action(pretty_name) - set description [template::util::richtext::create $action(description) $action(description_mime_type)] +if { ![empty_string_p $action(recipient_role)] } { + # We have a recipient role - use message form - set documents {} - db_foreach documents { - select cr.title as object_title, - ci.name as object_name - from sim_task_object_map m, - cr_items ci, - cr_revisions cr - where m.task_id = :action_id - and m.relation_tag = 'attachment' - and ci.item_id = m.object_id - and cr.revision_id = ci.live_revision - order by m.order_n - } { - set object_url [simulation::object::url \ - -name $object_name] - append documents "$object_titleTODO (1h): Merge the casting_sims list into the dev_sims list
Index: openacs-4/packages/simulation/www/simplay/document-upload.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/document-upload.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/simulation/www/simplay/document-upload.tcl 16 Jan 2004 10:20:39 -0000 1.6 +++ openacs-4/packages/simulation/www/simplay/document-upload.tcl 21 Jan 2004 11:17:34 -0000 1.7 @@ -20,62 +20,14 @@ lappend role_options [list [workflow::role::get_element -role_id $one_role_id -element pretty_name] $one_role_id] } -ad_form -name document -export { case_id role_id workflow_id } -html {enctype multipart/form-data} -form { - {item_id:key} -} - set focus "document.document_file" -ad_form -extend -name document -form { - {document_file:file(file) - {label "Document file"} - } - {title:text(text) - {label "Title"} - {html {size 50}} - } - {description:text(textarea),optional - {label "Description"} - {html {cols 60 rows 8}} - } -} -on_submit { +ad_form -name document -export { case_id role_id workflow_id } -html {enctype multipart/form-data} \ + -form [simulation::ui::forms::document_upload::form_block] \ + -on_submit { - db_transaction { + simulation::ui::forms::document_upload::insert_document \ + $case_id $role_id $item_id $document_file $title $description - set parent_id [bcms::folder::get_id_by_package_id -parent_id 0] - - set existing_items [db_list select_items { select name from cr_items where parent_id = :parent_id }] - set name [util_text_to_url -existing_urls $existing_items -text $title] - - set content_type sim_prop - set storage_type file - - set item_id [bcms::item::create_item \ - -item_id $item_id \ - -item_name $name \ - -parent_id $parent_id \ - -content_type $content_type \ - -storage_type $storage_type] - - set revision_id [bcms::revision::upload_file_revision \ - -item_id $item_id \ - -title $title \ - -content_type $content_type \ - -upload_file $document_file \ - -description $description] - - bcms::revision::set_revision_status \ - -revision_id $revision_id \ - -status "live" - - set relation_tag "portfolio" - db_dml add_document_to_portfolio { - insert into sim_case_role_object_map - (case_id, object_id, role_id, relation_tag) - values - (:case_id, :item_id, :role_id, :relation_tag) - } + ad_returnredirect [export_vars -base case { case_id role_id }] } - - ad_returnredirect [export_vars -base case { case_id role_id }] -} Index: openacs-4/packages/simulation/www/simplay/task-detail.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/task-detail.adp,v diff -u -r1.6 -r1.7 --- openacs-4/packages/simulation/www/simplay/task-detail.adp 12 Jan 2004 15:37:28 -0000 1.6 +++ openacs-4/packages/simulation/www/simplay/task-detail.adp 21 Jan 2004 11:17:34 -0000 1.7 @@ -1,14 +1,15 @@+@action.description@ +
-TODO (0.25h): Task should be part of heading
+
TODO (0.5h): description and "document" -link should be inline before the message form instead of being part of -the form - +
+ TODO (0.5h): show task attachment links beneath the action description +
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.11 -r1.12 --- openacs-4/packages/simulation/www/simplay/task-detail.tcl 16 Jan 2004 10:20:39 -0000 1.11 +++ openacs-4/packages/simulation/www/simplay/task-detail.tcl 21 Jan 2004 11:17:34 -0000 1.12 @@ -1,107 +1,146 @@ ad_page_contract { - Details for a task + Details for a task. If there is a recipient_role a message is created. If there + is not recipient role we upload a document instead. } { case_id:integer role_id:integer enabled_action_id:integer + item_id:optional } simulation::case::assert_user_may_play_role -case_id $case_id -role_id $role_id workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action - set action_id $enabled_action(action_id) - 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 page_title $action(pretty_name) +set context [list [list . "SimPlay"] [list [export_vars -base case { case_id role_id }] "Case"] [list [export_vars -base tasks { case_id role_id }] "Tasks"] $page_title] -set title "Task" -set context [list [list . "SimPlay"] [list [export_vars -base case { case_id role_id }] "Case"] [list [export_vars -base tasks { case_id role_id }] "Tasks"] $title] +set action(recipient_role) "" -ad_form -name action -edit_buttons { { Send ok } } -export { case_id role_id enabled_action_id } -form { - {pretty_name:text(inform) - {label "Task"} - } - {description:richtext,optional - {label "Description"} - {mode display} - } - {documents:text(inform),optional - {label "Documents"} - } - {sender_name:text(inform),optional - {label "From"} - } - {recipient_name:text(inform),optional - {label "To"} - } - {subject:text - {label "Subject"} - {html {size 80}} - } - {body:richtext - {label "Body"} - {html {cols 60 rows 20}} - } - {attachments:integer(checkbox),multiple,optional - {label "Attachments"} - {options $attachment_options} - } -} -on_request { - set pretty_name $action(pretty_name) - set description [template::util::richtext::create $action(description) $action(description_mime_type)] +if { ![empty_string_p $action(recipient_role)] } { + # We have a recipient role - use message form - set documents {} - db_foreach documents { - select cr.title as object_title, - ci.name as object_name - from sim_task_object_map m, - cr_items ci, - cr_revisions cr - where m.task_id = :action_id - and m.relation_tag = 'attachment' - and ci.item_id = m.object_id - and cr.revision_id = ci.live_revision - order by m.order_n - } { - set object_url [simulation::object::url \ - -name $object_name] - append documents "$object_title