Commit b8c081ec1ef4e33047d5a6b0e262ffdd8feaaeaf

Authored by Mitali Srivastava
1 parent 2e5c4938

Bug #5263: Maintain combo box selection after detail page is unloaded and CI is loaded

400-SOURCECODE/AIAHTML5.Web/app/controllers/CIController.js
... ... @@ -17,17 +17,19 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
17 17 $scope.selectedCIListViewData = [];
18 18 $scope.filterstring = false;
19 19 $scope.query = {
20   - selectedbodyregion: null,
21   - selectedbodysystem: null,
22   - selectedorientation: null,
23   - selectedimagetype: null,
24   - selectedspecialty: null,
  20 + selectedbodyregion: '',
  21 + selectedbodysystem: '',
  22 + selectedorientation: '',
  23 + selectedimagetype: '',
  24 + selectedspecialty: '',
25 25 };
26 26  
27 27 $scope.$on('$viewContentLoaded', function (event) {
28 28 // code that will be executed ...
29 29 // every time this view is loaded
30 30  
  31 + $scope.LoadCIJsonData();
  32 +
31 33 $scope.CIAllBodyRegion = BodyRegions;
32 34 $scope.CIAllBodySystem = BodySystems;
33 35 $scope.CIAllOrientation = ViewOrientations;
... ... @@ -37,45 +39,121 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
37 39 //push the details of open module in array $rootScope.openModules
38 40 $rootScope.openModules.push({ "ModuleId": 4 });
39 41  
  42 + //set the local storage
  43 + var curBodyRegion = localStorage.getItem("CICurBodyRegion");
  44 + if (typeof (curBodyRegion) !== "undefined" && curBodyRegion !== null) {
  45 + $scope.query.selectedbodyregion = curBodyRegion;
  46 + }
  47 + else {
  48 + $scope.query.selectedbodyregion = "";
  49 + }
  50 +
  51 + var curBodySystem = localStorage.getItem("CICurBodySystem");
  52 + if (typeof (curBodySystem) !== "undefined" && curBodySystem !== null) {
  53 + $scope.query.selectedbodysystem = curBodySystem;
  54 + }
  55 + else {
  56 + $scope.query.selectedbodysystem = "";
  57 + }
  58 +
  59 + var curOrientation = localStorage.getItem("CICurOrientation");
  60 + if (typeof (curOrientation) !== "undefined" && curOrientation !== null) {
  61 + $scope.query.selectedorientation = curOrientation;
  62 + }
  63 + else {
  64 + $scope.query.selectedorientation = "";
  65 + }
  66 +
  67 + var curImageType = localStorage.getItem("CICurImageType");
  68 + if (typeof (curImageType) !== "undefined" && curImageType !== null) {
  69 + $scope.query.selectedimagetype = curImageType;
  70 + }
  71 + else {
  72 + $scope.query.selectedimagetype = "";
  73 + }
  74 +
  75 + var curSpeciality = localStorage.getItem("CICurSpeciality");
  76 + if (typeof (curSpeciality) !== "undefined" && curSpeciality !== null) {
  77 + $scope.query.selectedspecialty = curSpeciality;
  78 + }
  79 + else {
  80 + $scope.query.selectedspecialty = "";
  81 + }
  82 +
  83 +
  84 + if ($scope.query.selectedbodyregion == "" && $scope.query.selectedbodysystem == "" && $scope.query.selectedorientation == "" && $scope.query.selectedimagetype == "" && $scope.query.selectedspecialty == "") {
  85 + $scope.loadAllCI();
  86 + }
  87 + else {
  88 + $scope.ApplySearch($scope.query);
  89 + }
  90 +
40 91 });
41 92  
42   - var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json')
43   - promise.then(
44   - function (result) {
45   - $scope.IllustrationData = result;
46   - //$scope.selectedCIListViewData = $scope.IllustrationData.root.CIData;
  93 + $scope.LoadCIJsonData = function () {
47 94  
48   - $scope.selectedCIListViewData = new jinqJs()
49   - .from($scope.IllustrationData.root.CIData)
50   - .orderBy([{ field: '_Title', sort: 'asc' }])
51   - .select();
  95 + var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json')
  96 + promise.then(
  97 + function (result) {
  98 + $scope.IllustrationData = result;
  99 + //$scope.selectedCIListViewData = $scope.IllustrationData.root.CIData;
52 100  
53   - $('#grid-view').empty();
  101 + $scope.selectedCIListViewData = new jinqJs()
  102 + .from($scope.IllustrationData.root.CIData)
  103 + .orderBy([{ field: '_Title', sort: 'asc' }])
  104 + .select();
54 105  
55   - angular.forEach($scope.selectedCIListViewData, function (value, key) {
56   - $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage;
  106 + },
  107 + function (error) {
  108 + // handle errors here
  109 + console.log(' $scope.IllustrationData = ' + error.statusText);
  110 + }
  111 + );
57 112  
58   - var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="openView($event)">'
59   - + '<div class="thumbnail" >'
60   - + '<img id="' + value._Title + '"ng-src="' + $scope.imagePath + '" alt="" title="" >'
61   - + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
62 113  
  114 + };
63 115  
64   - $compile($el)($scope);
  116 + $scope.loadAllCI = function () {
  117 +
  118 + var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json')
  119 + promise.then(
  120 + function (result) {
  121 + $scope.IllustrationData = result;
  122 + //$scope.selectedCIListViewData = $scope.IllustrationData.root.CIData;
  123 +
  124 + $scope.selectedCIListViewData = new jinqJs()
  125 + .from($scope.IllustrationData.root.CIData)
  126 + .orderBy([{ field: '_Title', sort: 'asc' }])
  127 + .select();
  128 +
  129 + console.log($scope.selectedCIListViewData);
  130 + $('#grid-view').empty();
  131 + angular.forEach($scope.selectedCIListViewData, function (value, key) {
  132 + $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage;
  133 +
  134 + var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="openView($event)">'
  135 + + '<div class="thumbnail" >'
  136 + + '<img id="' + value._Title + '"ng-src="' + $scope.imagePath + '" alt="" title="" >'
  137 + + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
  138 +
  139 +
  140 + $compile($el)($scope);
  141 +
  142 + $(".sidebar").mCustomScrollbar({
  143 + autoHideScrollbar: true,
  144 + //theme:"rounded"
  145 + });
65 146  
66   - $(".sidebar").mCustomScrollbar({
67   - autoHideScrollbar: true,
68   - //theme:"rounded"
69 147 });
70 148  
71   - });
  149 + },
  150 + function (error) {
  151 + // handle errors here
  152 + console.log(' $scope.IllustrationData = ' + error.statusText);
  153 + }
  154 + );
72 155  
73   - },
74   - function (error) {
75   - // handle errors here
76   - console.log(' $scope.IllustrationData = ' + error.statusText);
77   - }
78   - );
  156 + }
79 157  
80 158 $scope.IsVisible = function () {
81 159 $scope.scroll();
... ... @@ -119,40 +197,26 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
119 197  
120 198 $scope.Reset = function (query) {
121 199  
122   - //query.selectedbodyregion = "";
123   - //query.selectedbodysystem = "";
124   - //query.selectedorientation = "";
125   - //query.selectedimagetype = "";
126   - //query.selectedspecialty = "";
127   - query.selectedbodyregion = null;
128   - query.selectedbodysystem = null;
129   - query.selectedorientation = null;
130   - query.selectedimagetype = null;
131   - query.selectedspecialty = null;
  200 + query.selectedbodyregion = "";
  201 + query.selectedbodysystem = "";
  202 + query.selectedorientation = "";
  203 + query.selectedimagetype = "";
  204 + query.selectedspecialty = "";
  205 +
  206 +
  207 + //set localstorage values
  208 + localStorage.setItem("CICurBodyRegion", query.selectedbodyregion);
  209 + localStorage.setItem("CICurBodySystem", query.selectedbodysystem);
  210 + localStorage.setItem("CICurOrientation", query.selectedorientation);
  211 + localStorage.setItem("CICurImageType", query.selectedimagetype);
  212 + localStorage.setItem("CICurSpeciality", query.selectedspecialty);
132 213  
133 214 $scope.filterstring = false;
134 215 while ($scope.searchCIListViewData.length) {
135 216 $scope.searchCIListViewData.pop();
136 217 }
137   - $('#grid-view').empty();
138   -
139   - angular.forEach($scope.selectedCIListViewData, function (value, key) {
140   - $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage;
141   -
142   - var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="openView($event)">'
143   - + '<div class="thumbnail" >'
144   - + '<img id="' + value._Title + '"ng-src="' + $scope.imagePath + '" alt="" title="" >'
145   - + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
146   -
147   -
148   - $compile($el)($scope);
149   -
150   - $(".sidebar").mCustomScrollbar({
151   - autoHideScrollbar: true,
152   - //theme:"rounded"
153   - });
154 218  
155   - });
  219 + $scope.loadAllCI();
156 220  
157 221 }
158 222  
... ... @@ -164,143 +228,168 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
164 228 $scope.searchCIListViewData.pop();
165 229 }
166 230  
167   - $('#grid-view').empty();
  231 + //$('#grid-view').empty();
168 232  
169 233 filtercount = 0;
170   - if (typeof (query.selectedbodyregion) !== "undefined" && query.selectedbodyregion !== null) {
  234 + if (typeof (query.selectedbodyregion) !== "undefined" && (query.selectedbodyregion !== null || query.selectedbodyregion !== "null")) {
171 235 filtercount = filtercount + 1;
  236 + localStorage.setItem("CICurBodyRegion", query.selectedbodyregion);
172 237 }
173   - if (typeof (query.selectedbodysystem) !== "undefined" && query.selectedbodysystem !== null) {
  238 + if (typeof (query.selectedbodysystem) !== "undefined" && (query.selectedbodysystem !== null || query.selectedbodysystem !== "null")) {
174 239 filtercount = filtercount + 1;
  240 + localStorage.setItem("CICurBodySystem", query.selectedbodysystem);
175 241 }
176   - if (typeof (query.selectedorientation) !== "undefined" && query.selectedorientation !== null) {
  242 + if (typeof (query.selectedorientation) !== "undefined" && (query.selectedorientation !== null || query.selectedorientation !== "null")) {
177 243 filtercount = filtercount + 1;
  244 + localStorage.setItem("CICurOrientation", query.selectedorientation);
178 245 }
179   - if (typeof (query.selectedimagetype) !== "undefined" && query.selectedimagetype !== null) {
  246 + if (typeof (query.selectedimagetype) !== "undefined" && (query.selectedimagetype !== null || query.selectedimagetype !== "null")) {
180 247 filtercount = filtercount + 1;
  248 + localStorage.setItem("CICurImageType", query.selectedimagetype);
181 249 }
182   - if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null) {
  250 + if (typeof (query.selectedspecialty) !== "undefined" && (query.selectedspecialty !== null || query.selectedspecialty !== "null")) {
183 251 filtercount = filtercount + 1;
  252 + localStorage.setItem("CICurSpeciality", query.selectedspecialty);
184 253 }
185 254  
186   - angular.forEach($scope.selectedCIListViewData, function (value, key) {
187 255  
188   - var selectimg = true;
189   - var count = 0;
  256 + var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json')
  257 + promise.then(
  258 + function (result) {
  259 + $scope.IllustrationData = result;
  260 + //$scope.selectedCIListViewData = $scope.IllustrationData.root.CIData;
190 261  
  262 + $scope.selectedCIListViewData = new jinqJs()
  263 + .from($scope.IllustrationData.root.CIData)
  264 + .orderBy([{ field: '_Title', sort: 'asc' }])
  265 + .select();
  266 +
  267 + $('#grid-view').empty();
  268 +
  269 + angular.forEach($scope.selectedCIListViewData, function (value, key) {
  270 +
  271 + var selectimg = true;
  272 + var count = 0;
191 273  
192   - if (typeof (query.selectedbodyregion) !== "undefined" && query.selectedbodyregion !== null) {
193   - var posbodyregion = value._BodyRegion.indexOf((query.selectedbodyregion.trim()));
194   - if (posbodyregion > -1) {
195   - selectimg = true;
196   - count = count + 1;
197 274  
198   - }
199   - else {
200   - selectimg = false;
201   - count = count - 1;
202   - }
  275 + if (typeof (query.selectedbodyregion) !== "undefined" && (query.selectedbodyregion !== null || query.selectedbodyregion !== "null")) {
  276 + var posbodyregion = value._BodyRegion.indexOf((query.selectedbodyregion.trim()));
  277 + if (posbodyregion > -1) {
  278 + selectimg = true;
  279 + count = count + 1;
203 280  
204   - }
  281 + }
  282 + else {
  283 + selectimg = false;
  284 + count = count - 1;
  285 + }
205 286  
206   - if (typeof (query.selectedbodysystem) !== "undefined" && query.selectedbodysystem !== null) {
207   - var posbodysystem = value._BodySystem.indexOf(query.selectedbodysystem);
208   - if (posbodysystem > -1) {
209   - count = count + 1;
210   - selectimg = true;
211   - } else {
212   - selectimg = false;
213   - count = count - 1;
214   - }
215   - }
  287 + }
216 288  
217   - if (typeof (query.selectedorientation) !== "undefined" && query.selectedorientation !== null) {
218   - var posorientation = value._ViewOrientation.indexOf(query.selectedorientation);
219   - if (posorientation > -1) {
220   - count = count + 1;
221   - selectimg = true;
  289 + if (typeof (query.selectedbodysystem) !== "undefined" && (query.selectedbodysystem !== null || query.selectedbodysystem !== "null")) {
  290 + var posbodysystem = value._BodySystem.indexOf(query.selectedbodysystem);
  291 + if (posbodysystem > -1) {
  292 + count = count + 1;
  293 + selectimg = true;
  294 + } else {
  295 + selectimg = false;
  296 + count = count - 1;
  297 + }
  298 + }
222 299  
223   - } else {
224   - selectimg = false;
225   - count = count - 1;
226   - }
  300 + if (typeof (query.selectedorientation) !== "undefined" && (query.selectedorientation !== null || query.selectedorientation !== "null")) {
  301 + var posorientation = value._ViewOrientation.indexOf(query.selectedorientation);
  302 + if (posorientation > -1) {
  303 + count = count + 1;
  304 + selectimg = true;
227 305  
228   - }
  306 + } else {
  307 + selectimg = false;
  308 + count = count - 1;
  309 + }
229 310  
230   - if (typeof (query.selectedimagetype) !== "undefined" && query.selectedimagetype !== null) {
231   - var posimagetype = value._ImageType.indexOf(query.selectedimagetype);
232   - if (posimagetype > -1) {
233   - count = count + 1;
234   - selectimg = true;
  311 + }
235 312  
236   - } else {
237   - selectimg = false;
238   - count = count - 1;
239   - }
  313 + if (typeof (query.selectedimagetype) !== "undefined" && (query.selectedimagetype !== null || query.selectedimagetype !== "null")) {
  314 + var posimagetype = value._ImageType.indexOf(query.selectedimagetype);
  315 + if (posimagetype > -1) {
  316 + count = count + 1;
  317 + selectimg = true;
240 318  
241   - }
  319 + } else {
  320 + selectimg = false;
  321 + count = count - 1;
  322 + }
242 323  
243   - if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null) {
244   - var posspeciality = value._MedicalSpecialty.indexOf(query.selectedspecialty);
245   - if (posspeciality > -1) {
246   - count = count + 1;
247   - selectimg = true;
248   - } else {
249   - selectimg = false;
250   - count = count - 1;
251   - }
  324 + }
252 325  
253   - }
  326 + if (typeof (query.selectedspecialty) !== "undefined" && (query.selectedspecialty !== null || query.selectedspecialty !== "null")) {
  327 + var posspeciality = value._MedicalSpecialty.indexOf(query.selectedspecialty);
  328 + if (posspeciality > -1) {
  329 + count = count + 1;
  330 + selectimg = true;
  331 + } else {
  332 + selectimg = false;
  333 + count = count - 1;
  334 + }
254 335  
255   - if (selectimg === true && count >= filtercount) {
  336 + }
256 337  
  338 + if (selectimg === true && count >= filtercount) {
257 339  
258   - $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage;
259 340  
260   - var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="openView($event)">'
261   - + '<div class="thumbnail" >'
262   - + '<img id="' + value._Title + '"ng-src="' + $scope.imagePath + '" alt="" title="" >'
263   - + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
  341 + $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage;
264 342  
  343 + var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="openView($event)">'
  344 + + '<div class="thumbnail" >'
  345 + + '<img id="' + value._Title + '"ng-src="' + $scope.imagePath + '" alt="" title="" >'
  346 + + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
265 347  
266   - $compile($el)($scope);
267 348  
268   - $(".sidebar").mCustomScrollbar({
269   - autoHideScrollbar: true,
270   - //theme:"rounded"
271   - });
  349 + $compile($el)($scope);
272 350  
  351 + $(".sidebar").mCustomScrollbar({
  352 + autoHideScrollbar: true,
  353 + //theme:"rounded"
  354 + });
273 355  
274   - $scope.searchCIListViewData.push(
275   - {
276   - "_id": value._id,
277   - "_ImageId": value._ImageId,
278   - "_Title": value._Title,
279   - "_contentImage": value._contentImage,
280   - "_ThumbnailImage": value._ThumbnailImage,
281   - "_BodySystem": value._BodySystem,
282   - "_BodyRegion": value._BodyRegion,
283   - "_ViewOrientation": value._ViewOrientation,
284   - "_MedicalSpecialty": value._MedicalSpecialty,
285   - "_ImageType": value._ImageType,
286   - "_Summary": value._Summary
287 356  
288   - });
  357 + $scope.searchCIListViewData.push(
  358 + {
  359 + "_id": value._id,
  360 + "_ImageId": value._ImageId,
  361 + "_Title": value._Title,
  362 + "_contentImage": value._contentImage,
  363 + "_ThumbnailImage": value._ThumbnailImage,
  364 + "_BodySystem": value._BodySystem,
  365 + "_BodyRegion": value._BodyRegion,
  366 + "_ViewOrientation": value._ViewOrientation,
  367 + "_MedicalSpecialty": value._MedicalSpecialty,
  368 + "_ImageType": value._ImageType,
  369 + "_Summary": value._Summary
289 370  
290   - }
  371 + });
291 372  
  373 + }
292 374  
293   - });
294 375  
295   - //Show Error Message in case of gridview if no data is found
296   - if ($scope.searchCIListViewData.length == 0) {
  376 + });
297 377  
298   - var $el = $('<div class="col-sm-12" style="padding-left:25px;padding-top:10px;"><strong style="color:white">No illustration found for the selected search criteria!</strong></div>').appendTo('#grid-view');
299   - $compile($el)($scope);
300   - }
301   - }
  378 + //Show Error Message in case of gridview if no data is found
  379 + if ($scope.searchCIListViewData.length == 0) {
302 380  
  381 + var $el = $('<div class="col-sm-12" style="padding-left:25px;padding-top:10px;"><strong style="color:white">No illustration found for the selected search criteria!</strong></div>').appendTo('#grid-view');
  382 + $compile($el)($scope);
  383 + }
  384 + },
  385 + function (error) {
  386 + // handle errors here
  387 + console.log(' $scope.IllustrationData = ' + error.statusText);
  388 + }
  389 + );
303 390  
  391 +
  392 + }
304 393  
305 394  
306 395 $scope.scroll = function () {
... ... @@ -404,23 +493,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
404 493 $rootScope.isLoading = false;
405 494 $('#spinner').css('visibility', 'hidden');
406 495  
407   - //$.jsPanel({
408   - // id: 'ciImagePanel',
409   - // selector: '.ciView',
410   - // theme: 'success',
411   - // currentController: 'CIController',
412   - // parentSlug: 'clinical-illustrations',
413   - // content: '<div class="row"><div class="col-sm-12 img-thumbnail" align="center">' +
414   - // '<img src="' + $scope.clickedCIImage + '" alt="" title="" style="width:100%;height:auto;" class="img-responsive "></div><div class="col-sm-12 well">' +
415   - // '<div id="sid"><p>' + $scope.clickedCISummary + '</p></div><button class="btn btn-primary pull-right">Text Off</button>'+
416   - // '<script>$(document).ready(function(){$("button").click(function(){$("#sid").toggle();if($.trim($(this).text()) === "Text Off"){$(this).text("Text On");}else{$(this).text("Text Off");}});});</script></div>' +
417   - // '</div>',
418   - // title: localStorage.getItem("currentViewTitle"),
419   - // position: {
420   - // top: 70,
421   - // left: 1,
422   - // },
423   -
424 496 $.jsPanel({
425 497 id: 'ciImagePanel',
426 498 selector: '.ciView',
... ... @@ -441,8 +513,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
441 513 left: 1,
442 514 },
443 515  
444   - //size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 },
445   -
446 516 size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 },
447 517  
448 518 });
... ... @@ -455,25 +525,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
455 525 "slug": $rootScope.currentSlug
456 526 });
457 527  
458   - //var e1 = angular.element(document.getElementById("CIView"));
459   - //$timeout(function () {
460   -
461   - // //$compile(e1.contents())($scope)
462   -
463   - // var $el = $('<div class="row"><div class="col-sm-12 img-thumbnail" align="center">' +
464   - // '<img src="' + $scope.clickedCIImage + '" alt="" title="" " class="img-responsive "><div class="col-sm-12 well">' +
465   - // '<div id="sid"><p>' + $scope.clickedCISummary + '</p></div><button class="btn btn-primary pull-right">Text Off</button>' +
466   - // '<script>$(document).ready(function(){$("button").click(function(){$("#sid").toggle();if($.trim($(this).text()) === "Text Off"){$(this).text("Text On");}else{$(this).text("Text Off");}});});</script></div>' +
467   - // '</div></div>').appendTo('#ciView');
468   -
469   - // $compile($el)($scope);
470   -
471   - //}, 250);
472   - // $compile(e1.contents())($scope);
473   -
474   - //$('#ciView').css("height", $(window).outerHeight() - 110);
475   -
476   - //$('#ciView').css("width", $(window).outerWidth() - 10);
477 528  
478 529 }
479 530  
... ...