-/*-\r
- * ================================================================================\r
- * ECOMP Portal\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ================================================================================\r
- */\r
-'use strict';\r
-(function () {\r
- class FunctionalMenuCtrl {\r
- constructor($log, functionalMenuService, $scope,ngDialog, confirmBoxService) {\r
- $log.info('FunctionalMenuCtrl init');\r
-\r
- $scope.invokeDialog = () => {\r
- // alert("click dialog");\r
- };\r
-\r
- this.regenerateFunctionalMenuAncestors = () => {\r
- functionalMenuService.regenerateFunctionalMenuAncestors().then(res => {\r
- $log.debug("FunctionalMenuCtrl:regenerateFunctionalMenuAncestors::returned from regenerateFunctionalMenuAncestors API call");\r
- confirmBoxService.showInformation('You have successfully regenerated the menu.').then(isConfirmed => {\r
- });\r
- })['catch'](function (err) {\r
- $log.error("FunctionalMenuCtrl:regenerateFunctionalMenuAncestors:: error: " + err);\r
- confirmBoxService.showInformation('There was an error while regenerating the menu.').then(isConfirmed => {\r
- });\r
- });\r
- };\r
-\r
- let getFunctionalMenu = () => {\r
- this.isLoadingTable = true;\r
- functionalMenuService.getManagedFunctionalMenu().then(res => {\r
-\r
- let actualData=[];\r
-\r
- //Adding children and label attribute to all objects in res\r
- for(let i = 0; i < res.length; i++){\r
- res[i].children=[];\r
- res[i].label=res[i].text;\r
- res[i].id=res[i].text;\r
-\r
- }\r
- //Adding actual child items to children array in res objects\r
- for(let i = 0; i < res.length; i++){\r
-\r
- let parentId=res[i].menuId;\r
- for(let j = 0; j < res.length; j++){\r
- let childId=res[j].parentMenuId;\r
- if(parentId===childId){\r
- res[i].children.push(res[j]);\r
-\r
- }\r
- }\r
- }\r
-\r
- // Sort the top-level menu items in order based on the column\r
- res.sort(function(a, b) {\r
- return a.column-b.column;\r
- });\r
-\r
- // Sort all the children in order based on the column\r
- for(let i = 0; i < res.length; i++){\r
- res[i].children.sort(function(a, b){\r
- return a.column-b.column;\r
- });\r
- }\r
-\r
- //Forming actual parent items\r
- for(let i = 0; i < res.length; i++){\r
- let parentId=res[i].parentMenuId;\r
- if(parentId===null){\r
- actualData.push(res[i]);\r
- }\r
- }\r
-\r
- $scope.treedata = actualData;\r
-\r
- }).catch(err => {\r
- $log.error('FunctionalMenuCtrl:getFunctionalMenu:: error ',err);\r
- }).finally(()=> {\r
- this.isLoadingTable = false;\r
- });\r
-\r
- };\r
-\r
-\r
- let init = () => {\r
- this.isLoadingTable = false;\r
- this.functionalMenu = [];\r
- getFunctionalMenu();\r
- this.searchString = '';\r
-\r
-\r
- };\r
-\r
- this.filterByDropdownValue = item => {\r
- if(this.filterByApp.value === ''){\r
- return true;\r
- }\r
- return item.appName === this.filterByApp.value;\r
- };\r
-\r
- let getDialogTitle = (source) => {\r
- switch (source) {\r
- case 'edit':\r
- return "Functional Menu - Edit";\r
- case 'view':\r
- return "Functional Menu - View";\r
- case 'add':\r
- return "Functional Menu - Add";\r
- default:\r
- return "Functional Menu";\r
- };\r
- };\r
-\r
- $scope.reloadTreeStructure = (selectedItem,source) => {\r
- getFunctionalMenu();\r
- };\r
- $scope.openMenuDetailsModal = (selectedItem,source) => {\r
- let data = null;\r
- let selectedMenuDetails = null;\r
- console.log('selectedItem: ', selectedItem);\r
-\r
- functionalMenuService.getMenuDetails(selectedItem.menuId)\r
- .then(function( resp ){\r
- selectedMenuDetails = resp;\r
- $log.info('FunctionalMenuCtrl::openMenuDetailsModal: getMenuDetails: ', resp );\r
-\r
- if(selectedItem){\r
- data = {\r
- menuItem: {menu: _.clone(selectedItem),menuDetails:_.clone(selectedMenuDetails)},\r
- source: source,\r
- title: getDialogTitle(source)\r
- };\r
- }\r
- ngDialog.open({\r
- templateUrl: 'app/views/functionalMenu/functionalMenu-dialog/menu-details.modal.html',\r
- controller: 'MenuDetailsModalCtrl',\r
- controllerAs: 'functionalMenuDetails',\r
- data: data\r
- }).closePromise.then(needUpdate => {\r
- if(needUpdate.value === true){\r
- $log.debug('FunctionalMenuCtrl::openMenuDetailsModal: updating table data...');\r
- if(source==="edit") {\r
- init();\r
- }\r
- }\r
- });\r
- });\r
- };\r
-\r
-\r
- $scope.createNewMenuItem = (selectedItem,source) => {\r
-\r
- if(selectedItem != null && selectedItem.getLevel() >= 4){\r
- confirmBoxService.showInformation('You are not allowed to have a menu item at a level greater than 4.').then(isConfirmed => {\r
-\r
- });\r
- return ;\r
- }\r
-\r
- let data = null;\r
- let selectedMenuDetails = null;\r
- functionalMenuService.getMenuDetails(selectedItem.menuId)\r
- .then(function( resp ){\r
- selectedMenuDetails = resp;\r
-\r
- if((selectedItem.children===null || !selectedItem.children.length>0) &&\r
- (!!selectedMenuDetails.url || !!selectedMenuDetails.appid || !!selectedMenuDetails.roles)){\r
- confirmBoxService.showInformation('Warning: the child menu item "' + selectedItem.name + '" is already configured with an application. You can create a new mid-level menu item, and move this item under it.').then(isConfirmed => {\r
- return;\r
- });\r
- }else{\r
- if(selectedItem){\r
- data = {\r
- menuItem: {menu: _.clone(selectedItem)},\r
- source:source,\r
- title: getDialogTitle(source)\r
- };\r
- }\r
-\r
- ngDialog.open({\r
- templateUrl: 'app/views/functionalMenu/functionalMenu-dialog/menu-details.modal.html',\r
- controller: 'MenuDetailsModalCtrl',\r
- controllerAs: 'functionalMenuDetails',\r
- data: data\r
- }).closePromise.then(needUpdate => {\r
- if(needUpdate.value === true){\r
- $log.debug('FunctionalMenuCtrl::getMenuDetails: updating table data...');\r
- init();\r
- //getOnboardingWidgets();\r
- }\r
- });\r
- }\r
- });\r
- };\r
-\r
- $scope.deleteMenuItem = (selectedItem,source) => {\r
- $log.info('FunctionalMenuCtrl:deleteMenuItem:: delete selectedItem: ', selectedItem);\r
-\r
- if(selectedItem.children!=null && selectedItem.children.length>0){\r
- confirmBoxService.showInformation('You are not allowed to delete a menu item that has children. You can only delete leaf menu items.').then(isConfirmed => {\r
-\r
- });\r
- }else{\r
- confirmBoxService.deleteItem(selectedItem.name).then(isConfirmed => {\r
- if(isConfirmed){\r
- $log.info('FunctionalMenuCtrl:deleteMenuItem:: Deleting Menu Item :: name: '+selectedItem.name+'; menuId: '+selectedItem.menuId);\r
- $log.info('FunctionalMenuCtrl:deleteMenuItem:: selectedItem: ', selectedItem);\r
-\r
- functionalMenuService.deleteMenuItem(selectedItem.menuId).then(() => {\r
- //TODO:Have to splice menu item\r
- //this.widgetsList.splice(this.widgetsList.indexOf(widget), 1);\r
- $log.info('FunctionalMenuCtrl:deleteMenuItem:: Removed Menu Item :: '+selectedItem.name);\r
- init();\r
- }).catch(err => {\r
- $log.error(err);\r
- });\r
- }\r
- }).catch(err => {\r
- $log.error(err);\r
- });\r
- }\r
- };\r
-\r
- init();\r
- }\r
- }\r
- FunctionalMenuCtrl.$inject = ['$log', 'functionalMenuService','$scope', 'ngDialog', 'confirmBoxService'];\r
- angular.module('ecompApp').controller('FunctionalMenuCtrl', FunctionalMenuCtrl);\r
-\r
- angular.module('ecompApp').directive('jqTree', ['functionalMenuService','$log','confirmBoxService',function(functionalMenuService,$log,confirmBoxService){\r
- return {\r
- templateUrl: 'jqtree-tmpl.html',\r
- link: function(scope, el, attrs){\r
-\r
- var $jqTree = el.find('#jqTree').tree({\r
- data: scope.treedata,\r
- autoOpen: false,\r
- dragAndDrop: true,\r
- onCreateLi: function(node, $li) {\r
- $li.attr('id', node.id.replace(/\s+/g,'_'));\r
- }\r
- });\r
-\r
- el.find('#jqTree').bind('tree.move', function(event){\r
- event.preventDefault();\r
- console.log('moved_node', event.move_info.moved_node);\r
- console.log('target_node', event.move_info.target_node);\r
- console.log('position', event.move_info.position);\r
- console.log('previous_parent', event.move_info.previous_parent);\r
-\r
-\r
-\r
- if(event.move_info.target_node != null &&\r
- ((event.move_info.position === 'after' && event.move_info.target_node.getLevel() > 4) ||\r
- (event.move_info.position === 'inside' && event.move_info.target_node.getLevel() > 3))){\r
- confirmBoxService.showInformation('You are not allowed to have a menu item at a level greater than 4.').then(isConfirmed => {\r
-\r
- });\r
- return ;\r
- }\r
-\r
- var confMsg = 'Are you sure you want to move "'+event.move_info.moved_node.name+'" ?';\r
- if ((event.move_info.position === "inside") && (event.move_info.target_node.url != "")) {\r
- // If we are moving UNDER a node that has a url associated with it, warn the user\r
- // that all the app information will be removed if they do this.\r
- confMsg = 'Warning: You are moving "'+event.move_info.moved_node.name+'" under "'+event.move_info.target_node.name+'", which has application information associated with it. This will cause all the application information from "'+event.move_info.target_node.name+'" to be deleted.';\r
- }\r
- confirmBoxService.moveMenuItem(confMsg).then(isConfirmed => {\r
- if(isConfirmed){\r
- /*\r
- {\r
- "menuId": 129,\r
- "column": 3,\r
- "text": "",\r
- "parentMenuId": 37,\r
- "url": "",\r
- "appid": null,\r
- "roles": null\r
- }\r
-\r
- The menuId for the menu item being moved\r
- The column it is being moved to\r
- The parentMenuId for the parent it is being moved under\r
- */\r
-\r
- // The target_node is the node before the position we are\r
- // moving to. If we are moving to a lower column number, or\r
- // to a new parent, we must adjust the column to be after\r
- // the target_node.\r
- var new_column = event.move_info.target_node.column;\r
- var old_column = event.move_info.moved_node.column;\r
- if ((event.move_info.moved_node.parentMenuId !=\r
- event.move_info.target_node.parentMenuId) ||\r
- (new_column < old_column)\r
- ) {\r
- new_column += 1;\r
- }\r
- var activeMenuItem = {\r
- menuId:event.move_info.moved_node.menuId,\r
- column:new_column,\r
- text:"",\r
- parentMenuId:event.move_info.target_node.parentMenuId,\r
- url:"",\r
- appid: null,\r
- roles:null\r
- };\r
- // When position is "inside", this is a special case,\r
- // where you are moving to the first column under\r
- // a parent. The target_node is the parent node.\r
- // So we need to set the column to 1, and the parentMenuId to the menuId of\r
- // the target move.\r
- if (event.move_info.position === "inside") {\r
- console.log("special case: target_node is parent");\r
- activeMenuItem.column = 1;\r
- activeMenuItem.parentMenuId = event.move_info.target_node.menuId;\r
- }\r
-\r
-\r
- functionalMenuService.saveEditedMenuItem(activeMenuItem)\r
- .then(() => {\r
- $log.debug(' Menu Item moved');\r
- scope.reloadTreeStructure();\r
- }).catch(err => {\r
- $log.error(err);\r
- }).finally(()=>{\r
- });\r
- }\r
- }).catch(err => {\r
- $log.error(err);\r
- });\r
-\r
- //event.move_info.do_move();\r
- });\r
-\r
-\r
- $jqTree.jqTreeContextMenu(el.find('ul.dropdown-menu'), {\r
- "view": function (node) {scope.openMenuDetailsModal(node,'view'); },\r
- "edit": function (node) {scope.openMenuDetailsModal(node,'edit'); },\r
- "delete": function (node) { scope.deleteMenuItem(node,'delete') },\r
- "add": function (node) { scope.createNewMenuItem(node,'add') }\r
- });\r
-\r
- scope.$watch('treedata', function(oldValue, newValue){\r
- if(oldValue !== newValue){\r
- console.log('FunctionalMenuCtrl:: Tree value has changed in some way');\r
- $jqTree.tree('loadData', scope.treedata);\r
- $jqTree.tree('reload', function() {\r
- console.log('FunctionalMenuCtrl:: Tree is reloaded');\r
- });\r
- }\r
- });\r
- }\r
- };\r
- }]);\r
-\r
-})();\r
-\r
-\r
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+'use strict';
+(function () {
+ class FunctionalMenuCtrl {
+ constructor($log, functionalMenuService, $scope,ngDialog, confirmBoxService,$modal) {
+ $log.info('FunctionalMenuCtrl init');
+
+ $scope.invokeDialog = () => {
+ // alert("click dialog");
+ };
+
+ this.regenerateFunctionalMenuAncestors = () => {
+ functionalMenuService.regenerateFunctionalMenuAncestors().then(res => {
+ $log.debug("FunctionalMenuCtrl:regenerateFunctionalMenuAncestors::returned from regenerateFunctionalMenuAncestors API call");
+ confirmBoxService.showInformation('You have successfully regenerated the menu.').then(isConfirmed => {
+ });
+ })['catch'](function (err) {
+ $log.error("FunctionalMenuCtrl:regenerateFunctionalMenuAncestors:: error: " + err);
+ confirmBoxService.showInformation('There was an error while regenerating the menu.').then(isConfirmed => {
+ });
+ });
+ };
+
+ let getFunctionalMenu = () => {
+ this.isLoadingTable = true;
+ functionalMenuService.getManagedFunctionalMenu().then(res => {
+
+ let actualData=[];
+
+ //Adding children and label attribute to all objects in res
+ for(let i = 0; i < res.length; i++){
+ res[i].children=[];
+ res[i].label=res[i].text;
+ res[i].id=res[i].text;
+
+ }
+ //Adding actual child items to children array in res objects
+ for(let i = 0; i < res.length; i++){
+
+ let parentId=res[i].menuId;
+ for(let j = 0; j < res.length; j++){
+ let childId=res[j].parentMenuId;
+ if(parentId===childId){
+ res[i].children.push(res[j]);
+
+ }
+ }
+ }
+
+ // Sort the top-level menu items in order based on the column
+ res.sort(function(a, b) {
+ return a.column-b.column;
+ });
+
+ // Sort all the children in order based on the column
+ for(let i = 0; i < res.length; i++){
+ res[i].children.sort(function(a, b){
+ return a.column-b.column;
+ });
+ }
+
+ //Forming actual parent items
+ for(let i = 0; i < res.length; i++){
+ let parentId=res[i].parentMenuId;
+ if(parentId===null){
+ actualData.push(res[i]);
+ }
+ }
+
+ $scope.treedata = actualData;
+
+ }).catch(err => {
+ $log.error('FunctionalMenuCtrl:getFunctionalMenu:: error ',err);
+ }).finally(()=> {
+ this.isLoadingTable = false;
+ });
+
+ };
+
+
+ let init = () => {
+ this.isLoadingTable = false;
+ this.functionalMenu = [];
+ getFunctionalMenu();
+ this.searchString = '';
+
+
+ };
+
+ this.filterByDropdownValue = item => {
+ if(this.filterByApp.value === ''){
+ return true;
+ }
+ return item.appName === this.filterByApp.value;
+ };
+
+ let getDialogTitle = (source) => {
+ switch (source) {
+ case 'edit':
+ return "Functional Menu - Edit";
+ case 'view':
+ return "Functional Menu - View";
+ case 'add':
+ return "Functional Menu - Add";
+ default:
+ return "Functional Menu";
+ };
+ };
+
+ $scope.reloadTreeStructure = (selectedItem,source) => {
+ getFunctionalMenu();
+ };
+ $scope.openMenuDetailsModal = (selectedItem,source) => {
+ let data = null;
+ let selectedMenuDetails = null;
+ console.log('selectedItem: ', selectedItem);
+
+ functionalMenuService.getMenuDetails(selectedItem.menuId)
+ .then(function( resp ){
+ selectedMenuDetails = resp;
+ $log.info('FunctionalMenuCtrl::openMenuDetailsModal: getMenuDetails: ', resp );
+
+ if(selectedItem){
+ data = {
+ menuItem: {menu: _.clone(selectedItem),menuDetails:_.clone(selectedMenuDetails)},
+ source: source,
+ title: getDialogTitle(source)
+ };
+ }
+ var modalInstance = $modal.open({
+ templateUrl: 'app/views/functionalMenu/functionalMenu-dialog/menu-details.modal.html',
+ controller: 'MenuDetailsModalCtrl as functionalMenuDetails',
+ sizeClass: 'modal-large',
+ resolve: {
+ items: function () {
+ return data;
+ }
+ }
+ })
+
+ modalInstance.result.finally(function (needUpdate){
+ if(needUpdate.value === true){
+ $log.debug('FunctionalMenuCtrl::openMenuDetailsModal: updating table data...');
+ if(source==="edit") {
+ init();
+ }
+
+ }
+ });
+ });
+ };
+
+
+ $scope.createNewMenuItem = (selectedItem,source) => {
+
+ if(selectedItem != null && selectedItem.getLevel() >= 4){
+ confirmBoxService.showInformation('You are not allowed to have a menu item at a level greater than 4.').then(isConfirmed => {
+
+ });
+ return ;
+ }
+
+ let data = null;
+ let selectedMenuDetails = null;
+ functionalMenuService.getMenuDetails(selectedItem.menuId)
+ .then(function( resp ){
+ selectedMenuDetails = resp;
+
+ if((selectedItem.children===null || !selectedItem.children.length>0) &&
+ (!!selectedMenuDetails.url || !!selectedMenuDetails.appid || !!selectedMenuDetails.roles)){
+ confirmBoxService.showInformation('Warning: the child menu item "' + selectedItem.name + '" is already configured with an application. You can create a new mid-level menu item, and move this item under it.').then(isConfirmed => {
+ return;
+ });
+ }else{
+ if(selectedItem){
+ data = {
+ menuItem: {menu: _.clone(selectedItem)},
+ source:source,
+ title: getDialogTitle(source)
+ };
+ }
+
+ var modalInstance = $modal.open({
+ templateUrl: 'app/views/functionalMenu/functionalMenu-dialog/menu-details.modal.html',
+ controller: 'MenuDetailsModalCtrl as functionalMenuDetails',
+ sizeClass: 'modal-large',
+ resolve: {
+ items: function () {
+ return data;
+ }
+ }
+ })
+
+ modalInstance.result.finally(function (needUpdate){
+ if(needUpdate.value === true){
+ $log.debug('FunctionalMenuCtrl::getMenuDetails: updating table data...');
+ init();
+ //getOnboardingWidgets();
+
+ }
+ });
+ }
+ });
+ };
+
+ $scope.deleteMenuItem = (selectedItem,source) => {
+ $log.info('FunctionalMenuCtrl:deleteMenuItem:: delete selectedItem: ', selectedItem);
+
+ if(selectedItem.children!=null && selectedItem.children.length>0){
+ confirmBoxService.showInformation('You are not allowed to delete a menu item that has children. You can only delete leaf menu items.').then(isConfirmed => {
+
+ });
+ }else{
+ confirmBoxService.deleteItem(selectedItem.name).then(isConfirmed => {
+ if(isConfirmed){
+ $log.info('FunctionalMenuCtrl:deleteMenuItem:: Deleting Menu Item :: name: '+selectedItem.name+'; menuId: '+selectedItem.menuId);
+ $log.info('FunctionalMenuCtrl:deleteMenuItem:: selectedItem: ', selectedItem);
+
+ functionalMenuService.deleteMenuItem(selectedItem.menuId).then(() => {
+ //TODO:Have to splice menu item
+ //this.widgetsList.splice(this.widgetsList.indexOf(widget), 1);
+ $log.info('FunctionalMenuCtrl:deleteMenuItem:: Removed Menu Item :: '+selectedItem.name);
+ init();
+ }).catch(err => {
+ $log.error(err);
+ });
+ }
+ }).catch(err => {
+ $log.error(err);
+ });
+ }
+ };
+
+ init();
+ }
+ }
+ FunctionalMenuCtrl.$inject = ['$log', 'functionalMenuService','$scope', 'ngDialog', 'confirmBoxService','$modal'];
+ angular.module('ecompApp').controller('FunctionalMenuCtrl', FunctionalMenuCtrl);
+
+ angular.module('ecompApp').directive('jqTree', ['functionalMenuService','$log','confirmBoxService',function(functionalMenuService,$log,confirmBoxService){
+ return {
+ templateUrl: 'jqtree-tmpl.html',
+ link: function(scope, el, attrs){
+
+ var $jqTree = el.find('#jqTree').tree({
+ data: scope.treedata,
+ autoOpen: false,
+ dragAndDrop: true,
+ onCreateLi: function(node, $li) {
+ $li.attr('id', node.id.replace(/\s+/g,'_'));
+ }
+ });
+
+ el.find('#jqTree').bind('tree.move', function(event){
+ event.preventDefault();
+ console.log('moved_node', event.move_info.moved_node);
+ console.log('target_node', event.move_info.target_node);
+ console.log('position', event.move_info.position);
+ console.log('previous_parent', event.move_info.previous_parent);
+
+
+
+ if(event.move_info.target_node != null &&
+ ((event.move_info.position === 'after' && event.move_info.target_node.getLevel() > 4) ||
+ (event.move_info.position === 'inside' && event.move_info.target_node.getLevel() > 3))){
+ confirmBoxService.showInformation('You are not allowed to have a menu item at a level greater than 4.').then(isConfirmed => {
+
+ });
+ return ;
+ }
+
+ var confMsg = 'Are you sure you want to move "'+event.move_info.moved_node.name+'" ?';
+ if ((event.move_info.position === "inside") && (event.move_info.target_node.url != "")) {
+ // If we are moving UNDER a node that has a url associated with it, warn the user
+ // that all the app information will be removed if they do this.
+ confMsg = 'Warning: You are moving "'+event.move_info.moved_node.name+'" under "'+event.move_info.target_node.name+'", which has application information associated with it. This will cause all the application information from "'+event.move_info.target_node.name+'" to be deleted.';
+ }
+ confirmBoxService.moveMenuItem(confMsg).then(isConfirmed => {
+ if(isConfirmed){
+ /*
+ {
+ "menuId": 129,
+ "column": 3,
+ "text": "",
+ "parentMenuId": 37,
+ "url": "",
+ "appid": null,
+ "roles": null
+ }
+
+ The menuId for the menu item being moved
+ The column it is being moved to
+ The parentMenuId for the parent it is being moved under
+ */
+
+ // The target_node is the node before the position we are
+ // moving to. If we are moving to a lower column number, or
+ // to a new parent, we must adjust the column to be after
+ // the target_node.
+ var new_column = event.move_info.target_node.column;
+ var old_column = event.move_info.moved_node.column;
+ if ((event.move_info.moved_node.parentMenuId !=
+ event.move_info.target_node.parentMenuId) ||
+ (new_column < old_column)
+ ) {
+ new_column += 1;
+ }
+ var activeMenuItem = {
+ menuId:event.move_info.moved_node.menuId,
+ column:new_column,
+ text:"",
+ parentMenuId:event.move_info.target_node.parentMenuId,
+ url:"",
+ appid: null,
+ roles:null
+ };
+ // When position is "inside", this is a special case,
+ // where you are moving to the first column under
+ // a parent. The target_node is the parent node.
+ // So we need to set the column to 1, and the parentMenuId to the menuId of
+ // the target move.
+ if (event.move_info.position === "inside") {
+ console.log("special case: target_node is parent");
+ activeMenuItem.column = 1;
+ activeMenuItem.parentMenuId = event.move_info.target_node.menuId;
+ }
+
+
+ functionalMenuService.saveEditedMenuItem(activeMenuItem)
+ .then(() => {
+ $log.debug(' Menu Item moved');
+ scope.reloadTreeStructure();
+ }).catch(err => {
+ $log.error(err);
+ }).finally(()=>{
+ });
+ }
+ }).catch(err => {
+ $log.error(err);
+ });
+
+ //event.move_info.do_move();
+ });
+
+
+ $jqTree.jqTreeContextMenu(el.find('ul.dropdown-menu'), {
+ "view": function (node) {scope.openMenuDetailsModal(node,'view'); },
+ "edit": function (node) {scope.openMenuDetailsModal(node,'edit'); },
+ "delete": function (node) { scope.deleteMenuItem(node,'delete') },
+ "add": function (node) { scope.createNewMenuItem(node,'add') }
+ });
+
+ scope.$watch('treedata', function(oldValue, newValue){
+ if(oldValue !== newValue){
+ console.log('FunctionalMenuCtrl:: Tree value has changed in some way');
+ $jqTree.tree('loadData', scope.treedata);
+ $jqTree.tree('reload', function() {
+ console.log('FunctionalMenuCtrl:: Tree is reloaded');
+ });
+ }
+ });
+ }
+ };
+ }]);
+
+})();
+
+