From f3e77c0329074d10b43b032dfe2bc11b0277345f Mon Sep 17 00:00:00 2001 From: Birendra Date: Mon, 1 Jun 2020 13:45:08 +0530 Subject: [PATCH] add functionalities for export CB --- 400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------- 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js | 4 ++++ 400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html | 2 -- 400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-TinyMCEjspanel.html | 36 ++++++++++++++++++------------------ 400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-detail.html | 80 ++++++++++++++++++++++++++++++++++++++++++++------------------------------------ 400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-image-jspanel.html | 0 400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-image.html | 4 ---- 400-SOURCECODE/AIAHTML5.Web/content/images/CB/export-cb.png | Bin 0 -> 1018 bytes 400-SOURCECODE/AIAHTML5.Web/content/images/CB/import-cb.png | Bin 0 -> 1041 bytes 400-SOURCECODE/AIAHTML5.Web/themes/default/css/bootstrap/3.3.6/main.css | 6 ++++++ 10 files changed, 241 insertions(+), 99 deletions(-) delete mode 100644 400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-image-jspanel.html delete mode 100644 400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-image.html create mode 100644 400-SOURCECODE/AIAHTML5.Web/content/images/CB/export-cb.png create mode 100644 400-SOURCECODE/AIAHTML5.Web/content/images/CB/import-cb.png diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js index 88ea4ba..ff09667 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js @@ -85,11 +85,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $('#HomeContainerDiv').css('pointer-events', 'none'); $('#HomeContainerDiv').css('opacity', '0.7'); - $('#CBTextArea_ifr').css('pointer-events', 'none'); $('#CBTextArea_ifr').css('opacity', '0.7'); - $('#jstree').css('pointer-events', 'none'); $('#jstree').css('opacity', '0.7'); @@ -99,13 +97,12 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $('#cbEditorLeftSideBar').css('pointer-events', 'none'); $('#cbEditorLeftSideBar').css('opacity', '0.7'); - $('#cbEditorRightSideBar').css('pointer-events', 'none'); - $('#cbEditorRightSideBar').css('opacity', '0.7'); + $('#cbEditorRightSideBar').css('pointer-events', 'none'); + $('#cbEditorRightSideBar').css('opacity', '0.7'); $('.tox-editor-header').css('pointer-events', 'none'); $('.tox-editor-header').css('opacity', '0.7'); - - + $timeout(function () { // in case failed default time out 40 second @@ -143,7 +140,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $('#cbEditorRightSideBar').css('opacity', '01'); $('.tox-editor-header').css('pointer-events', 'auto'); - $('.tox-editor-header').css('opacity', '1'); + $('.tox-editor-header').css('opacity', '1'); } @@ -318,18 +315,18 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ function receivedFile(e) { //let lines = e.target.result; + $scope.CBEnableUI(); var jsonData = JSON.parse(e.target.result); localStorage.setItem("cbJsonDataObject", JSON.stringify(jsonData)); $rootScope.cbJsonData = ""; $rootScope.cbDynamicJsonData = ""; $rootScope.cbJsonData = JSON.parse(e.target.result); $rootScope.cbDynamicJsonData = JSON.parse(e.target.result); $rootScope.cbTreeFirstLabel = $rootScope.cbJsonData.slideshow.presentation.structure._label; - - $rootScope.getCBsummary(); - $scope.CBEnableUI(); - $rootScope.AutherName = ""; $rootScope.summary = ""; + + $rootScope.getCBsummary(); + $rootScope.FileTitle = $rootScope.cbTreeFirstLabel; $timeout(function () { @@ -469,7 +466,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } $scope.openTinyMCE = function (nodeid) { - $scope.CBDisableUI(); if ($scope.Currentselectednodeid == undefined || $scope.Currentselectednodeid != nodeid) { console.log("instance create for id : " + nodeid); @@ -488,7 +484,8 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $("#AddSection").addClass("cbAddSection"); $("#openResourceId").removeClass("openResources"); $("#openPictureId").removeClass("OpenPitures"); - + $("#export_btn").addClass("importExportSection"); + $("#import_btn").addClass("importExportSection"); } if ($scope.selectedNodeSingleObj._isBranch == "true") { $("#Deletesection").removeClass("DeletesectionClass"); @@ -497,7 +494,11 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $("#AddSection").removeClass("cbAddSection"); $("#openResourceId").addClass("openResources"); $("#openPictureId").addClass("OpenPitures"); + $("#export_btn").removeClass("importExportSection"); + $("#import_btn").removeClass("importExportSection"); } + $scope.nodeTypeIsBranch = $scope.selectedNodeSingleObj._isBranch; + $scope.DropDownSelectNodeClick(nodeid); $scope.SelectedNotes = ""; @@ -529,13 +530,21 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } }, 200); - //$scope.CBEnableUI(); + } else { tinymce.get("CBTextArea").setContent(""); $scope.CBEnableUI(); + //disable tiny editor while section active + if($scope.nodeTypeIsBranch=="true") + { + $('.tox-editor-header').css('pointer-events', 'none'); + $('.tox-editor-header').css('opacity', '0.7'); + $('#CBTextArea_ifr').css('pointer-events', 'none'); + $('#CBTextArea_ifr').css('opacity', '0.7'); + } + } - } else { $scope.CBEnableUI(); @@ -941,6 +950,127 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ document.getElementById('cbModelDeleteBackground').style.display = "block"; document.getElementById('cbModelDeleteConfirmBoxId').style.display = "block"; } + $rootScope.ExportSection = function () { + var currentid = document.getElementById('cbSelect').value; + + if ($rootScope.contentNotesForSaveCB.length == 0) { + $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents; + } + $scope.SectionContentForExportCB=[]; + + traverseTreeSelectedSingleObj($rootScope.stru, currentid); + + var strFromParent=$scope.selectedNodeSingleObj['structure']; + if(strFromParent.length<=0) + { + alert("Add slide in this section to export this curriculum"); + return; + } + $("#btnExportCB").css({"display":"block"}) ; + $("#btnSaveCB").css({"display":"none"}) ; + $(".export-curriculum").modal("show").draggable({ handle: ".modal-header" }); + $(".modal-backdrop").css("opacity", ".5"); + $(".modal-backdrop").css("z-index", "1200001"); + } + + $scope.ExportCurriculum =function() + { + var filename = document.getElementById("filename").value; + if (filename == "" ||filename == " ") + { + alert("Curriculum name is empty!"); + return; + } + + var strFromParent=$scope.selectedNodeSingleObj['structure']; + var parentLevel=$scope.selectedNodeSingleObj._label; + var parentId=$scope.selectedNodeSingleObj._id; + + var rootNoteSummary = new jinqJs() + .from($rootScope.contentNotesForSaveCB) + .where("_id == " + $scope.selectedNodeSingleObj._id) + .select(); + + $scope.SectionContentForExportCB.push( + { + "summary":rootNoteSummary[0].summary, + "author": rootNoteSummary[0].author, + "modified":rootNoteSummary[0].modified, + "password":rootNoteSummary[0].password, + "version":rootNoteSummary[0].version, + "windows":rootNoteSummary[0].windows, + "_id":rootNoteSummary[0]._id, + }); + + function traverseTreeforExportContent(o) { + for (var i in o) { + + if (o[i] !== null && typeof (o[i]) == "object") { + var selectedNode = o[i]; + var childId = selectedNode._id; + if(childId!=undefined) + { + for (var k = 0; k < $rootScope.contentNotesForSaveCB.length; k++) { + if (($rootScope.contentNotesForSaveCB[k]._id == childId)) { + $scope.SectionContentForExportCB.push($rootScope.contentNotesForSaveCB[k]); + } + } + } + + traverseTreeforExportContent(o[i]); + } + + } + } + + traverseTreeforExportContent(strFromParent); + + $rootScope.dynamicUpdatedJsonForExportCB = + { + "slideshow": { + "presentation": { + "structure": { + "structure":strFromParent, + "_label": parentLevel, + "_id": parentId, + "_isRoot": "true", + "_isBranch": "true", + "_isLocked": "false" + }, + "_anchor": "true", + "_window_position": "6,10", + "_window_size": "828,453" // Apply Dynamic + }, + "content": { + "element": $scope.SectionContentForExportCB, + } + } + + }; + + //add extension + filename += '.json'; + var blob = new Blob([angular.toJson($rootScope.dynamicUpdatedJsonForExportCB, true)], { type: 'text/text' }); + if (window.navigator && window.navigator.msSaveOrOpenBlob) { + window.navigator.msSaveOrOpenBlob(blob, filename); + } + else { + document.execCommand("SaveAs", true, filename); + + var event = document.createEvent('MouseEvents'), + saveElement = document.createElement('a'); + saveElement.download = filename; + saveElement.href = window.URL.createObjectURL(blob); + saveElement.dataset.downloadurl = ['text/json', saveElement.download, saveElement.href].join(':'); + event.initEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + saveElement.dispatchEvent(event); + + } + $rootScope.dynamicUpdatedJsonForExportCB = ""; + $("#filename").val(""); + + } + $rootScope.DeleteSlideSection = function () { var cbCurrentSelectedId = document.getElementById('cbSelect').value; @@ -1206,18 +1336,27 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ console.log($rootScope.contentNotesForSaveCB); } - $rootScope.saveCurricullam = function (file_Name) { - - //$scope.exportToFile(file_Name); + $rootScope.saveCurricullam = function () { + $("#btnExportCB").css({"display":"none"}) ; + $("#btnSaveCB").css({"display":"block"}) ; + $(".export-curriculum").modal("show").draggable({ handle: ".modal-header" }); + $(".modal-backdrop").css("opacity", ".5"); + $(".modal-backdrop").css("z-index", "1200001"); + } + + $rootScope.saveMyCurricullam = function () { + var filename = document.getElementById("filename").value; + if (filename == "" ||filename == " ") + { + alert("Curriculum name is empty!"); + return; + } 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; + if ($rootScope.structureObjForSaveCB.length == 0) { $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } - if ($rootScope.contentNotesForSaveCB.length == 0) { - //$rootScope.contentNotesForSaveCB = $rootScope.cbJsonData.slideshow.content.element; + if ($rootScope.contentNotesForSaveCB.length == 0) { $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents } $rootScope.updatedContentFromEditor(cbCurrentId); @@ -1229,10 +1368,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "slideshow": { "presentation": { "structure": { - "structure": //[ - - $rootScope.structureObjForSaveCB, - //], + "structure": $rootScope.structureObjForSaveCB, "_label": $rootScope.cbTreeFirstLabel, "_id": $rootScope.cbTreeFirstID, "_isRoot": "true", @@ -1244,27 +1380,22 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "_window_size": "828,453" // Apply Dynamic }, "content": { - "element": //[ - - $rootScope.contentNotesForSaveCB, - //] + "element": $rootScope.contentNotesForSaveCB, } } }; - $scope.slideshow = $rootScope.dynamicUpdatedJsonForSaveCB; - $scope.filename = "SandySaveCB.json"; - var filename = $scope.filename; + //add extension + filename += '.json'; + var blob = new Blob([angular.toJson($rootScope.dynamicUpdatedJsonForSaveCB, true)], { type: 'text/text' }); if (window.navigator && window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveOrOpenBlob(blob, filename); } else { document.execCommand("SaveAs", true, filename); - //$("#bo").document.execCommand("SaveAs", true, filename); - //angular.element(document.execCommand("SaveAs", false, filename)).scope(); - + var event = document.createEvent('MouseEvents'), saveElement = document.createElement('a'); saveElement.download = filename; @@ -1275,8 +1406,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ //window.URL.revokeObjectURL(url); // clean the url.createObjectURL resource } $rootScope.dynamicUpdatedJsonForSaveCB = ""; - //$rootScope.contentNotesForSaveCB = []; - //$rootScope.structureObjForSaveCB = []; + $("#filename").val(""); } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index bf65cbf..e6ff95d 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -1859,6 +1859,10 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data $("#printAllAVAnchor").addClass("PrintViewer"); $("#printPreviewAnchor").addClass("PrintPreview"); $("#exportImageAnchor").addClass("exportImage"); + //close while back from cb + $rootScope.CloseAnnotationTool(); + $rootScope.CloseListManager(); + } else if ($location.url() == "/curriculum-builder-detail") { $("#fileMenuAnchor").removeClass("disableFileMenu"); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html b/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html index dc07923..6b4450c 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html @@ -38,6 +38,4 @@ - - \ No newline at end of file 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 ce8d408..be823ad 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 @@ -1,6 +1,3 @@ - - -
@@ -22,21 +19,9 @@
- - -
- +
@@ -47,10 +32,21 @@
-->
- +
- + +
+ +
+ +
+
+
@@ -141,6 +137,10 @@ angular.element(document.querySelector('[ng-controller="CurrBuildController"]')).scope().myeditorclick(); } + function ExportSection() { + + angular.element(document.querySelector('[ng-controller="CurrBuildController"]')).scope().ExportSection(); + } //Added Code by Sandeep for User Story-52695 //function captureScreen() { diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-detail.html b/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-detail.html index 352003a..004fd30 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-detail.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/curriculum-builder-detail.html @@ -299,9 +299,44 @@
- - - + + + + +
@@ -321,40 +356,13 @@ }); }); - //var allowsubmit = false; - //$(function () { - // $('#cbPassword').keyup(function (e) { - // var pass = $(this).val(); - // //var confpass = $('#cbConfirmPassWord').val(); - // if (pass.length < 3) { - // $('#errorMsg').text('Password must contain at least 3 characters!'); - // $("#btnOK").attr('disabled', 'disabled'); - - // } else { - // $('#errorMsg').text(''); - // allowsubmit = true; - // //$("#btnOK").removeAttr('disabled'); - // } - // }); - - // //on keypress - // $('#cbConfirmPassWord').keyup(function (e) { - // var pass = $('#cbPassword').val(); - // var confpass = $(this).val(); - // if (pass == confpass) { - // $('#errorMsg').text(''); - // allowsubmit = true; - // $("#btnOK").removeAttr('disabled'); - // } else { - // $('#errorMsg').text('Password not matching'); - // allowsubmit = false; - // $("#btnOK").attr('disabled', 'disabled'); - // } - // }); - //}); -