From f1ea76242b4f4070cd4c2bce423c8b9a1363204d Mon Sep 17 00:00:00 2001 From: Matthieu Leproux Date: Thu, 15 Jul 2021 13:05:45 +0200 Subject: [PATCH] fixes #1451 Can now open move album from album manager --- admin/cat_list.php | 1 + admin/cat_modify.php | 1 + admin/themes/default/js/cat_move.js | 19 +++++++++ admin/themes/default/template/cat_list.tpl | 1 + admin/themes/default/template/cat_modify.tpl | 4 ++ admin/themes/default/template/cat_move.tpl | 42 +++++++++++++++++++- 6 files changed, 67 insertions(+), 1 deletion(-) diff --git a/admin/cat_list.php b/admin/cat_list.php index d5a46b82a..1b7317ac1 100644 --- a/admin/cat_list.php +++ b/admin/cat_list.php @@ -324,6 +324,7 @@ foreach ($categories as $category) 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], 'U_EDIT' => $base_url.'album-'.$category['id'], 'U_ADD_PHOTOS_ALBUM' => $base_url.'photos_add&album='.$category['id'], + 'U_MOVE' => $base_url.'cat_move#cat-'.$category['id'], 'IS_VIRTUAL' => empty($category['dir']) ); diff --git a/admin/cat_modify.php b/admin/cat_modify.php index 881723024..a819c1973 100644 --- a/admin/cat_modify.php +++ b/admin/cat_modify.php @@ -288,6 +288,7 @@ $template->assign( 'U_ADD_PHOTOS_ALBUM' => $base_url.'photos_add&album='.$category['id'], 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], 'U_HELP' => get_root_url().'admin/popuphelp.php?page=cat_modify', + 'U_MOVE' => $base_url.'cat_move#cat-'.$category['id'], 'F_ACTION' => $form_action, ) diff --git a/admin/themes/default/js/cat_move.js b/admin/themes/default/js/cat_move.js index 9971a7ffc..709adb517 100644 --- a/admin/themes/default/js/cat_move.js +++ b/admin/themes/default/js/cat_move.js @@ -63,6 +63,13 @@ $(document).ready(() => { cont.find(".icon-folder-open, .icon-sitemap").addClass(colors[colorId]); } + var url_split = window.location.href.split("&"); + var catToOpen = url_split[url_split.length-1].split("-")[1]; + + if(catToOpen) { + goToNode($('.tree').tree('getNodeById', catToOpen), $('.tree').tree('getNodeById', catToOpen)); + } + $('.tree').on( 'click', '.move-cat-toogler', function(e) { var node_id = $(this).attr('data-id'); var node = $('.tree').tree('getNodeById', node_id); @@ -157,6 +164,18 @@ $(document).ready(() => { } }); +function goToNode(node, firstNode) { + if (node.parent) { + goToNode(node.parent, firstNode); + if(node != firstNode) { + $(".tree").tree('openNode', node); + } + } else { + $(".tree").tree('openNode', node); + $("#cat-"+firstNode.id).addClass("animateFocus"); + } +} + function getId(parent) { if (parent.getLevel() == 0) { return 0; diff --git a/admin/themes/default/template/cat_list.tpl b/admin/themes/default/template/cat_list.tpl index 2778ff1c4..0d6dabea4 100644 --- a/admin/themes/default/template/cat_list.tpl +++ b/admin/themes/default/template/cat_list.tpl @@ -56,6 +56,7 @@ jQuery(document).ready(function(){
{'Edit'|@translate} {'sub-albums'|@translate} + {'Move'|@translate} {if cat_admin_access($category.ID)} {'Visit Gallery'|@translate} {else} diff --git a/admin/themes/default/template/cat_modify.tpl b/admin/themes/default/template/cat_modify.tpl index db2b1c22a..cb58063ed 100644 --- a/admin/themes/default/template/cat_modify.tpl +++ b/admin/themes/default/template/cat_modify.tpl @@ -262,6 +262,10 @@ function cropImage() { {'Synchronize'|@translate} {/if} + {if isset($U_MOVE) } + {'Move'|@translate} + {/if} + {if isset($U_DELETE) } {'Delete album'|@translate} {/if} diff --git a/admin/themes/default/template/cat_move.tpl b/admin/themes/default/template/cat_move.tpl index 0d4cfd8b9..91a01fce0 100644 --- a/admin/themes/default/template/cat_move.tpl +++ b/admin/themes/default/template/cat_move.tpl @@ -84,4 +84,44 @@ var delay_autoOpen = {$delay_before_autoOpen} {'Apply an automatic order to root albums'|@translate}
-
\ No newline at end of file +
+ + \ No newline at end of file