From b8c081ec1ef4e33047d5a6b0e262ffdd8feaaeaf Mon Sep 17 00:00:00 2001 From: mitali Date: Tue, 4 Oct 2016 18:50:37 +0530 Subject: [PATCH] Bug #5263: Maintain combo box selection after detail page is unloaded and CI is loaded --- 400-SOURCECODE/AIAHTML5.Web/app/controllers/CIController.js | 433 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 242 insertions(+), 191 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CIController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CIController.js index f40c283..07d6dbe 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CIController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CIController.js @@ -17,17 +17,19 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.selectedCIListViewData = []; $scope.filterstring = false; $scope.query = { - selectedbodyregion: null, - selectedbodysystem: null, - selectedorientation: null, - selectedimagetype: null, - selectedspecialty: null, + selectedbodyregion: '', + selectedbodysystem: '', + selectedorientation: '', + selectedimagetype: '', + selectedspecialty: '', }; $scope.$on('$viewContentLoaded', function (event) { // code that will be executed ... // every time this view is loaded + $scope.LoadCIJsonData(); + $scope.CIAllBodyRegion = BodyRegions; $scope.CIAllBodySystem = BodySystems; $scope.CIAllOrientation = ViewOrientations; @@ -37,45 +39,121 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout //push the details of open module in array $rootScope.openModules $rootScope.openModules.push({ "ModuleId": 4 }); + //set the local storage + var curBodyRegion = localStorage.getItem("CICurBodyRegion"); + if (typeof (curBodyRegion) !== "undefined" && curBodyRegion !== null) { + $scope.query.selectedbodyregion = curBodyRegion; + } + else { + $scope.query.selectedbodyregion = ""; + } + + var curBodySystem = localStorage.getItem("CICurBodySystem"); + if (typeof (curBodySystem) !== "undefined" && curBodySystem !== null) { + $scope.query.selectedbodysystem = curBodySystem; + } + else { + $scope.query.selectedbodysystem = ""; + } + + var curOrientation = localStorage.getItem("CICurOrientation"); + if (typeof (curOrientation) !== "undefined" && curOrientation !== null) { + $scope.query.selectedorientation = curOrientation; + } + else { + $scope.query.selectedorientation = ""; + } + + var curImageType = localStorage.getItem("CICurImageType"); + if (typeof (curImageType) !== "undefined" && curImageType !== null) { + $scope.query.selectedimagetype = curImageType; + } + else { + $scope.query.selectedimagetype = ""; + } + + var curSpeciality = localStorage.getItem("CICurSpeciality"); + if (typeof (curSpeciality) !== "undefined" && curSpeciality !== null) { + $scope.query.selectedspecialty = curSpeciality; + } + else { + $scope.query.selectedspecialty = ""; + } + + + if ($scope.query.selectedbodyregion == "" && $scope.query.selectedbodysystem == "" && $scope.query.selectedorientation == "" && $scope.query.selectedimagetype == "" && $scope.query.selectedspecialty == "") { + $scope.loadAllCI(); + } + else { + $scope.ApplySearch($scope.query); + } + }); - var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json') - promise.then( - function (result) { - $scope.IllustrationData = result; - //$scope.selectedCIListViewData = $scope.IllustrationData.root.CIData; + $scope.LoadCIJsonData = function () { - $scope.selectedCIListViewData = new jinqJs() - .from($scope.IllustrationData.root.CIData) - .orderBy([{ field: '_Title', sort: 'asc' }]) - .select(); + var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json') + promise.then( + function (result) { + $scope.IllustrationData = result; + //$scope.selectedCIListViewData = $scope.IllustrationData.root.CIData; - $('#grid-view').empty(); + $scope.selectedCIListViewData = new jinqJs() + .from($scope.IllustrationData.root.CIData) + .orderBy([{ field: '_Title', sort: 'asc' }]) + .select(); - angular.forEach($scope.selectedCIListViewData, function (value, key) { - $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage; + }, + function (error) { + // handle errors here + console.log(' $scope.IllustrationData = ' + error.statusText); + } + ); - var $el = $('
' - + '
' - + '' - + '

' + value._Title + '

').appendTo('#grid-view'); + }; - $compile($el)($scope); + $scope.loadAllCI = function () { + + var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json') + promise.then( + function (result) { + $scope.IllustrationData = result; + //$scope.selectedCIListViewData = $scope.IllustrationData.root.CIData; + + $scope.selectedCIListViewData = new jinqJs() + .from($scope.IllustrationData.root.CIData) + .orderBy([{ field: '_Title', sort: 'asc' }]) + .select(); + + console.log($scope.selectedCIListViewData); + $('#grid-view').empty(); + angular.forEach($scope.selectedCIListViewData, function (value, key) { + $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage; + + var $el = $('
' + + '
' + + '' + + '

' + value._Title + '

').appendTo('#grid-view'); + + + $compile($el)($scope); + + $(".sidebar").mCustomScrollbar({ + autoHideScrollbar: true, + //theme:"rounded" + }); - $(".sidebar").mCustomScrollbar({ - autoHideScrollbar: true, - //theme:"rounded" }); - }); + }, + function (error) { + // handle errors here + console.log(' $scope.IllustrationData = ' + error.statusText); + } + ); - }, - function (error) { - // handle errors here - console.log(' $scope.IllustrationData = ' + error.statusText); - } - ); + } $scope.IsVisible = function () { $scope.scroll(); @@ -119,40 +197,26 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.Reset = function (query) { - //query.selectedbodyregion = ""; - //query.selectedbodysystem = ""; - //query.selectedorientation = ""; - //query.selectedimagetype = ""; - //query.selectedspecialty = ""; - query.selectedbodyregion = null; - query.selectedbodysystem = null; - query.selectedorientation = null; - query.selectedimagetype = null; - query.selectedspecialty = null; + query.selectedbodyregion = ""; + query.selectedbodysystem = ""; + query.selectedorientation = ""; + query.selectedimagetype = ""; + query.selectedspecialty = ""; + + + //set localstorage values + localStorage.setItem("CICurBodyRegion", query.selectedbodyregion); + localStorage.setItem("CICurBodySystem", query.selectedbodysystem); + localStorage.setItem("CICurOrientation", query.selectedorientation); + localStorage.setItem("CICurImageType", query.selectedimagetype); + localStorage.setItem("CICurSpeciality", query.selectedspecialty); $scope.filterstring = false; while ($scope.searchCIListViewData.length) { $scope.searchCIListViewData.pop(); } - $('#grid-view').empty(); - - angular.forEach($scope.selectedCIListViewData, function (value, key) { - $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage; - - var $el = $('
' - + '
' - + '' - + '

' + value._Title + '

').appendTo('#grid-view'); - - - $compile($el)($scope); - - $(".sidebar").mCustomScrollbar({ - autoHideScrollbar: true, - //theme:"rounded" - }); - }); + $scope.loadAllCI(); } @@ -164,143 +228,168 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.searchCIListViewData.pop(); } - $('#grid-view').empty(); + //$('#grid-view').empty(); filtercount = 0; - if (typeof (query.selectedbodyregion) !== "undefined" && query.selectedbodyregion !== null) { + if (typeof (query.selectedbodyregion) !== "undefined" && (query.selectedbodyregion !== null || query.selectedbodyregion !== "null")) { filtercount = filtercount + 1; + localStorage.setItem("CICurBodyRegion", query.selectedbodyregion); } - if (typeof (query.selectedbodysystem) !== "undefined" && query.selectedbodysystem !== null) { + if (typeof (query.selectedbodysystem) !== "undefined" && (query.selectedbodysystem !== null || query.selectedbodysystem !== "null")) { filtercount = filtercount + 1; + localStorage.setItem("CICurBodySystem", query.selectedbodysystem); } - if (typeof (query.selectedorientation) !== "undefined" && query.selectedorientation !== null) { + if (typeof (query.selectedorientation) !== "undefined" && (query.selectedorientation !== null || query.selectedorientation !== "null")) { filtercount = filtercount + 1; + localStorage.setItem("CICurOrientation", query.selectedorientation); } - if (typeof (query.selectedimagetype) !== "undefined" && query.selectedimagetype !== null) { + if (typeof (query.selectedimagetype) !== "undefined" && (query.selectedimagetype !== null || query.selectedimagetype !== "null")) { filtercount = filtercount + 1; + localStorage.setItem("CICurImageType", query.selectedimagetype); } - if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null) { + if (typeof (query.selectedspecialty) !== "undefined" && (query.selectedspecialty !== null || query.selectedspecialty !== "null")) { filtercount = filtercount + 1; + localStorage.setItem("CICurSpeciality", query.selectedspecialty); } - angular.forEach($scope.selectedCIListViewData, function (value, key) { - var selectimg = true; - var count = 0; + var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json') + promise.then( + function (result) { + $scope.IllustrationData = result; + //$scope.selectedCIListViewData = $scope.IllustrationData.root.CIData; + $scope.selectedCIListViewData = new jinqJs() + .from($scope.IllustrationData.root.CIData) + .orderBy([{ field: '_Title', sort: 'asc' }]) + .select(); + + $('#grid-view').empty(); + + angular.forEach($scope.selectedCIListViewData, function (value, key) { + + var selectimg = true; + var count = 0; - if (typeof (query.selectedbodyregion) !== "undefined" && query.selectedbodyregion !== null) { - var posbodyregion = value._BodyRegion.indexOf((query.selectedbodyregion.trim())); - if (posbodyregion > -1) { - selectimg = true; - count = count + 1; - } - else { - selectimg = false; - count = count - 1; - } + if (typeof (query.selectedbodyregion) !== "undefined" && (query.selectedbodyregion !== null || query.selectedbodyregion !== "null")) { + var posbodyregion = value._BodyRegion.indexOf((query.selectedbodyregion.trim())); + if (posbodyregion > -1) { + selectimg = true; + count = count + 1; - } + } + else { + selectimg = false; + count = count - 1; + } - if (typeof (query.selectedbodysystem) !== "undefined" && query.selectedbodysystem !== null) { - var posbodysystem = value._BodySystem.indexOf(query.selectedbodysystem); - if (posbodysystem > -1) { - count = count + 1; - selectimg = true; - } else { - selectimg = false; - count = count - 1; - } - } + } - if (typeof (query.selectedorientation) !== "undefined" && query.selectedorientation !== null) { - var posorientation = value._ViewOrientation.indexOf(query.selectedorientation); - if (posorientation > -1) { - count = count + 1; - selectimg = true; + if (typeof (query.selectedbodysystem) !== "undefined" && (query.selectedbodysystem !== null || query.selectedbodysystem !== "null")) { + var posbodysystem = value._BodySystem.indexOf(query.selectedbodysystem); + if (posbodysystem > -1) { + count = count + 1; + selectimg = true; + } else { + selectimg = false; + count = count - 1; + } + } - } else { - selectimg = false; - count = count - 1; - } + if (typeof (query.selectedorientation) !== "undefined" && (query.selectedorientation !== null || query.selectedorientation !== "null")) { + var posorientation = value._ViewOrientation.indexOf(query.selectedorientation); + if (posorientation > -1) { + count = count + 1; + selectimg = true; - } + } else { + selectimg = false; + count = count - 1; + } - if (typeof (query.selectedimagetype) !== "undefined" && query.selectedimagetype !== null) { - var posimagetype = value._ImageType.indexOf(query.selectedimagetype); - if (posimagetype > -1) { - count = count + 1; - selectimg = true; + } - } else { - selectimg = false; - count = count - 1; - } + if (typeof (query.selectedimagetype) !== "undefined" && (query.selectedimagetype !== null || query.selectedimagetype !== "null")) { + var posimagetype = value._ImageType.indexOf(query.selectedimagetype); + if (posimagetype > -1) { + count = count + 1; + selectimg = true; - } + } else { + selectimg = false; + count = count - 1; + } - if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null) { - var posspeciality = value._MedicalSpecialty.indexOf(query.selectedspecialty); - if (posspeciality > -1) { - count = count + 1; - selectimg = true; - } else { - selectimg = false; - count = count - 1; - } + } - } + if (typeof (query.selectedspecialty) !== "undefined" && (query.selectedspecialty !== null || query.selectedspecialty !== "null")) { + var posspeciality = value._MedicalSpecialty.indexOf(query.selectedspecialty); + if (posspeciality > -1) { + count = count + 1; + selectimg = true; + } else { + selectimg = false; + count = count - 1; + } - if (selectimg === true && count >= filtercount) { + } + if (selectimg === true && count >= filtercount) { - $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage; - var $el = $('
' - + '
' - + '' - + '

' + value._Title + '

').appendTo('#grid-view'); + $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage; + var $el = $('
' + + '
' + + '' + + '

' + value._Title + '

').appendTo('#grid-view'); - $compile($el)($scope); - $(".sidebar").mCustomScrollbar({ - autoHideScrollbar: true, - //theme:"rounded" - }); + $compile($el)($scope); + $(".sidebar").mCustomScrollbar({ + autoHideScrollbar: true, + //theme:"rounded" + }); - $scope.searchCIListViewData.push( - { - "_id": value._id, - "_ImageId": value._ImageId, - "_Title": value._Title, - "_contentImage": value._contentImage, - "_ThumbnailImage": value._ThumbnailImage, - "_BodySystem": value._BodySystem, - "_BodyRegion": value._BodyRegion, - "_ViewOrientation": value._ViewOrientation, - "_MedicalSpecialty": value._MedicalSpecialty, - "_ImageType": value._ImageType, - "_Summary": value._Summary - }); + $scope.searchCIListViewData.push( + { + "_id": value._id, + "_ImageId": value._ImageId, + "_Title": value._Title, + "_contentImage": value._contentImage, + "_ThumbnailImage": value._ThumbnailImage, + "_BodySystem": value._BodySystem, + "_BodyRegion": value._BodyRegion, + "_ViewOrientation": value._ViewOrientation, + "_MedicalSpecialty": value._MedicalSpecialty, + "_ImageType": value._ImageType, + "_Summary": value._Summary - } + }); + } - }); - //Show Error Message in case of gridview if no data is found - if ($scope.searchCIListViewData.length == 0) { + }); - var $el = $('
No illustration found for the selected search criteria!
').appendTo('#grid-view'); - $compile($el)($scope); - } - } + //Show Error Message in case of gridview if no data is found + if ($scope.searchCIListViewData.length == 0) { + var $el = $('
No illustration found for the selected search criteria!
').appendTo('#grid-view'); + $compile($el)($scope); + } + }, + function (error) { + // handle errors here + console.log(' $scope.IllustrationData = ' + error.statusText); + } + ); + + } $scope.scroll = function () { @@ -404,23 +493,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); - //$.jsPanel({ - // id: 'ciImagePanel', - // selector: '.ciView', - // theme: 'success', - // currentController: 'CIController', - // parentSlug: 'clinical-illustrations', - // content: '
' + - // '
' + - // '

' + $scope.clickedCISummary + '

'+ - // '
' + - // '
', - // title: localStorage.getItem("currentViewTitle"), - // position: { - // top: 70, - // left: 1, - // }, - $.jsPanel({ id: 'ciImagePanel', selector: '.ciView', @@ -441,8 +513,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout left: 1, }, - //size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, - size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, }); @@ -455,25 +525,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout "slug": $rootScope.currentSlug }); - //var e1 = angular.element(document.getElementById("CIView")); - //$timeout(function () { - - // //$compile(e1.contents())($scope) - - // var $el = $('
' + - // '
' + - // '

' + $scope.clickedCISummary + '

' + - // '
' + - // '
').appendTo('#ciView'); - - // $compile($el)($scope); - - //}, 250); - // $compile(e1.contents())($scope); - - //$('#ciView').css("height", $(window).outerHeight() - 110); - - //$('#ciView').css("width", $(window).outerWidth() - 10); } -- libgit2 0.21.4