Index: openacs-4/packages/acs-object-management/sql/postgresql/acs-views-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/sql/postgresql/acs-views-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/sql/postgresql/acs-views-create.sql 22 Feb 2011 17:37:03 -0000 1.1 +++ openacs-4/packages/acs-object-management/sql/postgresql/acs-views-create.sql 13 Mar 2011 22:56:22 -0000 1.2 @@ -290,15 +290,9 @@ perform acs_view__create_sql_view(replace(p_type, '':'', ''_'') || ''_v''); - -- Now fix all subtypes (really only necessary for the attributes view when an attribute - -- has been added or dropped, but there is no harm in doing it always). The supertype - -- not equal to object_type bit is again due to the fact that acs_object has itself - -- as its supertype rather than null. - for v_type_rec in select object_type from acs_object_types where supertype = p_type - and supertype <> object_type loop perform acs_object_type__refresh_view(v_type_rec.object_type); end loop; Index: openacs-4/packages/acs-object-management/tcl/attribute-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/attribute-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-object-management/tcl/attribute-procs.tcl 13 Aug 2009 00:15:05 -0000 1.2 +++ openacs-4/packages/acs-object-management/tcl/attribute-procs.tcl 13 Mar 2011 22:56:22 -0000 1.3 @@ -92,6 +92,24 @@ return $attribute_id } +ad_proc object_type::attribute::edit { + -object_type:required + -attribute_name:required + -pretty_name:required + {-pretty_plural ""} +} { + + Edit an attribute of an object type. Only the pretty names can be edited. + + @param object_type The type the new attribute belongs to. + @param attribute_name The name of the new attribute. + @param pretty_name The human-readable name for the new attribute. + @param pretty_plural Optional human-readable plural name for the new attribute. +} { + db_dml edit_attribute {} + object_type::flush_cache -object_type $object_type +} + ad_proc object_type::attribute::delete { -object_type:required -attribute_name:required Index: openacs-4/packages/acs-object-management/tcl/attribute-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/attribute-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/attribute-procs.xql 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/attribute-procs.xql 13 Mar 2011 22:56:22 -0000 1.2 @@ -1,6 +1,16 @@ <?xml version="1.0"?> <queryset> + <fullquery name="object_type::attribute::edit.edit_attribute"> + <querytext> + update acs_attributes + set pretty_name = :pretty_name, + pretty_plural = :pretty_plural + where object_type = :object_type + and attribute_name = :attribute_name + </querytext> + </fullquery> + <fullquery name="object_type::attribute::get_attribute_id.get_attribute_id"> <querytext> select attribute_id Index: openacs-4/packages/acs-object-management/tcl/object-type-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-type-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-object-management/tcl/object-type-procs.tcl 14 Aug 2009 01:06:08 -0000 1.3 +++ openacs-4/packages/acs-object-management/tcl/object-type-procs.tcl 13 Mar 2011 22:56:22 -0000 1.4 @@ -91,7 +91,6 @@ ad_proc -public object_type::delete { -object_type:required - {-cascade_p t} {-drop_table_p f} {-drop_children_p f} } { @@ -100,13 +99,12 @@ which depend on it. @param object_type The object type to delete. - @param cascade_p If true, append "cascade" to the SQL drop table command. + @param cascade_p If true, delete the type's objects. @param drop_table_p If true (recommended) drop the table associated with the object type. @param drop_children_p If true (recommended) drop all subtypes dependent on this type. } { set var_list [list \ [list object_type $object_type] \ - [list cascade_p $cascade_p] \ [list drop_table_p $drop_table_p] \ [list drop_children_p $drop_children_p]] package_exec_plsql -var_list $var_list acs_object_type drop_type Index: openacs-4/packages/acs-object-management/tcl/test/object-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/test/object-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-object-management/tcl/test/object-procs.tcl 28 Feb 2011 01:26:31 -0000 1.3 +++ openacs-4/packages/acs-object-management/tcl/test/object-procs.tcl 13 Mar 2011 22:56:22 -0000 1.4 @@ -115,7 +115,6 @@ aa_log $error aa_false "Type Removed" [catch { object_type::delete -object_type $object_type \ - -cascade_p t \ -drop_table_p t } error] aa_log $error Index: openacs-4/packages/acs-object-management/tcl/test/object-types-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/test/object-types-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/test/object-types-procs.tcl 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/test/object-types-procs.tcl 13 Mar 2011 22:56:22 -0000 1.2 @@ -40,7 +40,6 @@ if { [catch {object_type::delete \ -object_type object_type_test \ -drop_table_p t \ - -cascade_p t \ -drop_children_p t} error] } { aa_log_result fail "Attempt to delete type \"object_type_test\" failed: $error" } else { @@ -64,7 +63,6 @@ if { [catch {object_type::delete \ -object_type object_type_test2 \ -drop_table_p t \ - -cascade_p t \ -drop_children_p t} error] } { aa_log_result fail "Attempt to delete type \"object_type_test2\" failed: $error" } else { @@ -84,7 +82,6 @@ if { [catch {object_type::delete \ -object_type object_type_test3 \ -drop_table_p t \ - -cascade_p t \ -drop_children_p t} error] } { aa_log_result fail "Attempt to delete type \"object_type_test3\" failed: $error" } else { Index: openacs-4/packages/acs-object-management/www/admin/attribute.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/attribute.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-object-management/www/admin/attribute.tcl 27 Nov 2009 00:38:50 -0000 1.3 +++ openacs-4/packages/acs-object-management/www/admin/attribute.tcl 13 Mar 2011 22:56:22 -0000 1.4 @@ -23,24 +23,36 @@ ad_form -name attribute_form -export {object_type} -form { {attribute_id:key} - {attribute_name:text {label "[_ acs-object-management.attribute_name]"} {html {size 30 maxlength 100}} {help_text "[_ acs-object-management.attribute_name_help]"}} +} + +if {[ad_form_new_p -key attribute_id]} { + ad_form -extend -name attribute_form -form { + {attribute_name:text {label "[_ acs-object-management.attribute_name]"} {html {size 30 maxlength 100}} {help_text "[_ acs-object-management.attribute_name_help]"}} + } +} else { + ad_form -extend -name attribute_form -form { + {attribute_name:text(inform) {label "[_ acs-object-management.attribute_name]"}} + } +} + +ad_form -extend -name attribute_form -form { {pretty_name:text {label "[_ acs-object-management.pretty_name]"} {html {size 30 maxlength 100}} {help_text "[_ acs-object-management.attribute_pname_help]"}} {pretty_plural:text,optional {label "[_ acs-object-management.pretty_plural]"} {html {size 30 maxlength 100}} {help_text "[_ acs-object-management.attribute_pplural_help]"}} } -if {![ad_form_new_p -key attribute_id]} { +if {[ad_form_new_p -key attribute_id]} { ad_form -extend -name attribute_form -form { - {datatype:text(inform) {label "[_ acs-object-management.datatype]"} {options $datatype_options} {help_text "[_ acs-object-management.datatype_help]"}} + {datatype:text(select) {label "[_ acs-object-management.datatype]"} {options $datatype_options} {help_text "[_ acs-object-management.datatype_help]"}} + {default_value:text(textarea),optional {label "[_ acs-object-management.attribute_default]"} {html {rows 3 cols 40}} {help_text "[_ acs-object-management.attribute_default_help]"}} } } else { ad_form -extend -name attribute_form -form { - {datatype:text(select) {label "[_ acs-object-management.datatype]"} {options $datatype_options} {help_text "[_ acs-object-management.datatype_help]"}} + {datatype:text(inform) {label "[_ acs-object-management.datatype]"}} + {default_value:text(inform),optional {label "[_ acs-object-management.attribute_default]"}} } } -ad_form -extend -name attribute_form -form { - {default_value:text(textarea),optional {label "[_ acs-object-management.attribute_default]"} {html {rows 3 cols 40}} {help_text "[_ acs-object-management.attribute_default_help]"}} -} -new_request { +ad_form -extend -name attribute_form -form {} -new_request { set attribute_name "" set pretty_name "" set pretty_plural "" @@ -66,12 +78,11 @@ -create_column_p t } -edit_data { # Oh need to add an update function to the tcl API - dtype::edit_attribute \ - -name [string tolower $attribute_name] \ + object_type::attribute::edit \ + -attribute_name [string tolower $attribute_name] \ -object_type $object_type \ -pretty_name $pretty_name \ - -pretty_plural $pretty_plural \ - -default_value $default_value + -pretty_plural $pretty_plural } -after_submit { lang::message::register -update_sync $default_locale acs-translations "${object_type}_$attribute_name" $pretty_name lang::message::register -update_sync $default_locale acs-translations "${object_type}_${attribute_name}s" $pretty_plural