Commit 379b28ccc37af81cad23c3e4f09ff66b736b3a9a

Authored by Sandeep Kumar
1 parent 00e4c38f

Add Dynamic Section for Save draft CB

400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js
@@ -10,8 +10,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -10,8 +10,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
10 $rootScope.selectedNodeSingle = []; 10 $rootScope.selectedNodeSingle = [];
11 $scope.selectedNodeSingleObj = []; 11 $scope.selectedNodeSingleObj = [];
12 $rootScope.saveDraftSingleObj = []; 12 $rootScope.saveDraftSingleObj = [];
13 - $rootScope.saveDraftDynamicTest = [];  
14 - $rootScope.updateSaveDraftCB = []; 13 + $rootScope.contentEleNote = [];
  14 + $rootScope.dynamicUpdatedJsonForSaveCB = "";
  15 + //$rootScope.updateSaveDraftCB = [];
15 $scope.IsVisible = function () { 16 $scope.IsVisible = function () {
16 $scope.scroll(); 17 $scope.scroll();
17 } 18 }
@@ -25,8 +26,8 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -25,8 +26,8 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
25 26
26 $("#sidebar-wrapper").on('click', function (event) { 27 $("#sidebar-wrapper").on('click', function (event) {
27 28
28 - //4. on click disable menu option  
29 - $scope.$emit("cBEnableDisableMenuOption",""); 29 + //4. on click disable menu option
  30 + $scope.$emit("cBEnableDisableMenuOption","");
30 }); 31 });
31 32
32 // close all selected open panel in CB 33 // close all selected open panel in CB
@@ -179,96 +180,113 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -179,96 +180,113 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
179 180
180 $("#opencbview").trigger("click"); 181 $("#opencbview").trigger("click");
181 var fileupload = document.getElementById("opencbview"); 182 var fileupload = document.getElementById("opencbview");
182 - 183 +
183 fileupload.onchange = function () { 184 fileupload.onchange = function () {
184 -  
185 - var fileName = fileupload.value;  
186 - alert(fileName); 185 + $scope.getJsonFileFromLocal();
  186 + var fileName = fileupload.value.replace('C:\\fakepath\\', '');;
  187 + //alert(fileName);
187 188
188 //switch ($location.url()) { 189 //switch ($location.url()) {
189 // case '/curriculum-builder-detail': 190 // case '/curriculum-builder-detail':
190 // $location.url('/curriculum-builder'); 191 // $location.url('/curriculum-builder');
191 // break; 192 // break;
192 //} 193 //}
193 -  
194 // $scope.fileName = file_Name; 194 // $scope.fileName = file_Name;
195 $('#modal-CurBuilder').css("display", "block"); 195 $('#modal-CurBuilder').css("display", "block");
196 $("#CurBuilderbackground").css("display", "block"); 196 $("#CurBuilderbackground").css("display", "block");
197 - $http({ method: 'GET', url: fileName }).success(function (data) {  
198 - localStorage.setItem("cbJsonDataObject", JSON.stringify(data));  
199 - $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject"));  
200 - $rootScope.cbDynamicJsonData = data;  
201 - $rootScope.getCBsummary();  
202 -  
203 - $scope.openCurriculumDetail();  
204 - })  
205 - .error(function (data, status, headers, config) {  
206 - console.log(data);  
207 - });  
208 - }; 197 + var name = document.getElementById("opencbview").files[0].name;
  198 +
  199 + // $http({
  200 + // method: 'GET',
  201 + // url: '' + fileName
  202 + // }).success(function (data) {
  203 +
  204 + // localStorage.setItem("cbJsonDataObject", JSON.stringify(data));
  205 + // $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject"));
  206 + // $rootScope.cbDynamicJsonData = data;
  207 +
  208 + // $rootScope.getCBsummary();
  209 +
  210 + // $scope.openCurriculumDetailtest();
  211 + // })
  212 + //.error(function (data, status, headers, config) {
  213 + // console.log(data);
  214 + // });
  215 +
  216 + };
  217 + }
209 218
210 219
  220 + $scope.getJsonFileFromLocal = function loadFile() {
  221 + var input, file, fr;
  222 +
  223 + if (typeof window.FileReader !== 'function') {
  224 + alert("The file API isn't supported on this browser yet.");
  225 + return;
  226 + }
  227 + input = document.getElementById('opencbview');
  228 + if (!input) {
  229 + alert("Um, couldn't find the fileinput element.");
  230 + }
  231 + else if (!input.files) {
  232 + alert("This browser doesn't seem to support the `files` property of file inputs.");
  233 + }
  234 + else if (!input.files[0]) {
  235 + alert("Please select a file before clicking 'Load'");
  236 + }
  237 + else {
  238 + file = input.files[0];
  239 + fr = new FileReader();
  240 + fr.onload = receivedText;
  241 + fr.readAsText(file);
  242 + }
  243 +
  244 + function receivedText(e) {
  245 + let lines = e.target.result;
  246 + var newArr = JSON.parse(lines);
  247 +
  248 + localStorage.setItem("cbJsonDataObject", JSON.stringify(newArr));
  249 + $rootScope.cbJsonData = JSON.parse(lines);
  250 + $rootScope.cbDynamicJsonData = JSON.parse(lines);
  251 + $rootScope.getCBsummary();
  252 + $scope.CBEnableUI();
  253 + $scope.openCurriculumDetail();
  254 + }
211 } 255 }
212 256
213 - 257 + //$rootScope.OpenExistingCurriculum = function (file_Name) {
214 258
215 - $rootScope.saveCurricullam = function (file_Name) {  
216 - $scope.exportToFile();  
217 - $scope.selectedNodeSingleObj.push(  
218 - {  
219 - "slideshow": {  
220 - "presentation": {  
221 - "structure": {  
222 - "structure": [  
223 - {  
224 - "_label": "Untitled Slide",  
225 - "_id": "-1507902782",  
226 - "_isRoot": "false",  
227 - "_isBranch": "false",  
228 - "_isLocked": "false"  
229 - } 259 + // $("#opencbview").trigger("click");
  260 + // var fileupload = document.getElementById("opencbview");
230 261
231 - ],  
232 - "_label": "Untitled Curriculum",  
233 - "_id": "-225638207",  
234 - "_isRoot": "true",  
235 - "_isBranch": "true",  
236 - "_isLocked": "false"  
237 - },  
238 - "_anchor": "true",  
239 - "_window_position": "6,10",  
240 - "_window_size": "828,453"  
241 - },  
242 - "content": {  
243 - "element": [  
244 - {  
245 - "notes": "<TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Microsoft Sans Serif\" SIZE=\"13\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\"> </FONT></P></TEXTFORMAT><TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Microsoft Sans Serif\" SIZE=\"13\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\"> </FONT></P></TEXTFORMAT><TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Microsoft Sans Serif\" SIZE=\"13\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\"> </FONT></P></TEXTFORMAT>",  
246 - "windows": {  
247 - "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}}"  
248 - },  
249 - "_id": "-1507902782"  
250 - }  
251 - ]  
252 - }  
253 - }  
254 - });  
255 - console.log($scope.selectedNodeSingle);  
256 - $scope.exportToFile();  
257 - $http({ method: 'Post', url: 'content/data/json/cb/SlideShow/json/' + $scope.fileName + '.json' }).success(function (data) {  
258 - localStorage.setItem("cbJsonDataObject", JSON.stringify(data));  
259 - $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject"));  
260 - $rootScope.cbDynamicJsonData = data;  
261 - //$scope.getCBsummary();  
262 - $rootScope.cbJsonData.slideshow.content.element="Eement data";  
263 - $rootScope.cbDynamicJsonData.slideshow.content.element="slideshow element data";  
264 - $rootScope.note = "save data"  
265 - //$scope.openCurriculumDetail();  
266 - })  
267 - .error(function (data, status, headers, config) {  
268 - console.log(data);  
269 - }); 262 + // fileupload.onchange = function () {
270 263
271 - } 264 + // var fileName = fileupload.value;
  265 + // alert(fileName);
  266 +
  267 + // //switch ($location.url()) {
  268 + // // case '/curriculum-builder-detail':
  269 + // // $location.url('/curriculum-builder');
  270 + // // break;
  271 + // //}
  272 +
  273 + // // $scope.fileName = file_Name;
  274 + // $('#modal-CurBuilder').css("display", "block");
  275 + // $("#CurBuilderbackground").css("display", "block");
  276 + // $http({ method: 'GET', url: fileName }).success(function (data) {
  277 + // localStorage.setItem("cbJsonDataObject", JSON.stringify(data));
  278 + // $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject"));
  279 + // $rootScope.cbDynamicJsonData = data;
  280 + // $rootScope.getCBsummary();
  281 +
  282 + // $scope.openCurriculumDetail();
  283 + // })
  284 + // .error(function (data, status, headers, config) {
  285 + // console.log(data);
  286 + // });
  287 + // };
  288 + //}
  289 +
272 290
273 //$rootScope.saveCurricullam = function (file_Name) { 291 //$rootScope.saveCurricullam = function (file_Name) {
274 // $scope.selectedNodeSingleObj.push( 292 // $scope.selectedNodeSingleObj.push(
@@ -383,10 +401,10 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -383,10 +401,10 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
383 imfgEle.src = "data:image/png;base64," + $rootScope.windowsimageSource; 401 imfgEle.src = "data:image/png;base64," + $rootScope.windowsimageSource;
384 402
385 setTimeout(function () { 403 setTimeout(function () {
386 - var cleintht=imfgEle.clientHeight;  
387 - if(cleintht>0)  
388 - $('#CBSourceImagePanel .jsPanel-content').css('height', cleintht);  
389 - $scope.CBEnableUI(); 404 + var cleintht=imfgEle.clientHeight;
  405 + if(cleintht>0)
  406 + $('#CBSourceImagePanel .jsPanel-content').css('height', cleintht);
  407 + $scope.CBEnableUI();
390 }, 200) 408 }, 200)
391 409
392 }, 200) 410 }, 200)
@@ -474,7 +492,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -474,7 +492,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
474 }); 492 });
475 493
476 $timeout(function () { 494 $timeout(function () {
477 - $scope.TinyMCEPanelclick(); 495 + $scope.TinyMCEPanelclick();
478 },1000); 496 },1000);
479 497
480 if ($rootScope.isOpenResourceBtnClicked == true) { 498 if ($rootScope.isOpenResourceBtnClicked == true) {
@@ -504,7 +522,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -504,7 +522,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
504 $scope.myeditorclick=function() { 522 $scope.myeditorclick=function() {
505 523
506 //1. disable menu options 524 //1. disable menu options
507 - $scope.$emit("cBEnableDisableMenuOption",""); 525 + $scope.$emit("cBEnableDisableMenuOption","");
508 526
509 } 527 }
510 528
@@ -530,24 +548,24 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -530,24 +548,24 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
530 } 548 }
531 } 549 }
532 550
533 - function getLoadNodeId(o) { 551 + //function getLoadNodeId(o) {
534 552
535 - for (var i in o) { 553 + // for (var i in o) {
536 554
537 - if (o[i] !== null && typeof (o[i]) == "object") {  
538 - if (o[i]._isBranch == "false") {  
539 - $rootScope.firstSelectedNodeId = o[i]._id; 555 + // if (o[i] !== null && typeof (o[i]) == "object") {
  556 + // if (o[i]._isBranch == "false") {
  557 + // $rootScope.firstSelectedNodeId = o[i]._id;
540 558
541 559
542 - } 560 + // }
543 561
544 - getLoadNodeId(o[i]); 562 + // getLoadNodeId(o[i]);
545 563
546 564
547 - } 565 + // }
548 566
549 - }  
550 - } 567 + // }
  568 + //}
551 569
552 $scope.loadNotesById = function () { 570 $scope.loadNotesById = function () {
553 571
@@ -595,31 +613,31 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -595,31 +613,31 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
595 613
596 $("#viwerSelect").empty(); 614 $("#viwerSelect").empty();
597 $("#viwerSelect").hide(); 615 $("#viwerSelect").hide();
598 - if ($('#parentcustomDiv').html() != "") {  
599 - $('#parentcustomDiv').empty();  
600 - } 616 + if ($('#parentcustomDiv').html() != "") {
  617 + $('#parentcustomDiv').empty();
  618 + }
601 619
602 - if ($scope.SelectedNotes != "" && $scope.SelectedNotes != undefined) {  
603 - tinymce.get("CBTextArea").setContent($scope.SelectedNotes); 620 + if ($scope.SelectedNotes != "" && $scope.SelectedNotes != undefined) {
  621 + tinymce.get("CBTextArea").setContent($scope.SelectedNotes);
604 622
605 - setTimeout(function () {  
606 - if ($scope.selectedNodeSingleObj.windows != "") {  
607 - $scope.loadContentOfSelectedSlide($scope.selectedNodeSingleObj._id) 623 + setTimeout(function () {
  624 + if ($scope.selectedNodeSingleObj.windows != "") {
  625 + $scope.loadContentOfSelectedSlide($scope.selectedNodeSingleObj._id)
608 626
609 - }  
610 - else  
611 - {  
612 - $scope.CBEnableUI(); 627 + }
  628 + else
  629 + {
  630 + $scope.CBEnableUI();
613 631
614 - }  
615 - },200); 632 + }
  633 + },200);
616 634
617 - }  
618 - else  
619 - {  
620 - tinymce.get("CBTextArea").setContent("");  
621 - $scope.CBEnableUI();  
622 - } 635 + }
  636 + else
  637 + {
  638 + tinymce.get("CBTextArea").setContent("");
  639 + $scope.CBEnableUI();
  640 + }
623 641
624 } 642 }
625 else 643 else
@@ -631,7 +649,40 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -631,7 +649,40 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
631 $rootScope.cbSelectOnChange = function (obj) { 649 $rootScope.cbSelectOnChange = function (obj) {
632 $('#jstree').jstree(true).deselect_all(); 650 $('#jstree').jstree(true).deselect_all();
633 $('#jstree').jstree('select_node', obj.value); 651 $('#jstree').jstree('select_node', obj.value);
634 - } 652 + }
  653 + traverseSelectedObjForSaveDraftCB = function (o, current_id) {
  654 + for (var i in o) {
  655 + if (o[i] !== null && typeof (o[i]) == "object") {
  656 + if (o[i]._id == current_id) {
  657 + $scope.selectedObjforSaveDraftCB = o[i];
  658 + }
  659 + traverseSelectedObjForSaveDraftCB(o[i], current_id);
  660 + }
  661 + }
  662 + }
  663 +
  664 + $scope.updateDropdownforSaveDraftCB = function (nodeid) {
  665 + var current_id = document.getElementById('cbSelect').value;
  666 + if ($rootScope.saveDraftSingleObj.length == 0) {
  667 + $rootScope.saveDraftSingleObj = $rootScope.structure;
  668 + }
  669 + traverseSelectedObjForSaveDraftCB($rootScope.saveDraftSingleObj, current_id);
  670 + if ($rootScope.saveDraftSingleObj.length != $rootScope.stru.structure.structure.length) {
  671 + if ($scope.selectedObjforSaveDraftCB._isBranch == "true" && $scope.selectedObjforSaveDraftCB._id == nodeid) {
  672 + $('#cbSelect').append('<option selected value="' + $scope.selectedNodeSingleObj._id + '">' + $scope.selectedNodeSingleObj._label + '</option>');
  673 + document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSingleObj).length;
  674 + }
  675 + else {
  676 + for (var i = 0; i < $rootScope.selectedObjforSaveDraftCB.length; i++) {
  677 + if ($rootScope.selectedObjforSaveDraftCB[i]._id == nodeid) {
  678 + $scope.currentSlideNumber = i + 1;
  679 + $('#cbSelect').append('<option value="' + $rootScope.selectedObjforSaveDraftCB[i]._id + '">' + $rootScope.selectedObjforSaveDraftCB[i]._label + '</option>');
  680 + document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedObjforSaveDraftCB).length
  681 + }
  682 + }
  683 + }
  684 + }
  685 + }
635 686
636 //Start Code by Sandeep for TicketNo: 49226(3) 687 //Start Code by Sandeep for TicketNo: 49226(3)
637 $scope.DropDownSelectNodeClick = function (nodeid) { 688 $scope.DropDownSelectNodeClick = function (nodeid) {
@@ -643,6 +694,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -643,6 +694,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
643 $('#cbEditorRightSideBar').css('pointer-events', 'auto'); 694 $('#cbEditorRightSideBar').css('pointer-events', 'auto');
644 $('#cbEditorRightSideBar').css('opacity', '1'); 695 $('#cbEditorRightSideBar').css('opacity', '1');
645 696
  697 + //if ($rootScope.saveDraftSingleObj.length != $rootScope.stru.structure.structure.length && $rootScope.saveDraftSingleObj.length != 0) {
  698 + // $scope.updateDropdownforSaveDraftCB(nodeid);
  699 + //}
646 if ($scope.selectedNodeSingleObj._isBranch == "true") { 700 if ($scope.selectedNodeSingleObj._isBranch == "true") {
647 701
648 $("#cbSelect").empty(); 702 $("#cbSelect").empty();
@@ -652,7 +706,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -652,7 +706,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
652 706
653 localStorage.setItem("cbSelectId", nodeid); 707 localStorage.setItem("cbSelectId", nodeid);
654 if ($scope.selectedNodeSingleObj._id == nodeid) { 708 if ($scope.selectedNodeSingleObj._id == nodeid) {
655 - $scope.currentSlideNumber += 1; 709 + //$scope.currentSlideNumber += 1;
656 $('#cbSelect').append('<option selected value="' + $scope.selectedNodeSingleObj._id + '">' + $scope.selectedNodeSingleObj._label + '</option>'); 710 $('#cbSelect').append('<option selected value="' + $scope.selectedNodeSingleObj._id + '">' + $scope.selectedNodeSingleObj._label + '</option>');
657 } 711 }
658 else { 712 else {
@@ -663,17 +717,17 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -663,17 +717,17 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
663 document.getElementById("slideNumber").innerHTML = "Slide " + 1 + " of " + 1; 717 document.getElementById("slideNumber").innerHTML = "Slide " + 1 + " of " + 1;
664 } 718 }
665 else if ($scope.selectedNodeSingleObj._isBranch == "true") { 719 else if ($scope.selectedNodeSingleObj._isBranch == "true") {
  720 + $scope.currentSlideNumber += 1;
666 document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSingleObj).length; 721 document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSingleObj).length;
667 } 722 }
668 - else  
669 - { 723 + else{
670 document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSingleObj).length; 724 document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSingleObj).length;
671 - } 725 + }
672 } 726 }
673 else { 727 else {
674 traverse($rootScope.stru, nodeid); 728 traverse($rootScope.stru, nodeid);
675 $("#cbSelect").empty(); 729 $("#cbSelect").empty();
676 - for (i = 0; i < $scope.selectedNodeSiblingObjs.length; i++) { 730 + for (var i = 0; i < $scope.selectedNodeSiblingObjs.length; i++) {
677 localStorage.setItem("cbSelectId", nodeid); 731 localStorage.setItem("cbSelectId", nodeid);
678 if ($scope.selectedNodeSiblingObjs[i]._id == nodeid) { 732 if ($scope.selectedNodeSiblingObjs[i]._id == nodeid) {
679 $scope.currentSlideNumber = i + 1; 733 $scope.currentSlideNumber = i + 1;
@@ -753,21 +807,21 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -753,21 +807,21 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
753 } 807 }
754 } 808 }
755 809
756 - $rootScope.cbRenameModelShow = function () {  
757 - var current_id = document.getElementById('cbSelect').value;  
758 - document.getElementById('renameInputBoxId').value = "";  
759 - traverseTreeSelectedSingleObj($rootScope.stru, current_id);  
760 - if ($scope.selectedNodeSingleObj._isBranch == "true") {  
761 - traverseTreeSelectedSingleObj($rootScope.Auther, current_id);  
762 - document.getElementById('cbRenameDate').value = $scope.selectedNodeSingleObj.modified;  
763 - document.getElementById('cbModelRenameBackground').style.display = "block";  
764 - document.getElementById('cbModelSectionRenameId').style.display = "block";  
765 - }  
766 - else {  
767 - document.getElementById('cbModelRenameBackground').style.display = "block";  
768 - document.getElementById('cbModelRenameId').style.display = "block";  
769 - }  
770 - } 810 + //$rootScope.cbRenameModelShow = function () {
  811 + // var current_id = document.getElementById('cbSelect').value;
  812 + // document.getElementById('renameInputBoxId').value = "";
  813 + // traverseTreeSelectedSingleObj($rootScope.stru, current_id);
  814 + // if ($scope.selectedNodeSingleObj._isBranch == "true") {
  815 + // traverseTreeSelectedSingleObj($rootScope.Auther, current_id);
  816 + // document.getElementById('cbRenameDate').value = $scope.selectedNodeSingleObj.modified;
  817 + // document.getElementById('cbModelRenameBackground').style.display = "block";
  818 + // document.getElementById('cbModelSectionRenameId').style.display = "block";
  819 + // }
  820 + // else {
  821 + // document.getElementById('cbModelRenameBackground').style.display = "block";
  822 + // document.getElementById('cbModelRenameId').style.display = "block";
  823 + // }
  824 + //}
771 825
772 $rootScope.cbPasswordModelShow = function () { 826 $rootScope.cbPasswordModelShow = function () {
773 //var current_id = document.getElementById('cbSelect').value; 827 //var current_id = document.getElementById('cbSelect').value;
@@ -785,6 +839,136 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -785,6 +839,136 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
785 839
786 } 840 }
787 841
  842 + //$rootScope.cbRenameSlide = function () {
  843 + // var current_id
  844 + // if (($rootScope.getLocalStorageValue("cbSelectId")) != '') {
  845 + // current_id = $rootScope.getLocalStorageValue("cbSelectId");
  846 + // }
  847 + // else {
  848 + // current_id = document.getElementById('cbSelect').value;
  849 + // }
  850 + // //var current_id = document.getElementById('cbSelect').value;
  851 + // var newSlideText = document.getElementById('renameInputBoxId').value;
  852 + // var newSlideName = ("<span id=" + current_id + " class='ng-binding ng-scope'>" + newSlideText + "</span>");
  853 + // $("#jstree").jstree('set_text', current_id, newSlideName);
  854 + // traverseTreeSelectedSingleObj($rootScope.stru, current_id);
  855 + // $scope.selectedNodeSingleObj._label = newSlideText;
  856 + // $scope.DropDownSelectNodeClick(current_id);
  857 + // console.log(JSON.stringify($rootScope.stru));
  858 + // $rootScope.closeRenameModel();
  859 + //}
  860 +
  861 + //$rootScope.closeRenameModel = function () {
  862 + // document.getElementById('cbModelRenameBackground').style.display = "none";
  863 + // if (document.getElementById("cbModelRenameId").style.display == 'block') {
  864 + // document.getElementById('cbModelRenameId').style.display = "none";
  865 + // }
  866 + // if (document.getElementById("cbModelUserPassWord").style.display == 'block') {
  867 + // document.getElementById('cbModelUserPassWord').style.display = "none";
  868 + // }
  869 +
  870 + // if (document.getElementById("cbModelSectionRenameId").style.display == 'block') {
  871 + // document.getElementById('cbModelSectionRenameId').style.display = "none";
  872 + // }
  873 + //}
  874 +
  875 + //$rootScope.cbRenameSection = function () {
  876 + // var nodeid
  877 + // if (($rootScope.getLocalStorageValue("cbSelectId")) != '') {
  878 + // nodeid = $rootScope.getLocalStorageValue("cbSelectId");
  879 + // }
  880 + // else {
  881 + // nodeid = document.getElementById('cbSelect').value;
  882 + // }
  883 +
  884 +
  885 + // //var nodeid = document.getElementById('cbSelect').value;
  886 + // $scope.cbRenameDate();
  887 + // //var newSlideName = document.getElementById('cbRenameSectionTitle').value;
  888 + // var newAuthorName = document.getElementById('cbRenameAuthor').value;
  889 + // var newSummary = document.getElementById('cbRenameSummary').value;
  890 + // var newversion = document.getElementById('cbRenameVersionNo').value;
  891 + // var newSectionText = document.getElementById('cbRenameSectionTitle').value;
  892 + // var newSlideName = ("<span id=" + nodeid + " class='ng-binding ng-scope'>" + newSectionText + "</span>");
  893 + // $("#jstree").jstree('set_text', nodeid, newSlideName);
  894 + // traverseTreeSelectedSingleObj($rootScope.stru, nodeid);
  895 + // $scope.selectedNodeSingleObj._label = newSectionText;
  896 + // $scope.selectedNodeSingleObj = "";
  897 + // traverseTreeSelectedSingleObj($rootScope.Auther, nodeid);
  898 + // setTimeout(function () {
  899 + // $scope.selectedNodeSingleObj.summary = newSummary;
  900 + // $scope.selectedNodeSingleObj.author = newAuthorName;
  901 + // $scope.selectedNodeSingleObj.version = newversion;
  902 + // $scope.selectedNodeSingleObj.modified = $scope.dateTime;
  903 + // $scope.DropDownSelectNodeClick(nodeid);
  904 + // console.log("summary" + JSON.stringify($rootScope.cbDynamicJsonData));
  905 + // }, 100);
  906 + // $rootScope.closeRenameModel();
  907 +
  908 + //}
  909 +
  910 + //$scope.cbRenameDate = function () {
  911 + // var currentdate = new Date();
  912 + // var now = new Date();
  913 + // var year = now.getFullYear();
  914 + // var month = now.getMonth() + 1;
  915 + // var day = now.getDate();
  916 + // var hours = now.getHours();
  917 + // var minute = now.getMinutes();
  918 + // var ampm = hours >= 12 ? 'PM' : 'AM';
  919 + // hours = hours % 12;
  920 + // hours = hours ? hours : 12; // the hour '0' should be '12'
  921 + // if (month.toString().length == 1) {
  922 + // month = '0' + month;
  923 + // }
  924 + // if (day.toString().length == 1) {
  925 + // day = '0' + day;
  926 + // }
  927 + // if (hours.toString().length == 1) {
  928 + // hours = '0' + hours;
  929 + // }
  930 + // if (minute.toString().length == 1) {
  931 + // minute = '0' + minute;
  932 + // }
  933 +
  934 + // $scope.dateTime = month + '/' + day + '/' + year + ',' + hours + ':' + minute + ' ' + ampm;
  935 + //}
  936 +
  937 + $scope.setProperties = function () {
  938 + if ($scope.selectedNodeSingleObj.author != "undefined") {
  939 + $('#cbRenameAuthor').val($scope.selectedNodeSingleObj.author);
  940 + }
  941 + if ($scope.selectedNodeSingleObj.version != "undefined") {
  942 + $('#cbRenameSummary').val($scope.selectedNodeSingleObj.version);
  943 + }
  944 + if ($scope.selectedNodeSingleObj.summary != "undefined") {
  945 + $('#cbRenameVersionNo').val($scope.selectedNodeSingleObj.summary);
  946 + }
  947 + if ($scope.selectedNodeSingleObj.modified != "undefined") {
  948 + $('#cbRenameDate').val($scope.selectedNodeSingleObj.modified);
  949 + }
  950 + }
  951 +
  952 + $rootScope.cbRenameModelShow = function () {
  953 + var current_id = document.getElementById('cbSelect').value;
  954 + document.getElementById('renameInputBoxId').value = "";
  955 + traverseTreeSelectedSingleObj($rootScope.stru, current_id);
  956 + if ($scope.selectedNodeSingleObj._label != "undefined") {
  957 + $('#cbRenameSectionTitle').val($scope.selectedNodeSingleObj._label);
  958 + }
  959 + if ($scope.selectedNodeSingleObj._isBranch == "true") {
  960 + traverseTreeSelectedSingleObj($rootScope.Auther, current_id);
  961 + //document.getElementById('cbRenameDate').value = $scope.selectedNodeSingleObj.modified;
  962 + $scope.setProperties();
  963 + document.getElementById('cbModelRenameBackground').style.display = "block";
  964 + document.getElementById('cbModelSectionRenameId').style.display = "block";
  965 + }
  966 + else {
  967 + document.getElementById('cbModelRenameBackground').style.display = "block";
  968 + document.getElementById('cbModelRenameId').style.display = "block";
  969 + }
  970 + }
  971 +
788 $rootScope.cbRenameSlide = function () { 972 $rootScope.cbRenameSlide = function () {
789 var current_id 973 var current_id
790 if (($rootScope.getLocalStorageValue("cbSelectId")) != '') { 974 if (($rootScope.getLocalStorageValue("cbSelectId")) != '') {
@@ -799,6 +983,15 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -799,6 +983,15 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
799 $("#jstree").jstree('set_text', current_id, newSlideName); 983 $("#jstree").jstree('set_text', current_id, newSlideName);
800 traverseTreeSelectedSingleObj($rootScope.stru, current_id); 984 traverseTreeSelectedSingleObj($rootScope.stru, current_id);
801 $scope.selectedNodeSingleObj._label = newSlideText; 985 $scope.selectedNodeSingleObj._label = newSlideText;
  986 + if ($rootScope.saveDraftSingleObj.length == 0) {
  987 + $rootScope.saveDraftSingleObj = $rootScope.structure;
  988 + }
  989 + //Update Save Draft object for Rename slide
  990 + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) {
  991 + if ($rootScope.saveDraftSingleObj[i]._id == current_id) {
  992 + $rootScope.saveDraftSingleObj[i]._label = $scope.selectedNodeSingleObj._label
  993 + }
  994 + }
802 $scope.DropDownSelectNodeClick(current_id); 995 $scope.DropDownSelectNodeClick(current_id);
803 console.log(JSON.stringify($rootScope.stru)); 996 console.log(JSON.stringify($rootScope.stru));
804 $rootScope.closeRenameModel(); 997 $rootScope.closeRenameModel();
@@ -817,6 +1010,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -817,6 +1010,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
817 document.getElementById('cbModelSectionRenameId').style.display = "none"; 1010 document.getElementById('cbModelSectionRenameId').style.display = "none";
818 } 1011 }
819 } 1012 }
  1013 +
820 $rootScope.cbRenameSection = function () { 1014 $rootScope.cbRenameSection = function () {
821 var nodeid 1015 var nodeid
822 if (($rootScope.getLocalStorageValue("cbSelectId")) != '') { 1016 if (($rootScope.getLocalStorageValue("cbSelectId")) != '') {
@@ -838,7 +1032,21 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -838,7 +1032,21 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
838 $("#jstree").jstree('set_text', nodeid, newSlideName); 1032 $("#jstree").jstree('set_text', nodeid, newSlideName);
839 traverseTreeSelectedSingleObj($rootScope.stru, nodeid); 1033 traverseTreeSelectedSingleObj($rootScope.stru, nodeid);
840 $scope.selectedNodeSingleObj._label = newSectionText; 1034 $scope.selectedNodeSingleObj._label = newSectionText;
841 - $scope.selectedNodeSingleObj = ""; 1035 + //Update Save Draft object for rename section
  1036 + if ($rootScope.saveDraftSingleObj.length == 0) {
  1037 + $rootScope.saveDraftSingleObj = $rootScope.structure;
  1038 + }
  1039 + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) {
  1040 + if ($rootScope.saveDraftSingleObj[i]._id == nodeid) {
  1041 + $rootScope.saveDraftSingleObj[i]._label = $scope.selectedNodeSingleObj._label;
  1042 + //$rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure'];
  1043 + }
  1044 + //else if ($rootScope.saveDraftSingleObj[i]['structure']._id == nodeid) {
  1045 + // $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure'];
  1046 + //}
  1047 + }
  1048 +
  1049 + //$scope.selectedNodeSingleObj = "";
842 traverseTreeSelectedSingleObj($rootScope.Auther, nodeid); 1050 traverseTreeSelectedSingleObj($rootScope.Auther, nodeid);
843 setTimeout(function () { 1051 setTimeout(function () {
844 $scope.selectedNodeSingleObj.summary = newSummary; 1052 $scope.selectedNodeSingleObj.summary = newSummary;
@@ -849,7 +1057,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -849,7 +1057,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
849 console.log("summary" + JSON.stringify($rootScope.cbDynamicJsonData)); 1057 console.log("summary" + JSON.stringify($rootScope.cbDynamicJsonData));
850 }, 100); 1058 }, 100);
851 $rootScope.closeRenameModel(); 1059 $rootScope.closeRenameModel();
852 - 1060 + console.log(JSON.stringify($rootScope.stru, $rootScope.structure));
853 } 1061 }
854 1062
855 $scope.cbRenameDate = function () { 1063 $scope.cbRenameDate = function () {
@@ -878,10 +1086,12 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -878,10 +1086,12 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
878 1086
879 $scope.dateTime = month + '/' + day + '/' + year + ',' + hours + ':' + minute + ' ' + ampm; 1087 $scope.dateTime = month + '/' + day + '/' + year + ',' + hours + ':' + minute + ' ' + ampm;
880 } 1088 }
  1089 +
881 $rootScope.showDeleteSlideModel = function () { 1090 $rootScope.showDeleteSlideModel = function () {
882 document.getElementById('cbModelDeleteBackground').style.display = "block"; 1091 document.getElementById('cbModelDeleteBackground').style.display = "block";
883 document.getElementById('cbModelDeleteConfirmBoxId').style.display = "block"; 1092 document.getElementById('cbModelDeleteConfirmBoxId').style.display = "block";
884 } 1093 }
  1094 +
885 $rootScope.DeleteSlideSection = function () { 1095 $rootScope.DeleteSlideSection = function () {
886 var cbCurrentSelectedId = document.getElementById('cbSelect').value; 1096 var cbCurrentSelectedId = document.getElementById('cbSelect').value;
887 var CurrentSelectedLiId = $('#' + cbCurrentSelectedId).closest('li').attr('id'); 1097 var CurrentSelectedLiId = $('#' + cbCurrentSelectedId).closest('li').attr('id');
@@ -910,7 +1120,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -910,7 +1120,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
910 $rootScope.closeDeleteModel(); 1120 $rootScope.closeDeleteModel();
911 } 1121 }
912 1122
913 -  
914 $rootScope.closeDeleteModel = function () { 1123 $rootScope.closeDeleteModel = function () {
915 document.getElementById('cbModelDeleteBackground').style.display = "none"; 1124 document.getElementById('cbModelDeleteBackground').style.display = "none";
916 document.getElementById('cbModelDeleteConfirmBoxId').style.display = "none"; 1125 document.getElementById('cbModelDeleteConfirmBoxId').style.display = "none";
@@ -959,7 +1168,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -959,7 +1168,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
959 }, "last", function () { 1168 }, "last", function () {
960 // //$scope.addCBSlide(current_id, AddSlideId); 1169 // //$scope.addCBSlide(current_id, AddSlideId);
961 $scope.addSlide(createNodeId, AddSlideId); 1170 $scope.addSlide(createNodeId, AddSlideId);
962 - // $scope.DropDownSelectNodeClick(current_id); 1171 + //$scope.DropDownSelectNodeClick(current_id);
963 $('#jstree').jstree(true).deselect_all(); 1172 $('#jstree').jstree(true).deselect_all();
964 $('#jstree').jstree('select_node', AddSlideLiId); 1173 $('#jstree').jstree('select_node', AddSlideLiId);
965 //$('#jstree').jstree('select_node', AddSlideId); 1174 //$('#jstree').jstree('select_node', AddSlideId);
@@ -1007,7 +1216,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -1007,7 +1216,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
1007 }, "last", function () { 1216 }, "last", function () {
1008 //$scope.addCBSlide(current_id, AddSlideId); 1217 //$scope.addCBSlide(current_id, AddSlideId);
1009 $scope.addSection(createNodeId, AddSectionId); 1218 $scope.addSection(createNodeId, AddSectionId);
1010 - // $scope.DropDownSelectNodeClick(current_id); 1219 + //$scope.DropDownSelectNodeClick(current_id);
1011 $('#jstree').jstree(true).deselect_all(); 1220 $('#jstree').jstree(true).deselect_all();
1012 //$('#jstree').jstree('select_node', AddSectionId); 1221 //$('#jstree').jstree('select_node', AddSectionId);
1013 $('#jstree').jstree('select_node', AddSectionLiId); 1222 $('#jstree').jstree('select_node', AddSectionLiId);
@@ -1019,10 +1228,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -1019,10 +1228,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
1019 1228
1020 1229
1021 1230
1022 -  
1023 function traverseForLoadDropDown(o) { 1231 function traverseForLoadDropDown(o) {
1024 1232
1025 - for (i = 0; i < o.structure.structure.length; i++) { 1233 + for (var i = 0; i < o.structure.structure.length; i++) {
1026 $('#cbSelect').append('<option value="' + o.structure.structure[i]._id + '">' + o.structure.structure[i]._label + '</option>'); 1234 $('#cbSelect').append('<option value="' + o.structure.structure[i]._id + '">' + o.structure.structure[i]._label + '</option>');
1027 } 1235 }
1028 } 1236 }
@@ -1057,25 +1265,76 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -1057,25 +1265,76 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
1057 1265
1058 if ($rootScope.saveDraftSingleObj.length == 0) { 1266 if ($rootScope.saveDraftSingleObj.length == 0) {
1059 $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array 1267 $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array
1060 - } 1268 + }
  1269 + if ($rootScope.contentEleNote.length == 0) {
  1270 + $rootScope.contentEleNote = $rootScope.cbJsonData.slideshow.content.element;
  1271 + }
1061 traverse($rootScope.stru, currentid); 1272 traverse($rootScope.stru, currentid);
1062 - for (var j = 0; j < $scope.saveDraftSingleObj.length; j++) {  
1063 - if (($scope.saveDraftSingleObj[j]._id == currentid)) {  
1064 - $scope.saveDraftSingleObj.splice(j, 1); 1273 + for (var j = 0; j < $rootScope.saveDraftSingleObj.length; j++) {
  1274 + if (($rootScope.saveDraftSingleObj[j]._id == currentid)) {
  1275 +
  1276 + traverseTreeSelectedSingleObj($rootScope.stru, currentid);
  1277 + traverse($rootScope.stru, currentid);
  1278 + var childNodesForSelectedSection = $scope.selectedNodeSingleObj['structure'];
  1279 +
  1280 + //if ($rootScope.saveDraftSingleObj[j]['structure'].length > 0) {
  1281 + if (childNodesForSelectedSection.length > 0) {
  1282 + for (var l = 0; l < childNodesForSelectedSection.length; l++) {
  1283 + var childId = childNodesForSelectedSection[l]._id; // Get Child ID for selected Section node
  1284 + for (var k = 0; k < $rootScope.contentEleNote.length; k++) {
  1285 + if (($rootScope.contentEleNote[k]._id == childId)) {
  1286 + $rootScope.contentEleNote.splice(k, 1);
  1287 + }
  1288 + }
  1289 + }
  1290 + }
  1291 + $rootScope.saveDraftSingleObj.splice(j, 1);
  1292 + }
  1293 + }
  1294 +
  1295 + for (var k = 0; k < $rootScope.contentEleNote.length; k++) {
  1296 + if (($rootScope.contentEleNote[k]._id == currentid)) {
  1297 + $rootScope.contentEleNote.splice(k, 1);
1065 } 1298 }
1066 } 1299 }
1067 - console.log($scope.saveDraftSingleObj); 1300 +
  1301 + //Delete notes for SavedraftCB as per Selected Section from tree
  1302 + var deleteNotes = $rootScope.contentEleNote
  1303 + var remaingNotesForCB = new jinqJs()
  1304 + .from(deleteNotes)
  1305 + .delete().at("_id == " + currentid).select();
  1306 + $rootScope.contentEleNote = remaingNotesForCB;
  1307 +
  1308 + console.log($rootScope.contentEleNote);
  1309 + console.log($rootScope.saveDraftSingleObj);
1068 } 1310 }
1069 1311
1070 - $scope.DeleteSlide = function (currentid, CurrentSelectedParentSpanId) { 1312 + function getLoadNodeId(o) {
1071 1313
1072 - $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array 1314 + for (var i in o) {
  1315 + if (o[i] !== null && typeof (o[i]) == "object") {
  1316 + if (o[i]._isBranch == "false") {
  1317 + $rootScope.firstSelectedNodeId = o[i]._id;
  1318 + }
  1319 + getLoadNodeId(o[i]);
  1320 + }
  1321 + }
  1322 + }
  1323 +
  1324 + $scope.DeleteSlide = function (currentid, CurrentSelectedParentSpanId) {
  1325 + if ($rootScope.saveDraftSingleObj.length == 0) {
  1326 + $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array
  1327 + }
  1328 + if ($rootScope.contentEleNote.length == 0) {
  1329 + $rootScope.contentEleNote = $rootScope.cbJsonData.slideshow.content.element;
  1330 + }
1073 traverse($rootScope.stru, currentid); 1331 traverse($rootScope.stru, currentid);
1074 for (var j = 0; j < $scope.selectedNodeSiblingObjs.length; j++) { 1332 for (var j = 0; j < $scope.selectedNodeSiblingObjs.length; j++) {
1075 -  
1076 if (($scope.selectedNodeSiblingObjs[j]._id == currentid)) { 1333 if (($scope.selectedNodeSiblingObjs[j]._id == currentid)) {
1077 $scope.selectedNodeSiblingObjs.splice(j, 1); 1334 $scope.selectedNodeSiblingObjs.splice(j, 1);
1078 1335
  1336 + $rootScope.saveDraftSingleObj = $rootScope.structure;
  1337 +
1079 //Added Code by Sandeep for Delete slide from node tree for save draft CB 1338 //Added Code by Sandeep for Delete slide from node tree for save draft CB
1080 for (var x = 0; x < $rootScope.saveDraftSingleObj.length; x++) { 1339 for (var x = 0; x < $rootScope.saveDraftSingleObj.length; x++) {
1081 if (($rootScope.saveDraftSingleObj[x]._id == CurrentSelectedParentSpanId)) { 1340 if (($rootScope.saveDraftSingleObj[x]._id == CurrentSelectedParentSpanId)) {
@@ -1083,77 +1342,145 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -1083,77 +1342,145 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
1083 if ($rootScope.saveDraftSingleObj[x]['structure'][y]._id == currentid) { 1342 if ($rootScope.saveDraftSingleObj[x]['structure'][y]._id == currentid) {
1084 $rootScope.saveDraftSingleObj[x]['structure'].splice(y, 1); 1343 $rootScope.saveDraftSingleObj[x]['structure'].splice(y, 1);
1085 } 1344 }
  1345 + else {
  1346 + $rootScope.saveDraftSingleObj = $rootScope.structure;
  1347 + }
1086 } 1348 }
1087 } 1349 }
1088 } 1350 }
1089 - }  
1090 -  
1091 - 1351 + }
1092 } 1352 }
  1353 +
  1354 + //Delete notes for SavedraftCB as per Selected Slide from tree
  1355 + var deleteNotes = $rootScope.contentEleNote
  1356 + var remaingNotesForCB = new jinqJs()
  1357 + .from(deleteNotes)
  1358 + .delete().at("_id == " + currentid).select();
  1359 + $rootScope.contentEleNote = remaingNotesForCB;
1093 // prune($rootScope.stru, currentid); 1360 // prune($rootScope.stru, currentid);
1094 // alert("After" + JSON.stringify($rootScope.stru)); 1361 // alert("After" + JSON.stringify($rootScope.stru));
1095 -  
1096 - 1362 +
  1363 + console.log($rootScope.contentEleNote);
  1364 + console.log($rootScope.saveDraftSingleObj);
1097 } 1365 }
1098 1366
1099 - $scope.addSection = function (currentid, AddSecionId) { 1367 + $rootScope.saveCurricullam = function (file_Name) {
  1368 + $scope.exportToFile(file_Name);
  1369 + }
  1370 +
  1371 + $rootScope.exportToFile = function () {
  1372 +
  1373 + var cbCurrentId = document.getElementById('cbSelect').value;
1100 1374
1101 if ($rootScope.saveDraftSingleObj.length == 0) { 1375 if ($rootScope.saveDraftSingleObj.length == 0) {
1102 $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array 1376 $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array
1103 } 1377 }
1104 - //$rootScope.saveDraftSingleObj = $rootScope.stru;//All json Structure with tree array  
1105 - //$rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array  
1106 - //$rootScope.updateSaveDraftDynamicTest = []; 1378 + if ($rootScope.contentEleNote.length == 0) {
  1379 + $rootScope.contentEleNote = $rootScope.cbJsonData.slideshow.content.element;
  1380 + }
  1381 + $rootScope.dynamicUpdatedJsonForSaveCB =
  1382 + {
  1383 + "slideshow": {
  1384 + "presentation": {
  1385 + "structure": {
  1386 + "structure": //[
  1387 +
  1388 + $rootScope.saveDraftSingleObj,
  1389 + //],
  1390 + "_label": $rootScope.cbTreeFirstLabel,
  1391 + "_id": $rootScope.cbTreeFirstID,
  1392 + "_isRoot": "true",
  1393 + "_isBranch": "true",
  1394 + "_isLocked": "false"
  1395 + },
  1396 + "_anchor": "true",
  1397 + "_window_position": "6,10",
  1398 + "_window_size": "828,453"
  1399 + },
  1400 + "content": {
  1401 + "element": [
  1402 +
  1403 + $rootScope.contentEleNote,
  1404 + ]
  1405 + }
  1406 + }
  1407 +
  1408 + };
  1409 +
  1410 + $scope.slideshow = $rootScope.dynamicUpdatedJsonForSaveCB;
  1411 + $scope.filename = "SandySaveCB.json";
  1412 + var filename = $scope.filename;
  1413 + var blob = new Blob([angular.toJson($rootScope.dynamicUpdatedJsonForSaveCB, true)], { type: 'text/text' });
  1414 + if (window.navigator && window.navigator.msSaveOrOpenBlob) {
  1415 + window.navigator.msSaveOrOpenBlob(blob, filename);
  1416 + }
  1417 + else {
  1418 + var e = document.createEvent('MouseEvents'),
  1419 + a = document.createElement('a');
  1420 + a.download = filename;
  1421 + a.href = window.URL.createObjectURL(blob);
  1422 + a.dataset.downloadurl = ['text/json', a.download, a.href].join(':');
  1423 + e.initEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  1424 + a.dispatchEvent(e);
  1425 + // window.URL.revokeObjectURL(url); // clean the url.createObjectURL resource
  1426 + }
  1427 + $rootScope.dynamicUpdatedJsonForSaveCB = "";
  1428 + //$rootScope.contentEleNote = [];
  1429 + //$rootScope.saveDraftSingleObj = [];
  1430 +
  1431 + // $http({ method: 'Post', url: $scope.fileName }).success(function (data) {
  1432 + // localStorage.setItem("cbJsonDataObject", JSON.stringify(data));
  1433 + // $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject"));
  1434 + // $rootScope.cbDynamicJsonData = data;
  1435 + // //$scope.getCBsummary();
  1436 + // $rootScope.cbJsonData.slideshow.content.element = "Eement data";
  1437 + // $rootScope.cbDynamicJsonData.slideshow.content.element = "slideshow element data";
  1438 + // $rootScope.note = "save data"
  1439 + // //$scope.openCurriculumDetail();
  1440 + // })
  1441 + //.error(function (data, status, headers, config) {
  1442 + // console.log(data);
  1443 + //});
  1444 + };
  1445 +
  1446 + $scope.addSection = function (currentid, AddSecionId) {
  1447 +
  1448 + if ($rootScope.saveDraftSingleObj.length == 0) {
  1449 + $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array
  1450 + }
1107 1451
1108 traverseTreeSelectedSingleObj($rootScope.stru, currentid); 1452 traverseTreeSelectedSingleObj($rootScope.stru, currentid);
1109 traverse($rootScope.stru, currentid); 1453 traverse($rootScope.stru, currentid);
1110 - //if (currentid == "-225638207") {  
1111 - if($rootScope.cbTreeFirstID == currentid){ 1454 + if (currentid == "-225638207") {
1112 $rootScope.selectedNodeSingle.push( 1455 $rootScope.selectedNodeSingle.push(
1113 { 1456 {
1114 "structure": { 1457 "structure": {
1115 - "structure": [  
1116 - //{  
1117 - // "_label": "NEW ",  
1118 - // "_id": AddSlideId,  
1119 - // "_isRoot": "false",  
1120 - // "_isBranch": "false",  
1121 - // "_isLocked": "false"  
1122 - //}  
1123 - ],  
1124 - "_label": "New Section",  
1125 - "_id": AddSecionId,  
1126 - "_isRoot": "false",  
1127 - "_isBranch": "true",  
1128 - "_isLocked": "false"  
1129 - } 1458 + "structure": [
  1459 + ],
  1460 + "_label": "New Section",
  1461 + "_id": AddSecionId,
  1462 + "_isRoot": "false",
  1463 + "_isBranch": "true",
  1464 + "_isLocked": "false"
  1465 + }
1130 1466
1131 }); 1467 });
1132 -  
1133 $rootScope.saveDraftSingleObj.push( 1468 $rootScope.saveDraftSingleObj.push(
1134 - {  
1135 - "structure": {  
1136 - "structure": [  
1137 - ],  
1138 - "_label": "New Section",  
1139 - "_id": AddSecionId,  
1140 - "_isRoot": "false",  
1141 - "_isBranch": "true",  
1142 - "_isLocked": "false"  
1143 - }  
1144 - });  
1145 - } 1469 + {
  1470 + "structure": [
  1471 + ],
  1472 + "_label": "New Section",
  1473 + "_id": AddSecionId,
  1474 + "_isRoot": "false",
  1475 + "_isBranch": "true",
  1476 + "_isLocked": "false"
  1477 +
  1478 + });
  1479 + }
1146 else { 1480 else {
1147 $scope.selectedNodeSingleObj['structure'].push( 1481 $scope.selectedNodeSingleObj['structure'].push(
1148 { 1482 {
1149 "structure": [ 1483 "structure": [
1150 - //{  
1151 - // "_label": "M",  
1152 - // "_id": "51516C76-78F4-0D67-6B43-394B4168CF7C",  
1153 - // "_isRoot": "false",  
1154 - // "_isBranch": "false",  
1155 - // "_isLocked": "false"  
1156 - //}  
1157 ], 1484 ],
1158 "_label": "New Section", 1485 "_label": "New Section",
1159 "_id": AddSecionId, 1486 "_id": AddSecionId,
@@ -1161,34 +1488,37 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -1161,34 +1488,37 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
1161 "_isBranch": "true", 1488 "_isBranch": "true",
1162 "_isLocked": "false" 1489 "_isLocked": "false"
1163 }); 1490 });
1164 -  
1165 - for (i = 0; i < $rootScope.saveDraftSingleObj.length; i++) {  
1166 - if ($rootScope.saveDraftSingleObj[i]._id == currentid) {  
1167 - $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure'];  
1168 - } 1491 + if (currentid == $rootScope.cbTreeFirstID) {
  1492 + $rootScope.saveDraftSingleObj.push(
  1493 + {
  1494 + "structure": [
  1495 + ],
  1496 + "_label": "New Section",
  1497 + "_id": AddSecionId,
  1498 + "_isRoot": "false",
  1499 + "_isBranch": "true",
  1500 + "_isLocked": "false"
  1501 + });
1169 } 1502 }
  1503 + else {
  1504 + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) {
  1505 + if ($rootScope.saveDraftSingleObj[i]._id == currentid) {
  1506 + $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure'];
  1507 + }
  1508 + }
  1509 + }
1170 } 1510 }
1171 // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 1500); 1511 // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 1500);
1172 -  
1173 } 1512 }
1174 1513
1175 $scope.addSlide = function (currentid, AddSlideId) { 1514 $scope.addSlide = function (currentid, AddSlideId) {
1176 -  
1177 if ($rootScope.saveDraftSingleObj.length == 0) { 1515 if ($rootScope.saveDraftSingleObj.length == 0) {
1178 $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array 1516 $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array
1179 } 1517 }
1180 - //$rootScope.saveDraftSingleObj = $rootScope.stru;//All json Structure with tree array  
1181 - //$rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array  
1182 - //$rootScope.updateSaveDraftDynamicTest = [];  
1183 -  
1184 -  
1185 traverseTreeSelectedSingleObj($rootScope.stru, currentid); 1518 traverseTreeSelectedSingleObj($rootScope.stru, currentid);
1186 - traverse($rootScope.stru, currentid);  
1187 - //Assign object by traverse method $scope.selectedNodeSiblingObjs  
1188 - 1519 + // traverse($rootScope.stru, currentid);
1189 //console.log(JSON.stringify($scope.upDateJsonObj)) 1520 //console.log(JSON.stringify($scope.upDateJsonObj))
1190 - //if (currentid == "-225638207") {  
1191 - if ($rootScope.cbTreeFirstID == currentid) { 1521 + if (currentid == "-225638207") {
1192 $rootScope.selectedNodeSingle.push( 1522 $rootScope.selectedNodeSingle.push(
1193 { 1523 {
1194 "_label": "NEW Slide1", 1524 "_label": "NEW Slide1",
@@ -1197,19 +1527,13 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -1197,19 +1527,13 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
1197 "_isBranch": "false", 1527 "_isBranch": "false",
1198 "_isLocked": "false" 1528 "_isLocked": "false"
1199 }); 1529 });
1200 -  
1201 - $rootScope.saveDraftSingleObj.push({ 1530 + $rootScope.saveDraftSingleObj.push({
1202 "_label": "NEW Slide1", 1531 "_label": "NEW Slide1",
1203 "_id": AddSlideId, 1532 "_id": AddSlideId,
1204 "_isRoot": "false", 1533 "_isRoot": "false",
1205 "_isBranch": "false", 1534 "_isBranch": "false",
1206 "_isLocked": "false" 1535 "_isLocked": "false"
1207 - });  
1208 - //for (i = 0; i < $rootScope.saveDraftSingleObj.length; i++) {  
1209 - // if ($rootScope.saveDraftSingleObj[i]._id == currentid) {  
1210 - // $rootScope.saveDraftSingleObj[i] = $rootScope.selectedNodeSingle;  
1211 - // }  
1212 - //} 1536 + });
1213 } 1537 }
1214 else { 1538 else {
1215 $scope.selectedNodeSingleObj['structure'].push({ 1539 $scope.selectedNodeSingleObj['structure'].push({
@@ -1219,184 +1543,27 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -1219,184 +1543,27 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
1219 "_isBranch": "false", 1543 "_isBranch": "false",
1220 "_isLocked": "false" 1544 "_isLocked": "false"
1221 }); 1545 });
1222 - for (i = 0; i < $rootScope.saveDraftSingleObj.length; i++) {  
1223 - if($rootScope.saveDraftSingleObj[i]._id == currentid)  
1224 - {  
1225 - $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure']; 1546 + if (currentid == $rootScope.cbTreeFirstID) {
  1547 + $rootScope.saveDraftSingleObj.push({
  1548 + "_label": "New Slide",
  1549 + "_id": AddSlideId,
  1550 + "_isRoot": "false",
  1551 + "_isBranch": "false",
  1552 + "_isLocked": "false"
  1553 + });
  1554 + }
  1555 + else {
  1556 + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) {
  1557 + if ($rootScope.saveDraftSingleObj[i]._id == currentid) {
  1558 + $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure'];
  1559 + }
1226 } 1560 }
1227 - } 1561 + }
1228 } 1562 }
1229 // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 3000); 1563 // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 3000);
1230 setTimeout(function () { $("#jstree").jstree(true).set_icon(AddSlideId, "../../../content/images/CB/file.png"); }, 100); 1564 setTimeout(function () { $("#jstree").jstree(true).set_icon(AddSlideId, "../../../content/images/CB/file.png"); }, 100);
1231 -  
1232 -  
1233 } 1565 }
1234 1566
1235 - $rootScope.exportToFile = function () {  
1236 -  
1237 -  
1238 - $scope.DynamicAddspanID = [];  
1239 - $scope.contentEleNote = [];  
1240 - $scope.contentEleNote = $rootScope.cbJsonData.slideshow.content.element;  
1241 - //for (var i = 0; i < $rootScope.structure.length; i++) {  
1242 -  
1243 - //}  
1244 - var spanIds = [];  
1245 - var cbCurrentId = document.getElementById('cbSelect').value;  
1246 - //$('.jstree-container-ul li a span').each(function () {  
1247 - // var span_Id = $(this).attr("id");  
1248 - // var spanText = $(this).text();  
1249 - // //spanIds.push(span_Id);  
1250 - // if (span_Id == cbCurrentId) {  
1251 - // }  
1252 - // if (span_Id != "-225638207" && _parentId == 0) {  
1253 - // $scope.DynamicAddspanID.push(  
1254 - // {  
1255 - // "_label": spanText,  
1256 - // "_id": span_Id,  
1257 - // "_isRoot": "false",  
1258 - // "_isBranch": "false",  
1259 - // "_isLocked": "false",  
1260 - // }); + ","  
1261 - // }  
1262 - // else if (_isbranch == true && _parentId != 0) {  
1263 - // $scope.selectedNodeSingleObj['structure']  
1264 - // $scope.DynamicAddspanID.push({  
1265 - // "structure": [  
1266 - // {  
1267 - // "_label": spanText,  
1268 - // "_id": span_Id,  
1269 - // "_isRoot": "false",  
1270 - // "_isBranch": "false",  
1271 - // "_isLocked": "false",  
1272 - // }  
1273 -  
1274 - // ]  
1275 - // });  
1276 - // }  
1277 - //});  
1278 -  
1279 -  
1280 -  
1281 -  
1282 -  
1283 -  
1284 -  
1285 - //for (var i = 0; i < $rootScope.cbJsonData.slideshow.content.element.length; i++) {  
1286 - // $scope.contentEleNote.push(  
1287 - // {  
1288 - // "notes": $rootScope.cbJsonData.slideshow.content.element[i].notes,  
1289 - // "windows": {  
1290 - // "window": $rootScope.cbJsonData.slideshow.content.element[i].windows.window  
1291 - // },  
1292 - // "_id": $rootScope.cbJsonData.slideshow.content.element[i]._id  
1293 - // }); + ","  
1294 -  
1295 - //}  
1296 - //var myJSON = JSON.stringify($scope.DynamicAddspanID);  
1297 - $rootScope.saveDraftDynamicTest.push(  
1298 - {  
1299 - "slideshow": {  
1300 - "presentation": {  
1301 - "structure": {  
1302 - "structure": //[  
1303 -  
1304 - //$scope.DynamicAddspanID,  
1305 - $rootScope.saveDraftSingleObj,  
1306 -  
1307 -  
1308 - //],  
1309 - "_label": $rootScope.cbTreeFirstLabel,  
1310 - "_id": $rootScope.cbTreeFirstID,  
1311 - "_isRoot": "true",  
1312 - "_isBranch": "true",  
1313 - "_isLocked": "false"  
1314 - },  
1315 - "_anchor": "true",  
1316 - "_window_position": "6,10",  
1317 - "_window_size": "828,453"  
1318 - },  
1319 - "content": {  
1320 - "element": [  
1321 -  
1322 - //"notes": "<TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Microsoft Sans Serif\" SIZE=\"13\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\"> </FONT></P></TEXTFORMAT><TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Microsoft Sans Serif\" SIZE=\"13\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\"> </FONT></P></TEXTFORMAT><TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Microsoft Sans Serif\" SIZE=\"13\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\"> </FONT></P></TEXTFORMAT>",  
1323 - //"windows": {  
1324 - // "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}}"  
1325 - //},  
1326 - //"_id": "-1507902782"  
1327 - $scope.contentEleNote,  
1328 -  
1329 - ]  
1330 - }  
1331 - }  
1332 -  
1333 - });  
1334 -  
1335 -  
1336 -  
1337 - $scope.filename = "filename.json";  
1338 - var filename = $scope.filename;  
1339 - var blob = new Blob([angular.toJson($rootScope.saveDraftDynamicTest, true)], { type: 'text/text' });  
1340 - if (window.navigator && window.navigator.msSaveOrOpenBlob) {  
1341 - window.navigator.msSaveOrOpenBlob(blob, filename);  
1342 - } else {  
1343 - var e = document.createEvent('MouseEvents'),  
1344 - a = document.createElement('a');  
1345 - a.download = filename;  
1346 - a.href = window.URL.createObjectURL(blob);  
1347 - a.dataset.downloadurl = ['text/json', a.download, a.href].join(':');  
1348 - e.initEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);  
1349 - a.dispatchEvent(e);  
1350 - // window.URL.revokeObjectURL(url); // clean the url.createObjectURL resource  
1351 - }  
1352 - $http({ method: 'Post', url: $scope.fileName }).success(function (data) {  
1353 - localStorage.setItem("cbJsonDataObject", JSON.stringify(data));  
1354 - $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject"));  
1355 - $rootScope.cbDynamicJsonData = data;  
1356 - //$scope.getCBsummary();  
1357 - $rootScope.cbJsonData.slideshow.content.element = "Eement data";  
1358 - $rootScope.cbDynamicJsonData.slideshow.content.element = "slideshow element data";  
1359 - $rootScope.note = "save data"  
1360 - //$scope.openCurriculumDetail();  
1361 - })  
1362 - .error(function (data, status, headers, config) {  
1363 - console.log(data);  
1364 - });  
1365 - };  
1366 -  
1367 -  
1368 -  
1369 -  
1370 -  
1371 - //$scope.addSlide = function (currentid, AddSlideId) {  
1372 - // traverseTreeSelectedSingleObj($rootScope.stru, currentid);  
1373 - // // traverse($rootScope.stru, currentid);  
1374 - // //console.log(JSON.stringify($scope.upDateJsonObj))  
1375 - // if (currentid == "-225638207") {  
1376 - // $rootScope.selectedNodeSingle.push(  
1377 - // {  
1378 - // "_label": "NEW Slide1",  
1379 - // "_id": AddSlideId,  
1380 - // "_isRoot": "false",  
1381 - // "_isBranch": "false",  
1382 - // "_isLocked": "false"  
1383 - // });  
1384 - // }  
1385 - // else {  
1386 - // $scope.selectedNodeSingleObj['structure'].push({  
1387 - // "_label": "New Slide",  
1388 - // "_id": AddSlideId,  
1389 - // "_isRoot": "false",  
1390 - // "_isBranch": "false",  
1391 - // "_isLocked": "false"  
1392 - // });  
1393 - // }  
1394 - // // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 3000);  
1395 - // setTimeout(function () { $("#jstree").jstree(true).set_icon(AddSlideId, "../../../content/images/CB/file.png"); }, 100);  
1396 -  
1397 -  
1398 - //}  
1399 -  
1400 $scope.moveDown = function (currentid) { 1567 $scope.moveDown = function (currentid) {
1401 1568
1402 1569
@@ -1704,6 +1871,155 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ @@ -1704,6 +1871,155 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $
1704 } 1871 }
1705 1872
1706 1873
  1874 +
  1875 + $scope.addSectionForSaveDraft = function (currentid, AddSecionId, parentid) {
  1876 +
  1877 + if ($rootScope.saveDraftSingleObj.length == 0) {
  1878 + $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array
  1879 + }
  1880 + //$rootScope.saveDraftSingleObj = $rootScope.stru;//All json Structure with tree array
  1881 + //$rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array
  1882 + //$rootScope.updateSaveDraftDynamicTest = [];
  1883 +
  1884 + traverseTreeSelectedSingleObj($rootScope.stru, currentid);
  1885 + traverse($rootScope.stru, currentid);
  1886 + if (currentid == $rootScope.cbTreeFirstID) {
  1887 + $rootScope.selectedNodeSingle.push(
  1888 + {
  1889 + //"structure": {
  1890 + "structure": [
  1891 + //{
  1892 + // "_label": "NEW ",
  1893 + // "_id": AddSlideId,
  1894 + // "_isRoot": "false",
  1895 + // "_isBranch": "false",
  1896 + // "_isLocked": "false"
  1897 + //}
  1898 + ],
  1899 + "_label": "New Section",
  1900 + "_id": AddSecionId,
  1901 + "_isRoot": "false",
  1902 + "_isBranch": "true",
  1903 + "_isLocked": "false"
  1904 + //}
  1905 +
  1906 + });
  1907 +
  1908 + $rootScope.saveDraftSingleObj.push(
  1909 + {
  1910 +
  1911 + "structure": [
  1912 + ],
  1913 + "_label": "New Section",
  1914 + "_id": AddSecionId,
  1915 + "_isRoot": "false",
  1916 + "_isBranch": "true",
  1917 + "_isLocked": "false"
  1918 +
  1919 + });
  1920 + }
  1921 + //else if (currentid == parentid && $rootScope.cbTreeFirstID != parentid) {
  1922 + // $rootScope.selectedNodeSingle.push(
  1923 + // {
  1924 +
  1925 + // "structure": [
  1926 + // ],
  1927 + // "_label": "New Section",
  1928 + // "_id": AddSecionId,
  1929 + // "_isRoot": "false",
  1930 + // "_isBranch": "true",
  1931 + // "_isLocked": "false"
  1932 + // });
  1933 +
  1934 + // $rootScope.saveDraftSingleObj.push(
  1935 + // {
  1936 + // "structure": {
  1937 + // "structure": [
  1938 + // ],
  1939 + // "_label": "New Section",
  1940 + // "_id": AddSecionId,
  1941 + // "_isRoot": "false",
  1942 + // "_isBranch": "true",
  1943 + // "_isLocked": "false"
  1944 + // }
  1945 + // });
  1946 + // }
  1947 + else {
  1948 + $scope.selectedNodeSingleObj['structure'].push(
  1949 + {
  1950 + "structure": [
  1951 + ],
  1952 + "_label": "New Section",
  1953 + "_id": AddSecionId,
  1954 + "_isRoot": "false",
  1955 + "_isBranch": "true",
  1956 + "_isLocked": "false"
  1957 + });
  1958 +
  1959 + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) {
  1960 + if ($rootScope.saveDraftSingleObj[i]._id == currentid) {
  1961 + $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure'];
  1962 + }
  1963 + }
  1964 + }
  1965 + // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 1500);
  1966 +
  1967 + }
  1968 +
  1969 + $scope.addSlideForSaveDraft = function (currentid, AddSlideId, parentid) {
  1970 +
  1971 + if ($rootScope.saveDraftSingleObj.length == 0) {
  1972 + $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array
  1973 + }
  1974 + traverseTreeSelectedSingleObj($rootScope.stru, currentid);
  1975 + //traverse($rootScope.stru, currentid);
  1976 + //Assign object by traverse method $scope.selectedNodeSiblingObjs
  1977 +
  1978 + //console.log(JSON.stringify($scope.upDateJsonObj))
  1979 + //if (currentid == "-225638207") {
  1980 + if (currentid == $rootScope.cbTreeFirstID) {
  1981 + $rootScope.selectedNodeSingle.push(
  1982 + {
  1983 + "_label": "NEW Slide1",
  1984 + "_id": AddSlideId,
  1985 + "_isRoot": "false",
  1986 + "_isBranch": "false",
  1987 + "_isLocked": "false"
  1988 + });
  1989 +
  1990 + $rootScope.saveDraftSingleObj.push({
  1991 + "_label": "NEW Slide1",
  1992 + "_id": AddSlideId,
  1993 + "_isRoot": "false",
  1994 + "_isBranch": "false",
  1995 + "_isLocked": "false"
  1996 + });
  1997 + //for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) {
  1998 + // if ($rootScope.saveDraftSingleObj[i]._id == currentid) {
  1999 + // $rootScope.saveDraftSingleObj[i] = $rootScope.selectedNodeSingle;
  2000 + // }
  2001 + //}
  2002 + }
  2003 + else {
  2004 + $scope.selectedNodeSingleObj['structure'].push({
  2005 + "_label": "New Slide",
  2006 + "_id": AddSlideId,
  2007 + "_isRoot": "false",
  2008 + "_isBranch": "false",
  2009 + "_isLocked": "false"
  2010 + });
  2011 + for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) {
  2012 + if ($rootScope.saveDraftSingleObj[i]._id == currentid) {
  2013 + $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure'];
  2014 + }
  2015 + }
  2016 + }
  2017 + // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 3000);
  2018 + setTimeout(function () { $("#jstree").jstree(true).set_icon(AddSlideId, "../../../content/images/CB/file.png"); }, 100);
  2019 +
  2020 + }
  2021 +
  2022 +
1707 }] 2023 }]
1708 ); 2024 );
1709 2025