Index: openacs-4/packages/ams/www/attribute.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/attribute.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/ams/www/attribute.tcl 18 May 2005 17:11:48 -0000 1.2 +++ openacs-4/packages/ams/www/attribute.tcl 28 May 2005 15:37:27 -0000 1.3 @@ -1,108 +1,108 @@ -ad_page_contract { - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id$ - -} { - {attribute_id:notnull} - orderby:optional -} - -#db_1row get_attribute_info {} -ams::attribute::get -attribute_id $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 { - 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_options where ams_options.option_id = ams_option_types.option_id limit 1 ) IS NULL THEN 0 ELSE 1 END as in_use_p - from ams_option_types - where attribute_id = :attribute_id - order by sort_order -} { - set sort_order $sort_count - set sort_key $sort_key_count - incr sort_count 10 - incr sort_key_count 1 -} - -if { [template::multirow size options] > 0 } { - 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 +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id$ + +} { + {attribute_id:notnull} + orderby:optional +} + +#db_1row get_attribute_info {} +ams::attribute::get -attribute_id $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 "[_ ams.Options]" \ + -checkbox_name checkbox \ + -selected_format "normal" \ + -class "list" \ + -main_class "list" \ + -sub_class "narrow" \ + -pass_properties { + } -actions { + } -bulk_action_export_vars { + attribute_id + } -bulk_actions { + "[_ acs-kernel.common_Update]" "attribute-options-update" "[_ ams.Update_Options]" + } -elements { + edit { + label {} + } + option { + label "[_ ams.Option]" + display_template { + + @options.option@ + + + + + } + } + sort_order { + label "[_ ams.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_options where ams_options.option_id = ams_option_types.option_id limit 1 ) IS NULL THEN 0 ELSE 1 END as in_use_p + from ams_option_types + where attribute_id = :attribute_id + order by sort_order +} { + set sort_order $sort_count + set sort_key $sort_key_count + incr sort_count 10 + incr sort_key_count 1 +} + +if { [template::multirow size options] > 0 } { + 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