File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
backend/src/app/components/post.category Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 6262 vm . categoryTree = {
6363 collapsed : true ,
6464 accept : function ( sourceNodeScope , destNodesScope , destIndex ) {
65- console . log ( sourceNodeScope , destNodesScope , destIndex ) ;
6665 return true ;
6766 } ,
67+ dragStart : function ( event ) {
68+ var oldParent = event . dest . nodesScope . $parent . $parent . $modelValue ;
69+
70+ //if old parent get only a children, remove the handle tool
71+ if ( ! _ . isUndefined ( oldParent ) && oldParent . children . length === 1 ) {
72+ oldParent . rgt = oldParent . lft + 1 ;
73+ }
74+ } ,
6875 dropped : function ( event ) {
6976 if ( ! event . pos . moving ) {
7077 return ;
7178 }
72- var source = event . source . nodeScope . $modelValue . id ;
7379
80+ var source = event . source . nodeScope . $modelValue . id ;
81+ console . log ( 'sad' , event . source . nodeScope ) ;
7482 var categoryAPI = { } ;
7583
7684 var dest = event . dest . nodesScope . $parent . $modelValue ;
9199 }
92100
93101 postCategoryService . move ( source , categoryAPI ) . then ( function ( result ) {
102+ if ( ! _ . isUndefined ( dest ) && dest . children . length > 0 ) {
103+ dest . rgt += 1 ;
104+ }
105+
94106 // show notifications
95107 toaster . pop ( 'success' , '' , $translate . instant ( 'post.category.update_success_msg' ) ) ;
108+
96109 } ) ;
97110
98111 }
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ <h3 class="box-title">{{ 'post.category.categories' | translate }}</h3>
3030 < div ui-tree ="listCtrl.categoryTree " ng-if ="listCtrl.categories.length > 0 ">
3131 < ol ui-tree-nodes ="" ng-model ="listCtrl.categories ">
3232 < li ng-repeat ="node in listCtrl.categories "
33- collapsed ="{{ node.lft+1 !== node.rgt > 0 ? 'true' : 'false'}} "
33+ collapsed ="{{ node.lft+1 !== node.rgt ? 'true' : 'false'}} "
3434 ui-tree-node
3535 ng-include ="'nodes_renderer.html' "> </ li >
3636 </ ol >
@@ -73,7 +73,7 @@ <h3 class="box-title">{{ 'post.category.categories' | translate }}</h3>
7373
7474 < ol ui - tree - nodes = "" ng - model = "node.children" ng - if = "!collapsed" ng - class = "{hidden: collapsed}" >
7575 < li ng-if = "listCtrl.getChildrenLoading[node.id]" > < i class = "fa fa-refresh fa-spin" > </ i > </ li >
76- < li ng - repeat = "node in node.children" collapsed = "{{ node.lft+1 !== node.rgt > 0 ? 'true' : 'false'}}"
76+ < li ng - repeat = "node in node.children" collapsed = "{{ node.lft+1 !== node.rgt ? 'true' : 'false'}}"
7777 ui - tree - node
7878 ng - include = "'nodes_renderer.html'" >
7979 < / li >
You can’t perform that action at this time.
0 commit comments