From c32b401c21cdf46460e9a3b0ee90a2dff541cd2d Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Fri, 24 Jan 2020 17:10:29 +0530 Subject: [PATCH] Code changes for delete node from SaveCB --- 400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js | 581 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-TinyMCEjspanel.html | 2 +- 2 files changed, 377 insertions(+), 206 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js index bcebd9d..978f0cd 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js @@ -9,8 +9,8 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $scope.countRightlist; $rootScope.selectedNodeSingle = []; $scope.selectedNodeSingleObj = []; - $rootScope.saveDraftSingleObj = []; - $rootScope.contentEleNote = []; + $rootScope.structureObjForSaveCB = []; + $rootScope.contentNotesForSaveCB = []; $rootScope.dynamicUpdatedJsonForSaveCB = ""; //$rootScope.updateSaveDraftCB = []; $scope.IsVisible = function () { @@ -42,6 +42,8 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ tinymce.execCommand('mceRemoveEditor', true, 'CBTextArea'); tinymce.execCommand('mceAddEditor', true, 'CBTextArea'); + //$rootScope.structureObjForSaveCB = []; + //$rootScope.contentNotesForSaveCB = []; } if ($('#' + id).html() != undefined) { @@ -177,13 +179,30 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } $rootScope.OpenExistingCurriculum = function (file_Name) { - + + //$window.location.reload(); $("#opencbview").trigger("click"); var fileupload = document.getElementById("opencbview"); fileupload.onchange = function () { + // $route.reload(); + //$location.url("/curriculum-builder"); + //$location.path("/curriculum-builder"); + + //var name = document.getElementById("opencbview").files[0].name; + + //$scope.CBDisableUI(); + $rootScope.AutherName = ""; + $rootScope.summary = ""; + $rootScope.FileTitle = "Sandy File"; + + $('#modal-CurBuilder').css("display", "block"); + $("#CurBuilderbackground").css("display", "block") $scope.getJsonFileFromLocal(); - var fileName = fileupload.value.replace('C:\\fakepath\\', '');; + + + + //var fileName = fileupload.value.replace('C:\\fakepath\\', '');; //alert(fileName); //switch ($location.url()) { @@ -192,9 +211,8 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ // break; //} // $scope.fileName = file_Name; - $('#modal-CurBuilder').css("display", "block"); - $("#CurBuilderbackground").css("display", "block"); - var name = document.getElementById("opencbview").files[0].name; + + // $http({ // method: 'GET', @@ -242,14 +260,16 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } function receivedText(e) { - let lines = e.target.result; - var newArr = JSON.parse(lines); + let lines = e.target.result; + var newArr = JSON.parse(lines); localStorage.setItem("cbJsonDataObject", JSON.stringify(newArr)); + $rootScope.cbJsonData = ""; $rootScope.cbDynamicJsonData = ""; $rootScope.cbJsonData = JSON.parse(lines); $rootScope.cbDynamicJsonData = JSON.parse(lines); $rootScope.getCBsummary(); $scope.CBEnableUI(); + $scope.openCurriculumDetail(); } } @@ -463,7 +483,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ //$scope.structure = $scope.selectedNodeSingle[0].structure.structure[0]._label; $rootScope.cbTreeFirstLabel = $scope.selectedNodeSingle[0]._label; $rootScope.structure = $scope.selectedNodeSingle[0].structure.structure; - //$rootScope.saveDraftSingleObj = $rootScope.stru.slideshow.presentation.structure.structure; + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; $rootScope.cbTreeFirstID = $scope.selectedNodeSingle[0]._id; $location.url("/curriculum-builder-detail"); } @@ -605,6 +625,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } $scope.DropDownSelectNodeClick(nodeid); $scope.SelectedNotes = ""; + traverseTreeSelectedSingleObj($rootScope.note, nodeid); $scope.SelectedNotes = $scope.selectedNodeSingleObj.notes; @@ -622,17 +643,18 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ 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); + $scope.CBEnableUI(); } else @@ -665,12 +687,13 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $scope.updateDropdownforSaveDraftCB = function (nodeid) { var current_id = document.getElementById('cbSelect').value; - if ($rootScope.saveDraftSingleObj.length == 0) { - $rootScope.saveDraftSingleObj = $rootScope.structure; - //$rootScope.saveDraftSingleObj = $rootScope.stru.slideshow.presentation.structure.structure; + if ($rootScope.structureObjForSaveCB.length == 0) { + //$rootScope.structureObjForSaveCB = $rootScope.structure; + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } - traverseSelectedObjForSaveDraftCB($rootScope.saveDraftSingleObj, current_id); - if ($rootScope.saveDraftSingleObj.length != $rootScope.stru.structure.structure.length) { + traverseSelectedObjForSaveDraftCB($rootScope.structureObjForSaveCB, current_id); + if ($rootScope.structureObjForSaveCB.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; @@ -689,15 +712,20 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ //Start Code by Sandeep for TicketNo: 49226(3) $scope.DropDownSelectNodeClick = function (nodeid) { + if ($rootScope.contentNotesForSaveCB.length == 0) { + $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents + } + var currentCb_id = document.getElementById('cbSelect').value; + $rootScope.updatedContentFromEditor(currentCb_id); - //var current_id = document.getElementById('cbSelect').value; + traverseTreeSelectedSingleObj($rootScope.stru, nodeid); traverse($rootScope.stru, nodeid); $('#cbEditorRightSideBar').css('pointer-events', 'auto'); $('#cbEditorRightSideBar').css('opacity', '1'); - //if ($rootScope.saveDraftSingleObj.length != $rootScope.stru.structure.structure.length && $rootScope.saveDraftSingleObj.length != 0) { + //if ($rootScope.structureObjForSaveCB.length != $rootScope.stru.structure.structure.length && $rootScope.structureObjForSaveCB.length != 0) { // $scope.updateDropdownforSaveDraftCB(nodeid); //} if ($scope.selectedNodeSingleObj._isBranch == "true") { @@ -986,18 +1014,18 @@ 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; - //$rootScope.saveDraftSingleObj = $rootScope.stru.slideshow.presentation.structure.structure; + if ($rootScope.structureObjForSaveCB.length == 0) { + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.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 + for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) { + if ($rootScope.structureObjForSaveCB[i]._id == current_id) { + $rootScope.structureObjForSaveCB[i]._label = $scope.selectedNodeSingleObj._label } } $scope.DropDownSelectNodeClick(current_id); - console.log(JSON.stringify($rootScope.stru)); + //console.log(JSON.stringify($rootScope.stru)); $rootScope.closeRenameModel(); } @@ -1035,17 +1063,17 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ traverseTreeSelectedSingleObj($rootScope.stru, nodeid); $scope.selectedNodeSingleObj._label = newSectionText; //Update Save Draft object for rename section - if ($rootScope.saveDraftSingleObj.length == 0) { - $rootScope.saveDraftSingleObj = $rootScope.structure; - //$rootScope.saveDraftSingleObj = $rootScope.stru.slideshow.presentation.structure.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']; + if ($rootScope.structureObjForSaveCB.length == 0) { + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; + } + for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) { + if ($rootScope.structureObjForSaveCB[i]._id == nodeid) { + $rootScope.structureObjForSaveCB[i]._label = $scope.selectedNodeSingleObj._label; + //$rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure']; } - //else if ($rootScope.saveDraftSingleObj[i]['structure']._id == nodeid) { - // $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure']; + //else if ($rootScope.structureObjForSaveCB[i]['structure']._id == nodeid) { + // $rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure']; //} } if ($rootScope.cbTreeFirstID == nodeid) { @@ -1059,11 +1087,12 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $scope.selectedNodeSingleObj.version = newversion; $scope.selectedNodeSingleObj.modified = $scope.dateTime; //Add code for Save Draft Content - if ($rootScope.contentEleNote.length == 0) { - $rootScope.contentEleNote = $rootScope.cbDynamicContents.element; + if ($rootScope.contentNotesForSaveCB.length == 0) { + $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents; } $scope.DropDownSelectNodeClick(nodeid); - console.log("summary" + JSON.stringify($rootScope.cbDynamicJsonData)); + console.log("Structure:" + JSON.stringify($rootScope.structureObjForSaveCB)); + console.log("Notes:" + JSON.stringify($rootScope.contentNotesForSaveCB)); }, 100); $rootScope.closeRenameModel(); } @@ -1121,7 +1150,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ else { $rootScope.cbBack(); } - $scope.deleteSectionForCB(cbCurrentSelectedId, CurrentSelectedParentSpanId); + //$scope.deleteSectionForCB(cbCurrentSelectedId, CurrentSelectedParentSpanId); $scope.DeleteSlide(cbCurrentSelectedId, CurrentSelectedParentSpanId); var CurrentId = document.getElementById('cbSelect').value; $scope.DropDownSelectNodeClick(CurrentId); @@ -1270,53 +1299,72 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $scope.deleteSectionForCB = function (currentid, CurrentSelectedParentSpanId) { - if ($rootScope.saveDraftSingleObj.length == 0) { - $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array - //$rootScope.saveDraftSingleObj = $rootScope.stru.slideshow.presentation.structure.structure; + if ($rootScope.structureObjForSaveCB.length == 0) { + //$rootScope.structureObjForSaveCB = $rootScope.structure;// only Tree Array + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } - if ($rootScope.contentEleNote.length == 0) { - //$rootScope.contentEleNote = $rootScope.cbJsonData.slideshow.content.element; - $rootScope.contentEleNote = $rootScope.cbDynamicContents.element;//Assign Dnamic Contents + if ($rootScope.contentNotesForSaveCB.length == 0) { + //$rootScope.contentNotesForSaveCB = $rootScope.cbJsonData.slideshow.content.element; + $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents } - traverse($rootScope.stru, currentid); - for (var j = 0; j < $rootScope.saveDraftSingleObj.length; j++) { - //if (($rootScope.saveDraftSingleObj[j]._id == currentid)) { - if ($rootScope.saveDraftSingleObj[j]._id == currentid && $rootScope.saveDraftSingleObj[j]._isBranch == "true") { - 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); + traverseTreeSelectedSingleObj($rootScope.structureObjForSaveCB, currentid); + if ($scope.selectedNodeSingleObj._isBranch == "true") { + for (var j = 0; j < $scope.selectedNodeSingleObj['structure'].length; j++) { + if ($scope.selectedNodeSingleObj._id == currentid) { + var childNodesForSelectedSection = $scope.selectedNodeSingleObj['structure']; + + 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.contentNotesForSaveCB.length; k++) { + if (($rootScope.contentNotesForSaveCB[k]._id == childId)) { + $rootScope.contentNotesForSaveCB.splice(k, 1); + } } } - } + } } - $rootScope.saveDraftSingleObj.splice(j, 1); + $scope.selectedNodeSingleObj['structure'].splice(j, 1); + //$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } - } + } + + //traverse($rootScope.stru, currentid); + //for (var j = 0; j < $rootScope.structureObjForSaveCB.length; j++) { + // //if (($rootScope.structureObjForSaveCB[j]._id == currentid)) { + // if ($rootScope.structureObjForSaveCB[j]._id == currentid && $rootScope.structureObjForSaveCB[j]._isBranch == "true") { + // traverseTreeSelectedSingleObj($rootScope.stru, currentid); + // traverse($rootScope.stru, currentid); + // var childNodesForSelectedSection = $scope.selectedNodeSingleObj['structure']; + + // //if ($rootScope.structureObjForSaveCB[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.contentNotesForSaveCB.length; k++) { + // if (($rootScope.contentNotesForSaveCB[k]._id == childId)) { + // $rootScope.contentNotesForSaveCB.splice(k, 1); + // } + // } + // } + // } + // $rootScope.structureObjForSaveCB.splice(j, 1); + // } + //} - for (var k = 0; k < $rootScope.contentEleNote.length; k++) { - if (($rootScope.contentEleNote[k]._id == currentid)) { - $rootScope.contentEleNote.splice(k, 1); - } - } + //Delete notes for SavedraftCB as per Selected Section from tree - var deleteNotes = $rootScope.contentEleNote + var deleteNotes = $rootScope.contentNotesForSaveCB var remaingNotesForCB = new jinqJs() .from(deleteNotes) .delete().at("_id == " + currentid).select(); - $rootScope.contentEleNote = remaingNotesForCB; + $rootScope.contentNotesForSaveCB = remaingNotesForCB; - $rootScope.contentEleNote = $rootScope.cbDynamicContents; - console.log($rootScope.contentEleNote); - console.log($rootScope.saveDraftSingleObj); + //$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents; + } function getLoadNodeId(o) { @@ -1332,76 +1380,195 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } $scope.DeleteSlide = function (currentid, CurrentSelectedParentSpanId) { - if ($rootScope.saveDraftSingleObj.length == 0) { - $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array - //$rootScope.saveDraftSingleObj = $rootScope.stru.slideshow.presentation.structure.structure; + if ($rootScope.structureObjForSaveCB.length == 0) { + //$rootScope.structureObjForSaveCB = $rootScope.structure;// only Tree Array + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } - if ($rootScope.contentEleNote.length == 0) { - //$rootScope.contentEleNote = $rootScope.cbJsonData.slideshow.content.element; - $rootScope.contentEleNote = $rootScope.cbDynamicContents.element;//Assign Dnamic Contents + if ($rootScope.contentNotesForSaveCB.length == 0) { + //$rootScope.contentNotesForSaveCB = $rootScope.cbJsonData.slideshow.content.element; + $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents } + traverse($rootScope.stru, currentid); + + for (var j = 0; j < $rootScope.structureObjForSaveCB.length; j++) { + //if (($rootScope.structureObjForSaveCB[j]._id == currentid)) { + if ($rootScope.structureObjForSaveCB[j]._id == currentid && $rootScope.structureObjForSaveCB[j]._isBranch == "true") { + traverseTreeSelectedSingleObj($rootScope.stru, currentid); + traverse($rootScope.stru, currentid); + var childNodesForSelectedSection = $scope.selectedNodeSingleObj['structure']; + + //if ($rootScope.structureObjForSaveCB[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.contentNotesForSaveCB.length; k++) { + if (($rootScope.contentNotesForSaveCB[k]._id == childId)) { + $rootScope.contentNotesForSaveCB.splice(k, 1); + } + } + } + } + $rootScope.structureObjForSaveCB.splice(j, 1); + } + } + for (var j = 0; j < $scope.selectedNodeSiblingObjs.length; j++) { if (($scope.selectedNodeSiblingObjs[j]._id == currentid)) { $scope.selectedNodeSiblingObjs.splice(j, 1); - $rootScope.saveDraftSingleObj = $rootScope.structure; - //$rootScope.saveDraftSingleObj = $rootScope.stru.slideshow.presentation.structure.structure; + //$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.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)) { - for (var y = 0; y < $rootScope.saveDraftSingleObj[x]['structure'].length; y++) { - if ($rootScope.saveDraftSingleObj[x]['structure'][y]._id == currentid) { - $rootScope.saveDraftSingleObj[x]['structure'].splice(y, 1); - } - else { - $rootScope.saveDraftSingleObj = $rootScope.structure; - //$rootScope.saveDraftSingleObj = $rootScope.stru.slideshow.presentation.structure.structure; - } + for (var x = 0; x < $rootScope.structureObjForSaveCB.length; x++) { + if (($rootScope.structureObjForSaveCB[x]._id == CurrentSelectedParentSpanId)) { + for (var y = 0; y < $rootScope.structureObjForSaveCB[x]['structure'].length; y++) { + if ($rootScope.structureObjForSaveCB[x]['structure'][y]._id == currentid) { + $rootScope.structureObjForSaveCB[x]['structure'].splice(y, 1); + } } } } } } - + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; + //traverseTreeSelectedSingleObj($rootScope.structureObjForSaveCB, currentid); + //if ($scope.selectedNodeSingleObj._isBranch == "true") { + // for (var j = 0; j < $scope.selectedNodeSingleObj['structure'].length; j++) { + // if ($scope.selectedNodeSingleObj._id == currentid) { + // var childNodesForSelectedSection = $scope.selectedNodeSingleObj['structure']; + + // 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.contentNotesForSaveCB.length; k++) { + // if (($rootScope.contentNotesForSaveCB[k]._id == childId)) { + // $rootScope.contentNotesForSaveCB.splice(k, 1); + // } + // } + // } + // } + // } + // $scope.selectedNodeSingleObj['structure'].splice(j, 1); + // //$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; + // } + //} + //Delete notes for SavedraftCB as per Selected Slide from tree - var deleteNotes = $rootScope.contentEleNote + var deleteNotes = $rootScope.contentNotesForSaveCB 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); + $rootScope.contentNotesForSaveCB = remaingNotesForCB; + + //alert("After" + JSON.stringify($rootScope.stru)); + console.log($rootScope.structureObjForSaveCB); + console.log($rootScope.contentNotesForSaveCB); } $rootScope.saveCurricullam = function (file_Name) { $scope.exportToFile(file_Name); } - $rootScope.exportToFile = function () { - if ($('.mce-content-body p ul li span').length > 0) { - $('.mce-content-body p ul li span').each(function () { - var sandytest = $(this).text(); - var test = $(this).attr('text'); - console.log(sandytest); - }); + + + $rootScope.updatedContentFromEditor = function (cbCurrentId) { + + var windowsInSelectedSlide; var notesForSelectedSlide; + var contentWindowsNotes = $rootScope.contentNotesForSaveCB + var selectedSlideContent = new jinqJs() + .from(contentWindowsNotes) + .where("_id == " + cbCurrentId) + .select(); + if (selectedSlideContent.length > 0) { + windowsInSelectedSlide = selectedSlideContent[0].windows; + notesForSelectedSlide = tinyMCE.activeEditor.getContent(); + if (notesForSelectedSlide == "" || notesForSelectedSlide == undefined) { + notesForSelectedSlide = selectedSlideContent[0].notes; + } } - - - var cbCurrentId = document.getElementById('cbSelect').value; + else { + windowsInSelectedSlide = ""; + notesForSelectedSlide = tinyMCE.activeEditor.getContent(); + } + + //Delete notes for SavedraftCB as per Selected Section from tree + var remaingNotesForCB = new jinqJs() + .from(contentWindowsNotes) + .delete().at("_id == " + cbCurrentId).select(); + $rootScope.contentNotesForSaveCB = remaingNotesForCB; + + traverseTreeSelectedSingleObj($rootScope.Auther, nodeid); + //traverseTreeSelectedSingleObj($rootScope.contentNotesForSaveCB, cbCurrentId); + //$scope.selectedNodeSingleObj.summary + //$scope.selectedNodeSingleObj.author + //$scope.selectedNodeSingleObj.version + //$scope.selectedNodeSingleObj.modified + if ($scope.selectedNodeSingleObj._isBranch == "false") { + $rootScope.contentNotesForSaveCB.push( + { + "notes": notesForSelectedSlide, + "windows": windowsInSelectedSlide, + "_id": cbCurrentId + }); + } + else if ($scope.selectedNodeSingleObj._isBranch == "true") { + $rootScope.contentNotesForSaveCB.push( + { + "summary": $scope.selectedNodeSingleObj.summary, + "author": $scope.selectedNodeSingleObj.author, + "modified": $scope.selectedNodeSingleObj.modified, + "password": "", + "version": $scope.selectedNodeSingleObj.version , + "windows": windowsInSelectedSlide, + "_id": cbCurrentId + //"notes": notesForSelectedSlide, + //"windows": windowsInSelectedSlide, + //"_id": cbCurrentId + }); + } + else if ($scope.selectedNodeSingleObj._isBranch == "true" && $scope.selectedNodeSingleObj._isRoot == "true") { + $rootScope.contentNotesForSaveCB.push( + { + "windows": windowsInSelectedSlide, + "summary": $scope.selectedNodeSingleObj.summary, + "author": $scope.selectedNodeSingleObj.author, + "modified": $scope.selectedNodeSingleObj.modified, + "password": "", + "version": $scope.selectedNodeSingleObj.version, + "_id": cbCurrentId + //"notes": notesForSelectedSlide, + //"windows": windowsInSelectedSlide, + //"_id": cbCurrentId + }); + } + $rootScope.cbDynamicContents = $rootScope.contentNotesForSaveCB; + $rootScope.note = $rootScope.contentNotesForSaveCB; + + console.log($rootScope.contentNotesForSaveCB); + //console.log(tinyMCE.activeEditor.getContent()); + //console.log($('#CBTextArea_ifr')[0].contentDocument.body.innerHTML); + + } - if ($rootScope.saveDraftSingleObj.length == 0) { - $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array - //$rootScope.saveDraftSingleObj = $rootScope.stru.slideshow.presentation.structure.structure; + + $rootScope.exportToFile = function () { + + var cbCurrentId = document.getElementById('cbSelect').value; + if ($rootScope.structureObjForSaveCB.length == 0) { + //$rootScope.structureObjForSaveCB = $rootScope.structure;// only Tree Array + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } - if ($rootScope.contentEleNote.length == 0) { - //$rootScope.contentEleNote = $rootScope.cbJsonData.slideshow.content.element; - $rootScope.contentEleNote = $rootScope.cbDynamicContents;//Assign Dnamic Contents + if ($rootScope.contentNotesForSaveCB.length == 0) { + //$rootScope.contentNotesForSaveCB = $rootScope.cbJsonData.slideshow.content.element; + $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents } + $rootScope.updatedContentFromEditor(cbCurrentId); + $rootScope.dynamicUpdatedJsonForSaveCB = { "slideshow": { @@ -1409,7 +1576,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "structure": { "structure": //[ - $rootScope.saveDraftSingleObj, + $rootScope.structureObjForSaveCB, //], "_label": $rootScope.cbTreeFirstLabel, "_id": $rootScope.cbTreeFirstID, @@ -1419,13 +1586,13 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ }, "_anchor": "true", "_window_position": "6,10", - "_window_size": "828,453" + "_window_size": "828,453" // Apply Dynamic }, "content": { - "element": [ + "element": //[ - $rootScope.contentEleNote, - ] + $rootScope.contentNotesForSaveCB, + //] } } @@ -1434,23 +1601,23 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $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 - //} + 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 = []; + //$rootScope.contentNotesForSaveCB = []; + //$rootScope.structureObjForSaveCB = []; // $http({ method: 'Post', url: $scope.fileName }).success(function (data) { // localStorage.setItem("cbJsonDataObject", JSON.stringify(data)); @@ -1469,9 +1636,10 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $scope.addSection = function (currentid, AddSecionId) { - if ($rootScope.saveDraftSingleObj.length == 0) { - $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array - //$rootScope.saveDraftSingleObj = $rootScope.stru.slideshow.presentation.structure.structure; + if ($rootScope.structureObjForSaveCB.length == 0) { + //$rootScope.structureObjForSaveCB = $rootScope.structure;// only Tree Array + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } traverseTreeSelectedSingleObj($rootScope.stru, currentid); @@ -1490,7 +1658,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } }); - $rootScope.saveDraftSingleObj.push( + $rootScope.structureObjForSaveCB.push( { "structure": [ ], @@ -1513,33 +1681,34 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "_isBranch": "true", "_isLocked": "false" }); - 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']; + //if (currentid == $rootScope.cbTreeFirstID) { + // $rootScope.structureObjForSaveCB.push( + // { + // "structure": [ + // ], + // "_label": "New Section", + // "_id": AddSecionId, + // "_isRoot": "false", + // "_isBranch": "true", + // "_isLocked": "false" + // }); + //} + //else { + for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) { + if ($rootScope.structureObjForSaveCB[i]._id == currentid) { + $rootScope.structureObjForSaveCB[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.slideshow.presentation.structure.structure; + if ($rootScope.structureObjForSaveCB.length == 0) { + //$rootScope.structureObjForSaveCB = $rootScope.structure;// only Tree Array + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } traverseTreeSelectedSingleObj($rootScope.stru, currentid); // traverse($rootScope.stru, currentid); @@ -1553,7 +1722,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "_isBranch": "false", "_isLocked": "false" }); - $rootScope.saveDraftSingleObj.push({ + $rootScope.structureObjForSaveCB.push({ "_label": "NEW Slide1", "_id": AddSlideId, "_isRoot": "false", @@ -1569,22 +1738,22 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "_isBranch": "false", "_isLocked": "false" }); - 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']; + //if (currentid == $rootScope.cbTreeFirstID) { + // $rootScope.structureObjForSaveCB.push({ + // "_label": "New Slide", + // "_id": AddSlideId, + // "_isRoot": "false", + // "_isBranch": "false", + // "_isLocked": "false" + // }); + //} + //else { + for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) { + if ($rootScope.structureObjForSaveCB[i]._id == currentid) { + $rootScope.structureObjForSaveCB[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); @@ -1622,7 +1791,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ break; } } - $rootScope.saveDraftSingleObj = $rootScope.stru.structure.structure; + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } $scope.moveUP = function (currentid) { @@ -1637,7 +1806,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $scope.selectedNodeSiblingObjs[j - 1] = key; } } - $rootScope.saveDraftSingleObj = $rootScope.stru.structure.structure; + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; //console.log("upDateJsonObjenew after" + JSON.stringify($scope.selectedNodeSiblingObjs)); //console.log("stru after" + JSON.stringify($rootScope.stru)); //console.log("structure after" + JSON.stringify($rootScope.structure)); @@ -1964,12 +2133,13 @@ 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.slideshow.presentation.structure.structure; + if ($rootScope.structureObjForSaveCB.length == 0) { + //$rootScope.structureObjForSaveCB = $rootScope.structure;// only Tree Array + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } - //$rootScope.saveDraftSingleObj = $rootScope.stru;//All json Structure with tree array - //$rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array + //$rootScope.structureObjForSaveCB = $rootScope.stru;//All json Structure with tree array + //$rootScope.structureObjForSaveCB = $rootScope.structure;// only Tree Array //$rootScope.updateSaveDraftDynamicTest = []; traverseTreeSelectedSingleObj($rootScope.stru, currentid); @@ -1996,7 +2166,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ }); - $rootScope.saveDraftSingleObj.push( + $rootScope.structureObjForSaveCB.push( { "structure": [ @@ -2022,7 +2192,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ // "_isLocked": "false" // }); - // $rootScope.saveDraftSingleObj.push( + // $rootScope.structureObjForSaveCB.push( // { // "structure": { // "structure": [ @@ -2047,9 +2217,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "_isLocked": "false" }); - for (var i = 0; i < $rootScope.saveDraftSingleObj.length; i++) { - if ($rootScope.saveDraftSingleObj[i]._id == currentid) { - $rootScope.saveDraftSingleObj[i]['structure'] = $scope.selectedNodeSingleObj['structure']; + for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) { + if ($rootScope.structureObjForSaveCB[i]._id == currentid) { + $rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure']; } } } @@ -2059,9 +2229,10 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $scope.addSlideForSaveDraft = function (currentid, AddSlideId, parentid) { - if ($rootScope.saveDraftSingleObj.length == 0) { - $rootScope.saveDraftSingleObj = $rootScope.structure;// only Tree Array - //$rootScope.saveDraftSingleObj = $rootScope.stru.slideshow.presentation.structure.structure; + if ($rootScope.structureObjForSaveCB.length == 0) { + //$rootScope.structureObjForSaveCB = $rootScope.structure;// only Tree Array + //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } traverseTreeSelectedSingleObj($rootScope.stru, currentid); //traverse($rootScope.stru, currentid); @@ -2079,16 +2250,16 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "_isLocked": "false" }); - $rootScope.saveDraftSingleObj.push({ + $rootScope.structureObjForSaveCB.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; + //for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) { + // if ($rootScope.structureObjForSaveCB[i]._id == currentid) { + // $rootScope.structureObjForSaveCB[i] = $rootScope.selectedNodeSingle; // } //} } @@ -2100,9 +2271,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "_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']; + for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) { + if ($rootScope.structureObjForSaveCB[i]._id == currentid) { + $rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure']; } } } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-TinyMCEjspanel.html b/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-TinyMCEjspanel.html index 7a246d6..d48b840 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-TinyMCEjspanel.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-TinyMCEjspanel.html @@ -66,7 +66,7 @@