From 379b28ccc37af81cad23c3e4f09ff66b736b3a9a Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Fri, 17 Jan 2020 14:36:38 +0530 Subject: [PATCH] Add Dynamic Section for Save draft CB --- 400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js | 1100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 708 insertions(+), 392 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js index b99de8e..0368777 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js @@ -10,8 +10,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $rootScope.selectedNodeSingle = []; $scope.selectedNodeSingleObj = []; $rootScope.saveDraftSingleObj = []; - $rootScope.saveDraftDynamicTest = []; - $rootScope.updateSaveDraftCB = []; + $rootScope.contentEleNote = []; + $rootScope.dynamicUpdatedJsonForSaveCB = ""; + //$rootScope.updateSaveDraftCB = []; $scope.IsVisible = function () { $scope.scroll(); } @@ -25,8 +26,8 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $("#sidebar-wrapper").on('click', function (event) { - //4. on click disable menu option - $scope.$emit("cBEnableDisableMenuOption",""); + //4. on click disable menu option + $scope.$emit("cBEnableDisableMenuOption",""); }); // close all selected open panel in CB @@ -179,96 +180,113 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $("#opencbview").trigger("click"); var fileupload = document.getElementById("opencbview"); - + fileupload.onchange = function () { - - var fileName = fileupload.value; - alert(fileName); + $scope.getJsonFileFromLocal(); + var fileName = fileupload.value.replace('C:\\fakepath\\', '');; + //alert(fileName); //switch ($location.url()) { // case '/curriculum-builder-detail': // $location.url('/curriculum-builder'); // break; //} - // $scope.fileName = file_Name; $('#modal-CurBuilder').css("display", "block"); $("#CurBuilderbackground").css("display", "block"); - $http({ method: 'GET', url: fileName }).success(function (data) { - localStorage.setItem("cbJsonDataObject", JSON.stringify(data)); - $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject")); - $rootScope.cbDynamicJsonData = data; - $rootScope.getCBsummary(); - - $scope.openCurriculumDetail(); - }) - .error(function (data, status, headers, config) { - console.log(data); - }); - }; + var name = document.getElementById("opencbview").files[0].name; + + // $http({ + // method: 'GET', + // url: '' + fileName + // }).success(function (data) { + + // localStorage.setItem("cbJsonDataObject", JSON.stringify(data)); + // $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject")); + // $rootScope.cbDynamicJsonData = data; + + // $rootScope.getCBsummary(); + + // $scope.openCurriculumDetailtest(); + // }) + //.error(function (data, status, headers, config) { + // console.log(data); + // }); + + }; + } + $scope.getJsonFileFromLocal = function loadFile() { + var input, file, fr; + + if (typeof window.FileReader !== 'function') { + alert("The file API isn't supported on this browser yet."); + return; + } + input = document.getElementById('opencbview'); + if (!input) { + alert("Um, couldn't find the fileinput element."); + } + else if (!input.files) { + alert("This browser doesn't seem to support the `files` property of file inputs."); + } + else if (!input.files[0]) { + alert("Please select a file before clicking 'Load'"); + } + else { + file = input.files[0]; + fr = new FileReader(); + fr.onload = receivedText; + fr.readAsText(file); + } + + function receivedText(e) { + let lines = e.target.result; + var newArr = JSON.parse(lines); + + localStorage.setItem("cbJsonDataObject", JSON.stringify(newArr)); + $rootScope.cbJsonData = JSON.parse(lines); + $rootScope.cbDynamicJsonData = JSON.parse(lines); + $rootScope.getCBsummary(); + $scope.CBEnableUI(); + $scope.openCurriculumDetail(); + } } - + //$rootScope.OpenExistingCurriculum = function (file_Name) { - $rootScope.saveCurricullam = function (file_Name) { - $scope.exportToFile(); - $scope.selectedNodeSingleObj.push( - { - "slideshow": { - "presentation": { - "structure": { - "structure": [ - { - "_label": "Untitled Slide", - "_id": "-1507902782", - "_isRoot": "false", - "_isBranch": "false", - "_isLocked": "false" - } + // $("#opencbview").trigger("click"); + // var fileupload = document.getElementById("opencbview"); - ], - "_label": "Untitled Curriculum", - "_id": "-225638207", - "_isRoot": "true", - "_isBranch": "true", - "_isLocked": "false" - }, - "_anchor": "true", - "_window_position": "6,10", - "_window_size": "828,453" - }, - "content": { - "element": [ - { - "notes": "

", - "windows": { - "window": "{\"windowTitle\":\"Hand (Post/Ant)\",\"selectedCallouts\":[],\"annotationData\":\"\",\"minimised\":false,\"scrollPosition\":{\"vertical\":78,\"horizontal\":120},\"selectedStructureID\":7446,\"maximised\":false,\"size\":{\"width\":800,\"height\":753},\"id\":\"424\",\"showSelectedPins\":true,\"scaleIndex\":0,\"bodySystemId\":11,\"windowListId\":\"0\",\"imageId\":\"424\",\"position\":{\"x\":840,\"y\":10},\"mType\":\"ATLAS_ANATOMY\",\"hideCallOuts\":true,\"containsCapturedContent\":true,\"selectedPins\":[\"32783\"],\"contextMenu\":{\"hideLeftBar\":false,\"hideTitleBar\":false,\"hideTopToolBar\":false,\"lockResize\":false}}" - }, - "_id": "-1507902782" - } - ] - } - } - }); - console.log($scope.selectedNodeSingle); - $scope.exportToFile(); - $http({ method: 'Post', url: 'content/data/json/cb/SlideShow/json/' + $scope.fileName + '.json' }).success(function (data) { - localStorage.setItem("cbJsonDataObject", JSON.stringify(data)); - $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject")); - $rootScope.cbDynamicJsonData = data; - //$scope.getCBsummary(); - $rootScope.cbJsonData.slideshow.content.element="Eement data"; - $rootScope.cbDynamicJsonData.slideshow.content.element="slideshow element data"; - $rootScope.note = "save data" - //$scope.openCurriculumDetail(); - }) - .error(function (data, status, headers, config) { - console.log(data); - }); + // fileupload.onchange = function () { - } + // var fileName = fileupload.value; + // alert(fileName); + + // //switch ($location.url()) { + // // case '/curriculum-builder-detail': + // // $location.url('/curriculum-builder'); + // // break; + // //} + + // // $scope.fileName = file_Name; + // $('#modal-CurBuilder').css("display", "block"); + // $("#CurBuilderbackground").css("display", "block"); + // $http({ method: 'GET', url: fileName }).success(function (data) { + // localStorage.setItem("cbJsonDataObject", JSON.stringify(data)); + // $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject")); + // $rootScope.cbDynamicJsonData = data; + // $rootScope.getCBsummary(); + + // $scope.openCurriculumDetail(); + // }) + // .error(function (data, status, headers, config) { + // console.log(data); + // }); + // }; + //} + //$rootScope.saveCurricullam = function (file_Name) { // $scope.selectedNodeSingleObj.push( @@ -383,10 +401,10 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ imfgEle.src = "data:image/png;base64," + $rootScope.windowsimageSource; setTimeout(function () { - var cleintht=imfgEle.clientHeight; - if(cleintht>0) - $('#CBSourceImagePanel .jsPanel-content').css('height', cleintht); - $scope.CBEnableUI(); + var cleintht=imfgEle.clientHeight; + if(cleintht>0) + $('#CBSourceImagePanel .jsPanel-content').css('height', cleintht); + $scope.CBEnableUI(); }, 200) }, 200) @@ -474,7 +492,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ }); $timeout(function () { - $scope.TinyMCEPanelclick(); + $scope.TinyMCEPanelclick(); },1000); if ($rootScope.isOpenResourceBtnClicked == true) { @@ -504,7 +522,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $scope.myeditorclick=function() { //1. disable menu options - $scope.$emit("cBEnableDisableMenuOption",""); + $scope.$emit("cBEnableDisableMenuOption",""); } @@ -530,24 +548,24 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } } - function getLoadNodeId(o) { + //function getLoadNodeId(o) { - for (var i in o) { + // for (var i in o) { - if (o[i] !== null && typeof (o[i]) == "object") { - if (o[i]._isBranch == "false") { - $rootScope.firstSelectedNodeId = o[i]._id; + // if (o[i] !== null && typeof (o[i]) == "object") { + // if (o[i]._isBranch == "false") { + // $rootScope.firstSelectedNodeId = o[i]._id; - } + // } - getLoadNodeId(o[i]); + // getLoadNodeId(o[i]); - } + // } - } - } + // } + //} $scope.loadNotesById = function () { @@ -595,31 +613,31 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $("#viwerSelect").empty(); $("#viwerSelect").hide(); - if ($('#parentcustomDiv').html() != "") { - $('#parentcustomDiv').empty(); - } + if ($('#parentcustomDiv').html() != "") { + $('#parentcustomDiv').empty(); + } - if ($scope.SelectedNotes != "" && $scope.SelectedNotes != undefined) { - tinymce.get("CBTextArea").setContent($scope.SelectedNotes); + if ($scope.SelectedNotes != "" && $scope.SelectedNotes != undefined) { + tinymce.get("CBTextArea").setContent($scope.SelectedNotes); - setTimeout(function () { - if ($scope.selectedNodeSingleObj.windows != "") { - $scope.loadContentOfSelectedSlide($scope.selectedNodeSingleObj._id) + setTimeout(function () { + if ($scope.selectedNodeSingleObj.windows != "") { + $scope.loadContentOfSelectedSlide($scope.selectedNodeSingleObj._id) - } - else - { - $scope.CBEnableUI(); + } + else + { + $scope.CBEnableUI(); - } - },200); + } + },200); - } - else - { - tinymce.get("CBTextArea").setContent(""); - $scope.CBEnableUI(); - } + } + else + { + tinymce.get("CBTextArea").setContent(""); + $scope.CBEnableUI(); + } } else @@ -631,7 +649,40 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $rootScope.cbSelectOnChange = function (obj) { $('#jstree').jstree(true).deselect_all(); $('#jstree').jstree('select_node', obj.value); - } + } + traverseSelectedObjForSaveDraftCB = function (o, current_id) { + for (var i in o) { + if (o[i] !== null && typeof (o[i]) == "object") { + if (o[i]._id == current_id) { + $scope.selectedObjforSaveDraftCB = o[i]; + } + traverseSelectedObjForSaveDraftCB(o[i], current_id); + } + } + } + + $scope.updateDropdownforSaveDraftCB = function (nodeid) { + var current_id = document.getElementById('cbSelect').value; + if ($rootScope.saveDraftSingleObj.length == 0) { + $rootScope.saveDraftSingleObj = $rootScope.structure; + } + traverseSelectedObjForSaveDraftCB($rootScope.saveDraftSingleObj, current_id); + if ($rootScope.saveDraftSingleObj.length != $rootScope.stru.structure.structure.length) { + if ($scope.selectedObjforSaveDraftCB._isBranch == "true" && $scope.selectedObjforSaveDraftCB._id == nodeid) { + $('#cbSelect').append(''); + document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSingleObj).length; + } + else { + for (var i = 0; i < $rootScope.selectedObjforSaveDraftCB.length; i++) { + if ($rootScope.selectedObjforSaveDraftCB[i]._id == nodeid) { + $scope.currentSlideNumber = i + 1; + $('#cbSelect').append(''); + document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedObjforSaveDraftCB).length + } + } + } + } + } //Start Code by Sandeep for TicketNo: 49226(3) $scope.DropDownSelectNodeClick = function (nodeid) { @@ -643,6 +694,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $('#cbEditorRightSideBar').css('pointer-events', 'auto'); $('#cbEditorRightSideBar').css('opacity', '1'); + //if ($rootScope.saveDraftSingleObj.length != $rootScope.stru.structure.structure.length && $rootScope.saveDraftSingleObj.length != 0) { + // $scope.updateDropdownforSaveDraftCB(nodeid); + //} if ($scope.selectedNodeSingleObj._isBranch == "true") { $("#cbSelect").empty(); @@ -652,7 +706,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ localStorage.setItem("cbSelectId", nodeid); if ($scope.selectedNodeSingleObj._id == nodeid) { - $scope.currentSlideNumber += 1; + //$scope.currentSlideNumber += 1; $('#cbSelect').append(''); } else { @@ -663,17 +717,17 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ document.getElementById("slideNumber").innerHTML = "Slide " + 1 + " of " + 1; } else if ($scope.selectedNodeSingleObj._isBranch == "true") { + $scope.currentSlideNumber += 1; document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSingleObj).length; } - else - { + else{ document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSingleObj).length; - } + } } else { traverse($rootScope.stru, nodeid); $("#cbSelect").empty(); - for (i = 0; i < $scope.selectedNodeSiblingObjs.length; i++) { + for (var i = 0; i < $scope.selectedNodeSiblingObjs.length; i++) { localStorage.setItem("cbSelectId", nodeid); if ($scope.selectedNodeSiblingObjs[i]._id == nodeid) { $scope.currentSlideNumber = i + 1; @@ -753,21 +807,21 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } } - $rootScope.cbRenameModelShow = function () { - var current_id = document.getElementById('cbSelect').value; - document.getElementById('renameInputBoxId').value = ""; - traverseTreeSelectedSingleObj($rootScope.stru, current_id); - if ($scope.selectedNodeSingleObj._isBranch == "true") { - traverseTreeSelectedSingleObj($rootScope.Auther, current_id); - document.getElementById('cbRenameDate').value = $scope.selectedNodeSingleObj.modified; - document.getElementById('cbModelRenameBackground').style.display = "block"; - document.getElementById('cbModelSectionRenameId').style.display = "block"; - } - else { - document.getElementById('cbModelRenameBackground').style.display = "block"; - document.getElementById('cbModelRenameId').style.display = "block"; - } - } + //$rootScope.cbRenameModelShow = function () { + // var current_id = document.getElementById('cbSelect').value; + // document.getElementById('renameInputBoxId').value = ""; + // traverseTreeSelectedSingleObj($rootScope.stru, current_id); + // if ($scope.selectedNodeSingleObj._isBranch == "true") { + // traverseTreeSelectedSingleObj($rootScope.Auther, current_id); + // document.getElementById('cbRenameDate').value = $scope.selectedNodeSingleObj.modified; + // document.getElementById('cbModelRenameBackground').style.display = "block"; + // document.getElementById('cbModelSectionRenameId').style.display = "block"; + // } + // else { + // document.getElementById('cbModelRenameBackground').style.display = "block"; + // document.getElementById('cbModelRenameId').style.display = "block"; + // } + //} $rootScope.cbPasswordModelShow = function () { //var current_id = document.getElementById('cbSelect').value; @@ -785,6 +839,136 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } + //$rootScope.cbRenameSlide = function () { + // var current_id + // if (($rootScope.getLocalStorageValue("cbSelectId")) != '') { + // current_id = $rootScope.getLocalStorageValue("cbSelectId"); + // } + // else { + // current_id = document.getElementById('cbSelect').value; + // } + // //var current_id = document.getElementById('cbSelect').value; + // var newSlideText = document.getElementById('renameInputBoxId').value; + // var newSlideName = ("" + newSlideText + ""); + // $("#jstree").jstree('set_text', current_id, newSlideName); + // traverseTreeSelectedSingleObj($rootScope.stru, current_id); + // $scope.selectedNodeSingleObj._label = newSlideText; + // $scope.DropDownSelectNodeClick(current_id); + // console.log(JSON.stringify($rootScope.stru)); + // $rootScope.closeRenameModel(); + //} + + //$rootScope.closeRenameModel = function () { + // document.getElementById('cbModelRenameBackground').style.display = "none"; + // if (document.getElementById("cbModelRenameId").style.display == 'block') { + // document.getElementById('cbModelRenameId').style.display = "none"; + // } + // if (document.getElementById("cbModelUserPassWord").style.display == 'block') { + // document.getElementById('cbModelUserPassWord').style.display = "none"; + // } + + // if (document.getElementById("cbModelSectionRenameId").style.display == 'block') { + // document.getElementById('cbModelSectionRenameId').style.display = "none"; + // } + //} + + //$rootScope.cbRenameSection = function () { + // var nodeid + // if (($rootScope.getLocalStorageValue("cbSelectId")) != '') { + // nodeid = $rootScope.getLocalStorageValue("cbSelectId"); + // } + // else { + // nodeid = document.getElementById('cbSelect').value; + // } + + + // //var nodeid = document.getElementById('cbSelect').value; + // $scope.cbRenameDate(); + // //var newSlideName = document.getElementById('cbRenameSectionTitle').value; + // var newAuthorName = document.getElementById('cbRenameAuthor').value; + // var newSummary = document.getElementById('cbRenameSummary').value; + // var newversion = document.getElementById('cbRenameVersionNo').value; + // var newSectionText = document.getElementById('cbRenameSectionTitle').value; + // var newSlideName = ("" + newSectionText + ""); + // $("#jstree").jstree('set_text', nodeid, newSlideName); + // traverseTreeSelectedSingleObj($rootScope.stru, nodeid); + // $scope.selectedNodeSingleObj._label = newSectionText; + // $scope.selectedNodeSingleObj = ""; + // traverseTreeSelectedSingleObj($rootScope.Auther, nodeid); + // setTimeout(function () { + // $scope.selectedNodeSingleObj.summary = newSummary; + // $scope.selectedNodeSingleObj.author = newAuthorName; + // $scope.selectedNodeSingleObj.version = newversion; + // $scope.selectedNodeSingleObj.modified = $scope.dateTime; + // $scope.DropDownSelectNodeClick(nodeid); + // console.log("summary" + JSON.stringify($rootScope.cbDynamicJsonData)); + // }, 100); + // $rootScope.closeRenameModel(); + + //} + + //$scope.cbRenameDate = function () { + // var currentdate = new Date(); + // var now = new Date(); + // var year = now.getFullYear(); + // var month = now.getMonth() + 1; + // var day = now.getDate(); + // var hours = now.getHours(); + // var minute = now.getMinutes(); + // var ampm = hours >= 12 ? 'PM' : 'AM'; + // hours = hours % 12; + // hours = hours ? hours : 12; // the hour '0' should be '12' + // if (month.toString().length == 1) { + // month = '0' + month; + // } + // if (day.toString().length == 1) { + // day = '0' + day; + // } + // if (hours.toString().length == 1) { + // hours = '0' + hours; + // } + // if (minute.toString().length == 1) { + // minute = '0' + minute; + // } + + // $scope.dateTime = month + '/' + day + '/' + year + ',' + hours + ':' + minute + ' ' + ampm; + //} + + $scope.setProperties = function () { + if ($scope.selectedNodeSingleObj.author != "undefined") { + $('#cbRenameAuthor').val($scope.selectedNodeSingleObj.author); + } + if ($scope.selectedNodeSingleObj.version != "undefined") { + $('#cbRenameSummary').val($scope.selectedNodeSingleObj.version); + } + if ($scope.selectedNodeSingleObj.summary != "undefined") { + $('#cbRenameVersionNo').val($scope.selectedNodeSingleObj.summary); + } + if ($scope.selectedNodeSingleObj.modified != "undefined") { + $('#cbRenameDate').val($scope.selectedNodeSingleObj.modified); + } + } + + $rootScope.cbRenameModelShow = function () { + var current_id = document.getElementById('cbSelect').value; + document.getElementById('renameInputBoxId').value = ""; + traverseTreeSelectedSingleObj($rootScope.stru, current_id); + if ($scope.selectedNodeSingleObj._label != "undefined") { + $('#cbRenameSectionTitle').val($scope.selectedNodeSingleObj._label); + } + if ($scope.selectedNodeSingleObj._isBranch == "true") { + traverseTreeSelectedSingleObj($rootScope.Auther, current_id); + //document.getElementById('cbRenameDate').value = $scope.selectedNodeSingleObj.modified; + $scope.setProperties(); + document.getElementById('cbModelRenameBackground').style.display = "block"; + document.getElementById('cbModelSectionRenameId').style.display = "block"; + } + else { + document.getElementById('cbModelRenameBackground').style.display = "block"; + document.getElementById('cbModelRenameId').style.display = "block"; + } + } + $rootScope.cbRenameSlide = function () { var current_id if (($rootScope.getLocalStorageValue("cbSelectId")) != '') { @@ -799,6 +983,15 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $("#jstree").jstree('set_text', current_id, newSlideName); traverseTreeSelectedSingleObj($rootScope.stru, current_id); $scope.selectedNodeSingleObj._label = newSlideText; + if ($rootScope.saveDraftSingleObj.length == 0) { + $rootScope.saveDraftSingleObj = $rootScope.structure; + } + //Update Save Draft object for Rename slide + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) { + if ($rootScope.saveDraftSingleObj[i]._id == current_id) { + $rootScope.saveDraftSingleObj[i]._label = $scope.selectedNodeSingleObj._label + } + } $scope.DropDownSelectNodeClick(current_id); console.log(JSON.stringify($rootScope.stru)); $rootScope.closeRenameModel(); @@ -817,6 +1010,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ document.getElementById('cbModelSectionRenameId').style.display = "none"; } } + $rootScope.cbRenameSection = function () { var nodeid if (($rootScope.getLocalStorageValue("cbSelectId")) != '') { @@ -838,7 +1032,21 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $("#jstree").jstree('set_text', nodeid, newSlideName); traverseTreeSelectedSingleObj($rootScope.stru, nodeid); $scope.selectedNodeSingleObj._label = newSectionText; - $scope.selectedNodeSingleObj = ""; + //Update Save Draft object for rename section + if ($rootScope.saveDraftSingleObj.length == 0) { + $rootScope.saveDraftSingleObj = $rootScope.structure; + } + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) { + if ($rootScope.saveDraftSingleObj[i]._id == nodeid) { + $rootScope.saveDraftSingleObj[i]._label = $scope.selectedNodeSingleObj._label; + //$rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure']; + } + //else if ($rootScope.saveDraftSingleObj[i]['structure']._id == nodeid) { + // $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure']; + //} + } + + //$scope.selectedNodeSingleObj = ""; traverseTreeSelectedSingleObj($rootScope.Auther, nodeid); setTimeout(function () { $scope.selectedNodeSingleObj.summary = newSummary; @@ -849,7 +1057,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ console.log("summary" + JSON.stringify($rootScope.cbDynamicJsonData)); }, 100); $rootScope.closeRenameModel(); - + console.log(JSON.stringify($rootScope.stru, $rootScope.structure)); } $scope.cbRenameDate = function () { @@ -878,10 +1086,12 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $scope.dateTime = month + '/' + day + '/' + year + ',' + hours + ':' + minute + ' ' + ampm; } + $rootScope.showDeleteSlideModel = function () { document.getElementById('cbModelDeleteBackground').style.display = "block"; document.getElementById('cbModelDeleteConfirmBoxId').style.display = "block"; } + $rootScope.DeleteSlideSection = function () { var cbCurrentSelectedId = document.getElementById('cbSelect').value; var CurrentSelectedLiId = $('#' + cbCurrentSelectedId).closest('li').attr('id'); @@ -910,7 +1120,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $rootScope.closeDeleteModel(); } - $rootScope.closeDeleteModel = function () { document.getElementById('cbModelDeleteBackground').style.display = "none"; document.getElementById('cbModelDeleteConfirmBoxId').style.display = "none"; @@ -959,7 +1168,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ }, "last", function () { // //$scope.addCBSlide(current_id, AddSlideId); $scope.addSlide(createNodeId, AddSlideId); - // $scope.DropDownSelectNodeClick(current_id); + //$scope.DropDownSelectNodeClick(current_id); $('#jstree').jstree(true).deselect_all(); $('#jstree').jstree('select_node', AddSlideLiId); //$('#jstree').jstree('select_node', AddSlideId); @@ -1007,7 +1216,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ }, "last", function () { //$scope.addCBSlide(current_id, AddSlideId); $scope.addSection(createNodeId, AddSectionId); - // $scope.DropDownSelectNodeClick(current_id); + //$scope.DropDownSelectNodeClick(current_id); $('#jstree').jstree(true).deselect_all(); //$('#jstree').jstree('select_node', AddSectionId); $('#jstree').jstree('select_node', AddSectionLiId); @@ -1019,10 +1228,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ - function traverseForLoadDropDown(o) { - for (i = 0; i < o.structure.structure.length; i++) { + for (var i = 0; i < o.structure.structure.length; i++) { $('#cbSelect').append(''); } } @@ -1057,25 +1265,76 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ if ($rootScope.saveDraftSingleObj.length == 0) { $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array - } + } + if ($rootScope.contentEleNote.length == 0) { + $rootScope.contentEleNote = $rootScope.cbJsonData.slideshow.content.element; + } traverse($rootScope.stru, currentid); - for (var j = 0; j < $scope.saveDraftSingleObj.length; j++) { - if (($scope.saveDraftSingleObj[j]._id == currentid)) { - $scope.saveDraftSingleObj.splice(j, 1); + for (var j = 0; j < $rootScope.saveDraftSingleObj.length; j++) { + if (($rootScope.saveDraftSingleObj[j]._id == currentid)) { + + traverseTreeSelectedSingleObj($rootScope.stru, currentid); + traverse($rootScope.stru, currentid); + var childNodesForSelectedSection = $scope.selectedNodeSingleObj['structure']; + + //if ($rootScope.saveDraftSingleObj[j]['structure'].length > 0) { + if (childNodesForSelectedSection.length > 0) { + for (var l = 0; l < childNodesForSelectedSection.length; l++) { + var childId = childNodesForSelectedSection[l]._id; // Get Child ID for selected Section node + for (var k = 0; k < $rootScope.contentEleNote.length; k++) { + if (($rootScope.contentEleNote[k]._id == childId)) { + $rootScope.contentEleNote.splice(k, 1); + } + } + } + } + $rootScope.saveDraftSingleObj.splice(j, 1); + } + } + + for (var k = 0; k < $rootScope.contentEleNote.length; k++) { + if (($rootScope.contentEleNote[k]._id == currentid)) { + $rootScope.contentEleNote.splice(k, 1); } } - console.log($scope.saveDraftSingleObj); + + //Delete notes for SavedraftCB as per Selected Section from tree + var deleteNotes = $rootScope.contentEleNote + var remaingNotesForCB = new jinqJs() + .from(deleteNotes) + .delete().at("_id == " + currentid).select(); + $rootScope.contentEleNote = remaingNotesForCB; + + console.log($rootScope.contentEleNote); + console.log($rootScope.saveDraftSingleObj); } - $scope.DeleteSlide = function (currentid, CurrentSelectedParentSpanId) { + function getLoadNodeId(o) { - $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array + for (var i in o) { + if (o[i] !== null && typeof (o[i]) == "object") { + if (o[i]._isBranch == "false") { + $rootScope.firstSelectedNodeId = o[i]._id; + } + getLoadNodeId(o[i]); + } + } + } + + $scope.DeleteSlide = function (currentid, CurrentSelectedParentSpanId) { + if ($rootScope.saveDraftSingleObj.length == 0) { + $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array + } + if ($rootScope.contentEleNote.length == 0) { + $rootScope.contentEleNote = $rootScope.cbJsonData.slideshow.content.element; + } traverse($rootScope.stru, currentid); for (var j = 0; j < $scope.selectedNodeSiblingObjs.length; j++) { - if (($scope.selectedNodeSiblingObjs[j]._id == currentid)) { $scope.selectedNodeSiblingObjs.splice(j, 1); + $rootScope.saveDraftSingleObj = $rootScope.structure; + //Added Code by Sandeep for Delete slide from node tree for save draft CB for (var x = 0; x < $rootScope.saveDraftSingleObj.length; x++) { if (($rootScope.saveDraftSingleObj[x]._id == CurrentSelectedParentSpanId)) { @@ -1083,77 +1342,145 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ if ($rootScope.saveDraftSingleObj[x]['structure'][y]._id == currentid) { $rootScope.saveDraftSingleObj[x]['structure'].splice(y, 1); } + else { + $rootScope.saveDraftSingleObj = $rootScope.structure; + } } } } - } - - + } } + + //Delete notes for SavedraftCB as per Selected Slide from tree + var deleteNotes = $rootScope.contentEleNote + var remaingNotesForCB = new jinqJs() + .from(deleteNotes) + .delete().at("_id == " + currentid).select(); + $rootScope.contentEleNote = remaingNotesForCB; // prune($rootScope.stru, currentid); // alert("After" + JSON.stringify($rootScope.stru)); - - + + console.log($rootScope.contentEleNote); + console.log($rootScope.saveDraftSingleObj); } - $scope.addSection = function (currentid, AddSecionId) { + $rootScope.saveCurricullam = function (file_Name) { + $scope.exportToFile(file_Name); + } + + $rootScope.exportToFile = function () { + + var cbCurrentId = document.getElementById('cbSelect').value; if ($rootScope.saveDraftSingleObj.length == 0) { $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array } - //$rootScope.saveDraftSingleObj = $rootScope.stru;//All json Structure with tree array - //$rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array - //$rootScope.updateSaveDraftDynamicTest = []; + if ($rootScope.contentEleNote.length == 0) { + $rootScope.contentEleNote = $rootScope.cbJsonData.slideshow.content.element; + } + $rootScope.dynamicUpdatedJsonForSaveCB = + { + "slideshow": { + "presentation": { + "structure": { + "structure": //[ + + $rootScope.saveDraftSingleObj, + //], + "_label": $rootScope.cbTreeFirstLabel, + "_id": $rootScope.cbTreeFirstID, + "_isRoot": "true", + "_isBranch": "true", + "_isLocked": "false" + }, + "_anchor": "true", + "_window_position": "6,10", + "_window_size": "828,453" + }, + "content": { + "element": [ + + $rootScope.contentEleNote, + ] + } + } + + }; + + $scope.slideshow = $rootScope.dynamicUpdatedJsonForSaveCB; + $scope.filename = "SandySaveCB.json"; + var filename = $scope.filename; + var blob = new Blob([angular.toJson($rootScope.dynamicUpdatedJsonForSaveCB, true)], { type: 'text/text' }); + if (window.navigator && window.navigator.msSaveOrOpenBlob) { + window.navigator.msSaveOrOpenBlob(blob, filename); + } + else { + var e = document.createEvent('MouseEvents'), + a = document.createElement('a'); + a.download = filename; + a.href = window.URL.createObjectURL(blob); + a.dataset.downloadurl = ['text/json', a.download, a.href].join(':'); + e.initEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + a.dispatchEvent(e); + // window.URL.revokeObjectURL(url); // clean the url.createObjectURL resource + } + $rootScope.dynamicUpdatedJsonForSaveCB = ""; + //$rootScope.contentEleNote = []; + //$rootScope.saveDraftSingleObj = []; + + // $http({ method: 'Post', url: $scope.fileName }).success(function (data) { + // localStorage.setItem("cbJsonDataObject", JSON.stringify(data)); + // $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject")); + // $rootScope.cbDynamicJsonData = data; + // //$scope.getCBsummary(); + // $rootScope.cbJsonData.slideshow.content.element = "Eement data"; + // $rootScope.cbDynamicJsonData.slideshow.content.element = "slideshow element data"; + // $rootScope.note = "save data" + // //$scope.openCurriculumDetail(); + // }) + //.error(function (data, status, headers, config) { + // console.log(data); + //}); + }; + + $scope.addSection = function (currentid, AddSecionId) { + + if ($rootScope.saveDraftSingleObj.length == 0) { + $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array + } traverseTreeSelectedSingleObj($rootScope.stru, currentid); traverse($rootScope.stru, currentid); - //if (currentid == "-225638207") { - if($rootScope.cbTreeFirstID == currentid){ + if (currentid == "-225638207") { $rootScope.selectedNodeSingle.push( { "structure": { - "structure": [ - //{ - // "_label": "NEW ", - // "_id": AddSlideId, - // "_isRoot": "false", - // "_isBranch": "false", - // "_isLocked": "false" - //} - ], - "_label": "New Section", - "_id": AddSecionId, - "_isRoot": "false", - "_isBranch": "true", - "_isLocked": "false" - } + "structure": [ + ], + "_label": "New Section", + "_id": AddSecionId, + "_isRoot": "false", + "_isBranch": "true", + "_isLocked": "false" + } }); - $rootScope.saveDraftSingleObj.push( - { - "structure": { - "structure": [ - ], - "_label": "New Section", - "_id": AddSecionId, - "_isRoot": "false", - "_isBranch": "true", - "_isLocked": "false" - } - }); - } + { + "structure": [ + ], + "_label": "New Section", + "_id": AddSecionId, + "_isRoot": "false", + "_isBranch": "true", + "_isLocked": "false" + + }); + } else { $scope.selectedNodeSingleObj['structure'].push( { "structure": [ - //{ - // "_label": "M", - // "_id": "51516C76-78F4-0D67-6B43-394B4168CF7C", - // "_isRoot": "false", - // "_isBranch": "false", - // "_isLocked": "false" - //} ], "_label": "New Section", "_id": AddSecionId, @@ -1161,34 +1488,37 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "_isBranch": "true", "_isLocked": "false" }); - - for (i = 0; i < $rootScope.saveDraftSingleObj.length; i++) { - if ($rootScope.saveDraftSingleObj[i]._id == currentid) { - $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure']; - } + if (currentid == $rootScope.cbTreeFirstID) { + $rootScope.saveDraftSingleObj.push( + { + "structure": [ + ], + "_label": "New Section", + "_id": AddSecionId, + "_isRoot": "false", + "_isBranch": "true", + "_isLocked": "false" + }); } + else { + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) { + if ($rootScope.saveDraftSingleObj[i]._id == currentid) { + $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure']; + } + } + } } // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 1500); - } $scope.addSlide = function (currentid, AddSlideId) { - if ($rootScope.saveDraftSingleObj.length == 0) { $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array } - //$rootScope.saveDraftSingleObj = $rootScope.stru;//All json Structure with tree array - //$rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array - //$rootScope.updateSaveDraftDynamicTest = []; - - traverseTreeSelectedSingleObj($rootScope.stru, currentid); - traverse($rootScope.stru, currentid); - //Assign object by traverse method $scope.selectedNodeSiblingObjs - + // traverse($rootScope.stru, currentid); //console.log(JSON.stringify($scope.upDateJsonObj)) - //if (currentid == "-225638207") { - if ($rootScope.cbTreeFirstID == currentid) { + if (currentid == "-225638207") { $rootScope.selectedNodeSingle.push( { "_label": "NEW Slide1", @@ -1197,19 +1527,13 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "_isBranch": "false", "_isLocked": "false" }); - - $rootScope.saveDraftSingleObj.push({ + $rootScope.saveDraftSingleObj.push({ "_label": "NEW Slide1", "_id": AddSlideId, "_isRoot": "false", "_isBranch": "false", "_isLocked": "false" - }); - //for (i = 0; i < $rootScope.saveDraftSingleObj.length; i++) { - // if ($rootScope.saveDraftSingleObj[i]._id == currentid) { - // $rootScope.saveDraftSingleObj[i] = $rootScope.selectedNodeSingle; - // } - //} + }); } else { $scope.selectedNodeSingleObj['structure'].push({ @@ -1219,184 +1543,27 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "_isBranch": "false", "_isLocked": "false" }); - for (i = 0; i < $rootScope.saveDraftSingleObj.length; i++) { - if($rootScope.saveDraftSingleObj[i]._id == currentid) - { - $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure']; + if (currentid == $rootScope.cbTreeFirstID) { + $rootScope.saveDraftSingleObj.push({ + "_label": "New Slide", + "_id": AddSlideId, + "_isRoot": "false", + "_isBranch": "false", + "_isLocked": "false" + }); + } + else { + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) { + if ($rootScope.saveDraftSingleObj[i]._id == currentid) { + $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure']; + } } - } + } } // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 3000); setTimeout(function () { $("#jstree").jstree(true).set_icon(AddSlideId, "../../../content/images/CB/file.png"); }, 100); - - } - $rootScope.exportToFile = function () { - - - $scope.DynamicAddspanID = []; - $scope.contentEleNote = []; - $scope.contentEleNote = $rootScope.cbJsonData.slideshow.content.element; - //for (var i = 0; i < $rootScope.structure.length; i++) { - - //} - var spanIds = []; - var cbCurrentId = document.getElementById('cbSelect').value; - //$('.jstree-container-ul li a span').each(function () { - // var span_Id = $(this).attr("id"); - // var spanText = $(this).text(); - // //spanIds.push(span_Id); - // if (span_Id == cbCurrentId) { - // } - // if (span_Id != "-225638207" && _parentId == 0) { - // $scope.DynamicAddspanID.push( - // { - // "_label": spanText, - // "_id": span_Id, - // "_isRoot": "false", - // "_isBranch": "false", - // "_isLocked": "false", - // }); + "," - // } - // else if (_isbranch == true && _parentId != 0) { - // $scope.selectedNodeSingleObj['structure'] - // $scope.DynamicAddspanID.push({ - // "structure": [ - // { - // "_label": spanText, - // "_id": span_Id, - // "_isRoot": "false", - // "_isBranch": "false", - // "_isLocked": "false", - // } - - // ] - // }); - // } - //}); - - - - - - - - //for (var i = 0; i < $rootScope.cbJsonData.slideshow.content.element.length; i++) { - // $scope.contentEleNote.push( - // { - // "notes": $rootScope.cbJsonData.slideshow.content.element[i].notes, - // "windows": { - // "window": $rootScope.cbJsonData.slideshow.content.element[i].windows.window - // }, - // "_id": $rootScope.cbJsonData.slideshow.content.element[i]._id - // }); + "," - - //} - //var myJSON = JSON.stringify($scope.DynamicAddspanID); - $rootScope.saveDraftDynamicTest.push( - { - "slideshow": { - "presentation": { - "structure": { - "structure": //[ - - //$scope.DynamicAddspanID, - $rootScope.saveDraftSingleObj, - - - //], - "_label": $rootScope.cbTreeFirstLabel, - "_id": $rootScope.cbTreeFirstID, - "_isRoot": "true", - "_isBranch": "true", - "_isLocked": "false" - }, - "_anchor": "true", - "_window_position": "6,10", - "_window_size": "828,453" - }, - "content": { - "element": [ - - //"notes": "

", - //"windows": { - // "window": "{\"windowTitle\":\"Hand (Post/Ant)\",\"selectedCallouts\":[],\"annotationData\":\"\",\"minimised\":false,\"scrollPosition\":{\"vertical\":78,\"horizontal\":120},\"selectedStructureID\":7446,\"maximised\":false,\"size\":{\"width\":800,\"height\":753},\"id\":\"424\",\"showSelectedPins\":true,\"scaleIndex\":0,\"bodySystemId\":11,\"windowListId\":\"0\",\"imageId\":\"424\",\"position\":{\"x\":840,\"y\":10},\"mType\":\"ATLAS_ANATOMY\",\"hideCallOuts\":true,\"containsCapturedContent\":true,\"selectedPins\":[\"32783\"],\"contextMenu\":{\"hideLeftBar\":false,\"hideTitleBar\":false,\"hideTopToolBar\":false,\"lockResize\":false}}" - //}, - //"_id": "-1507902782" - $scope.contentEleNote, - - ] - } - } - - }); - - - - $scope.filename = "filename.json"; - var filename = $scope.filename; - var blob = new Blob([angular.toJson($rootScope.saveDraftDynamicTest, true)], { type: 'text/text' }); - if (window.navigator && window.navigator.msSaveOrOpenBlob) { - window.navigator.msSaveOrOpenBlob(blob, filename); - } else { - var e = document.createEvent('MouseEvents'), - a = document.createElement('a'); - a.download = filename; - a.href = window.URL.createObjectURL(blob); - a.dataset.downloadurl = ['text/json', a.download, a.href].join(':'); - e.initEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); - a.dispatchEvent(e); - // window.URL.revokeObjectURL(url); // clean the url.createObjectURL resource - } - $http({ method: 'Post', url: $scope.fileName }).success(function (data) { - localStorage.setItem("cbJsonDataObject", JSON.stringify(data)); - $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject")); - $rootScope.cbDynamicJsonData = data; - //$scope.getCBsummary(); - $rootScope.cbJsonData.slideshow.content.element = "Eement data"; - $rootScope.cbDynamicJsonData.slideshow.content.element = "slideshow element data"; - $rootScope.note = "save data" - //$scope.openCurriculumDetail(); - }) - .error(function (data, status, headers, config) { - console.log(data); - }); - }; - - - - - - //$scope.addSlide = function (currentid, AddSlideId) { - // traverseTreeSelectedSingleObj($rootScope.stru, currentid); - // // traverse($rootScope.stru, currentid); - // //console.log(JSON.stringify($scope.upDateJsonObj)) - // if (currentid == "-225638207") { - // $rootScope.selectedNodeSingle.push( - // { - // "_label": "NEW Slide1", - // "_id": AddSlideId, - // "_isRoot": "false", - // "_isBranch": "false", - // "_isLocked": "false" - // }); - // } - // else { - // $scope.selectedNodeSingleObj['structure'].push({ - // "_label": "New Slide", - // "_id": AddSlideId, - // "_isRoot": "false", - // "_isBranch": "false", - // "_isLocked": "false" - // }); - // } - // // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 3000); - // setTimeout(function () { $("#jstree").jstree(true).set_icon(AddSlideId, "../../../content/images/CB/file.png"); }, 100); - - - //} - $scope.moveDown = function (currentid) { @@ -1704,6 +1871,155 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } + + $scope.addSectionForSaveDraft = function (currentid, AddSecionId, parentid) { + + if ($rootScope.saveDraftSingleObj.length == 0) { + $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array + } + //$rootScope.saveDraftSingleObj = $rootScope.stru;//All json Structure with tree array + //$rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array + //$rootScope.updateSaveDraftDynamicTest = []; + + traverseTreeSelectedSingleObj($rootScope.stru, currentid); + traverse($rootScope.stru, currentid); + if (currentid == $rootScope.cbTreeFirstID) { + $rootScope.selectedNodeSingle.push( + { + //"structure": { + "structure": [ + //{ + // "_label": "NEW ", + // "_id": AddSlideId, + // "_isRoot": "false", + // "_isBranch": "false", + // "_isLocked": "false" + //} + ], + "_label": "New Section", + "_id": AddSecionId, + "_isRoot": "false", + "_isBranch": "true", + "_isLocked": "false" + //} + + }); + + $rootScope.saveDraftSingleObj.push( + { + + "structure": [ + ], + "_label": "New Section", + "_id": AddSecionId, + "_isRoot": "false", + "_isBranch": "true", + "_isLocked": "false" + + }); + } + //else if (currentid == parentid && $rootScope.cbTreeFirstID != parentid) { + // $rootScope.selectedNodeSingle.push( + // { + + // "structure": [ + // ], + // "_label": "New Section", + // "_id": AddSecionId, + // "_isRoot": "false", + // "_isBranch": "true", + // "_isLocked": "false" + // }); + + // $rootScope.saveDraftSingleObj.push( + // { + // "structure": { + // "structure": [ + // ], + // "_label": "New Section", + // "_id": AddSecionId, + // "_isRoot": "false", + // "_isBranch": "true", + // "_isLocked": "false" + // } + // }); + // } + else { + $scope.selectedNodeSingleObj['structure'].push( + { + "structure": [ + ], + "_label": "New Section", + "_id": AddSecionId, + "_isRoot": "false", + "_isBranch": "true", + "_isLocked": "false" + }); + + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) { + if ($rootScope.saveDraftSingleObj[i]._id == currentid) { + $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure']; + } + } + } + // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 1500); + + } + + $scope.addSlideForSaveDraft = function (currentid, AddSlideId, parentid) { + + if ($rootScope.saveDraftSingleObj.length == 0) { + $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array + } + traverseTreeSelectedSingleObj($rootScope.stru, currentid); + //traverse($rootScope.stru, currentid); + //Assign object by traverse method $scope.selectedNodeSiblingObjs + + //console.log(JSON.stringify($scope.upDateJsonObj)) + //if (currentid == "-225638207") { + if (currentid == $rootScope.cbTreeFirstID) { + $rootScope.selectedNodeSingle.push( + { + "_label": "NEW Slide1", + "_id": AddSlideId, + "_isRoot": "false", + "_isBranch": "false", + "_isLocked": "false" + }); + + $rootScope.saveDraftSingleObj.push({ + "_label": "NEW Slide1", + "_id": AddSlideId, + "_isRoot": "false", + "_isBranch": "false", + "_isLocked": "false" + }); + //for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) { + // if ($rootScope.saveDraftSingleObj[i]._id == currentid) { + // $rootScope.saveDraftSingleObj[i] = $rootScope.selectedNodeSingle; + // } + //} + } + else { + $scope.selectedNodeSingleObj['structure'].push({ + "_label": "New Slide", + "_id": AddSlideId, + "_isRoot": "false", + "_isBranch": "false", + "_isLocked": "false" + }); + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) { + if ($rootScope.saveDraftSingleObj[i]._id == currentid) { + $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure']; + } + } + } + // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 3000); + setTimeout(function () { $("#jstree").jstree(true).set_icon(AddSlideId, "../../../content/images/CB/file.png"); }, 100); + + } + + }] ); -- libgit2 0.21.4