Index: openacs-4/contrib/packages/simulation/sql/postgresql/simulation-content-types-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/sql/postgresql/Attic/simulation-content-types-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/simulation/sql/postgresql/simulation-content-types-create.sql 17 Oct 2003 09:55:53 -0000 1.3 +++ openacs-4/contrib/packages/simulation/sql/postgresql/simulation-content-types-create.sql 24 Oct 2003 09:46:13 -0000 1.4 @@ -2,7 +2,19 @@ -- @creation-date 2003-10-14 -- @cvs-id $Id$ +-- sim_stylesheet +-- a chunk of css stylesheet +select content_type__create_type( + 'sim_stylesheet', -- content_type + 'content_revision', -- supertype + 'Stylesheet', -- pretty_name, + 'Stylesheets', -- pretty_plural + 'sim_stylesheets', -- table_name + 'stylesheet_id', -- id_column + null -- name_method +); + -- sim_character select content_type__create_type( @@ -18,16 +30,14 @@ select content_type__create_attribute( 'sim_character', -- content_type 'stylesheet', -- attribute_name - 'text', -- datatype + 'integer', -- datatype 'Stylesheet', -- pretty_name 'Stylesheets', -- pretty_plural 1, -- sort_order null, -- default_value - 'text' -- column_spec + 'integer constraint sim_char_stylesheet_fk references sim_stylesheets(stylesheet_id)' -- column_spec ); - - -- sim_prop select content_type__create_type( @@ -41,19 +51,17 @@ ); select content_type__create_attribute( - 'sim_prop', -- content_type + 'sim_prop', -- content_type 'stylesheet', -- attribute_name - 'text', -- datatype + 'integer', -- datatype 'Stylesheet', -- pretty_name 'Stylesheets', -- pretty_plural 1, -- sort_order null, -- default_value - 'text' -- column_spec + 'integer constraint sim_char_stylesheet_fk references sim_stylesheets(stylesheet_id)' -- column_spec ); - - -- sim_home select content_type__create_type( @@ -99,13 +107,14 @@ 'text' -- column_spec ); + select content_type__create_attribute( 'sim_home', -- content_type 'stylesheet', -- attribute_name - 'text', -- datatype + 'integer', -- datatype 'Stylesheet', -- pretty_name 'Stylesheets', -- pretty_plural 4, -- sort_order null, -- default_value - 'text' -- column_spec + 'integer constraint sim_char_stylesheet_fk references sim_stylesheets(stylesheet_id)' -- column_spec ); Index: openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/simulation-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 14 Oct 2003 13:58:03 -0000 1.1 +++ openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 24 Oct 2003 09:46:13 -0000 1.2 @@ -7,7 +7,20 @@ } namespace eval simulation {} +namespace eval simulation::object_type {} +ad_proc -public simulation::object_type::get_options { +} { + Generate a list of object types formatted as an option list for form-builder's widgets. +} { + set sim_types { sim_character sim_prop sim_home } + return [db_list_of_lists object_types " + select ot.pretty_name, + ot.object_type + from acs_object_types ot + where ot.object_type in ('[join $sim_types "','"]') + "] +} -# Lars: Nothing here yet, keeping it in case we want to add something + Index: openacs-4/contrib/packages/simulation/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/index.adp,v diff -u -r1.9 -r1.10 --- openacs-4/contrib/packages/simulation/www/index.adp 21 Oct 2003 12:53:50 -0000 1.9 +++ openacs-4/contrib/packages/simulation/www/index.adp 24 Oct 2003 09:46:13 -0000 1.10 @@ -1,37 +1,10 @@ Your live cases: - +

+

Join a Simulation: +

- - - - - - - - - - -
- Case - - Tasks -
- Legislative Drafting (EUR) - - 3 -
- Elementary Private Law (UVT) - - 0 -
- -
-Join a Simulation: - - -
Simulation @@ -47,19 +20,11 @@
- - -
-

Administrators also see:

- -
+

Sim Objects (administrators only) +

+

Add an object +

+

View and edit simulation templates

If not logged in:

Sieberdam currently has @@ -68,9 +33,6 @@
8 running simulations

Join a Simulation -

Index: openacs-4/contrib/packages/simulation/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/index.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/index.tcl 14 Oct 2003 13:58:03 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/index.tcl 24 Oct 2003 09:46:13 -0000 1.3 @@ -6,10 +6,22 @@ } -properties { } -# phase2: sortable, filterable +###################################################################### +# +# active_cases +# +# a list of active cases for logged-in user +# +###################################################################### + +#--------------------------------------------------------------------- +# active_cases list +#--------------------------------------------------------------------- + template::list::create \ - -name cases \ - -multirow cases \ + -name active_cases \ + -multirow active_cases \ + -html {width "100%"}\ -elements { case_name { label "Case" @@ -21,30 +33,107 @@ } } -# phase2: a list of cases for which the user has a role, along with a count of the -# number of active tasks for that role +#--------------------------------------------------------------------- +# active_cases database query +#--------------------------------------------------------------------- +# this is currently a dummy query. For Phase 2, it should get all cases +# for which the logged-in user has a role, and a count of active tasks +# for that role. -db_multirow cases cases_sql { +db_multirow active_cases active_cases_select { select 'case one' as case_name, 2 as task_count } + +###################################################################### +# +# object_count +# +# A count of all objects in the system, by type, for admins +# +###################################################################### + +#--------------------------------------------------------------------- +# object_count list +#--------------------------------------------------------------------- + template::list::create \ - -name cases \ - -multirow cases \ + -name object_count \ + -multirow object_count \ + -html {width "100%"} \ -elements { - case_name { - label "Case" - orderby case_name - } - task_count { - label "Tasks" - orderby task_count - } + type { + label "Type" + } + count { + label "Count" + link_url_col view_url + } } -db_multirow cases cases_sql { - select 'case one', 'case two' as case_name, - 0,2 as task_count - from dual +#--------------------------------------------------------------------- +# object_count database query +#--------------------------------------------------------------------- + +db_multirow -extend { view_url } object_count object_count_select " + select object_type as type, + count(object_type) as count + from acs_objects + where object_type like 'sim_%' + group by object_type +" { + set view_url [export_vars -base "object-list" { type }] } + + +###################################################################### +# +# sim_template_count +# +# A count of all templates, for admins +# They should probably be grouped, but I'm not sure what to group +# them by yet +# +###################################################################### + +#--------------------------------------------------------------------- +# sim_template_count list +#--------------------------------------------------------------------- + +template::list::create \ + -name sim_template_count \ + -multirow sim_template_count \ + -html {width "100%"} \ + -elements { + count { + label "Simulation Templates" + link_url_col view_url + } + } + + + +template::list::create \ + -name template_count \ + -multirow template_count \ + -elements { + type { + label "Type" + } + count { + label "Count" + link_url_col view_url + } + } + +#--------------------------------------------------------------------- +# template_count database query +#--------------------------------------------------------------------- + +db_multirow -extend { view_url } sim_template_count sim_template_count_query " + select count(workflow_id) as count + from workflows w +" { + set view_url [export_vars -base "sim-template-list"] +} Index: openacs-4/contrib/packages/simulation/www/object-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/object-edit.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/simulation/www/object-edit.tcl 17 Oct 2003 09:55:53 -0000 1.4 +++ openacs-4/contrib/packages/simulation/www/object-edit.tcl 24 Oct 2003 09:46:13 -0000 1.5 @@ -5,25 +5,55 @@ @cvs-id $Id$ } { item_id:integer,optional - parent_id:integer,optional - content_type:optional -} -validate { - not_item_id { - if { ![exists_and_not_null item_id] } { - if { ![exists_and_not_null parent_id] } { - ad_complain "parent_id is required" - } - if { ![exists_and_not_null content_type] } { - ad_complain "content_type is required" - } - } - } + {parent_id:integer {[bcms::folder::get_id_by_package_id -parent_id 0]}} + {content_type {sim_prop}} } +#TODO: object type should be non-editable for non-new things + +#--------------------------------------------------------------------- +# Determine if we are in edit mode or display mode +#--------------------------------------------------------------------- +# this is prototype code to correct for get_action's apparent +# unreliability + +#set mode [template::form::get_action sim_template] +#if { ![exists_and_not_null workflow_id]} { +# set mode "add" +#} else { +# # for now, use edit mode in place of display mode +# # set mode "display" +# set mode "edit" +#} + +if { ![ad_form_new_p -key item_id] } { + # Get data for existing object + array set item_info [bcms::item::get_item -item_id $item_id -revision live] + item::get_revision_content $item_info(revision_id) + set content_type $item_info(content_type) + set page_title "Edit Sim Object" +} else { + set page_title "Create Sim Object" +} +set context [list [list "object-list" "Sim Objects"] $page_title] + + +###################################################################### +# +# object +# +# A form for editing and viewing sim objects +# +###################################################################### + ad_form -name object -cancel_url object-list -form { {item_id:key} - {content_type:text(hidden)} {parent_id:integer(hidden),optional} + {content_type:text(radio) + {label "Type"} + {options {[simulation::object_type::get_options]}} + {mode "display"} + } {title:text {label "Title"} {html {size 50}} @@ -40,23 +70,13 @@ } } -if { ![ad_form_new_p -key item_id] } { - # Get data for existing object - array set item_info [bcms::item::get_item -item_id $item_id -revision live] - item::get_revision_content $item_info(revision_id) - set content_type $item_info(content_type) - set page_title "Edit Object" -} else { - set object_type_pretty [db_string pretty { select pretty_name from acs_object_types where object_type = :content_type }] - set page_title "Create $object_type_pretty" -} -set context [list [list "object-list" "Objects"] $page_title] - ##### # # Content edit/upload method # +# Add a form widget appropriate for the content attribute of the object type +# ##### array set content_method { @@ -88,6 +108,8 @@ # # Dynamic attributes for the content type # +# Look up the other attributes for this content type and put them on the form +# ##### # LARS: I'm doing this as a proof-of-concept type thing. If it works well enough for us, Index: openacs-4/contrib/packages/simulation/www/object-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/object-list.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/simulation/www/object-list.tcl 17 Oct 2003 09:55:54 -0000 1.4 +++ openacs-4/contrib/packages/simulation/www/object-list.tcl 24 Oct 2003 09:46:13 -0000 1.5 @@ -5,6 +5,7 @@ } { parent_id:optional {orderby "title,asc"} + {type:optional} } set page_title "Objects" Index: openacs-4/contrib/packages/simulation/www/role-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/role-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/role-edit.adp 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,7 @@ + + @page_title;noquote@ + @context;noquote@ + object.title + + + Index: openacs-4/contrib/packages/simulation/www/role-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/role-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/role-edit.tcl 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,103 @@ +ad_page_contract { + Add/edit template. + + @creation-date 2003-10-13 + @cvs-id $Id: role-edit.tcl,v 1.1 2003/10/24 09:46:13 joela Exp $ +} { + workflow_id:optional + role_id:optional +} -validate { + workflow_id_or_role_id { + if { ![exists_and_not_null workflow_id] && + ![exists_and_not_null role_id]} { + ad_complain "Either role_id or workflow_id is required." + } + } +} + +###################################################################### +# +# preparation +# +###################################################################### +# TODO: one of workflow_id or role_id is required +# enforce this in page contract validation +# redirect to sim-template-list if both missing + +set package_key [ad_conn package_key] +set package_id [ad_conn package_id] + +#--------------------------------------------------------------------- +# Get a list of relevant characters +#--------------------------------------------------------------------- +# TODO: make sure this query (and other queries to cr) get only the live +# record from cr_revisions +# deliberately not checking to see if character is already cast in sim +# because no reason not to have same character in multiple roles (?) + +set char_options [db_list_of_lists character_option_list " + select ci.name, + a.object_id + from cr_revisions cr, + cr_items ci, + acs_objects a + where a.object_type = 'sim_character' + and cr.revision_id = a.object_id + and ci.item_id = cr.item_id +"] + +###################################################################### +# +# role +# +# a form showing fields for a role in a workflow +# includes add and edit modes and handles form submission +# display mode is only in list form via sim-template-edit +# +###################################################################### + +#--------------------------------------------------------------------- +# role form +#--------------------------------------------------------------------- + +ad_form -name role -cancel_url sim-template-list -form { + {role_id:key} + {workflow_id:integer(hidden),optional} + {name:text + {label "Role Name"} + {html {size 20}} + } + {character_id:text(select) + {label "Character"} + {options $char_options} + } +} -edit_request { + workflow::role::get -role_id $role_id -array role_array + set workflow_id $role_array(workflow_id) + set name $role_array(pretty_name) + workflow::get -workflow_id $workflow_id -array sim_template_array + set page_title "Edit Role template $name" + set context [list [list "sim-template-list" "Sim Templates"] [list "sim-template-edit?workflow_id=$workflow_id" "$sim_template_array(pretty_name)"] $page_title] +} -new_request { + workflow::get -workflow_id $workflow_id -array sim_template_array + set page_title "Add Role to $sim_template_array(pretty_name)" + set context [list [list "sim-template-list" "Sim Templates"] [list "sim-template-edit?workflow_id=$workflow_id" "$sim_template_array(pretty_name)"] $page_title] +} -new_data { + # create the role + set role_id [workflow::role::new \ + -workflow_id $workflow_id \ + -short_name $name \ + -pretty_name $name] + # and then add extra data for simulation + db_dml set_role_character { + insert into sim_roles + values (:role_id, :character_id) + } +} -after_submit { + ad_returnredirect [export_vars -base "sim-template-edit" { workflow_id }] + ad_script_abort +} + +# maybe replace this chunk of copied text with an includable template +# which passes in a filter for the workflow_id? + Index: openacs-4/contrib/packages/simulation/www/sim-template-add-objects-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-add-objects-2.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/sim-template-add-objects-2.tcl 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,23 @@ +ad_page_contract { + + @creation-date 2003-10-13 + @cvs-id $Id: sim-template-add-objects-2.tcl,v 1.1 2003/10/24 09:46:13 joela Exp $ +} { + workflow_id + item_id +} + +set package_id [ad_conn package_id] + +###################################################################### +# +# add the object to the workflow +# +###################################################################### + +db_dml add_object_to_workflow_insert " +insert into sim_workflow_object_map +values (:workflow_id, :item_id) +" + +ad_returnredirect "sim-template-edit?workflow_id=$workflow_id" \ No newline at end of file Index: openacs-4/contrib/packages/simulation/www/sim-template-add-objects.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-add-objects.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/sim-template-add-objects.adp 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,7 @@ + + @page_title;noquote@ + @context;noquote@ + +

+

Create a new object and add it + Index: openacs-4/contrib/packages/simulation/www/sim-template-add-objects.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-add-objects.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/sim-template-add-objects.tcl 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,96 @@ +ad_page_contract { + + @creation-date 2003-10-13 + @cvs-id $Id: sim-template-add-objects.tcl,v 1.1 2003/10/24 09:46:13 joela Exp $ +} { + workflow_id + {orderby "title,asc"} + {type:optional} +} + +set package_id [ad_conn package_id] + +#--------------------------------------------------------------------- +# Get information about the workflow +#--------------------------------------------------------------------- + +workflow::get -workflow_id $workflow_id -array workflow +set page_title "Add Sim Objects to $workflow(pretty_name)" +set context [list [list "sim-template-list" "Sim Templates"] [list "sim-template-edit?workflow_id=$workflow_id" "$workflow(pretty_name)"] $page_title] + + +###################################################################### +# +# sim_objects +# +# A list of objects to add to a chosen workflow +# At the moment, this is all objects +# TODO: add checkbox to allow adding multiple objects in one go +# +###################################################################### + +#--------------------------------------------------------------------- +# sim_objects list +#--------------------------------------------------------------------- + +template::list::create \ + -name sim_objects \ + -multirow sim_objects \ + -no_data "No unlinked objects" \ + -elements { + object_type_pretty { + label "Type" + orderby upper(ot.pretty_name) + } + title { + label "Title" + orderby r.title + link_url_col view_url + } + description { + label "Description" + orderby r.description + } + add_to_sim_template { + sub_class narrow + link_url_col add_to_sim_template_url + display_template { + Add to Template + } + } + } + +#--------------------------------------------------------------------- +# sim_objects database query +#--------------------------------------------------------------------- + +db_multirow -extend { view_url add_to_sim_template_url } sim_objects sim_objects_select " + select i.item_id, + i.name, + r.title, + r.description, + i.content_type, + ot.pretty_name as object_type_pretty + from cr_folders f, + cr_items i, + cr_revisions r, + acs_object_types ot + where f.package_id = :package_id + and i.parent_id = f.folder_id + and r.revision_id = i.live_revision + and ot.object_type = i.content_type + and i.item_id not in (select object_id + from sim_workflow_object_map + where workflow_id = :workflow_id) + [template::list::orderby_clause -orderby -name "sim_objects"] +" { + set description [string_truncate -len 200 $description] + set view_url [export_vars -base "object/$name"] + set add_to_sim_template_url [export_vars -base "sim-template-add-objects-2.tcl" { item_id workflow_id }] +} + +#--------------------------------------------------------------------- +# Create variables for the adp +#--------------------------------------------------------------------- + +set create_object_url [export_vars -base "object-edit" { workflow_id } ] \ No newline at end of file Index: openacs-4/contrib/packages/simulation/www/sim-template-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/sim-template-edit.adp 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,17 @@ + + @page_title;noquote@ + @context;noquote@ + object.title + + + + +

Associated Sim Objects

+

+

Add Sim +Objects to this Workflow +

Roles

+

+

Add a role +

Tasks

+ \ No newline at end of file Index: openacs-4/contrib/packages/simulation/www/sim-template-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/sim-template-edit.tcl 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,245 @@ +ad_page_contract { + Add/edit template. + + @creation-date 2003-10-13 + @cvs-id $Id: sim-template-edit.tcl,v 1.1 2003/10/24 09:46:13 joela Exp $ +} { + workflow_id:optional +} + +set package_key [ad_conn package_key] +set package_id [ad_conn package_id] + +###################################################################### +# +# sim_template +# +# a form showing fields for a sim template +# includes add, edit, and display modes and handles form submission +# +# TODO: display mode doesn't exist yet - all display is through edit mode +# +###################################################################### + +#--------------------------------------------------------------------- +# sim_template form +#--------------------------------------------------------------------- + +ad_form -name sim_template -cancel_url sim-template-list -form { + {workflow_id:key} + {name:text,optional + {label "Template Name"} + {html {size 40}} + } +} -edit_request { + workflow::get -workflow_id $workflow_id -array sim_template_array + set name $sim_template_array(pretty_name) + set page_title "Edit template $name" + set context [list [list "sim-template-list" "Templates"] $page_title] +} -new_request { + set page_title "Create template" + set context [list [list "sim-template-list" "Templates"] $page_title] +} -new_data { + set workflow_id [workflow::new \ + -short_name $name \ + -pretty_name $name \ + -package_key $package_key] + # create a dummy action with initial action setting because + # workflow::get doesn't work on bare workflows + workflow::action::fsm::new -initial_action_p t -workflow_id $workflow_id \ + -short_name "dummy action" \ + -pretty_name "dummy action" +} -after_submit { + ad_returnredirect sim-template-edit?workflow_id=$workflow_id + ad_script_abort +} + +#--------------------------------------------------------------------- +# Determine if we are in edit mode or display mode +#--------------------------------------------------------------------- +# this is prototype code to correct for get_action's apparent +# unreliability + +set mode [template::form::get_action sim_template] +if { ![exists_and_not_null workflow_id]} { + set mode "add" +} else { + # for now, use edit mode in place of display mode + # set mode "display" + set mode "edit" +} + +###################################################################### +# +# sim_template +# +# a form showing fields for a sim template, handling view mode and +# edit mode, and handling form submission +# +###################################################################### + +switch $mode { + add { + set page_title "New Simulation Template" + } + edit { + set page_title "Editing $name" + + #------------------------------------------------------------- + # in display mode, show lists of subordinate things + #------------------------------------------------------------- + + ############################################################## + # + # sim_objects + # + # A list of all objects associated with the Simulation Template + # + ############################################################## + + # maybe replace this chunk of copied text with an includable template + # which passes in a filter for the workflow_id? + + + #------------------------------------------------------------- + # sim_objects list + #------------------------------------------------------------- + + template::list::create \ + -name sim_objects \ + -multirow sim_objects \ + -elements { + edit { + sub_class narrow + link_url_col edit_url + display_template { + Edit + } + } + object_type_pretty { + label "Type" + orderby upper(ot.pretty_name) + } + title { + label "Title" + orderby r.title + link_url_col view_url + } + description { + label "Description" + orderby r.description + } + } + + db_multirow -extend { edit_url view_url delete_url } sim_objects select_sim_objects " + select i.item_id, + i.name, + r.title, + r.description, + i.content_type, + ot.pretty_name as object_type_pretty + from cr_folders f, + cr_items i, + cr_revisions r, + acs_object_types ot, + sim_workflow_object_map swom + where f.package_id = :package_id + and i.parent_id = f.folder_id + and r.revision_id = i.live_revision + and ot.object_type = i.content_type + and swom.workflow_id = :workflow_id + and swom.object_id = i.item_id + + [template::list::orderby_clause -orderby -name "sim_objects"] +" { + set description [string_truncate -len 200 $description] + set edit_url [export_vars -base "object-edit" { item_id }] + set view_url [export_vars -base "object/$name"] + set delete_url [export_vars -base "object-delete" { item_id }] +} + + set sim_types { sim_character sim_prop sim_home } + + db_multirow -extend { create_url label } object_types select_object_types " + select ot.object_type as content_type, + ot.pretty_name + from acs_object_types ot + where ot.object_type in ('[join $sim_types "','"]') +" { + set create_url [export_vars -base object-edit { content_type parent_id }] + set label "Create new $pretty_name" +} + + ############################################################## + # + # roles + # + # A list of all roles associated with the Simulation Template + # + ############################################################## + + # maybe replace this chunk of copied text with an includable template + # which passes in a filter for the workflow_id? + + + #------------------------------------------------------------- + # roles list + #------------------------------------------------------------- + + template::list::create \ + -name roles \ + -multirow roles \ + -elements { + edit { + sub_class narrow + link_url_col edit_url + display_template { + Edit + } + } + title { + label "Name" + } + character { + label "Character" + link_url_col char_url + } + delete { + sub_class narrow + link_url_col delete_url + display_template { + Edit + } + } + } + +# TODO: fix this so it returns rows when it should + db_multirow -extend { edit_url char_url delete_url } roles select_roles " + select wr.role_id, + wr.pretty_name as name, + wr.sort_order, + cr.title as character, + i.name as char_name + from workflow_roles wr, + sim_roles sr, + cr_revisions cr, + cr_items i + where wr.workflow_id = :workflow_id + and sr.role_id = wr.role_id + and cr.item_id = sr.character_id + and i.item_id = sr.character_id + [template::list::orderby_clause -orderby -name "roles"] +" { + set edit_url [export_vars -base "role-edit" { role_id }] + set char_url [export_vars -base "object/$char_name"] + set delete_url [export_vars -base "role-delete" { role_id }] +} + } +} + +set context [list [list "sim-template-list" "Sim Templates"] $page_title] + + +# maybe replace this chunk of copied text with an includable template +# which passes in a filter for the workflow_id? + Index: openacs-4/contrib/packages/simulation/www/sim-template-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-list.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/sim-template-list.adp 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,7 @@ + + @page_title;noquote@ + @context;noquote@ + +

+

Add a template +

Add a template via wizard \ No newline at end of file Index: openacs-4/contrib/packages/simulation/www/sim-template-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-list.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/sim-template-list.tcl 17 Oct 2003 10:39:08 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/sim-template-list.tcl 24 Oct 2003 09:46:13 -0000 1.2 @@ -1,3 +1,73 @@ ad_page_contract { - List workflows on this system. + List workflows designated as templates (but not simulations or cases) on this system. } +set page_title "Templates" +set context [list $page_title] + +template::list::create \ + -name sim_templates \ + -multirow sim_templates \ + -elements { + edit { + sub_class narrow + link_url_col edit_url + display_template { + Edit + } + } + name { + label "Name" + orderby upper(ot.pretty_name) + link_url_col view_url + } + description { + label "Description" + orderby r.description + } + created_by { + label "Created by" + orderby r.createdby + } + object_count { + label "Objects" + } + role_count { + label "Roles" + } + task_count { + label "Tasks" + } + delete { + sub_class narrow + link_url_col delete_url + display_template { + Edit + } + } + } + +set package_id [ad_conn package_id] + +db_multirow -extend { edit_url view_url delete_url } sim_templates select_sim_templates " + select w.workflow_id, + w.pretty_name as name, + 'placeholder' as description, + a.creation_user as created_by, + (select count(object_id) + from sim_workflow_object_map + where workflow_id = w.workflow_id) as object_count, + (select count(role_id) + from workflow_roles + where workflow_id = w.workflow_id) as role_count, + (select count(action_id) + from workflow_actions + where workflow_id = w.workflow_id) as task_count + from workflows w, acs_objects a + where w.workflow_id = a.object_id + [template::list::orderby_clause -orderby -name sim_templates] +" { + set description [string_truncate -len 200 $description] + set edit_url [export_vars -base "sim-template-edit?workflow_id=$workflow_id"] + set view_url [export_vars -base "sim-template-edit?workflow_id=$workflow_id"] + set delete_url [export_vars -base "sim-template-delete?workflow_id=$workflow_id"] +} Index: openacs-4/contrib/packages/simulation/www/sim-template.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template.adp,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/sim-template.adp 17 Oct 2003 11:11:25 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/sim-template.adp 24 Oct 2003 09:46:13 -0000 1.3 @@ -1,51 +1,2 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Name - - - Description - - Author - -
- Edit - - Legislative Drafting - - Learn how to draft legislative text - - Center for ELaw@leiden - - - Edit - - -
\ No newline at end of file Index: openacs-4/contrib/packages/simulation/www/sim-template.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/sim-template.tcl 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,25 @@ +ad_page_contract { + + @creation-date 2003-10-13 + @cvs-id $Id: sim-template.tcl,v 1.1 2003/10/24 09:46:13 joela Exp $ +} { +} -properties { +} + + +multirow cases + +template::list::create \ + -name cases \ + -multirow cases \ + -elements { + case_name { + label "Case" + orderby case_name + } + task_count { + label "Tasks" + orderby task_count + } + } + Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/simulation/www/template.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/simulation/sql/postgresql/simulation-content-types-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/sql/postgresql/simulation-content-types-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/simulation/sql/postgresql/simulation-content-types-create.sql 17 Oct 2003 09:55:53 -0000 1.3 +++ openacs-4/packages/simulation/sql/postgresql/simulation-content-types-create.sql 24 Oct 2003 09:46:13 -0000 1.4 @@ -2,7 +2,19 @@ -- @creation-date 2003-10-14 -- @cvs-id $Id$ +-- sim_stylesheet +-- a chunk of css stylesheet +select content_type__create_type( + 'sim_stylesheet', -- content_type + 'content_revision', -- supertype + 'Stylesheet', -- pretty_name, + 'Stylesheets', -- pretty_plural + 'sim_stylesheets', -- table_name + 'stylesheet_id', -- id_column + null -- name_method +); + -- sim_character select content_type__create_type( @@ -18,16 +30,14 @@ select content_type__create_attribute( 'sim_character', -- content_type 'stylesheet', -- attribute_name - 'text', -- datatype + 'integer', -- datatype 'Stylesheet', -- pretty_name 'Stylesheets', -- pretty_plural 1, -- sort_order null, -- default_value - 'text' -- column_spec + 'integer constraint sim_char_stylesheet_fk references sim_stylesheets(stylesheet_id)' -- column_spec ); - - -- sim_prop select content_type__create_type( @@ -41,19 +51,17 @@ ); select content_type__create_attribute( - 'sim_prop', -- content_type + 'sim_prop', -- content_type 'stylesheet', -- attribute_name - 'text', -- datatype + 'integer', -- datatype 'Stylesheet', -- pretty_name 'Stylesheets', -- pretty_plural 1, -- sort_order null, -- default_value - 'text' -- column_spec + 'integer constraint sim_char_stylesheet_fk references sim_stylesheets(stylesheet_id)' -- column_spec ); - - -- sim_home select content_type__create_type( @@ -99,13 +107,14 @@ 'text' -- column_spec ); + select content_type__create_attribute( 'sim_home', -- content_type 'stylesheet', -- attribute_name - 'text', -- datatype + 'integer', -- datatype 'Stylesheet', -- pretty_name 'Stylesheets', -- pretty_plural 4, -- sort_order null, -- default_value - 'text' -- column_spec + 'integer constraint sim_char_stylesheet_fk references sim_stylesheets(stylesheet_id)' -- column_spec ); Index: openacs-4/packages/simulation/tcl/simulation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/simulation-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/tcl/simulation-procs.tcl 14 Oct 2003 13:58:03 -0000 1.1 +++ openacs-4/packages/simulation/tcl/simulation-procs.tcl 24 Oct 2003 09:46:13 -0000 1.2 @@ -7,7 +7,20 @@ } namespace eval simulation {} +namespace eval simulation::object_type {} +ad_proc -public simulation::object_type::get_options { +} { + Generate a list of object types formatted as an option list for form-builder's widgets. +} { + set sim_types { sim_character sim_prop sim_home } + return [db_list_of_lists object_types " + select ot.pretty_name, + ot.object_type + from acs_object_types ot + where ot.object_type in ('[join $sim_types "','"]') + "] +} -# Lars: Nothing here yet, keeping it in case we want to add something + Index: openacs-4/packages/simulation/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/index.adp,v diff -u -r1.9 -r1.10 --- openacs-4/packages/simulation/www/index.adp 21 Oct 2003 12:53:50 -0000 1.9 +++ openacs-4/packages/simulation/www/index.adp 24 Oct 2003 09:46:13 -0000 1.10 @@ -1,37 +1,10 @@ Your live cases: - +

+

Join a Simulation: +

- - - - - - - - - - -
- Case - - Tasks -
- Legislative Drafting (EUR) - - 3 -
- Elementary Private Law (UVT) - - 0 -
- -


-Join a Simulation: - - -
Simulation @@ -47,19 +20,11 @@
- - -
-

Administrators also see:

- -
+

Sim Objects (administrators only) +

+

Add an object +

+

View and edit simulation templates

If not logged in:

Sieberdam currently has @@ -68,9 +33,6 @@
8 running simulations

Join a Simulation -

Index: openacs-4/packages/simulation/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/index.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/www/index.tcl 14 Oct 2003 13:58:03 -0000 1.2 +++ openacs-4/packages/simulation/www/index.tcl 24 Oct 2003 09:46:13 -0000 1.3 @@ -6,10 +6,22 @@ } -properties { } -# phase2: sortable, filterable +###################################################################### +# +# active_cases +# +# a list of active cases for logged-in user +# +###################################################################### + +#--------------------------------------------------------------------- +# active_cases list +#--------------------------------------------------------------------- + template::list::create \ - -name cases \ - -multirow cases \ + -name active_cases \ + -multirow active_cases \ + -html {width "100%"}\ -elements { case_name { label "Case" @@ -21,30 +33,107 @@ } } -# phase2: a list of cases for which the user has a role, along with a count of the -# number of active tasks for that role +#--------------------------------------------------------------------- +# active_cases database query +#--------------------------------------------------------------------- +# this is currently a dummy query. For Phase 2, it should get all cases +# for which the logged-in user has a role, and a count of active tasks +# for that role. -db_multirow cases cases_sql { +db_multirow active_cases active_cases_select { select 'case one' as case_name, 2 as task_count } + +###################################################################### +# +# object_count +# +# A count of all objects in the system, by type, for admins +# +###################################################################### + +#--------------------------------------------------------------------- +# object_count list +#--------------------------------------------------------------------- + template::list::create \ - -name cases \ - -multirow cases \ + -name object_count \ + -multirow object_count \ + -html {width "100%"} \ -elements { - case_name { - label "Case" - orderby case_name - } - task_count { - label "Tasks" - orderby task_count - } + type { + label "Type" + } + count { + label "Count" + link_url_col view_url + } } -db_multirow cases cases_sql { - select 'case one', 'case two' as case_name, - 0,2 as task_count - from dual +#--------------------------------------------------------------------- +# object_count database query +#--------------------------------------------------------------------- + +db_multirow -extend { view_url } object_count object_count_select " + select object_type as type, + count(object_type) as count + from acs_objects + where object_type like 'sim_%' + group by object_type +" { + set view_url [export_vars -base "object-list" { type }] } + + +###################################################################### +# +# sim_template_count +# +# A count of all templates, for admins +# They should probably be grouped, but I'm not sure what to group +# them by yet +# +###################################################################### + +#--------------------------------------------------------------------- +# sim_template_count list +#--------------------------------------------------------------------- + +template::list::create \ + -name sim_template_count \ + -multirow sim_template_count \ + -html {width "100%"} \ + -elements { + count { + label "Simulation Templates" + link_url_col view_url + } + } + + + +template::list::create \ + -name template_count \ + -multirow template_count \ + -elements { + type { + label "Type" + } + count { + label "Count" + link_url_col view_url + } + } + +#--------------------------------------------------------------------- +# template_count database query +#--------------------------------------------------------------------- + +db_multirow -extend { view_url } sim_template_count sim_template_count_query " + select count(workflow_id) as count + from workflows w +" { + set view_url [export_vars -base "sim-template-list"] +} Index: openacs-4/packages/simulation/www/object-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/object-edit.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/simulation/www/object-edit.tcl 17 Oct 2003 09:55:53 -0000 1.4 +++ openacs-4/packages/simulation/www/object-edit.tcl 24 Oct 2003 09:46:13 -0000 1.5 @@ -5,25 +5,55 @@ @cvs-id $Id$ } { item_id:integer,optional - parent_id:integer,optional - content_type:optional -} -validate { - not_item_id { - if { ![exists_and_not_null item_id] } { - if { ![exists_and_not_null parent_id] } { - ad_complain "parent_id is required" - } - if { ![exists_and_not_null content_type] } { - ad_complain "content_type is required" - } - } - } + {parent_id:integer {[bcms::folder::get_id_by_package_id -parent_id 0]}} + {content_type {sim_prop}} } +#TODO: object type should be non-editable for non-new things + +#--------------------------------------------------------------------- +# Determine if we are in edit mode or display mode +#--------------------------------------------------------------------- +# this is prototype code to correct for get_action's apparent +# unreliability + +#set mode [template::form::get_action sim_template] +#if { ![exists_and_not_null workflow_id]} { +# set mode "add" +#} else { +# # for now, use edit mode in place of display mode +# # set mode "display" +# set mode "edit" +#} + +if { ![ad_form_new_p -key item_id] } { + # Get data for existing object + array set item_info [bcms::item::get_item -item_id $item_id -revision live] + item::get_revision_content $item_info(revision_id) + set content_type $item_info(content_type) + set page_title "Edit Sim Object" +} else { + set page_title "Create Sim Object" +} +set context [list [list "object-list" "Sim Objects"] $page_title] + + +###################################################################### +# +# object +# +# A form for editing and viewing sim objects +# +###################################################################### + ad_form -name object -cancel_url object-list -form { {item_id:key} - {content_type:text(hidden)} {parent_id:integer(hidden),optional} + {content_type:text(radio) + {label "Type"} + {options {[simulation::object_type::get_options]}} + {mode "display"} + } {title:text {label "Title"} {html {size 50}} @@ -40,23 +70,13 @@ } } -if { ![ad_form_new_p -key item_id] } { - # Get data for existing object - array set item_info [bcms::item::get_item -item_id $item_id -revision live] - item::get_revision_content $item_info(revision_id) - set content_type $item_info(content_type) - set page_title "Edit Object" -} else { - set object_type_pretty [db_string pretty { select pretty_name from acs_object_types where object_type = :content_type }] - set page_title "Create $object_type_pretty" -} -set context [list [list "object-list" "Objects"] $page_title] - ##### # # Content edit/upload method # +# Add a form widget appropriate for the content attribute of the object type +# ##### array set content_method { @@ -88,6 +108,8 @@ # # Dynamic attributes for the content type # +# Look up the other attributes for this content type and put them on the form +# ##### # LARS: I'm doing this as a proof-of-concept type thing. If it works well enough for us, Index: openacs-4/packages/simulation/www/object-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/object-list.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/simulation/www/object-list.tcl 17 Oct 2003 09:55:54 -0000 1.4 +++ openacs-4/packages/simulation/www/object-list.tcl 24 Oct 2003 09:46:13 -0000 1.5 @@ -5,6 +5,7 @@ } { parent_id:optional {orderby "title,asc"} + {type:optional} } set page_title "Objects" Index: openacs-4/packages/simulation/www/role-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/role-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/role-edit.adp 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,7 @@ + + @page_title;noquote@ + @context;noquote@ + object.title + + + Index: openacs-4/packages/simulation/www/role-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/role-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/role-edit.tcl 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,103 @@ +ad_page_contract { + Add/edit template. + + @creation-date 2003-10-13 + @cvs-id $Id: role-edit.tcl,v 1.1 2003/10/24 09:46:13 joela Exp $ +} { + workflow_id:optional + role_id:optional +} -validate { + workflow_id_or_role_id { + if { ![exists_and_not_null workflow_id] && + ![exists_and_not_null role_id]} { + ad_complain "Either role_id or workflow_id is required." + } + } +} + +###################################################################### +# +# preparation +# +###################################################################### +# TODO: one of workflow_id or role_id is required +# enforce this in page contract validation +# redirect to sim-template-list if both missing + +set package_key [ad_conn package_key] +set package_id [ad_conn package_id] + +#--------------------------------------------------------------------- +# Get a list of relevant characters +#--------------------------------------------------------------------- +# TODO: make sure this query (and other queries to cr) get only the live +# record from cr_revisions +# deliberately not checking to see if character is already cast in sim +# because no reason not to have same character in multiple roles (?) + +set char_options [db_list_of_lists character_option_list " + select ci.name, + a.object_id + from cr_revisions cr, + cr_items ci, + acs_objects a + where a.object_type = 'sim_character' + and cr.revision_id = a.object_id + and ci.item_id = cr.item_id +"] + +###################################################################### +# +# role +# +# a form showing fields for a role in a workflow +# includes add and edit modes and handles form submission +# display mode is only in list form via sim-template-edit +# +###################################################################### + +#--------------------------------------------------------------------- +# role form +#--------------------------------------------------------------------- + +ad_form -name role -cancel_url sim-template-list -form { + {role_id:key} + {workflow_id:integer(hidden),optional} + {name:text + {label "Role Name"} + {html {size 20}} + } + {character_id:text(select) + {label "Character"} + {options $char_options} + } +} -edit_request { + workflow::role::get -role_id $role_id -array role_array + set workflow_id $role_array(workflow_id) + set name $role_array(pretty_name) + workflow::get -workflow_id $workflow_id -array sim_template_array + set page_title "Edit Role template $name" + set context [list [list "sim-template-list" "Sim Templates"] [list "sim-template-edit?workflow_id=$workflow_id" "$sim_template_array(pretty_name)"] $page_title] +} -new_request { + workflow::get -workflow_id $workflow_id -array sim_template_array + set page_title "Add Role to $sim_template_array(pretty_name)" + set context [list [list "sim-template-list" "Sim Templates"] [list "sim-template-edit?workflow_id=$workflow_id" "$sim_template_array(pretty_name)"] $page_title] +} -new_data { + # create the role + set role_id [workflow::role::new \ + -workflow_id $workflow_id \ + -short_name $name \ + -pretty_name $name] + # and then add extra data for simulation + db_dml set_role_character { + insert into sim_roles + values (:role_id, :character_id) + } +} -after_submit { + ad_returnredirect [export_vars -base "sim-template-edit" { workflow_id }] + ad_script_abort +} + +# maybe replace this chunk of copied text with an includable template +# which passes in a filter for the workflow_id? + Index: openacs-4/packages/simulation/www/sim-template-add-objects-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-add-objects-2.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/sim-template-add-objects-2.tcl 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,23 @@ +ad_page_contract { + + @creation-date 2003-10-13 + @cvs-id $Id: sim-template-add-objects-2.tcl,v 1.1 2003/10/24 09:46:13 joela Exp $ +} { + workflow_id + item_id +} + +set package_id [ad_conn package_id] + +###################################################################### +# +# add the object to the workflow +# +###################################################################### + +db_dml add_object_to_workflow_insert " +insert into sim_workflow_object_map +values (:workflow_id, :item_id) +" + +ad_returnredirect "sim-template-edit?workflow_id=$workflow_id" \ No newline at end of file Index: openacs-4/packages/simulation/www/sim-template-add-objects.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-add-objects.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/sim-template-add-objects.adp 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,7 @@ + + @page_title;noquote@ + @context;noquote@ + +

+

Create a new object and add it + Index: openacs-4/packages/simulation/www/sim-template-add-objects.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-add-objects.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/sim-template-add-objects.tcl 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,96 @@ +ad_page_contract { + + @creation-date 2003-10-13 + @cvs-id $Id: sim-template-add-objects.tcl,v 1.1 2003/10/24 09:46:13 joela Exp $ +} { + workflow_id + {orderby "title,asc"} + {type:optional} +} + +set package_id [ad_conn package_id] + +#--------------------------------------------------------------------- +# Get information about the workflow +#--------------------------------------------------------------------- + +workflow::get -workflow_id $workflow_id -array workflow +set page_title "Add Sim Objects to $workflow(pretty_name)" +set context [list [list "sim-template-list" "Sim Templates"] [list "sim-template-edit?workflow_id=$workflow_id" "$workflow(pretty_name)"] $page_title] + + +###################################################################### +# +# sim_objects +# +# A list of objects to add to a chosen workflow +# At the moment, this is all objects +# TODO: add checkbox to allow adding multiple objects in one go +# +###################################################################### + +#--------------------------------------------------------------------- +# sim_objects list +#--------------------------------------------------------------------- + +template::list::create \ + -name sim_objects \ + -multirow sim_objects \ + -no_data "No unlinked objects" \ + -elements { + object_type_pretty { + label "Type" + orderby upper(ot.pretty_name) + } + title { + label "Title" + orderby r.title + link_url_col view_url + } + description { + label "Description" + orderby r.description + } + add_to_sim_template { + sub_class narrow + link_url_col add_to_sim_template_url + display_template { + Add to Template + } + } + } + +#--------------------------------------------------------------------- +# sim_objects database query +#--------------------------------------------------------------------- + +db_multirow -extend { view_url add_to_sim_template_url } sim_objects sim_objects_select " + select i.item_id, + i.name, + r.title, + r.description, + i.content_type, + ot.pretty_name as object_type_pretty + from cr_folders f, + cr_items i, + cr_revisions r, + acs_object_types ot + where f.package_id = :package_id + and i.parent_id = f.folder_id + and r.revision_id = i.live_revision + and ot.object_type = i.content_type + and i.item_id not in (select object_id + from sim_workflow_object_map + where workflow_id = :workflow_id) + [template::list::orderby_clause -orderby -name "sim_objects"] +" { + set description [string_truncate -len 200 $description] + set view_url [export_vars -base "object/$name"] + set add_to_sim_template_url [export_vars -base "sim-template-add-objects-2.tcl" { item_id workflow_id }] +} + +#--------------------------------------------------------------------- +# Create variables for the adp +#--------------------------------------------------------------------- + +set create_object_url [export_vars -base "object-edit" { workflow_id } ] \ No newline at end of file Index: openacs-4/packages/simulation/www/sim-template-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/sim-template-edit.adp 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,17 @@ + + @page_title;noquote@ + @context;noquote@ + object.title + + + + +

Associated Sim Objects

+

+

Add Sim +Objects to this Workflow +

Roles

+

+

Add a role +

Tasks

+ \ No newline at end of file Index: openacs-4/packages/simulation/www/sim-template-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/sim-template-edit.tcl 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,245 @@ +ad_page_contract { + Add/edit template. + + @creation-date 2003-10-13 + @cvs-id $Id: sim-template-edit.tcl,v 1.1 2003/10/24 09:46:13 joela Exp $ +} { + workflow_id:optional +} + +set package_key [ad_conn package_key] +set package_id [ad_conn package_id] + +###################################################################### +# +# sim_template +# +# a form showing fields for a sim template +# includes add, edit, and display modes and handles form submission +# +# TODO: display mode doesn't exist yet - all display is through edit mode +# +###################################################################### + +#--------------------------------------------------------------------- +# sim_template form +#--------------------------------------------------------------------- + +ad_form -name sim_template -cancel_url sim-template-list -form { + {workflow_id:key} + {name:text,optional + {label "Template Name"} + {html {size 40}} + } +} -edit_request { + workflow::get -workflow_id $workflow_id -array sim_template_array + set name $sim_template_array(pretty_name) + set page_title "Edit template $name" + set context [list [list "sim-template-list" "Templates"] $page_title] +} -new_request { + set page_title "Create template" + set context [list [list "sim-template-list" "Templates"] $page_title] +} -new_data { + set workflow_id [workflow::new \ + -short_name $name \ + -pretty_name $name \ + -package_key $package_key] + # create a dummy action with initial action setting because + # workflow::get doesn't work on bare workflows + workflow::action::fsm::new -initial_action_p t -workflow_id $workflow_id \ + -short_name "dummy action" \ + -pretty_name "dummy action" +} -after_submit { + ad_returnredirect sim-template-edit?workflow_id=$workflow_id + ad_script_abort +} + +#--------------------------------------------------------------------- +# Determine if we are in edit mode or display mode +#--------------------------------------------------------------------- +# this is prototype code to correct for get_action's apparent +# unreliability + +set mode [template::form::get_action sim_template] +if { ![exists_and_not_null workflow_id]} { + set mode "add" +} else { + # for now, use edit mode in place of display mode + # set mode "display" + set mode "edit" +} + +###################################################################### +# +# sim_template +# +# a form showing fields for a sim template, handling view mode and +# edit mode, and handling form submission +# +###################################################################### + +switch $mode { + add { + set page_title "New Simulation Template" + } + edit { + set page_title "Editing $name" + + #------------------------------------------------------------- + # in display mode, show lists of subordinate things + #------------------------------------------------------------- + + ############################################################## + # + # sim_objects + # + # A list of all objects associated with the Simulation Template + # + ############################################################## + + # maybe replace this chunk of copied text with an includable template + # which passes in a filter for the workflow_id? + + + #------------------------------------------------------------- + # sim_objects list + #------------------------------------------------------------- + + template::list::create \ + -name sim_objects \ + -multirow sim_objects \ + -elements { + edit { + sub_class narrow + link_url_col edit_url + display_template { + Edit + } + } + object_type_pretty { + label "Type" + orderby upper(ot.pretty_name) + } + title { + label "Title" + orderby r.title + link_url_col view_url + } + description { + label "Description" + orderby r.description + } + } + + db_multirow -extend { edit_url view_url delete_url } sim_objects select_sim_objects " + select i.item_id, + i.name, + r.title, + r.description, + i.content_type, + ot.pretty_name as object_type_pretty + from cr_folders f, + cr_items i, + cr_revisions r, + acs_object_types ot, + sim_workflow_object_map swom + where f.package_id = :package_id + and i.parent_id = f.folder_id + and r.revision_id = i.live_revision + and ot.object_type = i.content_type + and swom.workflow_id = :workflow_id + and swom.object_id = i.item_id + + [template::list::orderby_clause -orderby -name "sim_objects"] +" { + set description [string_truncate -len 200 $description] + set edit_url [export_vars -base "object-edit" { item_id }] + set view_url [export_vars -base "object/$name"] + set delete_url [export_vars -base "object-delete" { item_id }] +} + + set sim_types { sim_character sim_prop sim_home } + + db_multirow -extend { create_url label } object_types select_object_types " + select ot.object_type as content_type, + ot.pretty_name + from acs_object_types ot + where ot.object_type in ('[join $sim_types "','"]') +" { + set create_url [export_vars -base object-edit { content_type parent_id }] + set label "Create new $pretty_name" +} + + ############################################################## + # + # roles + # + # A list of all roles associated with the Simulation Template + # + ############################################################## + + # maybe replace this chunk of copied text with an includable template + # which passes in a filter for the workflow_id? + + + #------------------------------------------------------------- + # roles list + #------------------------------------------------------------- + + template::list::create \ + -name roles \ + -multirow roles \ + -elements { + edit { + sub_class narrow + link_url_col edit_url + display_template { + Edit + } + } + title { + label "Name" + } + character { + label "Character" + link_url_col char_url + } + delete { + sub_class narrow + link_url_col delete_url + display_template { + Edit + } + } + } + +# TODO: fix this so it returns rows when it should + db_multirow -extend { edit_url char_url delete_url } roles select_roles " + select wr.role_id, + wr.pretty_name as name, + wr.sort_order, + cr.title as character, + i.name as char_name + from workflow_roles wr, + sim_roles sr, + cr_revisions cr, + cr_items i + where wr.workflow_id = :workflow_id + and sr.role_id = wr.role_id + and cr.item_id = sr.character_id + and i.item_id = sr.character_id + [template::list::orderby_clause -orderby -name "roles"] +" { + set edit_url [export_vars -base "role-edit" { role_id }] + set char_url [export_vars -base "object/$char_name"] + set delete_url [export_vars -base "role-delete" { role_id }] +} + } +} + +set context [list [list "sim-template-list" "Sim Templates"] $page_title] + + +# maybe replace this chunk of copied text with an includable template +# which passes in a filter for the workflow_id? + Index: openacs-4/packages/simulation/www/sim-template-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-list.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/sim-template-list.adp 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,7 @@ + + @page_title;noquote@ + @context;noquote@ + +

+

Add a template +

Add a template via wizard \ No newline at end of file Index: openacs-4/packages/simulation/www/sim-template-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-list.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/www/sim-template-list.tcl 17 Oct 2003 10:39:08 -0000 1.1 +++ openacs-4/packages/simulation/www/sim-template-list.tcl 24 Oct 2003 09:46:13 -0000 1.2 @@ -1,3 +1,73 @@ ad_page_contract { - List workflows on this system. + List workflows designated as templates (but not simulations or cases) on this system. } +set page_title "Templates" +set context [list $page_title] + +template::list::create \ + -name sim_templates \ + -multirow sim_templates \ + -elements { + edit { + sub_class narrow + link_url_col edit_url + display_template { + Edit + } + } + name { + label "Name" + orderby upper(ot.pretty_name) + link_url_col view_url + } + description { + label "Description" + orderby r.description + } + created_by { + label "Created by" + orderby r.createdby + } + object_count { + label "Objects" + } + role_count { + label "Roles" + } + task_count { + label "Tasks" + } + delete { + sub_class narrow + link_url_col delete_url + display_template { + Edit + } + } + } + +set package_id [ad_conn package_id] + +db_multirow -extend { edit_url view_url delete_url } sim_templates select_sim_templates " + select w.workflow_id, + w.pretty_name as name, + 'placeholder' as description, + a.creation_user as created_by, + (select count(object_id) + from sim_workflow_object_map + where workflow_id = w.workflow_id) as object_count, + (select count(role_id) + from workflow_roles + where workflow_id = w.workflow_id) as role_count, + (select count(action_id) + from workflow_actions + where workflow_id = w.workflow_id) as task_count + from workflows w, acs_objects a + where w.workflow_id = a.object_id + [template::list::orderby_clause -orderby -name sim_templates] +" { + set description [string_truncate -len 200 $description] + set edit_url [export_vars -base "sim-template-edit?workflow_id=$workflow_id"] + set view_url [export_vars -base "sim-template-edit?workflow_id=$workflow_id"] + set delete_url [export_vars -base "sim-template-delete?workflow_id=$workflow_id"] +} Index: openacs-4/packages/simulation/www/sim-template.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/www/sim-template.adp 17 Oct 2003 11:11:25 -0000 1.2 +++ openacs-4/packages/simulation/www/sim-template.adp 24 Oct 2003 09:46:13 -0000 1.3 @@ -1,51 +1,2 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Name - - - Description - - Author - -
- Edit - - Legislative Drafting - - Learn how to draft legislative text - - Center for ELaw@leiden - - - Edit - - -
\ No newline at end of file Index: openacs-4/packages/simulation/www/sim-template.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/sim-template.tcl 24 Oct 2003 09:46:13 -0000 1.1 @@ -0,0 +1,25 @@ +ad_page_contract { + + @creation-date 2003-10-13 + @cvs-id $Id: sim-template.tcl,v 1.1 2003/10/24 09:46:13 joela Exp $ +} { +} -properties { +} + + +multirow cases + +template::list::create \ + -name cases \ + -multirow cases \ + -elements { + case_name { + label "Case" + orderby case_name + } + task_count { + label "Tasks" + orderby task_count + } + } + Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/simulation/www/template.tcl'. Fisheye: No comparison available. Pass `N' to diff?