Index: openacs-4/packages/ams/ams.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/ams.info,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/ams/ams.info 20 Oct 2004 21:40:01 -0000 1.1 +++ openacs-4/packages/ams/ams.info 30 Oct 2004 00:23:54 -0000 1.2 @@ -8,12 +8,12 @@ t ams - + Matthew Geddert Store attributes via the Content Repository, and auto generate input forms - AMS (Attribute Management System) uses the content repository to store attribute history for any object on the system. It has an admin interface that lets applications dynamically add fields to their forms. + AMS (Attribute Management System) helps in customizing your website. It lets you adjust what information is collected and displayed for any package that is integrated with it. AMS allows you to easily and dynamically add attributes to forms and display pages, using a Tcl API or an admin interface. AMS uses the content repository to store attribute history for any object on the system. - + Index: openacs-4/packages/ams/sql/postgresql/ams-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/sql/postgresql/ams-create.sql,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/ams/sql/postgresql/ams-create.sql 27 Oct 2004 02:04:18 -0000 1.3 +++ openacs-4/packages/ams/sql/postgresql/ams-create.sql 30 Oct 2004 00:23:54 -0000 1.4 @@ -347,8 +347,8 @@ 'ams_list', -- object_type 'description_mime_type', -- attribute_name 'text', -- datatype - 'Descriptions', -- pretty_name - 'Description Mime Types', -- pretty_plural -- default null + 'Description Mime Type', -- pretty_name + 'Descriptions Mime Types', -- pretty_plural -- default null null, -- table_name -- default null 'description_mime_type', -- column_name -- default null null, -- default_value -- default null Index: openacs-4/packages/ams/sql/postgresql/populate.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/sql/postgresql/populate.sql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/ams/sql/postgresql/populate.sql 20 Oct 2004 21:40:04 -0000 1.1 +++ openacs-4/packages/ams/sql/postgresql/populate.sql 30 Oct 2004 00:23:54 -0000 1.2 @@ -195,26 +195,6 @@ datatype, parameters ) values ( - 'number', - '#ams.Number#', - '#ams.Numbers#', - 'value', - 'number', - 'text', - 'numeric', - '{html {size 6}}' -); - -insert into ams_widgets ( - widget_name, - pretty_name, - pretty_plural, - storage_type, - acs_datatype, - widget, - datatype, - parameters -) values ( 'integer', '#ams.Integer#', '#ams.Integers#', Index: openacs-4/packages/ams/tcl/ams-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/tcl/ams-procs-postgresql.xql,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/ams/tcl/ams-procs-postgresql.xql 27 Oct 2004 02:05:17 -0000 1.5 +++ openacs-4/packages/ams/tcl/ams-procs-postgresql.xql 30 Oct 2004 00:23:54 -0000 1.6 @@ -47,6 +47,23 @@ + + + select ams.*, + acs.attribute_name, + acs.pretty_name, + acs.pretty_plural, + acs.object_type, + aw.storage_type + from ams_attributes ams, + acs_attributes acs, + ams_widgets aw + where ams.ams_attribute_id = :ams_attribute_id + and ams.attribute_id = acs.attribute_id + and ams.widget_name = aw.widget_name + + + select ac.attribute_name, @@ -258,6 +275,15 @@ + + + select * + from ams_lists + where list_id = :list_id + + + + select ams_attribute_id @@ -288,7 +314,7 @@ - + select ams_list__attribute_map ( :list_id, @@ -300,9 +326,41 @@ + + + select sort_order + from ams_list_attribute_map + where list_id = :list_id + order by sort_order desc + limit 1 + + + + + delete from ams_list_attribute_map + where list_id = :list_id + and ams_attribute_id = :ams_attribute_id + + + + + update ams_list_attribute_map + set required_p = 't' + where list_id = :list_id + and ams_attribute_id = :ams_attribute_id + + + + + update ams_list_attribute_map + set required_p = 'f' + where list_id = :list_id + and ams_attribute_id = :ams_attribute_id + + @@ -330,6 +388,9 @@ + + + select * from postal_addresses where address_id = :address_id Index: openacs-4/packages/ams/tcl/ams-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/tcl/ams-procs.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/ams/tcl/ams-procs.tcl 27 Oct 2004 02:05:17 -0000 1.6 +++ openacs-4/packages/ams/tcl/ams-procs.tcl 30 Oct 2004 00:23:54 -0000 1.7 @@ -136,7 +136,7 @@ set ams_attribute_id [ams::attribute::get_ams_attribute_id -object_type $object_type -attribute_name $attribute_name] } if { [exists_and_not_null ams_attribute_id] } { - ams::list::attribute_map -list_id $list_id \ + ams::list::attribute::map -list_id $list_id \ -ams_attribute_id $ams_attribute_id \ -required_p $required_p } @@ -384,6 +384,34 @@ namespace eval ams::attribute {} +ad_proc -public ams::attribute::get { + -ams_attribute_id:required + -array:required +} { + Get the info on an ams_attribute +} { + upvar 1 $array row + db_1row select_attribute_info {} -column_array row +} + +ad_proc -public ams::attribute::flush { + -ams_attribute_id:required +} { + Get the info on an ams_attribute +} { + ams::attribute::get -ams_attribute_id $ams_attribute_id -array attribute_info + + set object_type $attribute_info(object_type) + set attribute_name $attribute_info(attribute_name) + ams::attribute::widget_flush -ams_attribute_id $ams_attribute_id + ams::attribute::exists_p_flush -object_type $object_type -attribute_name $attribute_name + ams::attribute::get_ams_attribute_id_flush -object_type $object_type -attribute_name $attribute_name + ams::attribute::name_flush -ams_attribute_id $ams_attribute_id + ams::attribute::storage_type_flush -ams_attribute_id $ams_attribute_id + +} + + ad_proc -public ams::attribute::widget { -ams_attribute_id:required {-required:boolean} @@ -552,59 +580,7 @@

widget_name

- This should be a widget_name used by ams. Currently the valid widget names are: -
-       Text Widgets
-       ------------
-
-       textbox (shorthand for textbox_medium)
-       textbox_small
-       textbox_medium
-       textbox_large
-
-       textarea (shorthand for textarea_medium)
-       textarea_small
-       textarea_small_nospell
-       textarea_medium
-       textarea_large
-
-       richtext (shorthand for richtext_medium)
-       richtext_medium
-       richtext_large
-
-
-       Telephone Widgets
-       -----------------
-
-       phone (shorthand for telecom_number)
-       telecom_number
-
-       Postal Address Widgets
-       ----------------------
-
-       address (shorthand for postal_address)
-       postal_address
-
-
-       Multiple Choice Widgets
-       -----------------------
-
-       select             (one option allowed)
-       radio              (one option allowed)
-       checkbox           (multiple options allowed)
-       multiselect        (multiple options allowed)
-       multiselect_single (one option allowed)
-       
-
-       Other Widgets
-       -------------
-    
-       date
-       integer
-       number
-       email
-       url
-       
+ This should be a widget_name used by ams. All available widgets can be found at /ams/widgets.
@@ -656,10 +632,6 @@ oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {ams_attribute_id object_type attribute_name pretty_name pretty_plural default_value description widget_name deprecated_p context_id} set ams_attribute_id [package_instantiate_object -extra_vars $extra_vars ams_attribute] - ns_log Notice "$attribute_name storage type : [ams::attribute::storage_type -ams_attribute_id $ams_attribute_id]" - if { [exists_and_not_null options] } { - ns_log Notice "$attribute_name storage type : $options" - } # now we define options for an attribute - if they are provided and the attribute accepts options if { [string equal [ams::attribute::storage_type -ams_attribute_id $ams_attribute_id] "ams_options"] && [exists_and_not_null options] } { foreach { option } $options { @@ -1117,6 +1089,16 @@ namespace eval ams::list {} +ad_proc -public ams::list::get { + -list_id:required + -array:required +} { + Get the info on an ams_attribute +} { + upvar 1 $array row + db_1row select_list_info {} -column_array row +} + ad_proc -private ams::list::ams_attribute_ids_not_cached { -list_id:required } { @@ -1167,15 +1149,27 @@ @return 1 if the list exists for this object_type and package_key and 0 if the does not exist } { - set list_id [ams::list::get_list_id -package_key $package_key -object_type $object_type -list_name $list_name] + set list_id [ams::list::get_list_id_not_cached -package_key $package_key -object_type $object_type -list_name $list_name] if { [exists_and_not_null list_id] } { return 1 } else { return 0 } } +ad_proc -private ams::list::flush { + -package_key:required + -object_type:required + -list_name:required +} { + flush all inte info we have on an ams_list + @return 1 if the list exists for this object_type and package_key and 0 if the does not exist +} { + ams::list::ams_attribute_ids_flush -list_id [ams::list::get_list_id_not_cached -package_key $package_key -object_type $object_type -list_name $list_name] + ams::list::get_list_id_flush -package_key $package_key -object_type $object_type -list_name $list_name +} + ad_proc -private ams::list::get_list_id { -package_key:required -object_type:required @@ -1189,6 +1183,7 @@ return [util_memoize [list ams::list::get_list_id_not_cached -package_key $package_key -object_type $object_type -list_name $list_name]] } + ad_proc -private ams::list::get_list_id_not_cached { -package_key:required -object_type:required @@ -1253,8 +1248,9 @@ } +namespace eval ams::list::attribute {} -ad_proc -public ams::list::attribute_map { +ad_proc -public ams::list::attribute::map { -list_id:required -ams_attribute_id:required {-sort_order ""} @@ -1267,11 +1263,38 @@ @return option_map_id } { + if { ![exists_and_not_null sort_order] } { + set sort_order [expr 1 + [db_string get_highest_sort_order {} -default "0"]] + } return [db_exec_plsql ams_list_attribute_map {}] } +ad_proc -public ams::list::attribute::unmap { + -list_id:required + -ams_attribute_id:required +} { + Unmap an ams option from an ams list +} { + db_dml ams_list_attribute_unmap {} +} +ad_proc -public ams::list::attribute::required { + -list_id:required + -ams_attribute_id:required +} { + Specify and ams_attribute as required in an ams list +} { + db_dml ams_list_attribute_required {} +} +ad_proc -public ams::list::attribute::optional { + -list_id:required + -ams_attribute_id:required +} { + Specify and ams_attribute as optional in an ams list +} { + db_dml ams_list_attribute_optional {} +} Index: openacs-4/packages/ams/www/attribute-add-2.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/attribute-add-2.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/attribute-add-2.adp 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,8 @@ + +@title@ +@context@ + + + + + Index: openacs-4/packages/ams/www/attribute-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/attribute-add-2.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/attribute-add-2.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,121 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: attribute-add-2.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ +} { + {ams_attribute_id:integer,notnull} + {object_type:notnull} + {widget_name:notnull} + {attribute_name:notnull} + {pretty_name:notnull} + {pretty_plural:notnull} + {list_id:integer} + {description ""} +} + +acs_object_type::get -object_type $object_type -array "object_info" + +set title "Define Options" +set context [list [list objects Objects] [list "object?object_type=$object_type" $object_info(pretty_name)] [list "attribute-add?object_type=$object_type" "Add Attribute"] $title] + +db_1row select_widget_pretty_and_storage_type { select storage_type from ams_widgets where widget_name = :widget_name } + +acs_object_type::get -object_type $object_type -array "object_info" + + + + +if { [exists_and_not_null list_id] } { + set return_url "list-attributes-map?[export_vars -url {ams_attribute_id list_id}]" + set user_message "AMS Attribute $pretty_name Created and Mapped." +} else { + set return_url "object?[export_vars -url {object_type}]" + set user_message "AMS Attribute $pretty_name Created." +} + + + + +if { ![string equal $storage_type "ams_options"] } { + + ams::attribute::new \ + -ams_attribute_id $ams_attribute_id \ + -object_type $object_type \ + -attribute_name $attribute_name \ + -pretty_name $pretty_name \ + -pretty_plural $pretty_plural \ + -description $description \ + -widget_name $widget_name + +# {-options} + + util_user_message -html -message $user_message + ad_returnredirect $return_url + ad_script_abort +} + +ad_form -name attribute_form -form { + {ams_attribute_id:key} + {list_id:integer(hidden)} + {object_type:text(hidden)} + {widget_name:text(inform) {label "Widget"}} + {attribute_name:text(inform) {label "Attribute Name"}} + {pretty_name:text(inform) {label "Pretty Name"}} + {pretty_plural:text(inform) {label "Pretty Plural"}} +} + +if { [exists_and_not_null description] } { + ad_form -extend -name attribute_form -form { + {description:text(inform) {label "Description"}} + } +} else { + ad_form -extend -name attribute_form -form { + {description:text(hidden),optional} + } +} + +ad_form -extend -name attribute_form -form { + {option1:text {label "Option 1"} {html {size 50}}} + {option2:text,optional {label "Option 2"} {html {size 50}}} + {option3:text,optional {label "Option 3"} {html {size 50}}} + {option4:text,optional {label "Option 4"} {html {size 50}}} + {option5:text,optional {label "Option 5"} {html {size 50}}} + {option6:text,optional {label "Option 6"} {html {size 50}}} + {option7:text,optional {label "Option 7"} {html {size 50}}} + {option8:text,optional {label "Option 8"} {html {size 50}}} + {option9:text,optional {label "Option 9"} {html {size 50}} {help_text {If you need to add more options you will be able to do so by editing this attributes details}}} +} -new_request { +} -edit_request { +} -validate { +} -on_submit { + + set i 1 + set options [list] + while { $i <= "9" } { + set option_value [string trim [set option${i}]] + ns_log notice $option_value + if { [exists_and_not_null option_value] } { + lappend options $option_value + } + incr i + } + + ams::attribute::new \ + -ams_attribute_id $ams_attribute_id \ + -object_type $object_type \ + -attribute_name $attribute_name \ + -pretty_name $pretty_name \ + -pretty_plural $pretty_plural \ + -description $description \ + -widget_name $widget_name \ + -options $options + +} -after_submit { + util_user_message -html -message $user_message + ad_returnredirect $return_url + ad_script_abort +} + + +ad_return_template Index: openacs-4/packages/ams/www/attribute-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/attribute-add.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/attribute-add.adp 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,9 @@ + +@title@ +@context@ + + + + + + Index: openacs-4/packages/ams/www/attribute-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/attribute-add.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/attribute-add.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,49 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: attribute-add.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ +} { + {object_type:notnull} + {list_id:integer} +} + +acs_object_type::get -object_type $object_type -array "object_info" + +set title "Add Attribute" +set context [list [list objects Objects] [list "object?object_type=$object_type" $object_info(pretty_name)] "Add Attribute"] + +set widget_options " [db_list_of_lists select_widgets { select widget_name, widget_name from ams_widgets order by widget_name } ]" + + +ad_form -name attribute_form -form { + {ams_attribute_id:key} + {list_id:integer(hidden)} + {object_type:text(hidden)} + {widget_name:text(multiselect) {label "Widget"} {options $widget_options } {help_text {Widgets descriptions are available}}} + {attribute_name:text {label "Attribute Name"} {html {size 30 maxlength 100}} {help_text {This name must be lower case, contain only letters and underscores, and contain no spaces}}} + {pretty_name:text {label "Pretty Name"} {html {size 30 maxlength 100}}} + {pretty_plural:text {label "Pretty Plural"} {html {size 30 maxlength 100}}} + {description:text(textarea),optional {label "Description"} {html {cols 55 rows 4}}} +} -new_request { +} -edit_request { +} -validate { + # i need to add validation that the attribute isn't already in the database + { attribute_name + { [::regexp {^([0-9]|[a-z]|\_){1,}$} $attribute_name match attribute_name_validate] } + "You have used invalid characters." + } + { attribute_name + { ![::attribute::exists_p $object_type $attribute_name] } + "Attribute $attribute_name already exists for $object_info(pretty_name)." + } +} -on_submit { +} -new_data { +} -edit_data { +} -after_submit { + ad_returnredirect "attribute-add-2?[export_vars -url {ams_attribute_id object_type widget_name attribute_name pretty_name pretty_plural description list_id}]" + ad_script_abort +} + + +ad_return_template Index: openacs-4/packages/ams/www/attribute-option-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/attribute-option-delete.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/attribute-option-delete.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,25 @@ +ad_page_contract { + + Update sort order + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: attribute-option-delete.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + + +} { + option_id:integer,notnull +} -validate { + option_has_no_entries -requires {option_id} { + if { ![string match [db_string get_count { select count(*) from ams_option_map where option_id = :option_id } -default {0}] {0}] } { + ad_complain {You cannot delete an option that already has entries on it} + } + } +} + +db_1row get_option_info { select * from ams_options where option_id = :option_id } + +db_dml delete_option { delete from ams_options where option_id = :option_id } + + +ad_returnredirect -message "Option Deleted" "attribute?[export_vars -url {ams_attribute_id}]" Index: openacs-4/packages/ams/www/attribute-options-update.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/attribute-options-update.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/attribute-options-update.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,51 @@ +ad_page_contract { + + Update sort order + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: attribute-options-update.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + + +} { + option:array + sort_key:array + ams_attribute_id:integer,notnull +} +# first we check to see if there are new options. +# if yes we add them +foreach option_key [list new1 new2 new3] { + set option_string [string trim $option(${option_key})] + if { [exists_and_not_null option_string] } { + set option_id [ams::option::new -ams_attribute_id $ams_attribute_id -option $option_string] + set sort_key(${option_id}) $sort_key(${option_key}) + } +} + +# now that all the options are in the database we get the "old" sort order +# if not value for sort_key is provided we will keep the same order as before +set option_ids [db_list get_option_ids { select option_id from ams_options where ams_attribute_id = :ams_attribute_id order by sort_order }] + +# first we get the highest sort_order so variables without a sort_order can be given one +set highest_sort 0 +foreach option_id $option_ids { + if { $sort_key(${option_id}) > $highest_sort } { + set highest_sort $sort_key(${option_id}) + } +} + + +db_transaction { + foreach option_id $option_ids { + set sort_order $sort_key(${option_id}) + incr highest_sort + db_dml update_sort_order { update ams_options set sort_order = :highest_sort where sort_order = :sort_order and ams_attribute_id = :ams_attribute_id } + if { ![exists_and_not_null sort_order] } { + incr highest_sort 1 + set sort_order $highest_sort + } + db_dml update_sort_order { update ams_options set sort_order = :sort_order where option_id = :option_id } + } +} +ams::attribute::flush -ams_attribute_id $ams_attribute_id +ad_returnredirect -message "Options Updated" "attribute?[export_vars -url {ams_attribute_id}]" Index: openacs-4/packages/ams/www/attribute.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/attribute.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/attribute.adp 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,12 @@ + + +@title@ +@context@ + +

Pretty Name: @pretty_name@

+

Pretty Plural: @pretty_plural@

+

Widget: @attribute_info.widget_name@

+ + + + Index: openacs-4/packages/ams/www/attribute.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/attribute.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/attribute.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,129 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: attribute.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + + +} { + {ams_attribute_id:notnull} + orderby:optional +} + +ams::attribute::get -ams_attribute_id $ams_attribute_id -array "attribute_info" +acs_object_type::get -object_type $attribute_info(object_type) -array "object_info" + + +set pretty_name [_ $attribute_info(pretty_name)] +set pretty_plural [_ $attribute_info(pretty_plural)] +set title $pretty_name +set context [list [list objects Objects] [list "object?object_type=$attribute_info(object_type)" $object_info(pretty_name)] $title] + + + + +list::create \ + -name options \ + -multirow options \ + -key option_id \ + -row_pretty_plural "Options" \ + -checkbox_name checkbox \ + -selected_format "normal" \ + -class "list" \ + -main_class "list" \ + -sub_class "narrow" \ + -pass_properties { + } -actions { + } -bulk_action_export_vars { + ams_attribute_id + } -bulk_actions { + "Update" "attribute-options-update" "Update Options" + } -elements { + edit { + label {} + } + option { + label "Option" + display_template { + + @options.option@ + + + + + } + } + sort_order { + label "Sort Order" + display_template { + + } + } + actions { + label "" + display_template { + Delete + } + } + } -filters { + } -groupby { + } -orderby { + default_value default_sort,asc + default_sort { + label default_sort + multirow_cols {sort_key option} + } + } -formats { + normal { + label "Table" + layout table + row { + option {} + sort_order {} + actions {} + } + } + } + + +set sort_count 10 +set sort_key_count 10000 +db_multirow -extend { sort_order sort_key } options select_options { + select option_id, option, + CASE WHEN ( select '1' from ams_option_map where ams_option_map.option_id = ams_options.option_id limit 1 ) IS NULL THEN 0 ELSE 1 END as in_use_p + from ams_options + where ams_attribute_id = :ams_attribute_id + order by sort_order +} { + set option [_ $option] + set sort_order $sort_count + set sort_key $sort_key_count + incr sort_count 10 + incr sort_key_count 1 +} + + +set sort_order $sort_count +set sort_key $sort_key_count +template::multirow append options {new1} {} 1 $sort_count $sort_key +template::multirow append options {new2} {} 1 [incr sort_count 10] [incr sort_key 1] +template::multirow append options {new3} {} 1 [incr sort_count 10] [incr sort_key 1] + + + + + + + + + + + + + + + + + + +ad_return_template Index: openacs-4/packages/ams/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/index.adp,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/ams/www/index.adp 24 Oct 2004 23:17:26 -0000 1.2 +++ openacs-4/packages/ams/www/index.adp 30 Oct 2004 00:23:54 -0000 1.3 @@ -2,21 +2,8 @@ @title@ @context@ -

This is currently a testing page for the save and retrieval procs

- -
-@attr_list@
-
- - - - - - - -
    - -
  • @lists.first_names@ @lists.last_name@ @lists.middle_names@ - -
-
+ Index: openacs-4/packages/ams/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/index.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/ams/www/index.tcl 24 Oct 2004 23:17:26 -0000 1.4 +++ openacs-4/packages/ams/www/index.tcl 30 Oct 2004 00:23:54 -0000 1.5 @@ -12,40 +12,43 @@ set context {} -# YOU NEED TO SPECIFY A VALID OBJECT_ID -#set object_id "2864" # Once done comment out the error line -#ad_return_error "You need to specify and valid object id in the packages/ams/www/index.tcl file" "Once done comment out this line." -set package_key "ams" -set object_type "ams_list" -set list_name "ams_list_demo3" -set pretty_name "The Fields used to Add/Edit a Contact Person" +# ad_return_error "You need to specify and valid object id in the packages/ams/www/index.tcl file" "Once done comment out this line." -ams::define_list -package_key $package_key \ - -object_type $object_type \ - -list_name $list_name \ - -pretty_name $pretty_name \ - -attributes { - {first_names textbox {First Name(s)} {First Names} required} - {middle_names textbox {Middle Name(s)} {Middle Names}} - {last_name textbox {Last Name} {Last Names} required} - {email email {Email Address} {Email Addresses}} - {url url {Website} {Websites}} - {home_address address {Home Address} {Home Addresses}} - {organization_address address {Organization Address} {Organization Addresses}} - } -set object_id [ams::list::get_list_id \ - -package_key $package_key \ - -object_type $object_type \ - -list_name $list_name] - -#ad_form -name entry \ -# -form [ams::ad_form::elements -package_key $package_key \ -# -object_type $object_type \ -# -list_name $list_name \ -# -key "object_id"] \ + +#set package_key "ams" +#set object_type "ams_list" +#set list_name "ams_list_demo3" +#set pretty_name "The Fields used to Add/Edit a Contact Person" +# +#ams::define_list -package_key $package_key \ +# -object_type $object_type \ +# -list_name $list_name \ +# -pretty_name $pretty_name \ +# -attributes { +# {first_names textbox {First Name(s)} {First Names} required {description {this is my description of first names}}} +# {middle_names textbox {Middle Name(s)} {Middle Names}} +# {last_name textbox {Last Name} {Last Names} required} +# {email email {Email Address} {Email Addresses}} +# {url url {Website} {Websites}} +# {home_address address {Home Address} {Home Addresses}} +# {organization_address address {Organization Address} {Organization Addresses}} +# {home_phone telecom_number {Home Phone} {Home Phones}} +# {gender radio {Gender} {Genders} {options {{Male} {Female}}} required} +# } +# +#set object_id [ams::list::get_list_id \ +# -package_key $package_key \ +# -object_type $object_type \ +# -list_name $list_name] +#set object_id "452" +##ad_form -name entry \ +## -form [ams::ad_form::elements -package_key $package_key \ +## -object_type $object_type \ +## -list_name $list_name \ +## -key "object_id"] \ # -edit_request { # ams::object::attribute::values -vars -object_id $object_id # } -on_submit { @@ -60,29 +63,30 @@ # } # } # - -ams_form -package_key $package_key \ - -object_type $object_type \ - -list_name $list_name \ - -form_name "entry" \ - -object_id $object_id \ - -return_url "./" - -set attr_list [ams::object::attribute::values -object_id $object_id] - - -db_multirow lists get_list { select list_id, pretty_name from ams_lists } - -ams::multirow::extend \ - -package_key $package_key \ - -object_type $object_type \ - -list_name $list_name \ - -multirow "lists" \ - -key "list_id" + +#ams_form -package_key $package_key \ +# -object_type $object_type \ +# -list_name $list_name \ +# -form_name "entry" \ +# -object_id $object_id \ +# -return_url "./" # -#template::multirow extend lists [list first_names last_name home_address first_names] +# set attr_list [ams::object::attribute::values_flush -object_id $object_id] +#set attr_list [ams::object::attribute::values -object_id $object_id] # # +#db_multirow lists get_list { select list_id, pretty_name from ams_lists } +# +#ams::multirow::extend \ +# -package_key $package_key \ +# -object_type $object_type \ +# -list_name $list_name \ +# -multirow "lists" \ +# -key "list_id" +## +##template::multirow extend lists [list first_names last_name home_address first_names] +## +## #set key_id "list_id" #template::multirow foreach lists { # set object_id [set $key_id] Index: openacs-4/packages/ams/www/list-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/list-add.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/list-add.adp 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,11 @@ + +@title@ +@context@ + +

Note: Adding an AMS List here is primarily for demonstration purposes. In order for AMS Lists to be useful you need to integrated them with your package.

+ + + + + + Index: openacs-4/packages/ams/www/list-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/list-add.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/list-add.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,65 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: list-add.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ +} { + {object_type:notnull} + {package_key ""} +} + +acs_object_type::get -object_type $object_type -array "object_info" + +set title "Add List" +set context [list [list objects Objects] [list "object?object_type=$object_type" $object_info(pretty_name)] "Add List"] + +set package_options " [db_list_of_lists select_packages { select package_key, package_key from apm_package_types order by package_key } ]" + +if { [exists_and_not_null package_key] && [exists_and_not_null object_type] && [exists_and_not_null list_name] } { + ams::list::flush -package_key $package_key -object_type $object_type -list_name $list_name +} + +ad_form -name list_form -form { + {list_id:key} + {package_key:text(select) {label "Package Key"} {options $package_options}} + {object_type:text(inform) {label "Object Type"}} + {list_name:text {label "List Name"} {html {size 30 maxlength 100}} {help_text {This name must be lower case, contain only letters and underscores, and contain no spaces}}} + {pretty_name:text {label "Pretty Name"} {html {size 30 maxlength 100}}} + {pretty_plural:text {label "Pretty Plural"} {html {size 30 maxlength 100}}} + {description:text(textarea),optional {label "Description"} {html {cols 55 rows 4}}} +} -new_request { +} -edit_request { +} -validate { + # i need to add validation that the attribute isn't already in the database + { list_name + { [::regexp {^([0-9]|[a-z]|\_){1,}$} $list_name match list_name_validate] } + "You have used invalid characters." + } + { list_name + { ![::ams::list::exists_p -package_key $package_key -object_type $object_type -list_name $list_name] } + "List name $list_name already exists for $object_info(pretty_name)." + } +} -on_submit { + + ams::list::flush -package_key $package_key -object_type $object_type -list_name $list_name + + ams::list::new -list_id $list_id \ + -package_key $package_key \ + -object_type $object_type \ + -list_name $list_name \ + -pretty_name $pretty_name \ + -description $description \ + -description_mime_type "text/plain" \ + -context_id "" + + ams::list::flush -package_key $package_key -object_type $object_type -list_name $list_name + + +} -edit_data { +} -after_submit { + ad_returnredirect "list?[export_vars -url {package_key object_type list_name}]" + ad_script_abort +} + + +ad_return_template Index: openacs-4/packages/ams/www/list-attributes-map.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/list-attributes-map.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/list-attributes-map.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,23 @@ +ad_page_contract { + + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: list-attributes-map.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + +} { + {ams_attribute_id:integer,multiple} + {list_id:integer,notnull} +} + +foreach ams_attribute_id $ams_attribute_id { + ams::list::attribute::map -list_id $list_id -ams_attribute_id $ams_attribute_id +} + +ams::list::get -list_id $list_id -array "list_info" +set package_key $list_info(package_key) +set object_type $list_info(object_type) +set list_name $list_info(list_name) + +ad_returnredirect "list?[export_vars -url {package_key object_type list_name}]" +ad_script_abort Index: openacs-4/packages/ams/www/list-attributes-optional.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/list-attributes-optional.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/list-attributes-optional.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,23 @@ +ad_page_contract { + + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: list-attributes-optional.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + +} { + {ams_attribute_id:integer,multiple,notnull} + {list_id:integer,notnull} +} + +foreach ams_attribute_id $ams_attribute_id { + ams::list::attribute::optional -list_id $list_id -ams_attribute_id $ams_attribute_id +} + +ams::list::get -list_id $list_id -array "list_info" +set package_key $list_info(package_key) +set object_type $list_info(object_type) +set list_name $list_info(list_name) + +ad_returnredirect "list?[export_vars -url {package_key object_type list_name}]" +ad_script_abort Index: openacs-4/packages/ams/www/list-attributes-required.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/list-attributes-required.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/list-attributes-required.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,23 @@ +ad_page_contract { + + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: list-attributes-required.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + +} { + {ams_attribute_id:integer,multiple,notnull} + {list_id:integer,notnull} +} + +foreach ams_attribute_id $ams_attribute_id { + ams::list::attribute::required -list_id $list_id -ams_attribute_id $ams_attribute_id +} + +ams::list::get -list_id $list_id -array "list_info" +set package_key $list_info(package_key) +set object_type $list_info(object_type) +set list_name $list_info(list_name) + +ad_returnredirect "list?[export_vars -url {package_key object_type list_name}]" +ad_script_abort Index: openacs-4/packages/ams/www/list-attributes-unmap.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/list-attributes-unmap.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/list-attributes-unmap.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,22 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: list-attributes-unmap.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + +} { + {ams_attribute_id:integer,multiple} + {list_id:integer,notnull} +} + +foreach ams_attribute_id $ams_attribute_id { + ams::list::attribute::unmap -list_id $list_id -ams_attribute_id $ams_attribute_id +} + +ams::list::get -list_id $list_id -array "list_info" +set package_key $list_info(package_key) +set object_type $list_info(object_type) +set list_name $list_info(list_name) + +ad_returnredirect "list?[export_vars -url {package_key object_type list_name}]" +ad_script_abort Index: openacs-4/packages/ams/www/list-order-update.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/list-order-update.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/list-order-update.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,49 @@ +ad_page_contract { + + Update sort order + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: list-order-update.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + + +} { + sort_key:array + list_id:integer,notnull +} + + +set ams_attribute_ids [db_list get_attribute_ids { select ams_attribute_id from ams_list_attribute_map where list_id = :list_id order by sort_order }] + + +# first we get the highest sort_order so variables without a sort_order can be given one +set highest_sort 0 +set used_sorts [list] +foreach ams_attribute_id $ams_attribute_ids { + if { $sort_key(${ams_attribute_id}) > $highest_sort } { + set highest_sort $sort_key(${ams_attribute_id}) + } +} + +db_transaction { + foreach ams_attribute_id $ams_attribute_ids { + set sort_order $sort_key(${ams_attribute_id}) + incr highest_sort 1 + db_dml update_sort_order { update ams_list_attribute_map set sort_order = :highest_sort where sort_order = :sort_order and list_id = :list_id } + if { ![exists_and_not_null sort_order] } { + incr highest_sort 1 + set sort_order $highest_sort + } + db_dml update_sort_order { update ams_list_attribute_map set sort_order = :sort_order where ams_attribute_id = :ams_attribute_id and list_id = :list_id } + } +} + +ams::list::get -list_id $list_id -array "list_info" +set package_key $list_info(package_key) +set object_type $list_info(object_type) +set list_name $list_info(list_name) + +ad_returnredirect "list?[export_vars -url {package_key object_type list_name}]" +ad_script_abort + +ad_returnredirect "object-map?object_id=$object_id" Index: openacs-4/packages/ams/www/list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/list.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/list.adp 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,21 @@ + +@title@ +@context@ + + +

Package Key: @package_key@

+

Object Type: @object_type@

+

List Name: @list_name@

+ +

Mapped Attributes

+ + + + +

Unmapped Attributes

+ + + + Index: openacs-4/packages/ams/www/list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/list.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/list.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,238 @@ +ad_page_contract { + + This page lets users manage ams lists + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: list.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + +} { + package_key:notnull + object_type:notnull + list_name:notnull + groupby:optional + orderby:optional + {format "normal"} + {status "normal"} +} + +set list_id [ams::list::get_list_id -package_key $package_key -object_type $object_type -list_name $list_name] +ams::list::get -list_id $list_id -array "list_info" +set title [_ $list_info(pretty_name)] +set context [list [list lists Lists] $title] + +list::create \ + -name mapped_attributes \ + -multirow mapped_attributes \ + -key ams_attribute_id \ + -row_pretty_plural "Mapped Attributes" \ + -checkbox_name checkbox \ + -selected_format $format \ + -class "list" \ + -main_class "list" \ + -sub_class "narrow" \ + -pass_properties { + } -actions { + } -bulk_actions { + "Answer Required" "list-attributes-required" "Require an answer from the checked attributes" + "Answer Optional" "list-attributes-optional" "An answer from the checked attributes is optional" + "Unmap" "list-attributes-unmap" "Unmap check attributes" + "Update Ordering" "list-order-update" "Update ordering from values in list" + } -bulk_action_export_vars { + list_id + } -elements { + attribute_name { + label "Attribute" + display_col attribute_name + } + pretty_name { + label "Pretty Name" + display_col pretty_name + link_url_eval $attribute_url + } + widget { + label "Widget" + display_col widget + link_url_eval widgets + } + action { + label "Action" + display_template { + Unmap + } + } + answer { + label "Required" + display_template { + + + + + + + } + } + sort_order { + label "Ordering" + display_template { + + } + } + } -filters { + } -groupby { + } -orderby { + } -formats { + normal { + label "Table" + layout table + row { + checkbox {} + pretty_name {} + sort_order {} + answer {} + action {} + } + } + } + + +# Table "public.ams_lists" +# Column | Type | Modifiers +#-----------------------+-------------------------+----------- +# list_id | integer | not null +# package_key | character varying(100) | not null +# object_type | character varying(1000) | not null +# list_name | character varying(100) | not null +# pretty_name | character varying(200) | not null +# description | character varying(200) | +# description_mime_type | character varying(200) | + + +# Table "public.ams_list_attribute_map" +# Column | Type | Modifiers +#------------------+------------------------+----------- +# list_id | integer | not null +# ams_attribute_id | integer | not null +# sort_order | integer | not null +# required_p | boolean | not null +# section_heading | character varying(200) | + + +set sort_order_count 10 + +db_multirow -extend { sort_order_key attribute_url } mapped_attributes select_mapped_attributes { + select alam.required_p, + alam.section_heading, + ams.ams_attribute_id, + ams.widget_name, + ams.deprecated_p, + acs.attribute_name, + acs.pretty_name, + acs.pretty_plural, + acs.object_type + from ams_list_attribute_map alam, + ams_attributes ams, + acs_attributes acs + where alam.list_id = :list_id + and alam.ams_attribute_id = ams.ams_attribute_id + and ams.attribute_id = acs.attribute_id + order by alam.sort_order +} { + set pretty_name [_ $pretty_name] + set attribute_url "attribute?[export_vars -url {ams_attribute_id}]" + set sort_order_key $sort_order_count + incr sort_order_count 10 +} + + +#---------------------------------------------------------------------- +# List builder +#---------------------------------------------------------------------- + + + + + +list::create \ + -name unmapped_attributes \ + -multirow unmapped_attributes \ + -key ams_attribute_id \ + -row_pretty_plural "Unmapped Attributes" \ + -checkbox_name checkbox \ + -selected_format "normal" \ + -class "list" \ + -main_class "list" \ + -sub_class "narrow" \ + -pass_properties { + } -actions { + } -bulk_actions { + "Map" "list-attributes-map" "Map the selected attributes" + } -bulk_action_export_vars { + list_id + } -elements { + attribute_name { + label "Attribute" + display_col attribute_name + } + pretty_name { + label "Pretty Name" + display_col pretty_name + link_url_eval $attribute_url + } + widget { + label "Widget" + display_col widget_name + link_url_eval widgets + } + action { + label "Action" + display_template { + Map + } + } + } -filters { + } -groupby { + } -orderby { + } -formats { + normal { + label "Table" + layout table + row { + checkbox {} + pretty_name {} + widget {} + action {} + } + } + } + + + +# This query will override the ad_page_contract value entry_id + +db_multirow -extend { attribute_url } -unclobber unmapped_attributes get_unmapped_attributes { + select ams.ams_attribute_id, + ams.widget_name, + ams.deprecated_p, + acs.attribute_name, + acs.pretty_name, + acs.pretty_plural, + acs.object_type + from ams_attributes ams, + acs_attributes acs + where ams.ams_attribute_id not in ( select alam.ams_attribute_id from ams_list_attribute_map alam where alam.list_id = :list_id ) + and ams.attribute_id = acs.attribute_id +} { + set pretty_name [_ $pretty_name] + set attribute_url "attribute?[export_vars -url {ams_attribute_id}]" + +} + + + +ad_return_template + + + + + Index: openacs-4/packages/ams/www/lists.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/lists.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/lists.adp 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,11 @@ + + +@title@ +@context@ + +

You can create a list by selecting an acs_object. Note that list creation should be done with contracting packages. These lists shows what ams can do for your package.

+ + + + + Index: openacs-4/packages/ams/www/lists.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/lists.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/lists.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,76 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: lists.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + + +} { + {orderby "name"} +} + +set title "AMS Lists" +set context [list $title] + +list::create \ + -name lists \ + -multirow lists \ + -key list_id \ + -row_pretty_plural "AMS Lists" \ + -checkbox_name checkbox \ + -selected_format "normal" \ + -class "list" \ + -main_class "list" \ + -sub_class "narrow" \ + -actions { + } -bulk_actions { + } -elements { + edit { + label {} + } + pretty_name { + display_col pretty_name + label "Pretty Name" + } + package_key { + display_col package_key + label "Package Key" + } + list_name { + display_col list_name + label "List Name" + link_url_eval $list_url + } + object_type { + display_col object_type + label "Object Type" + link_url_eval $object_url + } + } -filters { + } -groupby { + } -orderby { + } -formats { + normal { + label "Table" + layout table + row { + package_key {} + object_type {} + list_name {} + pretty_name {} + } + } + } + + +db_multirow -extend { list_url object_url } lists select_lists { + select list_id, package_key, object_type, list_name, pretty_name + from ams_lists +} { + set object_url "list?[export_vars -url {object_type}]" + set list_url "list?[export_vars -url {package_key object_type list_name}]" + set pretty_name [_ $pretty_name] +} + + +ad_return_template Index: openacs-4/packages/ams/www/object.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/object.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/object.adp 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,15 @@ + + +@title@ +@context@ + + + +

AMS Attributes

+ + +

Attributes not managed by AMS

+ + +

AMS Lists associated with @object_info.pretty_plural@

+ Index: openacs-4/packages/ams/www/object.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/object.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/object.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,296 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: object.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + + +} { + {object_type:notnull} + orderby:optional +} + +acs_object_type::get -object_type $object_type -array "object_info" + +set title "$object_info(pretty_name)" +set context [list [list objects Objects] $title] + + +list::create \ + -name object_attributes \ + -multirow object_attributes \ + -key attribute_name \ + -row_pretty_plural "AMS Attributes" \ + -checkbox_name checkbox \ + -selected_format "normal" \ + -class "list" \ + -main_class "list" \ + -sub_class "narrow" \ + -pass_properties { + object_type + } -actions [list "Add" "attribute-add?object_type=$object_type" "Add an AMS Attribute"] \ + -bulk_actions { + } -elements { + edit { + label {} + } + pretty_name { + display_col pretty_name + label "Pretty Name" + link_url_eval $ams_attribute_url + } + attribute_name { + display_col attribute_name + label "Attribute Name" + link_url_eval $ams_attribute_url + } + widget_name { + display_col widget_name + label "Widget Name" + link_url_eval widgets + } + actions { + label "" + display_template { + Upgrade to AMS Attribute + } + } + } -filters { + object_type {} + } -groupby { + } -orderby { + default_value default_sort,asc + default_sort { + label default_sort + multirow_cols {ams_attribute_p pretty_name attribute_name} + } + pretty_name { + label pretty_name + multirow_cols {ams_attribute_p pretty_name attribute_name} + } + attribute_name { + label attribute_name + multirow_cols {ams_attribute_p attribute_name pretty_name} + } + widget_name { + label widget_name + multirow_cols {ams_attribute_p widget_name pretty_name attribute_name} + } + } -formats { + normal { + label "Table" + layout table + row { + pretty_name {} + attribute_name {} + widget_name {} + actions {} + } + } + } + + +db_multirow -extend { ams_attribute_url ams_attribute_p } object_attributes select_object_attributes { + select acs.attribute_name, + acs.pretty_name, + acs.pretty_plural, + acs.attribute_id, + ams.ams_attribute_id, + ams.widget_name + from acs_attributes acs, ams_attributes ams + where acs.object_type = :object_type + and acs.attribute_id = ams.attribute_id +} { + if { [exists_and_not_null ams_attribute_id] } { set ams_attribute_p 1 } else { set ams_attribute_p 0 } + + if { [exists_and_not_null ams_attribute_id] } { + set ams_attribute_url "attribute?ams_attribute_id=$ams_attribute_id" + } else { + set ams_attribute_url "" + } + if { [lang::message::message_exists_p en_US $pretty_name] } { + set pretty_name [_ $pretty_name] + } +} + + + + + + + + + + + + + + + + +# This code lets me setup AMS Attribute Upgrades for Attributes that were not created by AMS +# +# eventually we will allow these attributes to be "upgraded" to ams_attributes. We first need to provision a way +# for them to not be deleted at package drop time, since other packages created these attributes they may need them. + +list::create \ + -name non_ams_attributes \ + -multirow non_ams_object_attributes \ + -key attribute_name \ + -row_pretty_plural "Attributes not managed by AMS" \ + -checkbox_name checkbox \ + -selected_format "normal" \ + -class "list" \ + -main_class "list" \ + -sub_class "narrow" \ + -pass_properties { + variable + } -actions { + } -bulk_actions { + } -elements { + pretty_name { + display_col pretty_name + label "Pretty Name" + } + attribute_name { + display_col attribute_name + label "Attribute Name" + } + actions { + label "" + display_template { + Upgrade to AMS Attribute + } + } + } -filters { + object_type {} + } -groupby { + } -orderby { + } -formats { + normal { + label "Table" + layout table + row { + pretty_name {} + attribute_name {} + } + } + } + + +db_multirow non_ams_object_attributes select_non_ams_object_attributess { + select acs.attribute_name, + acs.pretty_name, + acs.pretty_plural, + acs.attribute_id + from acs_attributes acs + where acs.object_type = :object_type + and acs.attribute_id not in ( select attribute_id from ams_attributes ) +} { +} + + + + + + + + + + + + + + + + + + + + +# AMS Lists associated with this object type + +list::create \ + -name ams_lists \ + -multirow ams_lists \ + -key list_id \ + -row_pretty_plural "Attributes not managed by AMS" \ + -checkbox_name checkbox \ + -selected_format "normal" \ + -class "list" \ + -main_class "list" \ + -sub_class "narrow" \ + -pass_properties { + variable + } -actions [list "Add" "list-add?object_type=$object_type" "Add an AMS List"] \ + -bulk_actions { + } -elements { + package_key { + label "Package Key" + display_col package_key + } + object_type { + label "Object Type" + display_col object_type + } + list_name { + label "List Name" + display_col list_name + link_url_eval $list_link + } + pretty_name { + display_col pretty_name + label "Pretty Name" + } + description { + display_col description_html;noquote + label "Description" + } + actions { + label "" + display_template { + + } + } + } -filters { + object_type {} + } -groupby { + } -orderby { + } -formats { + normal { + label "Table" + layout table + row { + package_key {} + list_name {} + pretty_name {} + description {} + } + } + } + + +db_multirow -extend { description_html list_link } ams_lists select_ams_lists { + select * + from ams_lists + where object_type = :object_type +} { + set pretty_name [_ $pretty_name] + set list_link "list?[export_vars -url {package_key object_type list_name}]" + set description_html [ad_html_text_convert -from $description_mime_type -to "text/html" -truncate_len "175" $description] +} + + + + + + + + + + + + + + +ad_return_template Index: openacs-4/packages/ams/www/objects.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/objects.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/objects.adp 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,11 @@ + + +@title@ +@context@ + + + + + + + Index: openacs-4/packages/ams/www/objects.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/objects.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/objects.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,66 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: objects.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + + +} { + {orderby "name"} +} + +set title "Objects" +set context [list $title] + +list::create \ + -name object_types \ + -multirow object_types \ + -key object_type \ + -row_pretty_plural "Object Types" \ + -checkbox_name checkbox \ + -selected_format "normal" \ + -class "list" \ + -main_class "list" \ + -sub_class "narrow" \ + -actions { + } -bulk_actions { + } -elements { + edit { + label {} + } + pretty_name { + display_col pretty_name + label "Pretty Name" + link_url_eval $object_attributes_url + } + object_type { + display_col object_type + label "Object Type" + link_url_eval $object_attributes_url + } + } -filters { + } -groupby { + } -orderby { + } -formats { + normal { + label "Table" + layout table + row { + pretty_name {} + object_type {} + } + } + } + + +db_multirow -extend { object_attributes_url } object_types select_object_types { + select object_type, + pretty_name + from acs_object_types + order by lower(pretty_name) +} { + set object_attributes_url "object?object_type=$object_type" +} + + +ad_return_template Index: openacs-4/packages/ams/www/widgets.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/widgets.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/widgets.adp 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,13 @@ + +@title@ +@context@ + + + + + + + + + + Index: openacs-4/packages/ams/www/widgets.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/widgets.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/widgets.tcl 30 Oct 2004 00:23:54 -0000 1.1 @@ -0,0 +1,99 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: widgets.tcl,v 1.1 2004/10/30 00:23:54 matthewg Exp $ + + +} { +} + + +set title "Widgets" +set context [list $title] + + + + +list::create \ + -name widgets \ + -multirow widgets \ + -key widget_name \ + -row_pretty_plural "Object Types" \ + -checkbox_name checkbox \ + -selected_format "normal" \ + -class "list" \ + -main_class "list" \ + -sub_class "narrow" \ + -pass_properties { + variable + } -actions { + } -bulk_actions { + } -elements { + widget_name { + display_col widget_name + label "Widget Name" + } + pretty_name { + display_col pretty_name + label "Pretty Name" + } + pretty_plural { + display_col pretty_plural + label "Pretty Plural" + } + widget { + display_col widget + label "Widget" + } + datatype { + display_col datatype + label "Datatype" + } + parameters { + display_col parameters + label "Parameters" + } + } -filters { + object_type {} + } -groupby { + } -orderby { + } -formats { + normal { + label "Table" + layout table + row { + widget_name {} + pretty_name {} + widget {} + datatype {} + parameters {} + } + } + } + + +db_multirow widgets get_widgets { + select * + from ams_widgets + order by widget_name +} { +} + +template::multirow foreach widgets { + set form_element "${widget_name}_widget:${datatype}(${widget}),optional" + if { [string equal $storage_type "ams_options"] } { + append form_element { {options { {"Demo Example One" 1} {"Demo Example Two" 2} {"Demo Example Three" 3} {"Demo Example Four" 4} {"Demo Example Five" 5} {"Demo Example Six" 6} }}} + } + if { [exists_and_not_null parameters] } { + append form_element " ${parameters}" + } + lappend form_element [list "label" "

$widget_name

$pretty_plural

widget: $widget
datatype: $datatype
parameters: $parameters

"] + lappend form_elements $form_element +} + +ad_form -name widgets_form -form $form_elements -on_submit {} + + + +ad_return_template