Index: openacs-4/packages/categories/lib/tree-form.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/lib/tree-form.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/lib/tree-form.adp 14 Dec 2003 15:40:04 -0000 1.1 @@ -0,0 +1 @@ + Index: openacs-4/packages/categories/lib/tree-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/lib/tree-form.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/lib/tree-form.tcl 14 Dec 2003 15:40:04 -0000 1.1 @@ -0,0 +1,37 @@ +set package_id [ad_conn package_id] + +set languages [lang::system::get_locale_options] + +ad_form -name tree_form -mode [ad_decode [ad_form_new_p -key tree_id] 1 edit display] -action tree-form -export { locale object_id } -form { + {tree_id:key} + {tree_name:text {label "Name"} {html {size 50 maxlength 50}}} + {language:text(select) {label "Language"} {options $languages}} + {description:text(textarea),optional {label "Description"} {html {rows 5 cols 80}}} +} -new_request { + permission::require_permission -object_id $package_id -privilege category_admin + set language $locale +} -edit_request { + permission::require_permission -object_id $tree_id -privilege category_tree_write + set action Edit + util_unlist [category_tree::get_translation $tree_id $locale] tree_name description + set language $locale +} -on_submit { + set description [util_close_html_tags $description 4000] +} -new_data { + db_transaction { + category_tree::add -tree_id $tree_id -name $tree_name -description $description -locale $language -context_id $package_id + if { [info exists object_id] } { + category_tree::map -tree_id $tree_id -object_id $object_id + set return_url [export_vars -base one-object { locale object_id }] + } else { + set return_url [export_vars -base tree-view { tree_id locale }] + } + } +} -edit_data { + category_tree::update -tree_id $tree_id -name $tree_name -description $description -locale $language + set return_url [export_vars -base tree-view { tree_id locale object_id }] +} -after_submit { + ad_returnredirect $return_url + ad_script_abort +} + Index: openacs-4/packages/categories/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/index.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/index.adp 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/index.adp 14 Dec 2003 15:39:52 -0000 1.2 @@ -3,7 +3,9 @@ @context_bar;noquote@ - Category Administration
+
+ Category Administration +

Select Trees for browsing:

@@ -13,8 +15,8 @@ - - + + Index: openacs-4/packages/categories/www/cadmin/category-delete-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete-2.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/categories/www/cadmin/category-delete-2.tcl 11 Dec 2003 21:40:00 -0000 1.2 +++ openacs-4/packages/categories/www/cadmin/category-delete-2.tcl 14 Dec 2003 15:36:57 -0000 1.3 @@ -6,15 +6,17 @@ @cvs-id $Id: } { tree_id:integer - category_id:integer + category_id:integer,multiple {locale ""} object_id:integer,optional } permission::require_permission -object_id $tree_id -privilege category_tree_write db_transaction { - category::delete $category_id + foreach id $category_id { + category::delete $id + } category_tree::flush_cache $tree_id } on_error { ad_return_complaint 1 "Error Deleting Node

This node contains leaf (child) nodes. If you really want to delete those leaf nodes, plesae delete them first. Thank you." Index: openacs-4/packages/categories/www/cadmin/category-delete-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/category-delete-oracle.xql 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/category-delete-oracle.xql 14 Dec 2003 15:36:57 -0000 1.2 @@ -8,7 +8,7 @@ select case when count(*) = 0 then 0 else 1 end from dual where exists (select 1 from category_object_map - where category_id = :category_id) + where category_id = :id) Index: openacs-4/packages/categories/www/cadmin/category-delete-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/category-delete-postgresql.xql 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/category-delete-postgresql.xql 14 Dec 2003 15:36:57 -0000 1.2 @@ -8,7 +8,7 @@ select case when count(*) = 0 then 0 else 1 end where exists (select 1 from category_object_map - where category_id = :category_id) + where category_id = :id) Index: openacs-4/packages/categories/www/cadmin/category-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/categories/www/cadmin/category-delete.adp 22 May 2003 14:25:54 -0000 1.2 +++ openacs-4/packages/categories/www/cadmin/category-delete.adp 14 Dec 2003 15:36:57 -0000 1.3 @@ -3,11 +3,19 @@ @context_bar;noquote@ @locale;noquote@ - -This category is still mapped to some objects. - -Are you sure you want to delete category "@category_name@"? +

+ Are you sure you want to delete these categories: +

+ +
@form_vars;noquote@ Index: openacs-4/packages/categories/www/cadmin/category-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/categories/www/cadmin/category-delete.tcl 27 Apr 2003 11:37:12 -0000 1.2 +++ openacs-4/packages/categories/www/cadmin/category-delete.tcl 14 Dec 2003 15:36:57 -0000 1.3 @@ -6,7 +6,7 @@ @cvs-id $Id: } { tree_id:integer - category_id:integer + category_id:integer,multiple {locale ""} object_id:integer,optional } -properties { @@ -20,20 +20,26 @@ set user_id [ad_maybe_redirect_for_registration] permission::require_permission -object_id $tree_id -privilege category_tree_write -set category_name [category::get_name $category_id $locale] +multirow create categories category_id name objects_p + +foreach id $category_id { + multirow append categories \ + $id \ + [category::get_name $id $locale] \ + [db_string check_mapped_objects {}] +} + array set tree [category_tree::get_data $tree_id $locale] set tree_name $tree(tree_name) -set mapped_objects_p [db_string check_mapped_objects ""] - -set form_vars [export_form_vars tree_id category_id locale object_id] -set page_title "Delete category \"$category_name\"" +set form_vars [export_vars -form { tree_id category_id:multiple locale object_id }] +set page_title "Delete categories" if {[info exists object_id]} { set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]] } else { set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]] } -lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $tree_name] "Delete \"$category_name\"" +lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $tree_name] "Delete categories" ad_return_template Index: openacs-4/packages/categories/www/cadmin/category-form.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-form.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/categories/www/cadmin/category-form.adp 22 May 2003 14:25:54 -0000 1.2 +++ openacs-4/packages/categories/www/cadmin/category-form.adp 14 Dec 2003 15:36:57 -0000 1.3 @@ -2,6 +2,7 @@ @page_title;noquote@ @context_bar;noquote@ f +category_form.name
Index: openacs-4/packages/categories/www/cadmin/category-phase-in.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-phase-in.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/www/cadmin/category-phase-in.tcl 14 Dec 2003 15:36:57 -0000 1.1 @@ -0,0 +1,22 @@ +ad_page_contract { + Phases a category in/out. + + @author Timo Hentschel (thentschel@sussdorff-roy.com) + @cvs-id $Id: +} { + tree_id:integer + category_id:integer,multiple + {locale ""} + object_id:integer,optional +} + +permission::require_permission -object_id $tree_id -privilege category_tree_write + +db_transaction { + foreach id $category_id { + category::phase_in $id + } +} +category_tree::flush_cache $tree_id + +ad_returnredirect [export_vars -base tree-view { tree_id locale object_id }] Index: openacs-4/packages/categories/www/cadmin/category-phase-out.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-phase-out.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/category-phase-out.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/category-phase-out.tcl 14 Dec 2003 15:36:57 -0000 1.2 @@ -5,20 +5,28 @@ @cvs-id $Id: } { tree_id:integer - category_id:integer - phase_out_p:integer + category_id:integer,multiple + {phase_out_p:integer 1} {locale ""} object_id:integer,optional } permission::require_permission -object_id $tree_id -privilege category_tree_write -if {$phase_out_p} { - category::phase_out $category_id +if { $phase_out_p } { + db_transaction { + foreach id $category_id { + category::phase_out $id + } + } category_tree::flush_cache $tree_id } else { - category::phase_in $category_id + db_transaction { + foreach id $category_id { + category::phase_in $id + } + } category_tree::flush_cache $tree_id } -ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]" +ad_returnredirect [export_vars -base tree-view { tree_id locale object_id }] Index: openacs-4/packages/categories/www/cadmin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/index.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/categories/www/cadmin/index.adp 22 May 2003 14:25:54 -0000 1.2 +++ openacs-4/packages/categories/www/cadmin/index.adp 14 Dec 2003 15:36:57 -0000 1.3 @@ -3,53 +3,17 @@ @context_bar;noquote@ @locale;noquote@ -

Trees you have the write permission on:

+

Trees you can manage

- -
 @trees.tree_name@ 
+ - - - - - - - +

-

Name
- @trees_with_write_permission.tree_name@ - - (Site-Wide Tree) -
- - - - +

Trees you can view

+

-

Trees you have only the read permission on:

+Create a new tree - - - - - - - - - -
Name
- @trees_with_read_permission.tree_name@ - - (Site-Wide Tree) -
-
- - - - -

-Create a new tree -

Index: openacs-4/packages/categories/www/cadmin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/index.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/categories/www/cadmin/index.tcl 27 Apr 2003 11:37:12 -0000 1.2 +++ openacs-4/packages/categories/www/cadmin/index.tcl 14 Dec 2003 15:36:58 -0000 1.3 @@ -25,18 +25,50 @@ permission::require_permission -object_id $package_id -privilege category_admin -template::multirow create trees_with_write_permission tree_id tree_name site_wide_p short_name -template::multirow create trees_with_read_permission tree_id tree_name site_wide_p short_name +template::multirow create trees_with_write_permission tree_id tree_name site_wide_p description +template::multirow create trees_with_read_permission tree_id tree_name site_wide_p descrption -db_foreach trees "" { +db_foreach trees {} { + array unset tree_array + array set tree_array [category_tree::get_data $tree_id $locale] + if { [string equal $has_write_p "t"] } { - set tree_name [category_tree::get_name $tree_id $locale] - template::multirow append trees_with_write_permission $tree_id $tree_name $site_wide_p + template::multirow append trees_with_write_permission $tree_id $tree_array(tree_name) $site_wide_p $tree_array(description) } elseif { [string equal $has_read_p "t"] || [string equal $site_wide_p "t"] } { - set tree_name [category_tree::get_name $tree_id $locale] - template::multirow append trees_with_read_permission $tree_id $tree_name $site_wide_p + template::multirow append trees_with_read_permission $tree_id $tree_name $site_wide_p $tree_array(description) } } -ad_return_template +multirow extend trees_with_read_permission view_url +multirow foreach trees_with_read_permission { + set view_url [export_vars -no_empty -base tree-view { tree_id locale }] +} + +multirow extend trees_with_write_permission view_url +multirow foreach trees_with_write_permission { + set view_url [export_vars -no_empty -base tree-view { tree_id locale }] +} + + +set elements { + tree_name { + label "Name" + link_url_col view_url + } + description { + label "Description" + } +} + +template::list::create \ + -name trees_with_write_permission \ + -no_data "None" \ + -elements $elements + +template::list::create \ + -name trees_with_read_permission \ + -no_data "None" \ + -elements $elements + +set create_url [export_vars -no_empty -base tree-form { locale }] \ No newline at end of file Index: openacs-4/packages/categories/www/cadmin/master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/master.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/master.adp 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/master.adp 14 Dec 2003 15:36:58 -0000 1.2 @@ -1,17 +1,20 @@ @page_title;noquote@ @context_bar;noquote@ +@focus;noquote@ - - - @form_vars;noquote@ - - - + +

+
+ @form_vars;noquote@ + + +
+
Index: openacs-4/packages/categories/www/cadmin/master.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/master.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/categories/www/cadmin/master.tcl 27 Apr 2003 11:37:12 -0000 1.2 +++ openacs-4/packages/categories/www/cadmin/master.tcl 14 Dec 2003 15:36:58 -0000 1.3 @@ -19,6 +19,9 @@ set locale [ad_parameter DefaultLocale acs-lang "en_US"] } +# TODO: Refactor to use lang::system::get_locale_options and ad_form +# so we don't hit the DB on every request + db_multirow languages get_locales "" set current_page [ad_conn url] Index: openacs-4/packages/categories/www/cadmin/tree-form.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-form.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/categories/www/cadmin/tree-form.adp 22 May 2003 14:25:54 -0000 1.2 +++ openacs-4/packages/categories/www/cadmin/tree-form.adp 14 Dec 2003 15:36:58 -0000 1.3 @@ -2,7 +2,8 @@ @page_title;noquote@ @context_bar;noquote@ f +tree_form.tree_name
- +
Index: openacs-4/packages/categories/www/cadmin/tree-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-form.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/categories/www/cadmin/tree-form.tcl 27 Apr 2003 11:37:12 -0000 1.2 +++ openacs-4/packages/categories/www/cadmin/tree-form.tcl 14 Dec 2003 15:36:58 -0000 1.3 @@ -12,55 +12,18 @@ page_title:onevalue } -set user_id [ad_maybe_redirect_for_registration] -set package_id [ad_conn package_id] +auth::require_login -if {[info exists tree_id]} { +if { ![ad_form_new_p -key tree_id] } { set page_title "Edit tree" } else { set page_title "Add tree" } -if {[info exists object_id]} { +if { [info exists object_id] } { set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]] } else { set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]] } lappend context_bar $page_title -set languages [db_list_of_lists get_ad_locales ""] - -ad_form -name tree_form -action tree-form -export { locale object_id } -form { - {tree_id:key} - {tree_name:text {label "Name"} {html {size 50 maxlength 50}}} - {language:text(select) {label "Language"} {value $locale} {options $languages}} - {description:text(textarea),optional {label "Description"} {html {rows 5 cols 80}}} -} -new_request { - permission::require_permission -object_id $package_id -privilege category_admin - set tree_name "" - set description "" -} -edit_request { - permission::require_permission -object_id $tree_id -privilege category_tree_write - set action Edit - util_unlist [category_tree::get_translation $tree_id $locale] tree_name description -} -on_submit { - set description [util_close_html_tags $description 4000] -} -new_data { - db_transaction { - category_tree::add -tree_id $tree_id -name $tree_name -description $description -locale $language -context_id $package_id - if { [info exists object_id] } { - category_tree::map -tree_id $tree_id -object_id $object_id - set return_url "one-object?[export_url_vars locale object_id]" - } else { - set return_url ".?[export_url_vars locale]" - } - } -} -edit_data { - category_tree::update -tree_id $tree_id -name $tree_name -description $description -locale $language - set return_url "tree-view?[export_url_vars tree_id locale object_id]" -} -after_submit { - ad_returnredirect $return_url - ad_script_abort -} - -ad_return_template Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/categories/www/cadmin/tree-form.xql'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/categories/www/cadmin/tree-order-update.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-order-update.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/www/cadmin/tree-order-update.tcl 14 Dec 2003 15:36:58 -0000 1.1 @@ -0,0 +1,80 @@ +ad_page_contract { + Update sort order + + @author Timo Hentschel (thentschel@sussdorff-roy.com) + @author Lars Pind (lars@collaboraid.biz) + @cvs-id $Id: +} { + tree_id:integer + sort_key:array + {locale ""} + object_id:integer,optional +} + +permission::require_permission -object_id $tree_id -privilege category_tree_write + +array set tree [category_tree::get_data $tree_id $locale] + +db_transaction { + + set count 0 + db_foreach get_tree "" { + incr count 10 + if {[empty_string_p $parent_id]} { + # need this as an anchor for toplevel categories + set parent_id -1 + } + if {[info exists sort_key($category_id)]} { + lappend child($parent_id) [list $sort_key($category_id) $category_id 0 0] + } else { + lappend child($parent_id) [list $count $category_id 0 0] + } + } + set last_ind [expr ($count / 5) + 1] + + set count 1 + set stack [list] + set done_list [list] + # put toplevel categories on stack + if {[info exists child(-1)]} { + set stack [lsort -integer -index 0 $child(-1)] + } + + while {[llength $stack] > 0} { + set next [lindex $stack 0] + set act_category [lindex $next 1] + set stack [lrange $stack 1 end] + if {[lindex $next 2]>0} { + ## the children of this parent are done, so this category is also done + lappend done_list [list $act_category [lindex $next 2] $count] + } elseif {[info exists child($act_category)]} { + ## put category and all children back on stack + set next [lreplace $next 2 2 $count] + set stack [linsert $stack 0 $next] + set stack [concat [lsort -integer -index 0 $child($act_category)] $stack] + } else { + ## this category has no children, so it is done + lappend done_list [list $act_category $count [expr $count + 1]] + incr count 1 + } + incr count 1 + } + + if {$count == $last_ind} { + # we do this so that there is no conflict in the old left_inds and the new ones + db_dml reset_category_index "" + + foreach category $done_list { + util_unlist $category category_id left_ind right_ind + db_dml update_category_index "" + } + } + category_tree::flush_cache $tree_id +} + +if {$count != $last_ind} { + ad_return_complaint 1 "Error during update: $done_list" + return +} +ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]" + Index: openacs-4/packages/categories/www/cadmin/tree-order-update.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-order-update.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/www/cadmin/tree-order-update.xql 14 Dec 2003 15:36:58 -0000 1.1 @@ -0,0 +1,40 @@ + + + + + + + select category_id, parent_id + from categories + where tree_id = :tree_id + order by left_ind + + + + + + + + + update categories + set left_ind = -left_ind, + right_ind = -right_ind + where tree_id = :tree_id + + + + + + + + + update categories + set left_ind = :left_ind, + right_ind = :right_ind + where category_id = :category_id + + + + + + Index: openacs-4/packages/categories/www/cadmin/tree-view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-view.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/categories/www/cadmin/tree-view.adp 22 May 2003 14:25:54 -0000 1.2 +++ openacs-4/packages/categories/www/cadmin/tree-view.adp 14 Dec 2003 15:36:58 -0000 1.3 @@ -3,96 +3,6 @@ @context_bar;noquote@ @locale;noquote@ -

- - - -
Tree Name@tree_name@
Description @tree_description@
-

+ - - - - - - -
- @form_vars;noquote@ - - - - - - - - - - - - - - - - - - - - -
 Category NameHierarchy Level Sort Key
- - - - - @one_tree.left_indent;noquote@ @one_tree.category_name@ - - [ - Choose a new parent - | Add child - - | Edit - | Delete - | Phase out - Phase in - | Show Usage - ] - - - @one_tree.level@ - - @one_tree.left_indent;noquote@ -
- - - - - - - - -
-
- -
- - no categories have been created... - + Index: openacs-4/packages/categories/www/cadmin/tree-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-view.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/tree-view.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/tree-view.tcl 14 Dec 2003 15:36:58 -0000 1.2 @@ -55,4 +55,105 @@ template::multirow append one_tree $category_name $sort_key $category_id $deprecated_p $level [category::repeat_string " " [expr ($level-1)*5]] } -ad_return_template + + +#---------------------------------------------------------------------- +# List builder +#---------------------------------------------------------------------- + +multirow extend one_tree edit_url delete_url usage_url set_parent_url add_child_url phase_in_url phase_out_url +multirow foreach one_tree { + set usage_url [export_vars -base category-usage { category_id tree_id locale object_id }] + if { $can_write_p } { + set edit_url [export_vars -base category-form { category_id tree_id locale object_id }] + set delete_url [export_vars -base category-delete { category_id tree_id locale object_id }] + set set_parent_url [export_vars -base category-set-parent { category_id tree_id locale object_id }] + set add_child_url [export_vars -base category-form { { parent_id $category_id } tree_id locale object_id }] + if { [template::util::is_true $deprecated_p] } { + set phase_in_url [export_vars -base category-phase-out { category_id { phase_out_p 0 } tree_id locale object_id }] + } else { + set phase_out_url [export_vars -base category-phase-out { category_id { phase_out_p 1 } tree_id locale object_id }] + } + } +} + +set elements [list] + +if { $can_write_p } { + lappend elements edit { + sub_class narrow + display_template { + Edit + } + link_url_col edit_url + } +} + +lappend elements category_name { + label "Category" + display_template { + @one_tree.left_indent;noquote@@one_tree.category_name@ + (Deprecated - Restore) + } +} + +if { $can_write_p } { + lappend elements add_child { + sub_class narrow + display_template { + Add + } + link_url_col add_child_url + link_html { title "Add subcategory" } + } + lappend elements sort_key { + label "Ordering" + display_template { + + } + } + lappend elements actions { + label "Actions" + display_template { + Choose a new parent + } + } + + lappend elements delete { + sub_class narrow + display_template { + Delete + } + link_url_col delete_url + link_html { title "Delete category and all subcategories" } + } +} + +set actions [list] +set bulk_actions [list] +if { $can_write_p } { + set bulk_actions { + "Delete" "category-delete" "Delete checked categories" + "Deprecate" "category-phase-out" "Deprecate checked categories" + "Restore" "category-phase-in" "Restore checked categories" + "Update ordering" "tree-order-update" "Update ordering from values in list" + } + set actions [list \ + "Add root category" [export_vars -base category-form { tree_id locale object_id }] "Add category at the root level" \ + "Copy tree" [export_vars -base tree-copy { tree_id locale object_id }] "Copy categories from other tree" \ + "Delete tree" [export_vars -base tree-delete { tree_id locale object_id }] "Delete this category tree" \ + "Applications" [export_vars -base tree-usage { tree_id locale object_id }] "Applications using this tree"] + + if { $can_grant_p } { + lappend actions "Permissions" [export_vars -base permission-manage { tree_id locale object_id }] "Manage permissions for tree" + } + +} + +template::list::create \ + -name one_tree \ + -elements $elements \ + -key category_id \ + -actions $actions \ + -bulk_actions $bulk_actions \ + -bulk_action_export_vars { tree_id locale object_id } \ No newline at end of file